Commit 6b8a4066 authored by Hema Vishnu Pola [Microsoft]'s avatar Hema Vishnu Pola [Microsoft]
Browse files

Merge branch 'upgrade-cosmos' into 'master'

Upgrade cosmos

See merge request osdu/platform/system/lib/cloud/azure/os-core-lib-azure!35
parents 3d7a0213 ca871929
......@@ -10,13 +10,9 @@ The following software have components provided under the terms of this license:
- ASM Core (from )
- ASM based accessors helper used by json-smart (from )
- Adapter: RxJava (from )
- Apache Commons BeanUtils (from http://commons.apache.org/proper/commons-beanutils/)
- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/)
- Apache Commons Collections (from http://commons.apache.org/proper/commons-collections/)
- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/)
- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/)
- Apache Commons Text (from http://commons.apache.org/proper/commons-text/)
- Apache Commons Validator (from http://commons.apache.org/proper/commons-validator/)
- Apache HttpAsyncClient (from http://hc.apache.org/httpcomponents-asyncclient)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client)
......@@ -32,8 +28,6 @@ The following software have components provided under the terms of this license:
- Byte Buddy (without dependencies) (from )
- Byte Buddy Java agent (from )
- ClassMate (from http://github.com/cowtowncoder/java-classmate)
- Commons Digester (from http://commons.apache.org/digester/)
- Commons IO (from http://commons.apache.org/io/)
- Converter: Jackson (from )
- Elastic JNA Distribution (from https://github.com/java-native-access/jna)
- Elasticsearch: 5.0.0-alpha5 (from https://github.com/elastic/elasticsearch)
......@@ -59,11 +53,11 @@ The following software have components provided under the terms of this license:
- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson)
- Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda)
- Jackson-datatype-jdk8 (from )
- Jackson-module-Afterburner (from http://wiki.fasterxml.com/JacksonHome)
- Jackson-module-JAXB-annotations (from http://wiki.fasterxml.com/JacksonJAXBAnnotations)
- Jackson-module-parameter-names (from )
- Java Native Access (from https://github.com/java-native-access/jna)
- Java Native Access Platform (from https://github.com/java-native-access/jna)
- Java UUID Generator (from http://wiki.fasterxml.com/JugHome)
- Javassist (from http://www.javassist.org/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Lucene Common Analyzers (from )
......@@ -87,6 +81,7 @@ The following software have components provided under the terms of this license:
- Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java)
- Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java)
- Microsoft Azure Netty HTTP Client Library (from https://github.com/Azure/azure-sdk-for-java)
- Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java)
- Mockito (from http://mockito.org)
- Netty Reactive Streams Implementation (from )
- Netty/Buffer (from http://netty.io/)
......@@ -132,19 +127,21 @@ The following software have components provided under the terms of this license:
- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework)
- Spring Context (from https://github.com/spring-projects/spring-framework)
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Data Core (from )
- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework)
- Spring Transaction (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web MVC (from https://github.com/spring-projects/spring-framework)
- T-Digest (from https://github.com/tdunning/t-digest)
- Woodstox (from https://github.com/FasterXML/woodstox)
- aggs-matrix-stats (from https://github.com/elastic/elasticsearch)
- cli (from https://github.com/elastic/elasticsearch)
- commons-collections (from )
- compiler (from http://github.com/spullara/mustache.java)
- elasticsearch-core (from https://github.com/elastic/elasticsearch)
- error-prone annotations (from )
- io.grpc:grpc-context (from https://github.com/grpc/grpc-java)
- jackson-databind (from http://github.com/FasterXML/jackson)
- javatuples (from http://www.javatuples.org)
- javax.inject (from http://code.google.com/p/atinject/)
- lang-mustache (from https://github.com/elastic/elasticsearch)
- lettuce (from http://github.com/mp911de/lettuce/wiki)
......@@ -157,7 +154,6 @@ The following software have components provided under the terms of this license:
- rest (from https://github.com/elastic/elasticsearch)
- rest-high-level (from https://github.com/elastic/elasticsearch)
- rxjava (from https://github.com/ReactiveX/RxJava)
- rxjava (from https://github.com/ReactiveX/RxJava)
- secure-sm (from https://github.com/elastic/elasticsearch)
- swagger-annotations (from )
- swagger-jaxrs (from )
......@@ -367,7 +363,9 @@ The following software have components provided under the terms of this license:
- Netty/Common (from )
- Project Lombok (from https://projectlombok.org)
- SLF4J API Module (from http://www.slf4j.org)
- Spring Data for Azure Cosmos DB SQL API (from https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/cosmos/azure-spring-data-cosmos)
- adal4j (from https://github.com/AzureAD/azure-activedirectory-library-for-java)
- micrometer-core (from https://github.com/micrometer-metrics/micrometer)
- mockito-junit-jupiter (from https://github.com/mockito/mockito)
- msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java)
......@@ -400,6 +398,7 @@ The following software have components provided under the terms of this license:
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/)
- reactive-streams (from http://www.reactive-streams.org/)
========================================================================
SPL-1.0
......@@ -430,7 +429,6 @@ The following software have components provided under the terms of this license:
- Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java)
- Project Lombok (from https://projectlombok.org)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- reactive-streams (from http://www.reactive-streams.org/)
========================================================================
unknown
......
......@@ -21,7 +21,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<packaging>jar</packaging>
<version>0.0.35</version>
<version>0.0.36</version>
<name>core-lib-azure</name>
<properties>
......@@ -36,7 +36,6 @@
<javax.inject.version>1</javax.inject.version>
<azure.identity.version>1.0.1</azure.identity.version>
<azure.keyvault.version>4.1.0</azure.keyvault.version>
<azure.cosmos.version>4.0.0-preview.1</azure.cosmos.version>
<azure.storage.version>12.3.0</azure.storage.version>
<azure.servicebus.version>3.1.4</azure.servicebus.version>
<azure.appinsights.version>2.5.1</azure.appinsights.version>
......@@ -48,20 +47,20 @@
</properties>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.5.3</version>
</dependency>
<!-- Spring dependencies -->
<dependency>
......@@ -69,11 +68,6 @@
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
......@@ -109,10 +103,11 @@
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>${azure.keyvault.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.azure/azure-spring-data-cosmos -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
<version>${azure.cosmos.version}</version>
<artifactId>azure-spring-data-cosmos</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
......@@ -139,7 +134,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.2.4.RELEASE</version>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
......@@ -175,6 +170,18 @@
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
<repositories>
......
package org.opengroup.osdu.azure.cache;
import com.azure.cosmos.internal.AsyncDocumentClient;
import org.opengroup.osdu.core.common.cache.VmCache;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* Implementation of ICache for AsyncDocumentClient.
*/
@Component
@Lazy
public class AsyncCosmosClientCache extends VmCache<String, AsyncDocumentClient> {
/**
* Default cache constructor.
*/
public AsyncCosmosClientCache() {
super(60 * 60, 1000);
}
/**
* @param key cache key
* @return true if found in cache
*/
public boolean containsKey(final String key) {
return this.get(key) != null;
}
}
package org.opengroup.osdu.azure.cosmosdb;
import com.azure.cosmos.ConnectionMode;
import com.azure.cosmos.ConnectionPolicy;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.internal.AsyncDocumentClient;
import org.opengroup.osdu.azure.cache.AsyncCosmosClientCache;
import org.opengroup.osdu.azure.cache.CosmosClientCache;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
......@@ -29,10 +25,6 @@ public class CosmosClientFactoryImpl implements ICosmosClientFactory {
@Autowired
private CosmosClientCache syncClientCache;
@Lazy
@Autowired
private AsyncCosmosClientCache asyncCosmosClientCache;
/**
* @param dataPartitionId Data Partition Id
* @return Cosmos Client instance
......@@ -48,8 +40,8 @@ public class CosmosClientFactoryImpl implements ICosmosClientFactory {
PartitionInfoAzure pi = this.partitionService.getPartition(dataPartitionId);
CosmosClient cosmosClient = new CosmosClientBuilder()
.setEndpoint(pi.getCosmosEndpoint())
.setKey(pi.getCosmosPrimaryKey())
.endpoint(pi.getCosmosEndpoint())
.key(pi.getCosmosPrimaryKey())
.buildClient();
this.syncClientCache.put(cacheKey, cosmosClient);
......@@ -57,31 +49,4 @@ public class CosmosClientFactoryImpl implements ICosmosClientFactory {
return cosmosClient;
}
/**
* @param dataPartitionId Data Partition Id
* @return Async Document Client instance
*/
@Override
public AsyncDocumentClient getAsyncClient(final String dataPartitionId) {
Validators.checkNotNullAndNotEmpty(dataPartitionId, "dataPartitionId");
String cacheKey = String.format("%s-asyncCosmosClient", dataPartitionId);
if (this.syncClientCache.containsKey(cacheKey)) {
return this.asyncCosmosClientCache.get(cacheKey);
}
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
connectionPolicy.setConnectionMode(ConnectionMode.DIRECT);
PartitionInfoAzure pi = this.partitionService.getPartition(dataPartitionId);
AsyncDocumentClient client = new AsyncDocumentClient.Builder()
.withServiceEndpoint(pi.getCosmosEndpoint())
.withMasterKeyOrResourceToken(pi.getCosmosPrimaryKey())
.withConnectionPolicy(connectionPolicy)
.build();
this.asyncCosmosClientCache.put(cacheKey, client);
return client;
}
}
package org.opengroup.osdu.azure.cosmosdb;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.internal.AsyncDocumentClient;
/**
* Interface for Cosmos Client Factory to return appropriate cosmos client.
......@@ -15,9 +14,4 @@ public interface ICosmosClientFactory {
*/
CosmosClient getClient(String dataPartitionId);
/**
* @param dataPartitionId Data Partition Id
* @return Async Document Client instance
*/
AsyncDocumentClient getAsyncClient(String dataPartitionId);
}
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.azure.query;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
/**
*
*/
public final class CosmosStorePageRequest extends PageRequest {
private static final long serialVersionUID = 6093304300037688375L;
private String requestContinuation;
/**
* @param page page
* @param size size
* @param arequestContinuation requestContinuation
*/
public CosmosStorePageRequest(final int page, final int size, final String arequestContinuation) {
super(page, size, Sort.unsorted());
this.requestContinuation = arequestContinuation;
}
/**
* @param page page
* @param size size
* @param requestContinuation requestContinuation
* @return CosmosStorePageRequest
*/
public static CosmosStorePageRequest of(final int page, final int size, final String requestContinuation) {
return new CosmosStorePageRequest(page, size, requestContinuation);
}
/**
* @param page page
* @param size size
* @param arequestContinuation requestContinuation
* @param sort sort
*/
public CosmosStorePageRequest(final int page, final int size, final String arequestContinuation, final Sort sort) {
super(page, size, sort);
this.requestContinuation = arequestContinuation;
}
/**
* @param page page
* @param size size
* @param requestContinuation requestContinuation
* @param sort sort
* @return CosmosStorePageRequest
*/
public static CosmosStorePageRequest of(final int page, final int size, final String requestContinuation, final Sort sort) {
return new CosmosStorePageRequest(page, size, requestContinuation, sort);
}
/**
* @return requestContinuation
*/
public String getRequestContinuation() {
return this.requestContinuation;
}
/**
* @return hashCode
*/
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (this.requestContinuation != null ? this.requestContinuation.hashCode() : 0);
return result;
}
/**
* @param obj obj
* @return equals
*/
public boolean equals(final Object obj) {
if (this == obj) {
return true;
} else if (!(obj instanceof CosmosStorePageRequest)) {
return false;
} else {
CosmosStorePageRequest that = (CosmosStorePageRequest) obj;
boolean continuationTokenEquals = this.requestContinuation != null ? this.requestContinuation.equals(that.requestContinuation) : that.requestContinuation == null;
return continuationTokenEquals && super.equals(that);
}
}
}
......@@ -14,37 +14,38 @@
package org.opengroup.osdu.azure.cosmosdb;
import com.azure.cosmos.ConflictException;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientException;
import com.azure.cosmos.CosmosContainer;
import com.azure.cosmos.CosmosDatabase;
import com.azure.cosmos.CosmosItem;
import com.azure.cosmos.CosmosItemProperties;
import com.azure.cosmos.CosmosItemResponse;
import com.azure.cosmos.FeedOptions;
import com.azure.cosmos.FeedResponse;
import com.azure.cosmos.NotFoundException;
import com.azure.cosmos.SqlQuerySpec;
import com.azure.cosmos.internal.AsyncDocumentClient;
import com.azure.cosmos.internal.Document;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.implementation.ConflictException;
import com.azure.cosmos.implementation.NotFoundException;
import com.azure.cosmos.models.CosmosItemRequestOptions;
import com.azure.cosmos.models.CosmosItemResponse;
import com.azure.cosmos.models.PartitionKey;
import com.azure.cosmos.models.SqlQuerySpec;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.azure.cosmosdb.CosmosStore;
import org.opengroup.osdu.azure.cosmosdb.ICosmosClientFactory;
import org.opengroup.osdu.azure.multitenancy.TenantInfoDoc;
import org.opengroup.osdu.core.common.model.http.AppException;
import reactor.core.publisher.Flux;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
......@@ -71,24 +72,24 @@ class CosmosStoreTest {
private static final String COLLECTION_LINK = "/dbs/cosmosdb/colls/collection";
private static final String DATA_PARTITION_ID = "data-partition-id";
@Mock
private AsyncDocumentClient documentClient;
@Mock
private CosmosContainer container;
@Mock
private CosmosItem cosmosItem;
private TenantInfoDoc cosmosItem;
@Mock
private CosmosItemProperties cosmosItemProperties;
private CosmosItemResponse<TenantInfoDoc> cosmosResponse;
/*
@Mock
private CosmosItemResponse cosmosResponse;
private CosmosItemProperties cosmosItemProperties;
@Mock
private Iterator<FeedResponse<CosmosItemProperties>> queryResponse;
*/
@Mock
private ICosmosClientFactory cosmosClientFactory;
......@@ -102,21 +103,21 @@ class CosmosStoreTest {
private CosmosStore cosmosStore;
@BeforeEach
void init() throws CosmosClientException {
void init() throws CosmosException {
// mock the common cosmos request/response pattern that most tests need. because
// not all tests will leverage these, we make the mocks lenient.
lenient().doReturn(cosmosItem).when(container).getItem(ID, PARTITION_KEY);
lenient().doReturn(cosmosResponse).when(cosmosItem).read(any());
lenient().doReturn(cosmosItemProperties).when(cosmosResponse).getProperties();
lenient().doReturn(cosmosItem).when(cosmosResponse).getItem();
lenient().doReturn(cosmosResponse).when(container).readItem(any(), any(), any(), any());
//lenient().doReturn(cosmosItemProperties).when(cosmosResponse).getProperties();
lenient().doReturn(cosmosClient).when(cosmosClientFactory).getClient(anyString());
lenient().doReturn(cosmosDatabase).when(cosmosClient).getDatabase(any());
lenient().doReturn(container).when(cosmosDatabase).getContainer(anyString());
lenient().doReturn(documentClient).when(cosmosClientFactory).getAsyncClient(anyString());
}
@Test
void delete_throws404_ifNotFound() throws CosmosClientException {
doThrow(NotFoundException.class).when(cosmosItem).delete(any());
void delete_throws404_ifNotFound() throws CosmosException {
doThrow(NotFoundException.class).when(container).deleteItem(any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.deleteItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY);
});
......@@ -124,8 +125,8 @@ class CosmosStoreTest {
}
@Test
void delete_throws500_ifUnknownError() throws CosmosClientException {
doThrow(CosmosClientException.class).when(cosmosItem).delete(any());
void delete_throws500_ifUnknownError() throws CosmosException {
doThrow(CosmosException.class).when(container).deleteItem(any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.deleteItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY);
});
......@@ -133,65 +134,57 @@ class CosmosStoreTest {
}
@Test
void findItem_returnsEmpty_ifNotFound() throws CosmosClientException {
doThrow(NotFoundException.class).when(cosmosItem).read(any());
assertFalse(cosmosStore.findItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY, String.class).isPresent());
}
@Test
void findItem_throws500_ifMalformedDocument() throws IOException {
doThrow(IOException.class).when(cosmosItemProperties).getObject(any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.findItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY, String.class);
});
assertEquals(500, exception.getError().getCode());
void findItem_returnsEmpty_ifNotFound() throws CosmosException {
doThrow(NotFoundException.class).when(container).readItem(any(), any(), any(), any());
assertFalse(cosmosStore.findItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY, any(Class.class)).isPresent());
}
@Test
void findItem_throws500_ifUnknownError() throws CosmosClientException {
doThrow(CosmosClientException.class).when(cosmosItem).read(any());
void findItem_throws500_ifUnknownError() throws CosmosException {
doThrow(CosmosException.class).when(container).readItem(any(), any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.findItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY, String.class);
cosmosStore.findItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, ID, PARTITION_KEY, any(Class.class));
});
assertEquals(500, exception.getError().getCode());
}
@Test
void upsertItem_throws500_ifUnknownError() throws CosmosClientException {
doThrow(CosmosClientException.class).when(container).upsertItem(any());
void upsertItem_throws500_ifUnknownError() throws CosmosException {
doThrow(CosmosException.class).when(container).upsertItem(any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.upsertItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data");
cosmosStore.upsertItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data", any());
});
assertEquals(500, exception.getError().getCode());
}
@Test
void createItem_throws409_ifDuplicateDocument() throws CosmosClientException {
doThrow(ConflictException.class).when(container).createItem(any());
void createItem_throws409_ifDuplicateDocument() throws CosmosException {
doThrow(ConflictException.class).when(container).createItem(any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.createItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data");
cosmosStore.createItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data", any());
});
assertEquals(409, exception.getError().getCode());
}
@Test
void createItem_throws500_ifUnknownError() throws CosmosClientException {
doThrow(CosmosClientException.class).when(container).createItem(any());
void createItem_throws500_ifUnknownError() throws CosmosException {
doThrow(CosmosException.class).when(container).createItem(any(), any(), any());
AppException exception = assertThrows(AppException.class, () -> {
cosmosStore.createItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data");
cosmosStore.createItem(DATA_PARTITION_ID, COSMOS_DB, COLLECTION, "some-data", any());
});
assertEquals(500, exception.getError().getCode());
}