diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/README.md b/sdk/cosmos/azure-cosmos-benchmark/README.md similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/README.md rename to sdk/cosmos/azure-cosmos-benchmark/README.md diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml b/sdk/cosmos/azure-cosmos-benchmark/pom.xml similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml rename to sdk/cosmos/azure-cosmos-benchmark/pom.xml index d0f8d64edec5..95170e7e02d8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/pom.xml +++ b/sdk/cosmos/azure-cosmos-benchmark/pom.xml @@ -6,14 +6,14 @@ Licensed under the MIT License. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.azure + com.azure azure-cosmos-parent - 3.3.0 + 4.0.0-preview.4 - com.microsoft.azure + com.azure azure-cosmos-benchmark - 3.3.0 + 4.0.0-preview.4 Microsoft Azure SDK for SQL API of Azure Cosmos DB Service - Benchmarking tool This package contains Benchmarking tool for Microsoft Azure SDK for SQL API of Azure Cosmos DB Service https://github.com/Azure/azure-sdk-for-java @@ -31,9 +31,9 @@ Licensed under the MIT License. - com.microsoft.azure + com.azure azure-cosmos - 3.3.0 + 4.0.0-preview.4 diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java index cc654b35fb7b..d88010c30e94 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncBenchmark.java @@ -66,9 +66,9 @@ abstract class AsyncBenchmark { logger = LoggerFactory.getLogger(this.getClass()); Database database = DocDBUtils.getDatabase(client, cfg.getDatabaseId()); - collection = DocDBUtils.getCollection(client, database.selfLink(), cfg.getCollectionId()); - nameCollectionLink = String.format("dbs/%s/colls/%s", database.id(), collection.id()); - partitionKey = collection.getPartitionKey().paths().iterator().next().split("/")[1]; + collection = DocDBUtils.getCollection(client, database.getSelfLink(), cfg.getCollectionId()); + nameCollectionLink = String.format("dbs/%s/colls/%s", database.getId(), collection.getId()); + partitionKey = collection.getPartitionKey().getPaths().iterator().next().split("/")[1]; concurrencyControlSemaphore = new Semaphore(cfg.getConcurrency()); configuration = cfg; @@ -81,14 +81,14 @@ abstract class AsyncBenchmark { for (int i = 0; i < cfg.getNumberOfPreCreatedDocuments(); i++) { String uuid = UUID.randomUUID().toString(); Document newDoc = new Document(); - newDoc.id(uuid); + newDoc.setId(uuid); BridgeInternal.setProperty(newDoc, partitionKey, uuid); BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField3", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField4", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField5", dataFieldValue); - Flux obs = client.createDocument(collection.selfLink(), newDoc, null, false) + Flux obs = client.createDocument(collection.getSelfLink(), newDoc, null, false) .map(ResourceResponse::getResource); createDocumentObservables.add(obs); } @@ -146,15 +146,15 @@ protected String getCollectionLink() { if (configuration.isUseNameLink()) { return this.nameCollectionLink; } else { - return collection.selfLink(); + return collection.getSelfLink(); } } protected String getDocumentLink(Document doc) { if (configuration.isUseNameLink()) { - return this.nameCollectionLink + "/docs/" + doc.id(); + return this.nameCollectionLink + "/docs/" + doc.getId(); } else { - return doc.selfLink(); + return doc.getSelfLink(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java index bce63c558558..67a8eade046b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncMixedBenchmark.java @@ -37,7 +37,7 @@ protected void performWorkload(BaseSubscriber documentBaseSubscriber, String idString = uuid + i; Document newDoc = new Document(); - newDoc.id(idString); + newDoc.setId(idString); BridgeInternal.setProperty(newDoc, partitionKey, idString); BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue); @@ -50,17 +50,17 @@ protected void performWorkload(BaseSubscriber documentBaseSubscriber, FeedOptions options = new FeedOptions(); options.maxItemCount(10); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select top 100 * from c order by c._ts"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options) - .map(frp -> frp.results().get(0)); + .map(frp -> frp.getResults().get(0)); } else { int index = r.nextInt(1000); RequestOptions options = new RequestOptions(); - options.setPartitionKey(new PartitionKey(docsToRead.get(index).id())); + options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId())); obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options).map(ResourceResponse::getResource); } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java index ecb875087261..c4516f88c904 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQueryBenchmark.java @@ -42,8 +42,8 @@ protected void performWorkload(BaseSubscriber> baseSubscr if (configuration.getOperationType() == Configuration.Operation.QueryCross) { int index = r.nextInt(1000); - options.enableCrossPartitionQuery(true); - String sqlQuery = "Select * from c where c._rid = \"" + docsToRead.get(index).resourceId() + "\""; + options.setEnableCrossPartitionQuery(true); + String sqlQuery = "Select * from c where c._rid = \"" + docsToRead.get(index).getResourceId() + "\""; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else if (configuration.getOperationType() == Configuration.Operation.QuerySingle) { @@ -55,29 +55,29 @@ protected void performWorkload(BaseSubscriber> baseSubscr } else if (configuration.getOperationType() == Configuration.Operation.QueryParallel) { options.maxItemCount(10); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select * from c"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else if (configuration.getOperationType() == Configuration.Operation.QueryOrderby) { options.maxItemCount(10); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select * from c order by c._ts"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else if (configuration.getOperationType() == Configuration.Operation.QueryAggregate) { options.maxItemCount(10); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select value max(c._ts) from c"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else if (configuration.getOperationType() == Configuration.Operation.QueryAggregateTopOrderby) { - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select top 1 value count(c) from c order by c._ts"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else if (configuration.getOperationType() == Configuration.Operation.QueryTopOrderby) { - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); String sqlQuery = "Select top 1000 * from c order by c._ts"; obs = client.queryDocuments(getCollectionLink(), sqlQuery, options); } else { diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQuerySinglePartitionMultiple.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQuerySinglePartitionMultiple.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQuerySinglePartitionMultiple.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncQuerySinglePartitionMultiple.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java index bcb10266abcf..06e1287e91e1 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncReadBenchmark.java @@ -54,7 +54,7 @@ protected void hookOnError(Throwable throwable) { protected void performWorkload(BaseSubscriber> baseSubscriber, long i) throws InterruptedException { int index = (int) (i % docsToRead.size()); RequestOptions options = new RequestOptions(); - options.setPartitionKey(new PartitionKey(docsToRead.get(index).id())); + options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId())); Flux> obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options); diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java index 3cd19ccb7623..79409b2a46f4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/AsyncWriteBenchmark.java @@ -62,7 +62,7 @@ protected void performWorkload(BaseSubscriber> baseSu String idString = uuid + i; Document newDoc = new Document(); - newDoc.id(idString); + newDoc.setId(idString); BridgeInternal.setProperty(newDoc, partitionKey, idString); BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue); BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue); diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java index 1ab63af0d5cf..4c609aed9c6a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Configuration.java @@ -220,8 +220,8 @@ int getDocumentDataFieldSize() { ConnectionPolicy getConnectionPolicy() { ConnectionPolicy policy = new ConnectionPolicy(); - policy.connectionMode(connectionMode); - policy.maxPoolSize(maxConnectionPoolSize); + policy.setConnectionMode(connectionMode); + policy.setMaxPoolSize(maxConnectionPoolSize); return policy; } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java index a2304938a446..f6d51980a8df 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/DocDBUtils.java @@ -22,10 +22,10 @@ static Database getDatabase(AsyncDocumentClient client, String databaseId) { new SqlParameterList(new SqlParameter("@id", databaseId))), null) .single().block(); - if (feedResponsePages.results().isEmpty()) { + if (feedResponsePages.getResults().isEmpty()) { throw new RuntimeException("cannot find datatbase " + databaseId); } - return feedResponsePages.results().get(0); + return feedResponsePages.getResults().get(0); } static DocumentCollection getCollection(AsyncDocumentClient client, String databaseLink, @@ -37,9 +37,9 @@ static DocumentCollection getCollection(AsyncDocumentClient client, String datab null) .single().block(); - if (feedResponsePages.results().isEmpty()) { + if (feedResponsePages.getResults().isEmpty()) { throw new RuntimeException("cannot find collection " + collectionId); } - return feedResponsePages.results().get(0); + return feedResponsePages.getResults().get(0); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Main.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Main.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Main.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/Main.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java rename to sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java index ee85ba33a4d4..1c7a7a570dc9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/data/cosmos/benchmark/ReadMyWriteWorkflow.java @@ -158,7 +158,7 @@ private Flux writeDocument(Integer i) { String idString = Utils.randomUUID().toString(); String randomVal = Utils.randomUUID().toString(); Document document = new Document(); - document.id(idString); + document.setId(idString); BridgeInternal.setProperty(document, partitionKey, idString); BridgeInternal.setProperty(document, QUERY_FIELD_NAME, randomVal); BridgeInternal.setProperty(document, "dataField1", randomVal); @@ -217,11 +217,11 @@ private SqlQuerySpec generateRandomQuery() { */ private Flux xPartitionQuery(SqlQuerySpec query) { FeedOptions options = new FeedOptions(); - options.maxDegreeOfParallelism(-1); - options.enableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(-1); + options.setEnableCrossPartitionQuery(true); return client.queryDocuments(getCollectionLink(), query, options) - .flatMap(p -> Flux.fromIterable(p.results())); + .flatMap(p -> Flux.fromIterable(p.getResults())); } /** @@ -239,7 +239,7 @@ private Flux singlePartitionQuery(Document d) { QUERY_FIELD_NAME, d.getString(QUERY_FIELD_NAME))); return client.queryDocuments(getCollectionLink(), sqlQuerySpec, options) - .flatMap(p -> Flux.fromIterable(p.results())); + .flatMap(p -> Flux.fromIterable(p.getResults())); } /** @@ -348,7 +348,7 @@ static InWhereClause asInWhereClause(String fieldName, List documentLi StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(fieldName); stringBuilder.append(" IN ("); - List params = parameters.stream().map(SqlParameter::name).collect(Collectors.toList()); + List params = parameters.stream().map(SqlParameter::getName).collect(Collectors.toList()); stringBuilder.append(String.join(", ", params)); stringBuilder.append(")"); diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/resources/log4j.properties b/sdk/cosmos/azure-cosmos-benchmark/src/main/resources/log4j.properties similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/main/resources/log4j.properties rename to sdk/cosmos/azure-cosmos-benchmark/src/main/resources/log4j.properties diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java rename to sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java index 556d58405d18..b237158df609 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/QueryBuilderTest.java @@ -14,7 +14,7 @@ public class QueryBuilderTest { @Test(groups = {"unit"}) public void basic() { ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder(); - assertThat(queryBuilder.toSqlQuerySpec().queryText()) + assertThat(queryBuilder.toSqlQuerySpec().getQueryText()) .isEqualTo("SELECT * FROM root"); } @@ -22,7 +22,7 @@ public void basic() { public void top() { ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder(); queryBuilder.top(50); - assertThat(queryBuilder.toSqlQuerySpec().queryText()) + assertThat(queryBuilder.toSqlQuerySpec().getQueryText()) .isEqualTo("SELECT TOP 50 * FROM root"); } @@ -30,7 +30,7 @@ public void top() { public void orderBy() { ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder(); queryBuilder.orderBy("prop"); - assertThat(queryBuilder.toSqlQuerySpec().queryText()) + assertThat(queryBuilder.toSqlQuerySpec().getQueryText()) .isEqualTo("SELECT * FROM root ORDER BY root.prop"); } @@ -42,9 +42,9 @@ public void whereInClause() { new SqlParameter("@param2", 2)); queryBuilder.whereClause(new ReadMyWriteWorkflow.QueryBuilder.WhereClause.InWhereClause("colName", parameters)); - assertThat(queryBuilder.toSqlQuerySpec().queryText()) + assertThat(queryBuilder.toSqlQuerySpec().getQueryText()) .isEqualTo("SELECT * FROM root WHERE root.colName IN (@param1, @param2)"); - assertThat(queryBuilder.toSqlQuerySpec().parameters()).containsExactlyElementsOf(parameters); + assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters); } @Test(groups = {"unit"}) @@ -57,8 +57,8 @@ public void topOrderByWhereClause() { new SqlParameter("@param2", 2)); queryBuilder.whereClause(new ReadMyWriteWorkflow.QueryBuilder.WhereClause.InWhereClause("colName", parameters)); - assertThat(queryBuilder.toSqlQuerySpec().queryText()) + assertThat(queryBuilder.toSqlQuerySpec().getQueryText()) .isEqualTo("SELECT TOP 5 * FROM root WHERE root.colName IN (@param1, @param2) ORDER BY root.prop"); - assertThat(queryBuilder.toSqlQuerySpec().parameters()).containsExactlyElementsOf(parameters); + assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java rename to sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java index 4cc7b35e01b0..a782fe85d7e7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/ReadMyWritesConsistencyTest.java @@ -14,7 +14,6 @@ import com.azure.data.cosmos.internal.DocumentCollection; import com.azure.data.cosmos.internal.RequestOptions; import com.azure.data.cosmos.internal.TestConfigurations; -import com.azure.data.cosmos.internal.directconnectivity.Protocol; import com.beust.jcommander.JCommander; import com.google.common.base.CaseFormat; import com.google.common.base.Strings; @@ -81,7 +80,7 @@ public void beforeClass() { options.setOfferThroughput(initialCollectionThroughput); AsyncDocumentClient housekeepingClient = Utils.housekeepingClient(); database = Utils.createDatabaseForTest(housekeepingClient); - collection = housekeepingClient.createCollection("dbs/" + database.id(), + collection = housekeepingClient.createCollection("dbs/" + database.getId(), getCollectionDefinitionWithRangeRangeIndex(), options).single().block().getResource(); housekeepingClient.close(); @@ -117,8 +116,8 @@ public void readMyWrites(boolean useNameLink) throws Exception { String cmd = Strings.lenientFormat(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, desiredConsistency), concurrency, numberOfOperationsAsString, @@ -163,26 +162,26 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); BridgeInternal.setProperty(stringIndex, "precision", -1); indexes.add(stringIndex); Index numberIndex = Index.Range(DataType.NUMBER); - BridgeInternal.setProperty(numberIndex, "precision", -1); + BridgeInternal.setProperty(numberIndex, "getPrecision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setIndexingPolicy(indexingPolicy); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; @@ -196,8 +195,8 @@ private void scheduleScaleUp(int delayStartInSeconds, int newThroughput) { // for bulk insert and later queries. return housekeepingClient.queryOffers( String.format("SELECT * FROM r WHERE r.offerResourceId = '%s'", - collection.resourceId()) - , null).flatMap(page -> Flux.fromIterable(page.results())) + collection.getResourceId()) + , null).flatMap(page -> Flux.fromIterable(page.getResults())) .take(1).flatMap(offer -> { logger.info("going to scale up collection, newThroughput {}", newThroughput); offer.setThroughput(newThroughput); diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java rename to sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java index 486e0003fa03..dca4e5770eaa 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/Utils.java @@ -19,9 +19,9 @@ public class Utils { public static AsyncDocumentClient housekeepingClient() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); RetryOptions options = new RetryOptions(); - options.maxRetryAttemptsOnThrottledRequests(100); - options.maxRetryWaitTimeInSeconds(60); - connectionPolicy.retryOptions(options); + options.setMaxRetryAttemptsOnThrottledRequests(100); + options.setMaxRetryWaitTimeInSeconds(60); + connectionPolicy.setRetryOptions(options); return new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -29,7 +29,7 @@ public static AsyncDocumentClient housekeepingClient() { } public static String getCollectionLink(Database db, DocumentCollection collection) { - return "dbs/" + db.id() + "/colls/" + collection; + return "dbs/" + db.getId() + "/colls/" + collection; } public static Database createDatabaseForTest(AsyncDocumentClient client) { @@ -44,7 +44,7 @@ public static void safeCleanDatabases(AsyncDocumentClient client) { public static void safeClean(AsyncDocumentClient client, Database database) { if (database != null) { - safeClean(client, database.id()); + safeClean(client, database.getId()); } } @@ -96,4 +96,4 @@ public Flux> deleteDatabase(String id) { return client.deleteDatabase("dbs/" + id, null); } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java rename to sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java index 322ba57d7d15..42a02f312963 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/data/cosmos/benchmark/WorkflowTest.java @@ -44,8 +44,8 @@ public void readMyWritesCLI() throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id()); + database.getId(), + collection.getId()); Main.main(StringUtils.split(cmd)); } @@ -60,8 +60,8 @@ public void readMyWrites(boolean useNameLink) throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), numberOfOperations) + (useNameLink ? " -useNameLink" : ""); @@ -100,8 +100,8 @@ public void writeLatencyCLI() throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id()); + database.getId(), + collection.getId()); Main.main(StringUtils.split(cmd)); } @@ -116,8 +116,8 @@ public void writeLatency(boolean useNameLink) throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), numberOfOperations) + (useNameLink ? " -useNameLink" : ""); @@ -157,8 +157,8 @@ public void writeThroughput(boolean useNameLink) throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), numberOfOperations) + (useNameLink ? " -useNameLink" : ""); @@ -198,8 +198,8 @@ public void readLatency(boolean useNameLink) throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), numberOfOperations) + (useNameLink ? " -useNameLink" : ""); @@ -239,8 +239,8 @@ public void readThroughput(boolean useNameLink) throws Exception { String cmd = String.format(cmdFormat, TestConfigurations.HOST, TestConfigurations.MASTER_KEY, - database.id(), - collection.id(), + database.getId(), + collection.getId(), numberOfOperations) + (useNameLink ? " -useNameLink" : ""); @@ -275,7 +275,7 @@ public void beforeClass() { options.setOfferThroughput(10000); AsyncDocumentClient housekeepingClient = Utils.housekeepingClient(); database = Utils.createDatabaseForTest(housekeepingClient); - collection = housekeepingClient.createCollection("dbs/"+ database.id(), + collection = housekeepingClient.createCollection("dbs/"+ database.getId(), getCollectionDefinitionWithRangeRangeIndex(), options) .single().block().getResource(); @@ -303,11 +303,11 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); BridgeInternal.setProperty(stringIndex, "precision", -1); @@ -316,15 +316,15 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() { Index numberIndex = Index.Range(DataType.NUMBER); BridgeInternal.setProperty(numberIndex, "precision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setIndexingPolicy(indexingPolicy); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml b/sdk/cosmos/azure-cosmos-examples/pom.xml similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml rename to sdk/cosmos/azure-cosmos-examples/pom.xml index 31fc7f1ab690..f3b04de8f961 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/pom.xml +++ b/sdk/cosmos/azure-cosmos-examples/pom.xml @@ -6,14 +6,14 @@ Licensed under the MIT License. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.azure + com.azure azure-cosmos-parent - 3.3.0 + 4.0.0-preview.4 - com.microsoft.azure + com.azure azure-cosmos-examples - 3.3.0 + 4.0.0-preview.4 Microsoft Azure SDK for SQL API of Azure Cosmos DB Service - Examples This package contains examples for Microsoft Azure SDK for SQL API of Azure Cosmos DB Service https://github.com/Azure/azure-sdk-for-java @@ -87,9 +87,9 @@ Licensed under the MIT License. - com.microsoft.azure + com.azure azure-cosmos - 3.3.0 + 4.0.0-preview.4 diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/AccountSettings.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/AccountSettings.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/AccountSettings.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/AccountSettings.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java similarity index 76% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java index 50b9c4dde9bb..59caf9d44f45 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/BasicDemo.java @@ -2,14 +2,14 @@ // Licensed under the MIT License. package com.azure.data.cosmos.examples; -import com.azure.data.cosmos.CosmosClient; +import com.azure.data.cosmos.CosmosAsyncClient; +import com.azure.data.cosmos.CosmosAsyncContainer; +import com.azure.data.cosmos.CosmosAsyncDatabase; +import com.azure.data.cosmos.CosmosAsyncItem; +import com.azure.data.cosmos.CosmosAsyncItemResponse; import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItem; import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemResponse; import com.azure.data.cosmos.FeedOptions; import com.azure.data.cosmos.FeedResponse; import reactor.core.publisher.Flux; @@ -21,9 +21,9 @@ public class BasicDemo { private static final String DATABASE_NAME = "test_db"; private static final String CONTAINER_NAME = "test_container"; - private CosmosClient client; - private CosmosDatabase database; - private CosmosContainer container; + private CosmosAsyncClient client; + private CosmosAsyncDatabase database; + private CosmosAsyncContainer container; public static void main(String[] args) { BasicDemo demo = new BasicDemo(); @@ -32,10 +32,10 @@ public static void main(String[] args) { private void start(){ // Get client - client = CosmosClient.builder() - .endpoint(AccountSettings.HOST) - .key(AccountSettings.MASTER_KEY) - .build(); + client = CosmosAsyncClient.builder() + .setEndpoint(AccountSettings.HOST) + .setKey(AccountSettings.MASTER_KEY) + .buildAsyncClient(); //CREATE a database and a container createDbAndContainerBlocking(); @@ -43,14 +43,14 @@ private void start(){ //Get a proxy reference to container container = client.getDatabase(DATABASE_NAME).getContainer(CONTAINER_NAME); - CosmosContainer container = client.getDatabase(DATABASE_NAME).getContainer(CONTAINER_NAME); + CosmosAsyncContainer container = client.getDatabase(DATABASE_NAME).getContainer(CONTAINER_NAME); TestObject testObject = new TestObject("item_new_id_1", "test", "test description", "US"); TestObject testObject2 = new TestObject("item_new_id_2", "test2", "test description2", "CA"); //CREATE an Item async - Mono itemResponseMono = container.createItem(testObject); + Mono itemResponseMono = container.createItem(testObject); //CREATE another Item async - Mono itemResponseMono1 = container.createItem(testObject2); + Mono itemResponseMono1 = container.createItem(testObject2); //Wait for completion try { @@ -77,14 +77,14 @@ private void start(){ private void createAndReplaceItem() { TestObject replaceObject = new TestObject("item_new_id_3", "test3", "test description3", "JP"); - CosmosItem cosmosItem = null; + CosmosAsyncItem cosmosItem = null; //CREATE item sync try { cosmosItem = container.createItem(replaceObject) .doOnError(throwable -> log("CREATE 3", throwable)) .publishOn(Schedulers.elastic()) .block() - .item(); + .getItem(); }catch (RuntimeException e){ log("Couldn't create items due to above exceptions"); } @@ -98,9 +98,9 @@ private void createAndReplaceItem() { private void createDbAndContainerBlocking() { client.createDatabaseIfNotExists(DATABASE_NAME) - .doOnSuccess(cosmosDatabaseResponse -> log("Database: " + cosmosDatabaseResponse.database().id())) - .flatMap(dbResponse -> dbResponse.database().createContainerIfNotExists(new CosmosContainerProperties(CONTAINER_NAME, "/country"))) - .doOnSuccess(cosmosContainerResponse -> log("Container: " + cosmosContainerResponse.container().id())) + .doOnSuccess(cosmosDatabaseResponse -> log("Database: " + cosmosDatabaseResponse.getDatabase().getId())) + .flatMap(dbResponse -> dbResponse.getDatabase().createContainerIfNotExists(new CosmosContainerProperties(CONTAINER_NAME, "/country"))) + .doOnSuccess(cosmosContainerResponse -> log("Container: " + cosmosContainerResponse.getContainer().getId())) .doOnError(throwable -> log(throwable.getMessage())) .publishOn(Schedulers.elastic()) .block(); @@ -111,8 +111,8 @@ private void queryItems(){ log("+ Querying the collection "); String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); - options.maxDegreeOfParallelism(2); + options.setEnableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(2); Flux> queryFlux = container.queryItems(query, options); queryFlux.publishOn(Schedulers.elastic()).subscribe(cosmosItemFeedResponse -> {}, @@ -123,7 +123,7 @@ private void queryItems(){ .toIterable() .forEach(cosmosItemFeedResponse -> { - log(cosmosItemFeedResponse.results()); + log(cosmosItemFeedResponse.getResults()); }); } @@ -132,7 +132,7 @@ private void queryWithContinuationToken(){ log("+ Query with paging using continuation token"); String query = "SELECT * from root r "; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(true); options.maxItemCount(1); String continuation = null; @@ -141,8 +141,8 @@ private void queryWithContinuationToken(){ Flux> queryFlux = container.queryItems(query, options); FeedResponse page = queryFlux.blockFirst(); assert page != null; - log(page.results()); - continuation = page.continuationToken(); + log(page.getResults()); + continuation = page.getContinuationToken(); }while(continuation!= null); } @@ -152,10 +152,12 @@ private void log(Object object) { } private void log(String msg, Throwable throwable){ - log(msg + ": " + ((CosmosClientException)throwable).statusCode()); + if (throwable instanceof CosmosClientException) { + log(msg + ": " + ((CosmosClientException) throwable).getStatusCode()); + } } - class TestObject { + static class TestObject { String id; String name; String description; @@ -200,4 +202,4 @@ public void setDescription(String description) { this.description = description; } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java similarity index 68% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java index e7e7067b186d..be85d69cb193 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java @@ -2,18 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.examples.ChangeFeed; -import com.azure.data.cosmos.ChangeFeedProcessor; -import com.azure.data.cosmos.ConnectionPolicy; -import com.azure.data.cosmos.ConsistencyLevel; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.SerializationFormattingPolicy; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.apache.commons.lang3.RandomStringUtils; import java.time.Duration; @@ -37,16 +27,16 @@ public static void main (String[]args) { try { System.out.println("-->CREATE DocumentClient"); - CosmosClient client = getCosmosClient(); + CosmosAsyncClient client = getCosmosClient(); System.out.println("-->CREATE sample's database: " + DATABASE_NAME); - CosmosDatabase cosmosDatabase = createNewDatabase(client, DATABASE_NAME); + CosmosAsyncDatabase cosmosDatabase = createNewDatabase(client, DATABASE_NAME); System.out.println("-->CREATE container for documents: " + COLLECTION_NAME); - CosmosContainer feedContainer = createNewCollection(client, DATABASE_NAME, COLLECTION_NAME); + CosmosAsyncContainer feedContainer = createNewCollection(client, DATABASE_NAME, COLLECTION_NAME); System.out.println("-->CREATE container for lease: " + COLLECTION_NAME + "-leases"); - CosmosContainer leaseContainer = createNewLeaseCollection(client, DATABASE_NAME, COLLECTION_NAME + "-leases"); + CosmosAsyncContainer leaseContainer = createNewLeaseCollection(client, DATABASE_NAME, COLLECTION_NAME + "-leases"); changeFeedProcessorInstance = getChangeFeedProcessor("SampleHost_1", feedContainer, leaseContainer); @@ -82,13 +72,13 @@ public static void main (String[]args) { System.exit(0); } - public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosContainer feedContainer, CosmosContainer leaseContainer) { + public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, CosmosAsyncContainer feedContainer, CosmosAsyncContainer leaseContainer) { return ChangeFeedProcessor.Builder() - .hostName(hostName) - .feedContainer(feedContainer) - .leaseContainer(leaseContainer) - .handleChanges(docs -> { - System.out.println("--->handleChanges() START"); + .setHostName(hostName) + .setFeedContainer(feedContainer) + .setLeaseContainer(leaseContainer) + .setHandleChanges(docs -> { + System.out.println("--->setHandleChanges() START"); for (CosmosItemProperties document : docs) { System.out.println("---->DOCUMENT RECEIVED: " + document.toJson(SerializationFormattingPolicy.INDENTED)); @@ -99,28 +89,28 @@ public static ChangeFeedProcessor getChangeFeedProcessor(String hostName, Cosmos .build(); } - public static CosmosClient getCosmosClient() { + public static CosmosAsyncClient getCosmosClient() { - return CosmosClient.builder() - .endpoint(SampleConfigurations.HOST) - .key(SampleConfigurations.MASTER_KEY) - .connectionPolicy(ConnectionPolicy.defaultPolicy()) - .consistencyLevel(ConsistencyLevel.EVENTUAL) - .build(); + return CosmosAsyncClient.builder() + .setEndpoint(SampleConfigurations.HOST) + .setKey(SampleConfigurations.MASTER_KEY) + .setConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) + .setConsistencyLevel(ConsistencyLevel.EVENTUAL) + .buildAsyncClient(); } - public static CosmosDatabase createNewDatabase(CosmosClient client, String databaseName) { - return client.createDatabaseIfNotExists(databaseName).block().database(); + public static CosmosAsyncDatabase createNewDatabase(CosmosAsyncClient client, String databaseName) { + return client.createDatabaseIfNotExists(databaseName).block().getDatabase(); } - public static void deleteDatabase(CosmosDatabase cosmosDatabase) { + public static void deleteDatabase(CosmosAsyncDatabase cosmosDatabase) { cosmosDatabase.delete().block(); } - public static CosmosContainer createNewCollection(CosmosClient client, String databaseName, String collectionName) { - CosmosDatabase databaseLink = client.getDatabase(databaseName); - CosmosContainer collectionLink = databaseLink.getContainer(collectionName); - CosmosContainerResponse containerResponse = null; + public static CosmosAsyncContainer createNewCollection(CosmosAsyncClient client, String databaseName, String collectionName) { + CosmosAsyncDatabase databaseLink = client.getDatabase(databaseName); + CosmosAsyncContainer collectionLink = databaseLink.getContainer(collectionName); + CosmosAsyncContainerResponse containerResponse = null; try { containerResponse = collectionLink.read().block(); @@ -132,7 +122,7 @@ public static CosmosContainer createNewCollection(CosmosClient client, String da if (ex.getCause() instanceof CosmosClientException) { CosmosClientException cosmosClientException = (CosmosClientException) ex.getCause(); - if (cosmosClientException.statusCode() != 404) { + if (cosmosClientException.getStatusCode() != 404) { throw ex; } } else { @@ -150,13 +140,13 @@ public static CosmosContainer createNewCollection(CosmosClient client, String da throw new RuntimeException(String.format("Failed to create collection %s in database %s.", collectionName, databaseName)); } - return containerResponse.container(); + return containerResponse.getContainer(); } - public static CosmosContainer createNewLeaseCollection(CosmosClient client, String databaseName, String leaseCollectionName) { - CosmosDatabase databaseLink = client.getDatabase(databaseName); - CosmosContainer leaseCollectionLink = databaseLink.getContainer(leaseCollectionName); - CosmosContainerResponse leaseContainerResponse = null; + public static CosmosAsyncContainer createNewLeaseCollection(CosmosAsyncClient client, String databaseName, String leaseCollectionName) { + CosmosAsyncDatabase databaseLink = client.getDatabase(databaseName); + CosmosAsyncContainer leaseCollectionLink = databaseLink.getContainer(leaseCollectionName); + CosmosAsyncContainerResponse leaseContainerResponse = null; try { leaseContainerResponse = leaseCollectionLink.read().block(); @@ -174,7 +164,7 @@ public static CosmosContainer createNewLeaseCollection(CosmosClient client, Stri if (ex.getCause() instanceof CosmosClientException) { CosmosClientException cosmosClientException = (CosmosClientException) ex.getCause(); - if (cosmosClientException.statusCode() != 404) { + if (cosmosClientException.getStatusCode() != 404) { throw ex; } } else { @@ -191,17 +181,17 @@ public static CosmosContainer createNewLeaseCollection(CosmosClient client, Stri throw new RuntimeException(String.format("Failed to create collection %s in database %s.", leaseCollectionName, databaseName)); } - return leaseContainerResponse.container(); + return leaseContainerResponse.getContainer(); } - public static void createNewDocuments(CosmosContainer containerClient, int count, Duration delay) { + public static void createNewDocuments(CosmosAsyncContainer containerClient, int count, Duration delay) { String suffix = RandomStringUtils.randomAlphabetic(10); for (int i = 0; i <= count; i++) { CosmosItemProperties document = new CosmosItemProperties(); - document.id(String.format("0%d-%s", i, suffix)); + document.setId(String.format("0%d-%s", i, suffix)); containerClient.createItem(document).subscribe(doc -> { - System.out.println("---->DOCUMENT WRITE: " + doc.properties().toJson(SerializationFormattingPolicy.INDENTED)); + System.out.println("---->DOCUMENT WRITE: " + doc.getProperties().toJson(SerializationFormattingPolicy.INDENTED)); }); long remainingWork = delay.toMillis(); diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleConfigurations.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleConfigurations.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleConfigurations.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed/SampleConfigurations.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java similarity index 74% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java index 2f8af65fc63d..36b69713d784 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/examples/HelloWorldDemo.java @@ -13,43 +13,43 @@ public static void main(String[] args) { } void runDemo() { - // Create a new CosmosClient via the builder + // Create a new CosmosAsyncClient via the builder // It only requires endpoint and key, but other useful settings are available - CosmosClient client = CosmosClient.builder() - .endpoint("") - .key("") - .build(); + CosmosAsyncClient client = CosmosAsyncClient.builder() + .setEndpoint("") + .setKey("") + .buildAsyncClient(); // Get a reference to the container // This will create (or read) a database and its container. - CosmosContainer container = client.createDatabaseIfNotExists("contoso-travel") + CosmosAsyncContainer container = client.createDatabaseIfNotExists("contoso-travel") // TIP: Our APIs are Reactor Core based, so try to chain your calls - .flatMap(response -> response.database() + .flatMap(response -> response.getDatabase() .createContainerIfNotExists("passengers", "/id")) - .flatMap(response -> Mono.just(response.container())) + .flatMap(response -> Mono.just(response.getContainer())) .block(); // Blocking for demo purposes (avoid doing this in production unless you must) // Create an item container.createItem(new Passenger("carla.davis@outlook.com", "Carla Davis", "SEA", "IND")) .flatMap(response -> { - System.out.println("Created item: " + response.properties().toJson()); + System.out.println("Created item: " + response.getProperties().toJson()); // Read that item 👓 - return response.item().read(); + return response.getItem().read(); }) .flatMap(response -> { - System.out.println("Read item: " + response.properties().toJson()); + System.out.println("Read item: " + response.getProperties().toJson()); // Replace that item 🔁 try { - Passenger p = response.properties().getObject(Passenger.class); + Passenger p = response.getProperties().getObject(Passenger.class); p.setDestination("SFO"); - return response.item().replace(p); + return response.getItem().replace(p); } catch (IOException e) { System.err.println(e); return Mono.error(e); } }) // delete that item 💣 - .flatMap(response -> response.item().delete()) + .flatMap(response -> response.getItem().delete()) .block(); // Blocking for demo purposes (avoid doing this in production unless you must) } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/ConfigurationManager.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/ConfigurationManager.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/ConfigurationManager.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/ConfigurationManager.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java index fd64d2cf0a51..92f7f19ccc00 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/Helpers.java @@ -28,11 +28,11 @@ static public Mono createDatabaseIfNotExists(AsyncDocumentClient clien e -> { if (e instanceof CosmosClientException) { CosmosClientException dce = (CosmosClientException) e; - if (dce.statusCode() == 404) { + if (dce.getStatusCode() == 404) { // if doesn't exist create it Database d = new Database(); - d.id(databaseName); + d.setId(databaseName); return client.createDatabase(d, null); } @@ -49,11 +49,11 @@ static public Mono createCollectionIfNotExists(AsyncDocument e -> { if (e instanceof CosmosClientException) { CosmosClientException dce = (CosmosClientException) e; - if (dce.statusCode() == 404) { + if (dce.getStatusCode() == 404) { // if doesn't exist create it DocumentCollection collection = new DocumentCollection(); - collection.id(collectionName); + collection.setId(collectionName); return client.createCollection(createDatabaseUri(databaseName), collection, null); } @@ -65,12 +65,12 @@ static public Mono createCollectionIfNotExists(AsyncDocument } static public Mono createCollectionIfNotExists(AsyncDocumentClient client, String databaseName, DocumentCollection collection) { - return client.readCollection(createDocumentCollectionUri(databaseName, collection.id()), null) + return client.readCollection(createDocumentCollectionUri(databaseName, collection.getId()), null) .onErrorResume( e -> { if (e instanceof CosmosClientException) { CosmosClientException dce = (CosmosClientException) e; - if (dce.statusCode() == 404) { + if (dce.getStatusCode() == 404) { // if doesn't exist create it return client.createCollection(createDatabaseUri(databaseName), collection, null); diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java index b8dd4b83e84f..4615dc7e2f10 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/ConflictWorker.java @@ -83,7 +83,7 @@ private DocumentCollection createCollectionIfNotExists(AsyncDocumentClient creat private DocumentCollection getCollectionDefForManual(String id) { DocumentCollection collection = new DocumentCollection(); - collection.id(id); + collection.setId(id); ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(); collection.setConflictResolutionPolicy(policy); return collection; @@ -91,7 +91,7 @@ private DocumentCollection getCollectionDefForManual(String id) { private DocumentCollection getCollectionDefForLastWinWrites(String id, String conflictResolutionPath) { DocumentCollection collection = new DocumentCollection(); - collection.id(id); + collection.setId(id); ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy(conflictResolutionPath); collection.setConflictResolutionPolicy(policy); return collection; @@ -99,7 +99,7 @@ private DocumentCollection getCollectionDefForLastWinWrites(String id, String co private DocumentCollection getCollectionDefForCustom(String id, String storedProc) { DocumentCollection collection = new DocumentCollection(); - collection.id(id); + collection.setId(id); ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(storedProc); collection.setConflictResolutionPolicy(policy); return collection; @@ -123,7 +123,7 @@ public void initialize() throws Exception { String.format("dbs/%s/colls/%s/sprocs/%s", this.databaseName, this.udpCollectionName, "resolver"))); StoredProcedure lwwSproc = new StoredProcedure(); - lwwSproc.id("resolver"); + lwwSproc.setId("resolver"); lwwSproc.setBody(IOUtils.toString( getClass().getClassLoader().getResourceAsStream("resolver-storedproc.txt"), "UTF-8")); @@ -177,7 +177,7 @@ public void runInsertConflictOnManual() throws Exception { ArrayList> insertTask = new ArrayList<>(); Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); int index = 0; for (AsyncDocumentClient client : this.clients) { @@ -202,7 +202,7 @@ public void runInsertConflictOnManual() throws Exception { public void runUpdateConflictOnManual() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.manualCollectionUri, conflictDocument, 0) @@ -238,7 +238,7 @@ public void runUpdateConflictOnManual() throws Exception { public void runDeleteConflictOnManual() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.manualCollectionUri, conflictDocument, 0) .singleOrEmpty().block(); @@ -279,7 +279,7 @@ public void runInsertConflictOnLWW() throws Exception { ArrayList> insertTask = new ArrayList<>(); Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); int index = 0; for (AsyncDocumentClient client : this.clients) { @@ -304,7 +304,7 @@ public void runInsertConflictOnLWW() throws Exception { public void runUpdateConflictOnLWW() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.lwwCollectionUri, conflictDocument, 0) .singleOrEmpty().block(); @@ -339,7 +339,7 @@ public void runUpdateConflictOnLWW() throws Exception { public void runDeleteConflictOnLWW() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.lwwCollectionUri, conflictDocument, 0) .singleOrEmpty().block(); @@ -382,7 +382,7 @@ public void runInsertConflictOnUdp() throws Exception { ArrayList> insertTask = new ArrayList<>(); Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); int index = 0; for (AsyncDocumentClient client : this.clients) { @@ -407,7 +407,7 @@ public void runInsertConflictOnUdp() throws Exception { public void runUpdateConflictOnUdp() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.udpCollectionUri, conflictDocument, 0) .singleOrEmpty().block(); @@ -441,7 +441,7 @@ public void runUpdateConflictOnUdp() throws Exception { public void runDeleteConflictOnUdp() throws Exception { do { Document conflictDocument = new Document(); - conflictDocument.id(UUID.randomUUID().toString()); + conflictDocument.setId(UUID.randomUUID().toString()); conflictDocument = this.tryInsertDocument(clients.get(0), this.udpCollectionUri, conflictDocument, 0) .singleOrEmpty().block(); @@ -494,7 +494,7 @@ private Flux tryInsertDocument(AsyncDocumentClient client, String coll private boolean hasDocumentClientException(Throwable e, int statusCode) { if (e instanceof CosmosClientException) { CosmosClientException dce = (CosmosClientException) e; - return dce.statusCode() == statusCode; + return dce.getStatusCode() == statusCode; } return false; @@ -515,7 +515,7 @@ private boolean hasDocumentClientExceptionCause(Throwable e, int statusCode) { while (e != null) { if (e instanceof CosmosClientException) { CosmosClientException dce = (CosmosClientException) e; - return dce.statusCode() == statusCode; + return dce.getStatusCode() == statusCode; } e = e.getCause(); @@ -530,11 +530,11 @@ private Flux tryUpdateDocument(AsyncDocumentClient client, String coll RequestOptions options = new RequestOptions(); options.setAccessCondition(new AccessCondition()); - options.getAccessCondition().type(AccessConditionType.IF_MATCH); - options.getAccessCondition().condition(document.etag()); + options.getAccessCondition().setType(AccessConditionType.IF_MATCH); + options.getAccessCondition().setCondition(document.getETag()); - return client.replaceDocument(document.selfLink(), document, null).onErrorResume(e -> { + return client.replaceDocument(document.getSelfLink(), document, null).onErrorResume(e -> { // pre condition failed if (hasDocumentClientException(e, 412)) { @@ -552,11 +552,11 @@ private Flux tryDeleteDocument(AsyncDocumentClient client, String coll RequestOptions options = new RequestOptions(); options.setAccessCondition(new AccessCondition()); - options.getAccessCondition().type(AccessConditionType.IF_MATCH); - options.getAccessCondition().condition(document.etag()); + options.getAccessCondition().setType(AccessConditionType.IF_MATCH); + options.getAccessCondition().setCondition(document.getETag()); - return client.deleteDocument(document.selfLink(), options).onErrorResume(e -> { + return client.deleteDocument(document.getSelfLink(), options).onErrorResume(e -> { // pre condition failed if (hasDocumentClientException(e, 412)) { @@ -593,21 +593,21 @@ private boolean validateManualConflict(AsyncDocumentClient client, Document conf FeedResponse response = client.readConflicts(this.manualCollectionUri, null) .take(1).single().block(); - for (Conflict conflict : response.results()) { + for (Conflict conflict : response.getResults()) { if (!isDelete(conflict)) { Document conflictDocumentContent = conflict.getResource(Document.class); - if (equals(conflictDocument.id(), conflictDocumentContent.id())) { - if (equals(conflictDocument.resourceId(), conflictDocumentContent.resourceId()) && - equals(conflictDocument.etag(), conflictDocumentContent.etag())) { + if (equals(conflictDocument.getId(), conflictDocumentContent.getId())) { + if (equals(conflictDocument.getResourceId(), conflictDocumentContent.getResourceId()) && + equals(conflictDocument.getETag(), conflictDocumentContent.getETag())) { logger.info("Document from Region {} lost conflict @ {}", - conflictDocument.id(), + conflictDocument.getId(), conflictDocument.getInt("regionId"), client.getReadEndpoint()); return true; } else { try { //Checking whether this is the winner. - Document winnerDocument = client.readDocument(conflictDocument.selfLink(), null) + Document winnerDocument = client.readDocument(conflictDocument.getSelfLink(), null) .single().block().getResource(); logger.info("Document from region {} won the conflict @ {}", conflictDocument.getInt("regionId"), @@ -627,7 +627,7 @@ private boolean validateManualConflict(AsyncDocumentClient client, Document conf } } } else { - if (equals(conflict.getSourceResourceId(), conflictDocument.resourceId())) { + if (equals(conflict.getSourceResourceId(), conflictDocument.getResourceId())) { logger.info("DELETE conflict found @ {}", client.getReadEndpoint()); return false; @@ -636,7 +636,7 @@ private boolean validateManualConflict(AsyncDocumentClient client, Document conf } logger.error("Document {} is not found in conflict feed @ {}, retrying", - conflictDocument.id(), + conflictDocument.getId(), client.getReadEndpoint()); TimeUnit.MILLISECONDS.sleep(500); @@ -648,23 +648,23 @@ private void deleteConflict(Document conflictDocument) { FeedResponse conflicts = delClient.readConflicts(this.manualCollectionUri, null).take(1).single().block(); - for (Conflict conflict : conflicts.results()) { + for (Conflict conflict : conflicts.getResults()) { if (!isDelete(conflict)) { Document conflictContent = conflict.getResource(Document.class); - if (equals(conflictContent.resourceId(), conflictDocument.resourceId()) - && equals(conflictContent.etag(), conflictDocument.etag())) { + if (equals(conflictContent.getResourceId(), conflictDocument.getResourceId()) + && equals(conflictContent.getETag(), conflictDocument.getETag())) { logger.info("Deleting manual conflict {} from region {}", conflict.getSourceResourceId(), conflictContent.getInt("regionId")); - delClient.deleteConflict(conflict.selfLink(), null) + delClient.deleteConflict(conflict.getSelfLink(), null) .single().block(); } - } else if (equals(conflict.getSourceResourceId(), conflictDocument.resourceId())) { + } else if (equals(conflict.getSourceResourceId(), conflictDocument.getResourceId())) { logger.info("Deleting manual conflict {} from region {}", conflict.getSourceResourceId(), conflictDocument.getInt("regionId")); - delClient.deleteConflict(conflict.selfLink(), null) + delClient.deleteConflict(conflict.getSelfLink(), null) .single().block(); } } @@ -685,18 +685,18 @@ private void validateLWW(AsyncDocumentClient client, List conflictDocu FeedResponse response = client.readConflicts(this.lwwCollectionUri, null) .take(1).single().block(); - if (response.results().size() != 0) { - logger.error("Found {} conflicts in the lww collection", response.results().size()); + if (response.getResults().size() != 0) { + logger.error("Found {} conflicts in the lww collection", response.getResults().size()); return; } if (hasDeleteConflict) { do { try { - client.readDocument(conflictDocument.get(0).selfLink(), null).single().block(); + client.readDocument(conflictDocument.get(0).getSelfLink(), null).single().block(); logger.error("DELETE conflict for document {} didnt win @ {}", - conflictDocument.get(0).id(), + conflictDocument.get(0).getId(), client.getReadEndpoint()); TimeUnit.MILLISECONDS.sleep(500); @@ -712,7 +712,7 @@ private void validateLWW(AsyncDocumentClient client, List conflictDocu return; } else { logger.error("DELETE conflict for document {} didnt win @ {}", - conflictDocument.get(0).id(), + conflictDocument.get(0).getId(), client.getReadEndpoint()); TimeUnit.MILLISECONDS.sleep(500); @@ -735,7 +735,7 @@ private void validateLWW(AsyncDocumentClient client, List conflictDocu while (true) { try { - Document existingDocument = client.readDocument(winnerDocument.selfLink(), null) + Document existingDocument = client.readDocument(winnerDocument.getSelfLink(), null) .single().block().getResource(); if (existingDocument.getInt("regionId") == winnerDocument.getInt("regionId")) { @@ -775,8 +775,8 @@ private String documentNameLink(String collectionId, String documentId) { private void validateUDPAsync(AsyncDocumentClient client, List conflictDocument, boolean hasDeleteConflict) throws Exception { FeedResponse response = client.readConflicts(this.udpCollectionUri, null).take(1).single().block(); - if (response.results().size() != 0) { - logger.error("Found {} conflicts in the udp collection", response.results().size()); + if (response.getResults().size() != 0) { + logger.error("Found {} conflicts in the udp collection", response.getResults().size()); return; } @@ -784,11 +784,11 @@ private void validateUDPAsync(AsyncDocumentClient client, List conflic do { try { client.readDocument( - documentNameLink(udpCollectionName, conflictDocument.get(0).id()), null) + documentNameLink(udpCollectionName, conflictDocument.get(0).getId()), null) .single().block(); logger.error("DELETE conflict for document {} didnt win @ {}", - conflictDocument.get(0).id(), + conflictDocument.get(0).getId(), client.getReadEndpoint()); TimeUnit.MILLISECONDS.sleep(500); @@ -799,7 +799,7 @@ private void validateUDPAsync(AsyncDocumentClient client, List conflic return; } else { logger.error("DELETE conflict for document {} didnt win @ {}", - conflictDocument.get(0).id(), + conflictDocument.get(0).getId(), client.getReadEndpoint()); TimeUnit.MILLISECONDS.sleep(500); @@ -824,7 +824,7 @@ private void validateUDPAsync(AsyncDocumentClient client, List conflic try { Document existingDocument = client.readDocument( - documentNameLink(udpCollectionName, winnerDocument.id()), null) + documentNameLink(udpCollectionName, winnerDocument.getId()), null) .single().block().getResource(); if (existingDocument.getInt("regionId") == winnerDocument.getInt( diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Main.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Main.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Main.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Main.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java index 91e224dd5ffe..34b971fdfd8f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java @@ -51,8 +51,8 @@ public MultiMasterScenario() { for (String region : regions) { ConnectionPolicy policy = new ConnectionPolicy(); - policy.usingMultipleWriteLocations(true); - policy.preferredLocations(Collections.singletonList(region)); + policy.setUsingMultipleWriteLocations(true); + policy.setPreferredLocations(Collections.singletonList(region)); AsyncDocumentClient client = new AsyncDocumentClient.Builder() diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java rename to sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java index 5d91d924366e..850a207bcbb0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/data/cosmos/rx/examples/multimaster/samples/Worker.java @@ -50,7 +50,7 @@ public Mono runLoopAsync(int documentsToInsert) { long startTick = System.currentTimeMillis(); Document d = new Document(); - d.id(UUID.randomUUID().toString()); + d.setId(UUID.randomUUID().toString()); this.client.createDocument(this.documentCollectionUri, d, null, false) .subscribeOn(schedulerForBlockingWork).single().block(); @@ -85,13 +85,13 @@ public Mono readAllAsync(int expectedNumberOfDocuments) { do { FeedOptions options = new FeedOptions(); - options.requestContinuation(response != null ? response.continuationToken() : null); + options.requestContinuation(response != null ? response.getContinuationToken() : null); response = this.client.readDocuments(this.documentCollectionUri, options).take(1) .subscribeOn(schedulerForBlockingWork).single().block(); - totalItemRead += response.results().size(); - } while (response.continuationToken() != null); + totalItemRead += response.getResults().size(); + } while (response.getContinuationToken() != null); if (totalItemRead < expectedNumberOfDocuments) { logger.info("Total item read {} from {} is less than {}, retrying reads", @@ -122,22 +122,22 @@ void deleteAll() { do { FeedOptions options = new FeedOptions(); - options.requestContinuation(response != null ? response.continuationToken() : null); + options.requestContinuation(response != null ? response.getContinuationToken() : null); response = this.client.readDocuments(this.documentCollectionUri, options).take(1) .subscribeOn(schedulerForBlockingWork).single().block(); - documents.addAll(response.results()); - } while (response.continuationToken() != null); + documents.addAll(response.getResults()); + } while (response.getContinuationToken() != null); for (Document document : documents) { try { - this.client.deleteDocument(document.selfLink(), null) + this.client.deleteDocument(document.getSelfLink(), null) .subscribeOn(schedulerForBlockingWork).single().block(); } catch (RuntimeException exEx) { CosmosClientException dce = getDocumentClientExceptionCause(exEx); - if (dce.statusCode() != 404) { + if (dce.getStatusCode() != 404) { logger.info("Error occurred while deleting {} from {}", dce, client.getWriteEndpoint()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/log4j.properties b/sdk/cosmos/azure-cosmos-examples/src/main/resources/log4j.properties similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/log4j.properties rename to sdk/cosmos/azure-cosmos-examples/src/main/resources/log4j.properties diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/multi-master-sample-config.properties b/sdk/cosmos/azure-cosmos-examples/src/main/resources/multi-master-sample-config.properties similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/multi-master-sample-config.properties rename to sdk/cosmos/azure-cosmos-examples/src/main/resources/multi-master-sample-config.properties diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/resolver-storedproc.txt b/sdk/cosmos/azure-cosmos-examples/src/main/resources/resolver-storedproc.txt similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/main/resources/resolver-storedproc.txt rename to sdk/cosmos/azure-cosmos-examples/src/main/resources/resolver-storedproc.txt diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java index 0c45a360f2b0..00c9079b7ad8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/DocumentClientTest.java @@ -36,7 +36,7 @@ public final String getTestName() { @BeforeMethod(alwaysRun = true) public final void setTestName(Method method) { - String connectionMode = this.clientBuilder.getConnectionPolicy().connectionMode() == ConnectionMode.DIRECT + String connectionMode = this.clientBuilder.getConnectionPolicy().getConnectionMode() == ConnectionMode.DIRECT ? "Direct " + this.clientBuilder.getConfigs().getProtocol() : "Gateway"; diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java index bb6c46878c44..d84194fb5c58 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java @@ -73,7 +73,7 @@ public class CollectionCRUDAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -89,11 +89,11 @@ public void setUp() { @BeforeMethod(groups = "samples", timeOut = TIMEOUT) public void before() { collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); } @@ -232,7 +232,7 @@ public void createCollection_toBlocking_CollectionAlreadyExists_Fails() { .block(); // Blocks assertThat("Should not reach here", false); } catch (Exception e) { - assertThat("Collection already exists.", ((CosmosClientException) e.getCause()).statusCode(), + assertThat("Collection already exists.", ((CosmosClientException) e.getCause()).getStatusCode(), equalTo(409)); } } @@ -324,7 +324,7 @@ public void collectionCreateAndQuery() throws Exception { // Query the created collection using async api Flux> queryCollectionObservable = client.queryCollections( - getDatabaseLink(), String.format("SELECT * FROM r where r.id = '%s'", collection.id()), + getDatabaseLink(), String.format("SELECT * FROM r where r.id = '%s'", collection.getId()), null); final CountDownLatch countDownLatch = new CountDownLatch(1); @@ -335,13 +335,13 @@ public void collectionCreateAndQuery() throws Exception { // First element of the list should have only 1 result FeedResponse collectionFeedResponse = collectionFeedResponseList.get(0); - assertThat(collectionFeedResponse.results().size(), equalTo(1)); + assertThat(collectionFeedResponse.getResults().size(), equalTo(1)); - // This collection should have the same id as the one we created - DocumentCollection foundCollection = collectionFeedResponse.results().get(0); - assertThat(foundCollection.id(), equalTo(collection.id())); + // This collection should have the same getId as the one we created + DocumentCollection foundCollection = collectionFeedResponse.getResults().get(0); + assertThat(foundCollection.getId(), equalTo(collection.getId())); - System.out.println(collectionFeedResponse.activityId()); + System.out.println(collectionFeedResponse.getActivityId()); countDownLatch.countDown(); }, error -> { System.err.println("an error occurred while querying the collection: actual cause: " + error.getMessage()); @@ -353,39 +353,39 @@ public void collectionCreateAndQuery() throws Exception { } private String getDatabaseLink() { - return "dbs/" + createdDatabase.id(); + return "dbs/" + createdDatabase.getId(); } private String getCollectionLink(DocumentCollection collection) { - return "dbs/" + createdDatabase.id() + "/colls/" + collection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + collection.getId(); } private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); // Set the partitionKeyDefinition for a partitioned collection. // Here, we are setting the partitionKey of the Collection to be /city PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List paths = new ArrayList<>(); paths.add("/city"); - partitionKeyDefinition.paths(paths); + partitionKeyDefinition.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDefinition); // Set indexing policy to be range range for string and number IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); - BridgeInternal.setProperty(stringIndex, "precision", -1); + BridgeInternal.setProperty(stringIndex, "getPrecision", -1); indexes.add(stringIndex); Index numberIndex = Index.Range(DataType.NUMBER); - BridgeInternal.setProperty(numberIndex, "precision", -1); + BridgeInternal.setProperty(numberIndex, "getPrecision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); collectionDefinition.setIndexingPolicy(indexingPolicy); diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java index 4901b8aa7f03..e20be5ac7b18 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/ConflictAPITest.java @@ -53,7 +53,7 @@ public class ConflictAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -64,11 +64,11 @@ public void setUp() { this.client = this.clientBuilder().build(); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); // CREATE database @@ -76,7 +76,7 @@ public void setUp() { // CREATE collection createdCollection = client - .createCollection("/dbs/" + createdDatabase.id(), collectionDefinition, null) + .createCollection("/dbs/" + createdDatabase.getId(), collectionDefinition, null) .single().block().getResource(); int numberOfDocuments = 20; @@ -116,11 +116,11 @@ public void readConflicts_toBlocking_toIterator() { int numberOfResults = 0; while (it.hasNext()) { FeedResponse page = it.next(); - System.out.println("items: " + page.results()); - String pageSizeAsString = page.responseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); - assertThat("header item count must be present", pageSizeAsString, notNullValue()); + System.out.println("items: " + page.getResults()); + String pageSizeAsString = page.getResponseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); + assertThat("header getItem count must be present", pageSizeAsString, notNullValue()); int pageSize = Integer.valueOf(pageSizeAsString); - assertThat("Result size must match header item count", page.results(), hasSize(pageSize)); + assertThat("Result size must match header getItem count", page.getResults(), hasSize(pageSize)); numberOfResults += pageSize; } assertThat("number of total results", numberOfResults, equalTo(expectedNumberOfConflicts)); @@ -148,13 +148,13 @@ public void transformObservableToCompletableFuture() throws Exception { int totalNumberOfRetrievedConflicts = 0; for (FeedResponse page : pageList) { - totalNumberOfRetrievedConflicts += page.results().size(); + totalNumberOfRetrievedConflicts += page.getResults().size(); } assertThat(0, equalTo(totalNumberOfRetrievedConflicts)); } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java index 150099170d95..300f0c090cdb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java @@ -57,7 +57,7 @@ public class DatabaseCRUDAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -70,9 +70,9 @@ public void setUp() { private Database getDatabaseDefinition() { Database databaseDefinition = new Database(); - databaseDefinition.id(Utils.generateDatabaseId()); + databaseDefinition.setId(Utils.generateDatabaseId()); - databaseIds.add(databaseDefinition.id()); + databaseIds.add(databaseDefinition.getId()); return databaseDefinition; } @@ -180,7 +180,7 @@ public void createDatabase_toBlocking_DatabaseAlreadyExists_Fails() { .block(); // Blocks to get the result assertThat("Should not reach here", false); } catch (Exception e) { - assertThat("Database already exists.", ((CosmosClientException) e.getCause()).statusCode(), + assertThat("Database already exists.", ((CosmosClientException) e.getCause()).getStatusCode(), equalTo(409)); } } @@ -208,8 +208,8 @@ public void createAndReadDatabase() throws Exception { // CREATE a database Database database = client.createDatabase(getDatabaseDefinition(), null).single().block().getResource(); - // READ the created database using async api - Flux> readDatabaseObservable = client.readDatabase("dbs/" + database.id(), + // READ the created getDatabase using async api + Flux> readDatabaseObservable = client.readDatabase("dbs/" + database.getId(), null); final CountDownLatch completionLatch = new CountDownLatch(1); @@ -238,7 +238,7 @@ public void createAndDeleteDatabase() throws Exception { // DELETE the created database using async api Flux> deleteDatabaseObservable = client - .deleteDatabase("dbs/" + database.id(), null); + .deleteDatabase("dbs/" + database.getId(), null); final CountDownLatch completionLatch = new CountDownLatch(1); @@ -267,7 +267,7 @@ public void databaseCreateAndQuery() throws Exception { // Query the created database using async api Flux> queryDatabaseObservable = client - .queryDatabases(String.format("SELECT * FROM r where r.id = '%s'", databaseDefinition.id()), null); + .queryDatabases(String.format("SELECT * FROM r where r.id = '%s'", databaseDefinition.getId()), null); final CountDownLatch completionLatch = new CountDownLatch(1); @@ -277,13 +277,13 @@ public void databaseCreateAndQuery() throws Exception { // First element of the list should have only 1 result FeedResponse databaseFeedResponse = databaseFeedResponseList.get(0); - assertThat(databaseFeedResponse.results().size(), equalTo(1)); + assertThat(databaseFeedResponse.getResults().size(), equalTo(1)); - // This database should have the same id as the one we created - Database foundDatabase = databaseFeedResponse.results().get(0); - assertThat(foundDatabase.id(), equalTo(databaseDefinition.id())); + // This getDatabase should have the same getId as the one we created + Database foundDatabase = databaseFeedResponse.getResults().get(0); + assertThat(foundDatabase.getId(), equalTo(databaseDefinition.getId())); - System.out.println(databaseFeedResponse.activityId()); + System.out.println(databaseFeedResponse.getActivityId()); completionLatch.countDown(); }, error -> { System.err.println("an error occurred while querying the database: actual cause: " + error.getMessage()); diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java index 930d02dc0a22..11bea5cee487 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java @@ -82,7 +82,7 @@ public class DocumentCRUDAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -93,12 +93,12 @@ public void setUp() { this.client = this.clientBuilder().build(); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); ArrayList partitionKeyPaths = new ArrayList(); partitionKeyPaths.add(PARTITION_KEY_PATH); - partitionKeyDefinition.paths(partitionKeyPaths); + partitionKeyDefinition.setPaths(partitionKeyPaths); collectionDefinition.setPartitionKey(partitionKeyDefinition); // CREATE database @@ -106,7 +106,7 @@ public void setUp() { // CREATE collection createdCollection = client - .createCollection("dbs/" + createdDatabase.id(), collectionDefinition, null) + .createCollection("dbs/" + createdDatabase.getId(), collectionDefinition, null) .single().block().getResource(); } @@ -147,7 +147,7 @@ public void createDocument_Async() throws Exception { */ @Test(groups = "samples", timeOut = TIMEOUT) public void createDocument_Async_withoutLambda() throws Exception { - Document doc = new Document(String.format("{ 'id': 'doc%s', 'counter': '%d'}", UUID.randomUUID().toString(), 1)); + Document doc = new Document(String.format("{ 'getId': 'doc%s', 'counter': '%d'}", UUID.randomUUID().toString(), 1)); Flux> createDocumentObservable = client .createDocument(getCollectionLink(), doc, null, true); @@ -200,7 +200,7 @@ public void createDocument_toBlocking() { @Test(groups = "samples", timeOut = TIMEOUT) public void createDocumentWithProgrammableDocumentDefinition() throws Exception { Document documentDefinition = new Document(); - documentDefinition.id("test-document"); + documentDefinition.setId("test-document"); BridgeInternal.setProperty(documentDefinition, "counter", 1); // CREATE a document @@ -220,7 +220,7 @@ public void createDocumentWithProgrammableDocumentDefinition() throws Exception Document readDocument = documentResourceResponse.getResource(); // The read document must be the same as the written document - assertThat(readDocument.id(), equalTo("test-document")); + assertThat(readDocument.getId(), equalTo("test-document")); assertThat(readDocument.getInt("counter"), equalTo(1)); System.out.println(documentResourceResponse.getActivityId()); completionLatch.countDown(); @@ -292,7 +292,7 @@ public void createDocument_toBlocking_DocumentAlreadyExists_Fails() { .block(); // Blocks and gets the result Assert.fail("Document Already Exists. Document Creation must fail"); } catch (Exception e) { - assertThat("Document already exists.", ((CosmosClientException) e.getCause()).statusCode(), + assertThat("Document already exists.", ((CosmosClientException) e.getCause()).getStatusCode(), equalTo(409)); } } @@ -324,7 +324,7 @@ public void createDocument_Async_DocumentAlreadyExists_Fails() throws Exception Thread.sleep(2000); assertThat(errorList, hasSize(1)); assertThat(errorList.get(0), is(instanceOf(CosmosClientException.class))); - assertThat(((CosmosClientException) errorList.get(0)).statusCode(), equalTo(409)); + assertThat(((CosmosClientException) errorList.get(0)).getStatusCode(), equalTo(409)); } /** @@ -339,7 +339,7 @@ public void documentReplace_Async() throws Exception { // Try to replace the existing document Document replacingDocument = new Document( - String.format("{ 'id': 'doc%s', 'counter': '%d', 'new-prop' : '2'}", createdDocument.id(), 1)); + String.format("{ 'id': 'doc%s', 'counter': '%d', 'new-prop' : '2'}", createdDocument.getId(), 1)); Flux> replaceDocumentObservable = client .replaceDocument(getDocumentLink(createdDocument), replacingDocument, null); @@ -367,7 +367,7 @@ public void documentUpsert_Async() throws Exception { // Upsert the existing document Document upsertingDocument = new Document( - String.format("{ 'id': 'doc%s', 'counter': '%d', 'new-prop' : '2'}", doc.id(), 1)); + String.format("{ 'id': 'doc%s', 'counter': '%d', 'new-prop' : '2'}", doc.getId(), 1)); Flux> upsertDocumentObservable = client .upsertDocument(getCollectionLink(), upsertingDocument, null, false); @@ -414,10 +414,10 @@ public void documentDelete_Async() throws Exception { // Assert document is deleted FeedOptions queryOptions = new FeedOptions(); - queryOptions.enableCrossPartitionQuery(true); + queryOptions.setEnableCrossPartitionQuery(true); List listOfDocuments = client - .queryDocuments(getCollectionLink(), String.format("SELECT * FROM r where r.id = '%s'", createdDocument.id()), queryOptions) - .map(FeedResponse::results) // Map page to its list of documents + .queryDocuments(getCollectionLink(), String.format("SELECT * FROM r where r.id = '%s'", createdDocument.getId()), queryOptions) + .map(FeedResponse::getResults) // Map page to its list of documents .concatMap(Flux::fromIterable) // Flatten the observable .collectList() // Transform to a observable .single() // Gets the Mono> @@ -490,7 +490,7 @@ public void customSerialization() throws Exception { options.setPartitionKey(new PartitionKey(testObject.mypk)); Document readDocument = client - .readDocument(createdDocument.selfLink(), options) + .readDocument(createdDocument.getSelfLink(), options) .single() .block() .getResource(); @@ -516,10 +516,10 @@ public void transformObservableToCompletableFuture() throws Exception { } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } private String getDocumentLink(Document createdDocument) { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id() + "/docs/" + createdDocument.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId() + "/docs/" + createdDocument.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java index 6f478e033a76..5d812547d30a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/DocumentQueryAsyncAPITest.java @@ -77,7 +77,7 @@ public class DocumentQueryAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -88,11 +88,11 @@ public void setUp() { this.client = this.clientBuilder().build(); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); // CREATE database @@ -101,7 +101,7 @@ public void setUp() { // CREATE collection createdCollection = client - .createCollection("dbs/" + createdDatabase.id(), collectionDefinition, null) + .createCollection("dbs/" + createdDatabase.getId(), collectionDefinition, null) .single().block().getResource(); numberOfDocuments = 20; @@ -128,7 +128,7 @@ public void queryDocuments_Async() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> documentQueryObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options); @@ -145,7 +145,7 @@ public void queryDocuments_Async() throws Exception { } for (@SuppressWarnings("unused") - Document d : page.results()) { + Document d : page.getResults()) { resultsCountDown.countDown(); } }); @@ -174,7 +174,7 @@ public void queryDocuments_Async_withoutLambda() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> documentQueryObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options); @@ -195,7 +195,7 @@ public void accept(FeedResponse t) { } catch (InterruptedException e) { } - for (Document d : t.results()) { + for (Document d : t.getResults()) { resultsCountDown.countDown(); } } @@ -223,11 +223,11 @@ public void queryDocuments_findTotalRequestCharge() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux totalChargeObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options) - .map(FeedResponse::requestCharge) // Map the page to its request charge + .map(FeedResponse::getRequestCharge) // Map the page to its request charge .reduce(Double::sum).flux(); // Sum up all the request charges final CountDownLatch successfulCompletionLatch = new CountDownLatch(1); @@ -248,7 +248,7 @@ public void queryDocuments_unsubscribeAfterFirstPage() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> requestChargeObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options); @@ -285,7 +285,7 @@ public void queryDocuments_filterFetchedResults() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Predicate isPrimeNumber = new Predicate() { @@ -305,10 +305,10 @@ public boolean test(Document doc) { List resultList = Collections.synchronizedList(new ArrayList()); client.queryDocuments(getCollectionLink(), "SELECT * FROM root", options) - .map(FeedResponse::results) // Map the page to the list of documents + .map(FeedResponse::getResults) // Map the page to the list of documents .concatMap(Flux::fromIterable) // Flatten the Flux> to Flux .filter(isPrimeNumber) // Filter documents using isPrimeNumber predicate - .subscribe(doc -> resultList.add(doc)); // Collect the results + .subscribe(doc -> resultList.add(doc)); // Collect the getResults Thread.sleep(4000); @@ -345,7 +345,7 @@ public void queryDocuments_toBlocking_toIterator() { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> documentQueryObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options); @@ -360,13 +360,13 @@ public void queryDocuments_toBlocking_toIterator() { FeedResponse page = it.next(); pageCounter++; - String pageSizeAsString = page.responseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); - assertThat("header item count must be present", pageSizeAsString, notNullValue()); + String pageSizeAsString = page.getResponseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); + assertThat("header getItem count must be present", pageSizeAsString, notNullValue()); int pageSize = Integer.valueOf(pageSizeAsString); - assertThat("Result size must match header item count", page.results(), hasSize(pageSize)); + assertThat("Result size must match header getItem count", page.getResults(), hasSize(pageSize)); numberOfResults += pageSize; } - assertThat("number of total results", numberOfResults, equalTo(numberOfDocuments)); + assertThat("number of total getResults", numberOfResults, equalTo(numberOfDocuments)); assertThat("number of result pages", pageCounter, equalTo((numberOfDocuments + requestPageSize - 1) / requestPageSize)); } @@ -378,7 +378,7 @@ public void queryDocuments_toBlocking_toIterator() { public void qrderBy_Async() throws Exception { // CREATE a partitioned collection String collectionId = UUID.randomUUID().toString(); - DocumentCollection multiPartitionCollection = createMultiPartitionCollection("dbs/" + createdDatabase.id(), + DocumentCollection multiPartitionCollection = createMultiPartitionCollection("dbs/" + createdDatabase.getId(), collectionId, "/key"); // Insert documents @@ -387,30 +387,30 @@ public void qrderBy_Async() throws Exception { Document doc = new Document(String.format("{\"id\":\"documentId%d\",\"key\":\"%s\",\"prop\":%d}", i, RandomStringUtils.randomAlphabetic(2), i)); - client.createDocument("dbs/" + createdDatabase.id() + "/colls/" + multiPartitionCollection.id(), + client.createDocument("dbs/" + createdDatabase.getId() + "/colls/" + multiPartitionCollection.getId(), doc, null, true).single().block(); } // Query for the documents order by the prop field SqlQuerySpec query = new SqlQuerySpec("SELECT r.id FROM r ORDER BY r.prop", new SqlParameterList()); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(5); // Max degree of parallelism determines the number of partitions that // the SDK establishes simultaneous connections to. - options.maxDegreeOfParallelism(2); + options.setMaxDegreeOfParallelism(2); - // Get the observable order by query documents + // Get the observable getOrder by query documents Flux> documentQueryObservable = client.queryDocuments( - "dbs/" + createdDatabase.id() + "/colls/" + multiPartitionCollection.id(), query, options); + "dbs/" + createdDatabase.getId() + "/colls/" + multiPartitionCollection.getId(), query, options); List resultList = Collections.synchronizedList(new ArrayList<>()); - documentQueryObservable.map(FeedResponse::results) + documentQueryObservable.map(FeedResponse::getResults) // Map the logical page to the list of documents in the page .concatMap(Flux::fromIterable) // Flatten the list of documents - .map(Resource::id) // Map to the document Id + .map(Resource::getId) // Map to the document Id .subscribe(resultList::add); // Add each document Id to the resultList Thread.sleep(4000); @@ -432,7 +432,7 @@ public void transformObservableToCompletableFuture() throws Exception { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> documentQueryObservable = client .queryDocuments(getCollectionLink(), "SELECT * FROM root", options); @@ -447,13 +447,13 @@ public void transformObservableToCompletableFuture() throws Exception { int totalNumberOfRetrievedDocuments = 0; for (FeedResponse page : pageList) { - totalNumberOfRetrievedDocuments += page.results().size(); + totalNumberOfRetrievedDocuments += page.getResults().size(); } assertThat(numberOfDocuments, equalTo(totalNumberOfRetrievedDocuments)); } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } private DocumentCollection createMultiPartitionCollection(String databaseLink, String collectionId, @@ -461,12 +461,12 @@ private DocumentCollection createMultiPartitionCollection(String databaseLink, S PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add(partitionKeyPath); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); RequestOptions options = new RequestOptions(); options.setOfferThroughput(10100); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(collectionId); + collectionDefinition.setId(collectionId); collectionDefinition.setPartitionKey(partitionKeyDef); DocumentCollection createdCollection = client.createCollection(databaseLink, collectionDefinition, options) .single().block().getResource(); diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java index b93b2cd68f96..0f5fd7eabfc8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/InMemoryGroupbyTest.java @@ -40,7 +40,7 @@ public class InMemoryGroupbyTest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = 2 * TIMEOUT) public void setUp() throws Exception { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -54,16 +54,16 @@ public void setUp() throws Exception { createdDatabase = Utils.createDatabaseForTest(client); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); // CREATE collection createdCollection = client - .createCollection("dbs/" + createdDatabase.id(), collectionDefinition, null) + .createCollection("dbs/" + createdDatabase.getId(), collectionDefinition, null) .single().block().getResource(); int numberOfPayers = 10; @@ -106,14 +106,14 @@ public void groupByInMemory() { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux documentsObservable = client .queryDocuments(getCollectionLink(), new SqlQuerySpec("SELECT * FROM root r WHERE r.site_id=@site_id", new SqlParameterList(new SqlParameter("@site_id", "ABC"))), options) - .flatMap(page -> Flux.fromIterable(page.results())); + .flatMap(page -> Flux.fromIterable(page.getResults())); final LocalDateTime now = LocalDateTime.now(); @@ -138,14 +138,14 @@ public void groupByInMemory_MoreDetail() { int requestPageSize = 3; FeedOptions options = new FeedOptions(); options.maxItemCount(requestPageSize); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux documentsObservable = client .queryDocuments(getCollectionLink(), new SqlQuerySpec("SELECT * FROM root r WHERE r.site_id=@site_id", new SqlParameterList(new SqlParameter("@site_id", "ABC"))), options) - .flatMap(page -> Flux.fromIterable(page.results())); + .flatMap(page -> Flux.fromIterable(page.getResults())); final LocalDateTime now = LocalDateTime.now(); @@ -166,6 +166,6 @@ public void groupByInMemory_MoreDetail() { } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java index c6800e6e4026..4a1781a02991 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/OfferCRUDAsyncAPITest.java @@ -43,7 +43,7 @@ public class OfferCRUDAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -78,7 +78,7 @@ public void updateOffer() throws Exception { multiPartitionRequestOptions.setOfferThroughput(initialThroughput); // CREATE the collection - DocumentCollection createdCollection = client.createCollection("dbs/" + createdDatabase.id(), + DocumentCollection createdCollection = client.createCollection("dbs/" + createdDatabase.getId(), getMultiPartitionCollectionDefinition(), multiPartitionRequestOptions).single().block() .getResource(); @@ -86,16 +86,16 @@ public void updateOffer() throws Exception { // Find offer associated with this collection client.queryOffers( - String.format("SELECT * FROM r where r.offerResourceId = '%s'", createdCollection.resourceId()), + String.format("SELECT * FROM r where r.offerResourceId = '%s'", createdCollection.getResourceId()), null).flatMap(offerFeedResponse -> { - List offerList = offerFeedResponse.results(); + List offerList = offerFeedResponse.getResults(); // NUMBER of offers returned should be 1 assertThat(offerList.size(), equalTo(1)); // This offer must correspond to the collection we created Offer offer = offerList.get(0); int currentThroughput = offer.getThroughput(); - assertThat(offer.getString("offerResourceId"), equalTo(createdCollection.resourceId())); + assertThat(offer.getString("offerResourceId"), equalTo(createdCollection.getResourceId())); assertThat(currentThroughput, equalTo(initialThroughput)); System.out.println("initial throughput: " + currentThroughput); @@ -108,15 +108,15 @@ public void updateOffer() throws Exception { Offer offer = offerResourceResponse.getResource(); int currentThroughput = offer.getThroughput(); - // The current throughput of the offer must be equal to the new throughput value - assertThat(offer.getString("offerResourceId"), equalTo(createdCollection.resourceId())); + // The current throughput of the offer must be equal to the new throughput getValue + assertThat(offer.getString("offerResourceId"), equalTo(createdCollection.getResourceId())); assertThat(currentThroughput, equalTo(newThroughput)); System.out.println("updated throughput: " + currentThroughput); successfulCompletionLatch.countDown(); }, error -> { System.err - .println("an error occurred while updating the offer: actual cause: " + error.getMessage()); + .println("an getError occurred while updating the offer: actual cause: " + error.getMessage()); }); successfulCompletionLatch.await(); @@ -124,21 +124,21 @@ public void updateOffer() throws Exception { private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); // Set the partitionKeyDefinition for a partitioned collection // Here, we are setting the partitionKey of the Collection to be /city PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List paths = new ArrayList<>(); paths.add("/city"); - partitionKeyDefinition.paths(paths); + partitionKeyDefinition.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDefinition); // Set indexing policy to be range range for string and number IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); BridgeInternal.setProperty(stringIndex, "precision", -1); @@ -147,11 +147,11 @@ private DocumentCollection getMultiPartitionCollectionDefinition() { Index numberIndex = Index.Range(DataType.NUMBER); BridgeInternal.setProperty(numberIndex, "precision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); collectionDefinition.setIndexingPolicy(indexingPolicy); return collectionDefinition; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java index d3eccaa1af00..101b5d229334 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/StoredProcedureAsyncAPITest.java @@ -49,7 +49,7 @@ public class StoredProcedureAsyncAPITest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -62,7 +62,7 @@ public void setUp() { createdDatabase = Utils.createDatabaseForTest(client); createdCollection = client - .createCollection("dbs/" + createdDatabase.id(), getMultiPartitionCollectionDefinition(), null) + .createCollection("dbs/" + createdDatabase.getId(), getMultiPartitionCollectionDefinition(), null) .single().block().getResource(); } @@ -213,21 +213,21 @@ class SamplePojo { private static DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); // Set the partitionKeyDefinition for a partitioned collection // Here, we are setting the partitionKey of the Collection to be /city PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List paths = new ArrayList(); paths.add("/city"); - partitionKeyDefinition.paths(paths); + partitionKeyDefinition.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDefinition); // Set indexing policy to be range range for string and number IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); List indexes = new ArrayList(); Index stringIndex = Index.Range(DataType.STRING); BridgeInternal.setProperty(stringIndex, "precision", -1); @@ -236,7 +236,7 @@ private static DocumentCollection getMultiPartitionCollectionDefinition() { Index numberIndex = Index.Range(DataType.NUMBER); BridgeInternal.setProperty(numberIndex, "precision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); collectionDefinition.setIndexingPolicy(indexingPolicy); @@ -245,10 +245,10 @@ private static DocumentCollection getMultiPartitionCollectionDefinition() { } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } private String getSprocLink(StoredProcedure sproc) { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id() + "/sprocs/" + sproc.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId() + "/sprocs/" + sproc.getId(); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TestConfigurations.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TestConfigurations.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TestConfigurations.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TestConfigurations.java diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java index 7228a803102f..66e2b6bb3485 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/TokenResolverTest.java @@ -59,7 +59,7 @@ public class TokenResolverTest extends DocumentClientTest { @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -70,60 +70,60 @@ public void setUp() { this.client = this.clientBuilder().build(); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); - // CREATE database + // CREATE getDatabase createdDatabase = Utils.createDatabaseForTest(client); // CREATE collection createdCollection = client - .createCollection("dbs/" + createdDatabase.id(), collectionDefinition, null) + .createCollection("dbs/" + createdDatabase.getId(), collectionDefinition, null) .single().block().getResource(); for (int i = 0; i < 10; i++) { // CREATE a document Document documentDefinition = new Document(); - documentDefinition.id(UUID.randomUUID().toString()); - Document createdDocument = client.createDocument(createdCollection.selfLink(), documentDefinition, null, true).blockFirst().getResource(); + documentDefinition.setId(UUID.randomUUID().toString()); + Document createdDocument = client.createDocument(createdCollection.getSelfLink(), documentDefinition, null, true).blockFirst().getResource(); // CREATE a User who is meant to only read this document User readUserDefinition = new User(); - readUserDefinition.id(UUID.randomUUID().toString()); - User createdReadUser = client.createUser(createdDatabase.selfLink(), readUserDefinition, null).blockFirst().getResource(); + readUserDefinition.setId(UUID.randomUUID().toString()); + User createdReadUser = client.createUser(createdDatabase.getSelfLink(), readUserDefinition, null).blockFirst().getResource(); - // CREATE a read only permission for the above document + // CREATE a read only getPermission for the above document Permission readOnlyPermissionDefinition = new Permission(); - readOnlyPermissionDefinition.id(UUID.randomUUID().toString()); - readOnlyPermissionDefinition.setResourceLink(createdDocument.selfLink()); + readOnlyPermissionDefinition.setId(UUID.randomUUID().toString()); + readOnlyPermissionDefinition.setResourceLink(createdDocument.getSelfLink()); readOnlyPermissionDefinition.setPermissionMode(PermissionMode.READ); - // Assign the permission to the above user - Permission readOnlyCreatedPermission = client.createPermission(createdReadUser.selfLink(), readOnlyPermissionDefinition, null).blockFirst().getResource(); - userToReadOnlyResourceTokenMap.put(createdReadUser.id(), readOnlyCreatedPermission.getToken()); + // Assign the getPermission to the above getUser + Permission readOnlyCreatedPermission = client.createPermission(createdReadUser.getSelfLink(), readOnlyPermissionDefinition, null).blockFirst().getResource(); + userToReadOnlyResourceTokenMap.put(createdReadUser.getId(), readOnlyCreatedPermission.getToken()); - documentToReadUserMap.put(createdDocument.selfLink(), createdReadUser.id()); + documentToReadUserMap.put(createdDocument.getSelfLink(), createdReadUser.getId()); // CREATE a User who can both read and write this document User readWriteUserDefinition = new User(); - readWriteUserDefinition.id(UUID.randomUUID().toString()); - User createdReadWriteUser = client.createUser(createdDatabase.selfLink(), readWriteUserDefinition, null).blockFirst().getResource(); + readWriteUserDefinition.setId(UUID.randomUUID().toString()); + User createdReadWriteUser = client.createUser(createdDatabase.getSelfLink(), readWriteUserDefinition, null).blockFirst().getResource(); // CREATE a read/write permission for the above document Permission readWritePermissionDefinition = new Permission(); - readWritePermissionDefinition.id(UUID.randomUUID().toString()); - readWritePermissionDefinition.setResourceLink(createdDocument.selfLink()); + readWritePermissionDefinition.setId(UUID.randomUUID().toString()); + readWritePermissionDefinition.setResourceLink(createdDocument.getSelfLink()); readWritePermissionDefinition.setPermissionMode(PermissionMode.ALL); - // Assign the permission to the above user - Permission readWriteCreatedPermission = client.createPermission(createdReadWriteUser.selfLink(), readWritePermissionDefinition, null).blockFirst().getResource(); - userToReadWriteResourceTokenMap.put(createdReadWriteUser.id(), readWriteCreatedPermission.getToken()); + // Assign the getPermission to the above getUser + Permission readWriteCreatedPermission = client.createPermission(createdReadWriteUser.getSelfLink(), readWritePermissionDefinition, null).blockFirst().getResource(); + userToReadWriteResourceTokenMap.put(createdReadWriteUser.getId(), readWriteCreatedPermission.getToken()); - documentToReadWriteUserMap.put(createdDocument.selfLink(), createdReadWriteUser.id()); + documentToReadWriteUserMap.put(createdDocument.getSelfLink(), createdReadWriteUser.getId()); } } @@ -135,7 +135,7 @@ public void readDocumentThroughTokenResolver() throws Exception { AsyncDocumentClient asyncClientWithTokenResolver = null; try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); asyncClientWithTokenResolver = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -173,7 +173,7 @@ public void deleteDocumentThroughTokenResolver() throws Exception { AsyncDocumentClient asyncClientWithTokenResolver = null; try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); asyncClientWithTokenResolver = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -215,7 +215,7 @@ public void blockListUserThroughTokenResolver() throws Exception { try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); asyncClientWithTokenResolver = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -231,7 +231,7 @@ public void blockListUserThroughTokenResolver() throws Exception { .build(); options.setProperties(properties); - Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), options); + Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), options); List capturedErrors = Collections .synchronizedList(new ArrayList<>()); readObservable.subscribe(response -> {}, throwable -> capturedErrors.add(throwable)); @@ -248,13 +248,13 @@ public void blockListUserThroughTokenResolver() throws Exception { .put(USER_ID, validUserId) .build(); options.setProperties(properties); - readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), options); + readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), options); List capturedResponse = Collections .synchronizedList(new ArrayList<>()); readObservable.subscribe(resourceResponse -> capturedResponse.add(resourceResponse.getResource()), error -> error.printStackTrace()); Thread.sleep(4000); assertThat(capturedErrors, hasSize(1)); - assertThat(capturedResponse.get(0).id(), equalTo(createdCollection.id())); + assertThat(capturedResponse.get(0).getId(), equalTo(createdCollection.getId())); } finally { Utils.safeClose(asyncClientWithTokenResolver); } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java index 3e4c533ecfda..c683106766d5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/UniqueIndexAsyncAPITest.java @@ -43,16 +43,16 @@ public class UniqueIndexAsyncAPITest extends DocumentClientTest { @Test(groups = "samples", timeOut = TIMEOUT) public void uniqueIndex() { DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(); UniqueKey uniqueKey = new UniqueKey(); - uniqueKey.paths(ImmutableList.of("/name", "/field")); + uniqueKey.setPaths(ImmutableList.of("/name", "/field")); uniqueKeyPolicy.uniqueKeys(Lists.newArrayList(uniqueKey)); collectionDefinition.setUniqueKeyPolicy(uniqueKeyPolicy); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collectionDefinition.setPartitionKey(partitionKeyDef); DocumentCollection collection = client.createCollection(getDatabaseLink(), collectionDefinition, null).single().block().getResource(); @@ -77,13 +77,13 @@ public void uniqueIndex() { assertThat(subscriber.errorCount(), Matchers.equalTo(1)); // error code for failure is conflict - assertThat(((CosmosClientException) subscriber.getEvents().get(1).get(0)).statusCode(), equalTo(409)); + assertThat(((CosmosClientException) subscriber.getEvents().get(1).get(0)).getStatusCode(), equalTo(409)); } @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void setUp() { - ConnectionPolicy connectionPolicy = new ConnectionPolicy().connectionMode(ConnectionMode.DIRECT); + ConnectionPolicy connectionPolicy = new ConnectionPolicy().setConnectionMode(ConnectionMode.DIRECT); this.clientBuilder() .withServiceEndpoint(TestConfigurations.HOST) @@ -94,9 +94,9 @@ public void setUp() { this.client = this.clientBuilder().build(); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); - // CREATE database + // CREATE getDatabase createdDatabase = Utils.createDatabaseForTest(client); } @@ -107,10 +107,10 @@ public void shutdown() { } private String getCollectionLink(DocumentCollection collection) { - return "dbs/" + createdDatabase.id() + "/colls/" + collection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + collection.getId(); } private String getDatabaseLink() { - return "dbs/" + createdDatabase.id(); + return "dbs/" + createdDatabase.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java rename to sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java index 85eddfb5a1b6..8da14c82cecd 100644 --- a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/data/cosmos/rx/examples/Utils.java @@ -22,9 +22,9 @@ public class Utils { @AfterSuite(groups = "samples") public void cleanupStaleDatabase() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); RetryOptions options = new RetryOptions(); - connectionPolicy.retryOptions(options); + connectionPolicy.setRetryOptions(options); AsyncDocumentClient client = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -34,7 +34,7 @@ public void cleanupStaleDatabase() { } public static String getCollectionLink(Database db, DocumentCollection collection) { - return "dbs/" + db.id() + "/colls/" + collection; + return "dbs/" + db.getId() + "/colls/" + collection; } public static Database createDatabaseForTest(AsyncDocumentClient client) { @@ -49,7 +49,7 @@ private static void safeCleanDatabases(AsyncDocumentClient client) { public static void safeClean(AsyncDocumentClient client, Database database) { if (database != null) { - safeClean(client, database.id()); + safeClean(client, database.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos-examples/src/test/resources/log4j.properties b/sdk/cosmos/azure-cosmos-examples/src/test/resources/log4j.properties similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos-examples/src/test/resources/log4j.properties rename to sdk/cosmos/azure-cosmos-examples/src/test/resources/log4j.properties diff --git a/sdk/cosmos/microsoft-azure-cosmos/pom.xml b/sdk/cosmos/azure-cosmos/pom.xml similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/pom.xml rename to sdk/cosmos/azure-cosmos/pom.xml index d845ecd66627..fd745436b149 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/pom.xml +++ b/sdk/cosmos/azure-cosmos/pom.xml @@ -5,14 +5,14 @@ Licensed under the MIT License. 4.0.0 - com.microsoft.azure + com.azure azure-cosmos-parent - 3.3.0 + 4.0.0-preview.4 - com.microsoft.azure + com.azure azure-cosmos - 3.3.0 + 4.0.0-preview.4 Microsoft Azure SDK for SQL API of Azure Cosmos DB Service This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension rx support) for Azure Cosmos DB SQL API jar @@ -30,6 +30,13 @@ Licensed under the MIT License. + + + com.azure + azure-core + 1.0.0-preview.4 + + com.fasterxml.jackson.core jackson-databind diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java index 3d4fddf18af0..d4760a0d128b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/AccessCondition.java @@ -16,7 +16,7 @@ public final class AccessCondition { * * @return the condition type. */ - public AccessConditionType type() { + public AccessConditionType getType() { return this.type; } @@ -26,7 +26,7 @@ public AccessConditionType type() { * @param type the condition type to use. * @return the Access Condition */ - public AccessCondition type(AccessConditionType type) { + public AccessCondition setType(AccessConditionType type) { this.type = type; return this; } @@ -37,7 +37,7 @@ public AccessCondition type(AccessConditionType type) { * * @return the condition. */ - public String condition() { + public String getCondition() { return this.condition; } @@ -48,7 +48,7 @@ public String condition() { * @param condition the condition to use. * @return the Access Condition */ - public AccessCondition condition(String condition) { + public AccessCondition setCondition(String condition) { this.condition = condition; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/AccessConditionType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/AccessConditionType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/AccessConditionType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/AccessConditionType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/BadRequestException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/BadRequestException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/BadRequestException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/BadRequestException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java index 7147e743e23d..c66c57539f81 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/BridgeInternal.java @@ -53,7 +53,7 @@ public static Document documentFromObject(Object document, ObjectMapper mapper) } public static void monitorTelemetry(MeterRegistry registry) { - CosmosClient.monitorTelemetry(registry); + CosmosAsyncClient.setMonitorTelemetry(registry); } public static ResourceResponse toResourceResponse(RxDocumentServiceResponse response, @@ -101,14 +101,14 @@ public static Map getFeedHeaders(ChangeFeedOptions options) { Map headers = new HashMap<>(); - if (options.maxItemCount() != null) { - headers.put(HttpConstants.HttpHeaders.PAGE_SIZE, options.maxItemCount().toString()); + if (options.getMaxItemCount() != null) { + headers.put(HttpConstants.HttpHeaders.PAGE_SIZE, options.getMaxItemCount().toString()); } String ifNoneMatchValue = null; - if (options.requestContinuation() != null) { - ifNoneMatchValue = options.requestContinuation(); - } else if (!options.startFromBeginning()) { + if (options.getRequestContinuation() != null) { + ifNoneMatchValue = options.getRequestContinuation(); + } else if (!options.getStartFromBeginning()) { ifNoneMatchValue = "*"; } // On REST level, change feed is using IF_NONE_MATCH/ETag instead of @@ -138,31 +138,31 @@ public static Map getFeedHeaders(FeedOptions options) { } if (options != null) { - if (options.sessionToken() != null) { - headers.put(HttpConstants.HttpHeaders.SESSION_TOKEN, options.sessionToken()); + if (options.getSessionToken() != null) { + headers.put(HttpConstants.HttpHeaders.SESSION_TOKEN, options.getSessionToken()); } - if (options.enableScanInQuery() != null) { - headers.put(HttpConstants.HttpHeaders.ENABLE_SCAN_IN_QUERY, options.enableScanInQuery().toString()); + if (options.getEnableScanInQuery() != null) { + headers.put(HttpConstants.HttpHeaders.ENABLE_SCAN_IN_QUERY, options.getEnableScanInQuery().toString()); } - if (options.emitVerboseTracesInQuery() != null) { + if (options.getEmitVerboseTracesInQuery() != null) { headers.put(HttpConstants.HttpHeaders.EMIT_VERBOSE_TRACES_IN_QUERY, - options.emitVerboseTracesInQuery().toString()); + options.getEmitVerboseTracesInQuery().toString()); } - if (options.enableCrossPartitionQuery() != null) { + if (options.getEnableCrossPartitionQuery() != null) { headers.put(HttpConstants.HttpHeaders.ENABLE_CROSS_PARTITION_QUERY, - options.enableCrossPartitionQuery().toString()); + options.getEnableCrossPartitionQuery().toString()); } - if (options.maxDegreeOfParallelism() != 0) { + if (options.getMaxDegreeOfParallelism() != 0) { headers.put(HttpConstants.HttpHeaders.PARALLELIZE_CROSS_PARTITION_QUERY, Boolean.TRUE.toString()); } - if (options.responseContinuationTokenLimitInKb() > 0) { + if (options.setResponseContinuationTokenLimitInKb() > 0) { headers.put(HttpConstants.HttpHeaders.RESPONSE_CONTINUATION_TOKEN_LIMIT_IN_KB, - Strings.toString(options.responseContinuationTokenLimitInKb())); + Strings.toString(options.setResponseContinuationTokenLimitInKb())); } if (options.populateQueryMetrics()) { @@ -220,15 +220,15 @@ public static E setPartitionKeyRangeId(E e, St } public static boolean isEnableMultipleWriteLocations(DatabaseAccount account) { - return account.enableMultipleWriteLocations(); + return account.getEnableMultipleWriteLocations(); } public static boolean getUseMultipleWriteLocations(ConnectionPolicy policy) { - return policy.usingMultipleWriteLocations(); + return policy.getUsingMultipleWriteLocations(); } public static void setUseMultipleWriteLocations(ConnectionPolicy policy, boolean value) { - policy.usingMultipleWriteLocations(value); + policy.setUsingMultipleWriteLocations(value); } public static URI getRequestUri(CosmosClientException cosmosClientException) { @@ -262,11 +262,11 @@ public static ConsistencyPolicy getConsistencyPolicy(DatabaseAccount databaseAcc } public static String getAltLink(Resource resource) { - return resource.altLink(); + return resource.getAltLink(); } public static void setAltLink(Resource resource, String altLink) { - resource.altLink(altLink); + resource.setAltLink(altLink); } public static void setMaxReplicaSetSize(ReplicationPolicy replicationPolicy, int value) { @@ -328,7 +328,7 @@ public static Object getValue(JsonNode value) { } public static CosmosClientException setCosmosResponseDiagnostics(CosmosClientException cosmosClientException, CosmosResponseDiagnostics cosmosResponseDiagnostics) { - return cosmosClientException.cosmosResponseDiagnostics(cosmosResponseDiagnostics); + return cosmosClientException.setCosmosResponseDiagnostics(cosmosResponseDiagnostics); } public static CosmosClientException createCosmosClientException(int statusCode) { @@ -337,8 +337,8 @@ public static CosmosClientException createCosmosClientException(int statusCode) public static CosmosClientException createCosmosClientException(int statusCode, String errorMessage) { CosmosClientException cosmosClientException = new CosmosClientException(statusCode, errorMessage, null, null); - cosmosClientException.error(new CosmosError()); - cosmosClientException.error().set(Constants.Properties.MESSAGE, errorMessage); + cosmosClientException.setError(new CosmosError()); + cosmosClientException.getError().set(Constants.Properties.MESSAGE, errorMessage); return cosmosClientException; } @@ -353,7 +353,7 @@ public static CosmosClientException createCosmosClientException(int statusCode, public static CosmosClientException createCosmosClientException(String resourceAddress, int statusCode, CosmosError cosmosErrorResource, Map responseHeaders) { CosmosClientException cosmosClientException = new CosmosClientException(statusCode, cosmosErrorResource == null ? null : cosmosErrorResource.getMessage(), responseHeaders, null); cosmosClientException.resourceAddress = resourceAddress; - cosmosClientException.error(cosmosErrorResource); + cosmosClientException.setError(cosmosErrorResource); return cosmosClientException; } @@ -371,13 +371,13 @@ public static CosmosClientBuilder injectConfigs(CosmosClientBuilder cosmosClient return cosmosClientBuilder.configs(configs); } - public static String extractContainerSelfLink(CosmosContainer container) { + public static String extractContainerSelfLink(CosmosAsyncContainer container) { return container.getLink(); } - public static String extractResourceSelfLink(Resource resource) { return resource.selfLink(); } + public static String extractResourceSelfLink(Resource resource) { return resource.getSelfLink(); } - public static void setResourceSelfLink(Resource resource, String selfLink) { resource.selfLink(selfLink); } + public static void setResourceSelfLink(Resource resource, String selfLink) { resource.setSelfLink(selfLink); } public static void populatePropertyBagJsonSerializable(JsonSerializable jsonSerializable) { jsonSerializable.populatePropertyBag(); } @@ -386,7 +386,7 @@ public static void setMapper(JsonSerializable jsonSerializable, ObjectMapper om) } public static void setTimestamp(Resource resource, OffsetDateTime date) { - resource.timestamp(date); + resource.setTimestamp(date); } public static CosmosResponseDiagnostics createCosmosResponseDiagnostics() { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java index fa7a0587cf76..c957404fecb6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedOptions.java @@ -46,7 +46,7 @@ public ChangeFeedOptions(ChangeFeedOptions options) { * @return a string indicating the partition key range ID * @see PartitionKeyRange */ - String partitionKeyRangeId() { + String getPartitionKeyRangeId() { return partitionKeyRangeId; } @@ -62,7 +62,7 @@ String partitionKeyRangeId() { * @see PartitionKeyRange * @return the ChangeFeedOptions. */ - ChangeFeedOptions partitionKeyRangeId(String partitionKeyRangeId) { + ChangeFeedOptions setPartitionKeyRangeId(String partitionKeyRangeId) { this.partitionKeyRangeId = partitionKeyRangeId; return this; } @@ -74,7 +74,7 @@ ChangeFeedOptions partitionKeyRangeId(String partitionKeyRangeId) { * @return a boolean value indicating change feed should start from beginning or * not */ - public boolean startFromBeginning() { + public boolean getStartFromBeginning() { return startFromBeginning; } @@ -86,7 +86,7 @@ public boolean startFromBeginning() { * from beginning or not * @return the ChangeFeedOptions. */ - public ChangeFeedOptions startFromBeginning(boolean startFromBeginning) { + public ChangeFeedOptions setStartFromBeginning(boolean startFromBeginning) { this.startFromBeginning = startFromBeginning; return this; } @@ -97,7 +97,7 @@ public ChangeFeedOptions startFromBeginning(boolean startFromBeginning) { * @return a zoned date time to start looking for changes after, if set or null * otherwise */ - public OffsetDateTime startDateTime() { + public OffsetDateTime getStartDateTime() { return startDateTime; } @@ -108,7 +108,7 @@ public OffsetDateTime startDateTime() { * @param startDateTime a zoned date time to start looking for changes after. * @return the ChangeFeedOptions. */ - public ChangeFeedOptions startDateTime(OffsetDateTime startDateTime) { + public ChangeFeedOptions setStartDateTime(OffsetDateTime startDateTime) { this.startDateTime = startDateTime; return this; } @@ -119,7 +119,7 @@ public ChangeFeedOptions startDateTime(OffsetDateTime startDateTime) { * * @return the max number of items. */ - public Integer maxItemCount() { + public Integer getMaxItemCount() { return this.maxItemCount; } @@ -130,7 +130,7 @@ public Integer maxItemCount() { * @param maxItemCount the max number of items. * @return the FeedOptionsBase. */ - public ChangeFeedOptions maxItemCount(Integer maxItemCount) { + public ChangeFeedOptions setMaxItemCount(Integer maxItemCount) { this.maxItemCount = maxItemCount; return this; } @@ -140,7 +140,7 @@ public ChangeFeedOptions maxItemCount(Integer maxItemCount) { * * @return the request continuation. */ - public String requestContinuation() { + public String getRequestContinuation() { return this.requestContinuation; } @@ -151,7 +151,7 @@ public String requestContinuation() { * the request continuation. * @return the FeedOptionsBase. */ - public ChangeFeedOptions requestContinuation(String requestContinuation) { + public ChangeFeedOptions setRequestContinuation(String requestContinuation) { this.requestContinuation = requestContinuation; return this; } @@ -162,7 +162,7 @@ public ChangeFeedOptions requestContinuation(String requestContinuation) { * * @return the partition key. */ - public PartitionKey partitionKey() { + public PartitionKey getPartitionKey() { return this.partitionkey; } @@ -174,7 +174,7 @@ public PartitionKey partitionKey() { * the partition key value. * @return the FeedOptionsBase. */ - public ChangeFeedOptions partitionKey(PartitionKey partitionkey) { + public ChangeFeedOptions setPartitionKey(PartitionKey partitionkey) { this.partitionkey = partitionkey; return this; } @@ -184,7 +184,7 @@ public ChangeFeedOptions partitionKey(PartitionKey partitionkey) { * * @return Map of request options properties */ - public Map properties() { + public Map getProperties() { return properties; } @@ -194,7 +194,7 @@ public Map properties() { * @param properties the properties. * @return the FeedOptionsBase. */ - public ChangeFeedOptions properties(Map properties) { + public ChangeFeedOptions setProperties(Map properties) { this.properties = properties; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java similarity index 76% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java index 127691616ba5..7b19939dd9ed 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessor.java @@ -26,13 +26,13 @@ *

* {@code * ChangeFeedProcessor changeFeedProcessor = ChangeFeedProcessor.Builder() - * .hostName(hostName) - * .feedContainer(feedContainer) - * .leaseContainer(leaseContainer) - * .handleChanges(docs -> { + * .setHostName(setHostName) + * .setFeedContainer(setFeedContainer) + * .setLeaseContainer(setLeaseContainer) + * .setHandleChanges(docs -> { * // Implementation for handling and processing CosmosItemProperties list goes here * }) - * .build(); + * .buildAsyncClient(); * } */ public interface ChangeFeedProcessor { @@ -52,19 +52,19 @@ public interface ChangeFeedProcessor { Mono stop(); /** - * Helper static method to build {@link ChangeFeedProcessor} instances + * Helper static method to buildAsyncClient {@link ChangeFeedProcessor} instances * as logical representation of the Azure Cosmos DB database service. *

* {@code * * ChangeFeedProcessor.Builder() - * .hostName("SampleHost") - * .feedContainer(feedContainer) - * .leaseContainer(leaseContainer) - * .handleChanges(docs -> { + * .setHostName("SampleHost") + * .setFeedContainer(setFeedContainer) + * .setLeaseContainer(setLeaseContainer) + * .setHandleChanges(docs -> { * // Implementation for handling and processing CosmosItemProperties list goes here * }) - * .build(); + * .buildAsyncClient(); * } * * @return a builder definition instance. @@ -83,15 +83,15 @@ interface BuilderDefinition { * @param hostName the name to be used for the host. When using multiple hosts, each host must have a unique name. * @return current Builder. */ - BuilderDefinition hostName(String hostName); + BuilderDefinition setHostName(String hostName); /** - * Sets and existing {@link CosmosContainer} to be used to read from the monitored collection. + * Sets and existing {@link CosmosAsyncContainer} to be used to read from the monitored collection. * - * @param feedContainer the instance of {@link CosmosContainer} to be used. + * @param feedContainer the instance of {@link CosmosAsyncContainer} to be used. * @return current Builder. */ - BuilderDefinition feedContainer(CosmosContainer feedContainer); + BuilderDefinition setFeedContainer(CosmosAsyncContainer feedContainer); /** * Sets the {@link ChangeFeedProcessorOptions} to be used. @@ -107,7 +107,7 @@ interface BuilderDefinition { * @param changeFeedProcessorOptions the change feed processor options to use. * @return current Builder. */ - BuilderDefinition options(ChangeFeedProcessorOptions changeFeedProcessorOptions); + BuilderDefinition setOptions(ChangeFeedProcessorOptions changeFeedProcessorOptions); /** * Sets a consumer function which will be called to process changes. @@ -115,15 +115,15 @@ interface BuilderDefinition { * @param consumer the consumer of {@link ChangeFeedObserver} to call for handling the feeds. * @return current Builder. */ - BuilderDefinition handleChanges(Consumer> consumer); + BuilderDefinition setHandleChanges(Consumer> consumer); /** - * Sets an existing {@link CosmosContainer} to be used to read from the leases collection. + * Sets an existing {@link CosmosAsyncContainer} to be used to read from the leases collection. * - * @param leaseContainer the instance of {@link CosmosContainer} to use. + * @param leaseContainer the instance of {@link CosmosAsyncContainer} to use. * @return current Builder. */ - BuilderDefinition leaseContainer(CosmosContainer leaseContainer); + BuilderDefinition setLeaseContainer(CosmosAsyncContainer leaseContainer); /** * Builds a new instance of the {@link ChangeFeedProcessor} with the specified configuration asynchronously. diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java index 6d2686bba32f..fcca233c881d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ChangeFeedProcessorOptions.java @@ -43,7 +43,7 @@ public ChangeFeedProcessorOptions() { * * @return the renew interval for all leases for partitions. */ - public Duration leaseRenewInterval() { + public Duration getLeaseRenewInterval() { return this.leaseRenewInterval; } @@ -53,7 +53,7 @@ public Duration leaseRenewInterval() { * @param leaseRenewInterval the renew interval for all leases for partitions currently held by {@link ChangeFeedProcessor} instance. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions leaseRenewInterval(Duration leaseRenewInterval) { + public ChangeFeedProcessorOptions setLeaseRenewInterval(Duration leaseRenewInterval) { this.leaseRenewInterval = leaseRenewInterval; return this; } @@ -63,7 +63,7 @@ public ChangeFeedProcessorOptions leaseRenewInterval(Duration leaseRenewInterval * * @return the interval to kick off a task to compute if partitions are distributed evenly among known host instances. */ - public Duration leaseAcquireInterval() { + public Duration getLeaseAcquireInterval() { return this.leaseAcquireInterval; } @@ -72,7 +72,7 @@ public Duration leaseAcquireInterval() { * @param leaseAcquireInterval he interval to kick off a task to compute if partitions are distributed evenly among known host instances. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions leaseAcquireInterval(Duration leaseAcquireInterval) { + public ChangeFeedProcessorOptions setLeaseAcquireInterval(Duration leaseAcquireInterval) { this.leaseAcquireInterval = leaseAcquireInterval; return this; } @@ -86,7 +86,7 @@ public ChangeFeedProcessorOptions leaseAcquireInterval(Duration leaseAcquireInte * * @return the interval for which the lease is taken on a lease representing a partition. */ - public Duration leaseExpirationInterval() { + public Duration getLeaseExpirationInterval() { return this.leaseExpirationInterval; } @@ -100,7 +100,7 @@ public Duration leaseExpirationInterval() { * @param leaseExpirationInterval the interval for which the lease is taken on a lease representing a partition. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions leaseExpirationInterval(Duration leaseExpirationInterval) { + public ChangeFeedProcessorOptions setLeaseExpirationInterval(Duration leaseExpirationInterval) { this.leaseExpirationInterval = leaseExpirationInterval; return this; } @@ -110,7 +110,7 @@ public ChangeFeedProcessorOptions leaseExpirationInterval(Duration leaseExpirati * * @return the delay in between polling a partition for new changes on the feed. */ - public Duration feedPollDelay() { + public Duration getFeedPollDelay() { return this.feedPollDelay; } @@ -120,7 +120,7 @@ public Duration feedPollDelay() { * @param feedPollDelay the delay in between polling a partition for new changes on the feed, after all current changes are drained. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions feedPollDelay(Duration feedPollDelay) { + public ChangeFeedProcessorOptions setFeedPollDelay(Duration feedPollDelay) { this.feedPollDelay = feedPollDelay; return this; } @@ -133,7 +133,7 @@ public ChangeFeedProcessorOptions feedPollDelay(Duration feedPollDelay) { * * @return a prefix to be used as part of the lease ID. */ - public String leasePrefix() { + public String getLeasePrefix() { return this.leasePrefix; } @@ -143,7 +143,7 @@ public String leasePrefix() { * @param leasePrefix a prefix to be used as part of the lease ID. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions leasePrefix(String leasePrefix) { + public ChangeFeedProcessorOptions setLeasePrefix(String leasePrefix) { this.leasePrefix = leasePrefix; return this; } @@ -153,7 +153,7 @@ public ChangeFeedProcessorOptions leasePrefix(String leasePrefix) { * * @return the maximum number of items to be returned in the enumeration operation in the Azure Cosmos DB service. */ - public int maxItemCount() { + public int getMaxItemCount() { return this.maxItemCount; } @@ -163,7 +163,7 @@ public int maxItemCount() { * @param maxItemCount the maximum number of items to be returned in the enumeration operation. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions maxItemCount(int maxItemCount) { + public ChangeFeedProcessorOptions setMaxItemCount(int maxItemCount) { this.maxItemCount = maxItemCount; return this; } @@ -176,7 +176,7 @@ public ChangeFeedProcessorOptions maxItemCount(int maxItemCount) { * * @return the start request continuation token to start looking for changes after. */ - public String startContinuation() { + public String getStartContinuation() { return this.startContinuation; } @@ -189,7 +189,7 @@ public String startContinuation() { * @param startContinuation the start request continuation token to start looking for changes after. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions startContinuation(String startContinuation) { + public ChangeFeedProcessorOptions setStartContinuation(String startContinuation) { this.startContinuation= startContinuation; return this; } @@ -204,7 +204,7 @@ public ChangeFeedProcessorOptions startContinuation(String startContinuation) { * * @return the time (exclusive) to start looking for changes after. */ - public OffsetDateTime startTime() { + public OffsetDateTime getStartTime() { return this.startTime; } @@ -219,7 +219,7 @@ public OffsetDateTime startTime() { * @param startTime the time (exclusive) to start looking for changes after. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions startTime(OffsetDateTime startTime) { + public ChangeFeedProcessorOptions setStartTime(OffsetDateTime startTime) { this.startTime = startTime; return this; } @@ -235,7 +235,7 @@ public ChangeFeedProcessorOptions startTime(OffsetDateTime startTime) { * * @return a value indicating whether change feed in the Azure Cosmos DB service should start from. */ - public boolean startFromBeginning() { + public boolean getStartFromBeginning() { return this.startFromBeginning; } @@ -250,7 +250,7 @@ public boolean startFromBeginning() { * @param startFromBeginning Indicates to start from beginning if true * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions startFromBeginning(boolean startFromBeginning) { + public ChangeFeedProcessorOptions setStartFromBeginning(boolean startFromBeginning) { this.startFromBeginning = startFromBeginning; return this; } @@ -263,7 +263,7 @@ public ChangeFeedProcessorOptions startFromBeginning(boolean startFromBeginning) * * @return the minimum scale count for the host. */ - public int minScaleCount() { + public int getMinScaleCount() { return this.minScaleCount; } @@ -276,7 +276,7 @@ public int minScaleCount() { * @param minScaleCount the minimum partition count for the host. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions minScaleCount(int minScaleCount) { + public ChangeFeedProcessorOptions setMinScaleCount(int minScaleCount) { this.minScaleCount = minScaleCount; return this; } @@ -289,7 +289,7 @@ public ChangeFeedProcessorOptions minScaleCount(int minScaleCount) { * * @return the maximum number of partitions the host can serve. */ - public int maxScaleCount() { + public int getMaxScaleCount() { return this.maxScaleCount; } @@ -299,7 +299,7 @@ public int maxScaleCount() { * @param maxScaleCount the maximum number of partitions the host can serve. * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions maxScaleCount(int maxScaleCount) { + public ChangeFeedProcessorOptions setMaxScaleCount(int maxScaleCount) { this.maxScaleCount = maxScaleCount; return this; } @@ -310,7 +310,7 @@ public ChangeFeedProcessorOptions maxScaleCount(int maxScaleCount) { * * @return a value indicating whether on start of the host all existing leases should be deleted and the host should start from scratch. */ - public boolean discardExistingLeases() { + public boolean getDiscardExistingLeases() { return this.discardExistingLeases; } @@ -321,7 +321,7 @@ public boolean discardExistingLeases() { * @param discardExistingLeases Indicates whether to discard all existing leases if true * @return the current ChangeFeedProcessorOptions instance. */ - public ChangeFeedProcessorOptions discardExistingLeases(boolean discardExistingLeases) { + public ChangeFeedProcessorOptions setDiscardExistingLeases(boolean discardExistingLeases) { this.discardExistingLeases = discardExistingLeases; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ClientSideRequestStatistics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ClientSideRequestStatistics.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ClientSideRequestStatistics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ClientSideRequestStatistics.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java similarity index 52% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java index ce7273c3cacf..400c157f77cf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CommonsBridgeInternal.java @@ -5,46 +5,46 @@ public class CommonsBridgeInternal { public static boolean isV2(PartitionKeyDefinition pkd) { - return pkd.version() != null && PartitionKeyDefinitionVersion.V2.val == pkd.version().val; + return pkd.getVersion() != null && PartitionKeyDefinitionVersion.V2.val == pkd.getVersion().val; } public static void setV2(PartitionKeyDefinition pkd) { - pkd.version(PartitionKeyDefinitionVersion.V2); + pkd.setVersion(PartitionKeyDefinitionVersion.V2); } /** - * Gets the partitionKeyRangeId. + * Gets the getPartitionKeyRangeId. * - * @return the partitionKeyRangeId. + * @return the getPartitionKeyRangeId. */ public static String partitionKeyRangeIdInternal(FeedOptions options) { - return options.partitionKeyRangeIdInternal(); + return options.getPartitionKeyRangeIdInternal(); } /** - * Gets the partitionKeyRangeId. + * Gets the getPartitionKeyRangeId. * - * @return the partitionKeyRangeId. + * @return the getPartitionKeyRangeId. */ public static String partitionKeyRangeIdInternal(ChangeFeedOptions options) { - return options.partitionKeyRangeId(); + return options.getPartitionKeyRangeId(); } /** - * Sets the partitionKeyRangeId. + * Sets the getPartitionKeyRangeId. * - * @return the partitionKeyRangeId. + * @return the getPartitionKeyRangeId. */ public static FeedOptions partitionKeyRangeIdInternal(FeedOptions options, String partitionKeyRangeId) { - return options.partitionKeyRangeIdInternal(partitionKeyRangeId); + return options.setPartitionKeyRangeIdInternal(partitionKeyRangeId); } /** - * Sets the partitionKeyRangeId. + * Sets the getPartitionKeyRangeId. * - * @return the partitionKeyRangeId. + * @return the getPartitionKeyRangeId. */ public static ChangeFeedOptions partitionKeyRangeIdInternal(ChangeFeedOptions options, String partitionKeyRangeId) { - return options.partitionKeyRangeId(partitionKeyRangeId); + return options.setPartitionKeyRangeId(partitionKeyRangeId); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java index 3cc94f9fc300..a8b0731e3dc2 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePath.java @@ -34,7 +34,7 @@ public CompositePath(String jsonString) { * * @return the path. */ - public String path() { + public String getPath() { return super.getString(Constants.Properties.PATH); } @@ -44,7 +44,7 @@ public String path() { * @param path the path. * @return the CompositePath. */ - public CompositePath path(String path) { + public CompositePath setPath(String path) { super.set(Constants.Properties.PATH, path); return this; } @@ -57,13 +57,13 @@ public CompositePath path(String path) { * * @return the sort order. */ - public CompositePathSortOrder order() { + public CompositePathSortOrder getOrder() { String strValue = super.getString(Constants.Properties.ORDER); if (!StringUtils.isEmpty(strValue)) { try { return CompositePathSortOrder.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.ORDER))); } catch (IllegalArgumentException e) { - this.getLogger().warn("INVALID indexingMode value {}.", super.getString(Constants.Properties.ORDER)); + this.getLogger().warn("INVALID getIndexingMode getValue {}.", super.getString(Constants.Properties.ORDER)); return CompositePathSortOrder.ASCENDING; } } @@ -79,7 +79,7 @@ public CompositePathSortOrder order() { * @param order the sort order. * @return the CompositePath. */ - public CompositePath order(CompositePathSortOrder order) { + public CompositePath setOrder(CompositePathSortOrder order) { super.set(Constants.Properties.ORDER, order.toString()); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePathSortOrder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePathSortOrder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePathSortOrder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CompositePathSortOrder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionMode.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionMode.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionMode.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java index 215acb251077..bfb4894d468e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConflictResolutionPolicy.java @@ -17,10 +17,10 @@ * A collection with custom conflict resolution with no user-registered stored procedure. *

{@code
  * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.id("Multi-master collection");
+ * collectionSpec.getId("Multi-master collection");
  *
  * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy();
- * collectionSpec.conflictResolutionPolicy(policy);
+ * collectionSpec.getConflictResolutionPolicy(policy);
  *
  * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
  *         .toBlocking().single().getResource();
@@ -31,10 +31,10 @@
  * A collection with custom conflict resolution with a user-registered stored procedure.
  * 
{@code
  * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.id("Multi-master collection");
+ * collectionSpec.getId("Multi-master collection");
  *
  * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createCustomPolicy(conflictResolutionSprocName);
- * collectionSpec.conflictResolutionPolicy(policy);
+ * collectionSpec.getConflictResolutionPolicy(policy);
  *
  * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
  *         .toBlocking().single().getResource();
@@ -46,10 +46,10 @@
  * A collection with custom conflict resolution with a user-registered stored procedure.
  * 
{@code
  * DocumentCollection collectionSpec = new DocumentCollection();
- * collectionSpec.id("Multi-master collection");
+ * collectionSpec.getId("Multi-master collection");
  *
  * ConflictResolutionPolicy policy = ConflictResolutionPolicy.createLastWriterWinsPolicy("/path/for/conflict/resolution");
- * collectionSpec.conflictResolutionPolicy(policy);
+ * collectionSpec.getConflictResolutionPolicy(policy);
  *
  * DocumentCollection collection = client.createCollection(databaseLink, collectionSpec, null)
  *         .toBlocking().single().getResource();
@@ -64,12 +64,13 @@ public class ConflictResolutionPolicy extends JsonSerializable {
      *
      * In case of a conflict occurring on a document, the document with the higher integer value in the default path
      * {@link Resource#timestamp()}, i.e., "/_ts" will be used.
+     * {@link Resource#getTimestamp()}, i.e., "/_ts" will be used.
      *
      * @return ConflictResolutionPolicy.
      */
     public static ConflictResolutionPolicy createLastWriterWinsPolicy() {
         ConflictResolutionPolicy policy = new ConflictResolutionPolicy();
-        policy.mode(ConflictResolutionMode.LAST_WRITER_WINS);
+        policy.setMode(ConflictResolutionMode.LAST_WRITER_WINS);
         return policy;
     }
 
@@ -87,9 +88,9 @@ public static ConflictResolutionPolicy createLastWriterWinsPolicy() {
      */
     public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflictResolutionPath) {
         ConflictResolutionPolicy policy = new ConflictResolutionPolicy();
-        policy.mode(ConflictResolutionMode.LAST_WRITER_WINS);
+        policy.setMode(ConflictResolutionMode.LAST_WRITER_WINS);
         if (conflictResolutionPath != null) {
-            policy.conflictResolutionPath(conflictResolutionPath);
+            policy.setConflictResolutionPath(conflictResolutionPath);
         }
         return policy;
     }
@@ -110,9 +111,9 @@ public static ConflictResolutionPolicy createLastWriterWinsPolicy(String conflic
      */
     public static ConflictResolutionPolicy createCustomPolicy(String conflictResolutionSprocName) {
         ConflictResolutionPolicy policy = new ConflictResolutionPolicy();
-        policy.mode(ConflictResolutionMode.CUSTOM);
+        policy.setMode(ConflictResolutionMode.CUSTOM);
         if (conflictResolutionSprocName != null) {
-            policy.conflictResolutionProcedure(conflictResolutionSprocName);
+            policy.setConflictResolutionProcedure(conflictResolutionSprocName);
         }
         return policy;
     }
@@ -127,7 +128,7 @@ public static ConflictResolutionPolicy createCustomPolicy(String conflictResolut
      */
     public static ConflictResolutionPolicy createCustomPolicy() {
         ConflictResolutionPolicy policy = new ConflictResolutionPolicy();
-        policy.mode(ConflictResolutionMode.CUSTOM);
+        policy.setMode(ConflictResolutionMode.CUSTOM);
         return policy;
     }
 
@@ -146,7 +147,7 @@ public ConflictResolutionPolicy(String jsonString) {
      *
      * @return ConflictResolutionMode.
      */
-    public ConflictResolutionMode mode() {
+    public ConflictResolutionMode getMode() {
 
         String strValue = super.getString(Constants.Properties.MODE);
 
@@ -154,7 +155,7 @@ public ConflictResolutionMode mode() {
             try {
                 return ConflictResolutionMode.valueOf(Strings.fromCamelCaseToUpperCase(super.getString(Constants.Properties.MODE)));
             } catch (IllegalArgumentException e) {
-                this.getLogger().warn("INVALID ConflictResolutionMode value {}.", super.getString(Constants.Properties.MODE));
+                this.getLogger().warn("INVALID ConflictResolutionMode getValue {}.", super.getString(Constants.Properties.MODE));
                 return ConflictResolutionMode.INVALID;
             }
         }
@@ -168,7 +169,7 @@ public ConflictResolutionMode mode() {
      *
      * @param mode One of the values of the {@link ConflictResolutionMode} enum.
      */
-    ConflictResolutionPolicy mode(ConflictResolutionMode mode) {
+    ConflictResolutionPolicy setMode(ConflictResolutionMode mode) {
         super.set(Constants.Properties.MODE, mode.toString());
         return this;
     }
@@ -184,7 +185,7 @@ ConflictResolutionPolicy mode(ConflictResolutionMode mode) {
      * @return The path to check values for last-writer wins conflict resolution.
      * That path is a rooted path of the property in the document, such as "/name/first".
      */
-    public String conflictResolutionPath() {
+    public String getConflictResolutionPath() {
         return super.getString(Constants.Properties.CONFLICT_RESOLUTION_PATH);
     }
 
@@ -199,7 +200,7 @@ public String conflictResolutionPath() {
      * @param value The path to check values for last-writer wins conflict resolution.
      *              That path is a rooted path of the property in the document, such as "/name/first".
      */
-    ConflictResolutionPolicy conflictResolutionPath(String value) {
+    ConflictResolutionPolicy setConflictResolutionPath(String value) {
         super.set(Constants.Properties.CONFLICT_RESOLUTION_PATH, value);
         return this;
     }
@@ -217,11 +218,11 @@ ConflictResolutionPolicy conflictResolutionPath(String value) {
      **
      * @return the stored procedure to perform conflict resolution.]
      */
-    public String conflictResolutionProcedure() {
+    public String getConflictResolutionProcedure() {
         return super.getString(Constants.Properties.CONFLICT_RESOLUTION_PROCEDURE);
     }
 
-    ConflictResolutionPolicy conflictResolutionProcedure(String value) {
+    ConflictResolutionPolicy setConflictResolutionProcedure(String value) {
         super.set(Constants.Properties.CONFLICT_RESOLUTION_PROCEDURE, value);
         return this;
     }
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionMode.java
similarity index 100%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionMode.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionMode.java
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java
similarity index 88%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java
index 328a3453d1b6..e33cc2df291e 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConnectionPolicy.java
@@ -53,7 +53,7 @@ public ConnectionPolicy() {
      *
      * @return the default connection policy.
      */
-    public static ConnectionPolicy defaultPolicy() {
+    public static ConnectionPolicy getDefaultPolicy() {
         if (ConnectionPolicy.default_policy == null) {
             ConnectionPolicy.default_policy = new ConnectionPolicy();
         }
@@ -66,7 +66,7 @@ public static ConnectionPolicy defaultPolicy() {
      *
      * @return the request timeout in milliseconds.
      */
-    public int requestTimeoutInMillis() {
+    public int getRequestTimeoutInMillis() {
         return this.requestTimeoutInMillis;
     }
 
@@ -77,7 +77,7 @@ public int requestTimeoutInMillis() {
      * @param requestTimeoutInMillis the request timeout in milliseconds.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy requestTimeoutInMillis(int requestTimeoutInMillis) {
+    public ConnectionPolicy setRequestTimeoutInMillis(int requestTimeoutInMillis) {
         this.requestTimeoutInMillis = requestTimeoutInMillis;
         return this;
     }
@@ -87,7 +87,7 @@ public ConnectionPolicy requestTimeoutInMillis(int requestTimeoutInMillis) {
      *
      * @return the connection mode.
      */
-    public ConnectionMode connectionMode() {
+    public ConnectionMode getConnectionMode() {
         return this.connectionMode;
     }
 
@@ -97,7 +97,7 @@ public ConnectionMode connectionMode() {
      * @param connectionMode the connection mode.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy connectionMode(ConnectionMode connectionMode) {
+    public ConnectionPolicy setConnectionMode(ConnectionMode connectionMode) {
         this.connectionMode = connectionMode;
         return this;
     }
@@ -107,7 +107,7 @@ public ConnectionPolicy connectionMode(ConnectionMode connectionMode) {
      *
      * @return connection pool size.
      */
-    public int maxPoolSize() {
+    public int getMaxPoolSize() {
         return this.maxPoolSize;
     }
 
@@ -118,7 +118,7 @@ public int maxPoolSize() {
      * @param maxPoolSize The value of the connection pool size.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy maxPoolSize(int maxPoolSize) {
+    public ConnectionPolicy setMaxPoolSize(int maxPoolSize) {
         this.maxPoolSize = maxPoolSize;
         return this;
     }
@@ -129,7 +129,7 @@ public ConnectionPolicy maxPoolSize(int maxPoolSize) {
      *
      * @return Idle connection timeout.
      */
-    public int idleConnectionTimeoutInMillis() {
+    public int getIdleConnectionTimeoutInMillis() {
         return this.idleConnectionTimeoutInMillis;
     }
 
@@ -140,7 +140,7 @@ public int idleConnectionTimeoutInMillis() {
      * @param idleConnectionTimeoutInMillis the timeout for an idle connection in seconds.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy idleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis) {
+    public ConnectionPolicy setIdleConnectionTimeoutInMillis(int idleConnectionTimeoutInMillis) {
         this.idleConnectionTimeoutInMillis = idleConnectionTimeoutInMillis;
         return this;
     }
@@ -150,7 +150,7 @@ public ConnectionPolicy idleConnectionTimeoutInMillis(int idleConnectionTimeoutI
      *
      * @return the value of user-agent suffix.
      */
-    public String userAgentSuffix() {
+    public String getUserAgentSuffix() {
         return this.userAgentSuffix;
     }
 
@@ -161,7 +161,7 @@ public String userAgentSuffix() {
      *                        used for monitoring purposes.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy userAgentSuffix(String userAgentSuffix) {
+    public ConnectionPolicy setUserAgentSuffix(String userAgentSuffix) {
         this.userAgentSuffix = userAgentSuffix;
         return this;
     }
@@ -171,7 +171,7 @@ public ConnectionPolicy userAgentSuffix(String userAgentSuffix) {
      *
      * @return the RetryOptions instance.
      */
-    public RetryOptions retryOptions() {
+    public RetryOptions getRetryOptions() {
         return this.retryOptions;
     }
 
@@ -186,7 +186,7 @@ public RetryOptions retryOptions() {
      * @param retryOptions the RetryOptions instance.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy retryOptions(RetryOptions retryOptions) {
+    public ConnectionPolicy setRetryOptions(RetryOptions retryOptions) {
         if (retryOptions == null) {
             throw new IllegalArgumentException("retryOptions value must not be null.");
         }
@@ -200,7 +200,7 @@ public ConnectionPolicy retryOptions(RetryOptions retryOptions) {
      *
      * @return whether endpoint discovery is enabled.
      */
-    public boolean enableEndpointDiscovery() {
+    public boolean getEnableEndpointDiscovery() {
         return this.enableEndpointDiscovery;
     }
 
@@ -216,7 +216,7 @@ public boolean enableEndpointDiscovery() {
      * @param enableEndpointDiscovery true if EndpointDiscovery is enabled.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy enableEndpointDiscovery(boolean enableEndpointDiscovery) {
+    public ConnectionPolicy setEnableEndpointDiscovery(boolean enableEndpointDiscovery) {
         this.enableEndpointDiscovery = enableEndpointDiscovery;
         return this;
     }
@@ -235,7 +235,7 @@ public ConnectionPolicy enableEndpointDiscovery(boolean enableEndpointDiscovery)
      *
      * @return flag to enable writes on any locations (regions) for geo-replicated database accounts.
      */
-    public boolean usingMultipleWriteLocations() {
+    public boolean getUsingMultipleWriteLocations() {
         return this.usingMultipleWriteLocations;
     }
 
@@ -251,7 +251,7 @@ public boolean usingMultipleWriteLocations() {
      *
      * @return flag to allow for reads to go to multiple regions configured on an account of Azure Cosmos DB service.
      */
-    public Boolean enableReadRequestsFallback() {
+    public Boolean getEnableReadRequestsFallback() {
         return this.enableReadRequestsFallback;
     }
 
@@ -270,7 +270,7 @@ public Boolean enableReadRequestsFallback() {
      * @param usingMultipleWriteLocations flag to enable writes on any locations (regions) for geo-replicated database accounts.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy usingMultipleWriteLocations(boolean usingMultipleWriteLocations) {
+    public ConnectionPolicy setUsingMultipleWriteLocations(boolean usingMultipleWriteLocations) {
         this.usingMultipleWriteLocations = usingMultipleWriteLocations;
         return this;
     }
@@ -288,7 +288,7 @@ public ConnectionPolicy usingMultipleWriteLocations(boolean usingMultipleWriteLo
      * @param enableReadRequestsFallback flag to enable reads to go to multiple regions configured on an account of Azure Cosmos DB service.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy enableReadRequestsFallback(Boolean enableReadRequestsFallback) {
+    public ConnectionPolicy setEnableReadRequestsFallback(Boolean enableReadRequestsFallback) {
         this.enableReadRequestsFallback = enableReadRequestsFallback;
         return this;
     }
@@ -298,7 +298,7 @@ public ConnectionPolicy enableReadRequestsFallback(Boolean enableReadRequestsFal
      *
      * @return the list of preferred location.
      */
-    public List preferredLocations() {
+    public List getPreferredLocations() {
         return this.preferredLocations != null ? preferredLocations : Collections.emptyList();
     }
 
@@ -315,7 +315,7 @@ public List preferredLocations() {
      * @param preferredLocations the list of preferred locations.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy preferredLocations(List preferredLocations) {
+    public ConnectionPolicy setPreferredLocations(List preferredLocations) {
         this.preferredLocations = preferredLocations;
         return this;
     }
@@ -325,7 +325,7 @@ public ConnectionPolicy preferredLocations(List preferredLocations) {
      *
      * @return the value of proxyHost.
      */
-    public InetSocketAddress proxy() {
+    public InetSocketAddress getProxy() {
         return this.inetSocketProxyAddress;
     }
 
@@ -336,7 +336,7 @@ public InetSocketAddress proxy() {
      * @param proxyPort The proxy server port.
      * @return the ConnectionPolicy.
      */
-    public ConnectionPolicy proxy(String proxyHost, int proxyPort) {
+    public ConnectionPolicy setProxy(String proxyHost, int proxyPort) {
         this.inetSocketProxyAddress = new InetSocketAddress(proxyHost, proxyPort);
         return this;
     }
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyLevel.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyLevel.java
similarity index 100%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyLevel.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyLevel.java
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java
similarity index 89%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java
index 17f12bf13097..1fa944c8e8df 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java
@@ -38,7 +38,7 @@ public ConsistencyPolicy() {
      *
      * @return the default consistency level.
      */
-    public ConsistencyLevel defaultConsistencyLevel() {
+    public ConsistencyLevel getDefaultConsistencyLevel() {
 
         ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL;
         try {
@@ -57,7 +57,7 @@ public ConsistencyLevel defaultConsistencyLevel() {
      * @param level the consistency level.
      * @return the ConsistenctPolicy.
      */
-    public ConsistencyPolicy defaultConsistencyLevel(ConsistencyLevel level) {
+    public ConsistencyPolicy setDefaultConsistencyLevel(ConsistencyLevel level) {
         super.set(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL, level.toString());
         return this;
     }
@@ -68,7 +68,7 @@ public ConsistencyPolicy defaultConsistencyLevel(ConsistencyLevel level) {
      *
      * @return the max staleness prefix.
      */
-    public int maxStalenessPrefix() {
+    public int getMaxStalenessPrefix() {
         Integer value = super.getInt(Constants.Properties.MAX_STALENESS_PREFIX);
         if (value == null) {
             return ConsistencyPolicy.DEFAULT_MAX_STALENESS_PREFIX;
@@ -83,7 +83,7 @@ public int maxStalenessPrefix() {
      * @param maxStalenessPrefix the max staleness prefix.
      * @return the ConsistenctPolicy.
      */
-    public ConsistencyPolicy maxStalenessPrefix(int maxStalenessPrefix) {
+    public ConsistencyPolicy setMaxStalenessPrefix(int maxStalenessPrefix) {
         super.set(Constants.Properties.MAX_STALENESS_PREFIX, maxStalenessPrefix);
         return this;
     }
@@ -93,7 +93,7 @@ public ConsistencyPolicy maxStalenessPrefix(int maxStalenessPrefix) {
      *
      * @return the max staleness prefix.
      */
-    public int maxStalenessIntervalInSeconds() {
+    public int getMaxStalenessIntervalInSeconds() {
         Integer value = super.getInt(Constants.Properties.MAX_STALENESS_INTERVAL_IN_SECONDS);
         if (value == null) {
             return ConsistencyPolicy.DEFAULT_MAX_STALENESS_INTERVAL;
@@ -107,7 +107,7 @@ public int maxStalenessIntervalInSeconds() {
      * @param maxStalenessIntervalInSeconds the max staleness interval in seconds.
      * @return the ConsistenctPolicy.
      */
-    public ConsistencyPolicy maxStalenessIntervalInSeconds(int maxStalenessIntervalInSeconds) {
+    public ConsistencyPolicy setMaxStalenessIntervalInSeconds(int maxStalenessIntervalInSeconds) {
         super.set(Constants.Properties.MAX_STALENESS_INTERVAL_IN_SECONDS, maxStalenessIntervalInSeconds);
         return this;
     }
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncClient.java
similarity index 80%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncClient.java
index 2740ead28186..fbf7859a64a6 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncClient.java
@@ -2,6 +2,7 @@
 // Licensed under the MIT License.
 package com.azure.data.cosmos;
 
+import com.azure.core.implementation.annotation.ServiceClient;
 import com.azure.data.cosmos.internal.AsyncDocumentClient;
 import com.azure.data.cosmos.internal.Configs;
 import com.azure.data.cosmos.internal.Database;
@@ -19,7 +20,10 @@
  * This asynchronous client is used to configure and execute requests
  * against the service.
  */
-public class CosmosClient implements AutoCloseable {
+@ServiceClient(
+    builder=CosmosClientBuilder.class,
+    isAsync = true)
+public class CosmosAsyncClient implements AutoCloseable {
 
     // Async document client wrapper
     private final Configs configs;
@@ -33,15 +37,15 @@ public class CosmosClient implements AutoCloseable {
     private final CosmosKeyCredential cosmosKeyCredential;
 
 
-     CosmosClient(CosmosClientBuilder builder) {
+     CosmosAsyncClient(CosmosClientBuilder builder) {
          this.configs = builder.configs();
-         this.serviceEndpoint = builder.endpoint();
-         this.keyOrResourceToken = builder.key();
-         this.connectionPolicy = builder.connectionPolicy();
-         this.desiredConsistencyLevel = builder.consistencyLevel();
-         this.permissions = builder.permissions();
-         this.tokenResolver = builder.tokenResolver();
-         this.cosmosKeyCredential = builder.cosmosKeyCredential();
+         this.serviceEndpoint = builder.getEndpoint();
+         this.keyOrResourceToken = builder.getKey();
+         this.connectionPolicy = builder.getConnectionPolicy();
+         this.desiredConsistencyLevel = builder.getConsistencyLevel();
+         this.permissions = builder.getPermissions();
+         this.tokenResolver = builder.getTokenResolver();
+         this.cosmosKeyCredential = builder.getCosmosKeyCredential();
          this.asyncDocumentClient = new AsyncDocumentClient.Builder()
              .withServiceEndpoint(this.serviceEndpoint)
              .withMasterKeyOrResourceToken(this.keyOrResourceToken)
@@ -58,7 +62,7 @@ AsyncDocumentClient getContextClient() {
     }
 
     /**
-     * Instantiate the cosmos client builder to build cosmos client
+     * Instantiate the cosmos client builder to buildAsyncClient cosmos client
      * @return {@link CosmosClientBuilder}
      */
     public static CosmosClientBuilder builder(){
@@ -69,7 +73,7 @@ public static CosmosClientBuilder builder(){
      * Monitor Cosmos client performance and resource utilization using the specified meter registry
      * @param registry  meter registry to use for performance monitoring
      */
-    static void monitorTelemetry(MeterRegistry registry) {
+    static void setMonitorTelemetry(MeterRegistry registry) {
         RntbdMetrics.add(registry);
     }
 
@@ -150,8 +154,8 @@ CosmosKeyCredential cosmosKeyCredential() {
      * @return a {@link Mono} containing the cosmos database response with the created or existing database or
      * an error.
      */
-    public Mono createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings) {
-        return createDatabaseIfNotExistsInternal(getDatabase(databaseSettings.id()));
+    public Mono createDatabaseIfNotExists(CosmosDatabaseProperties databaseSettings) {
+        return createDatabaseIfNotExistsInternal(getDatabase(databaseSettings.getId()));
     }
 
     /**
@@ -162,16 +166,16 @@ public Mono createDatabaseIfNotExists(CosmosDatabaseProp
      * @return a {@link Mono} containing the cosmos database response with the created or existing database or
      * an error
      */
-    public Mono createDatabaseIfNotExists(String id) {
+    public Mono createDatabaseIfNotExists(String id) {
         return createDatabaseIfNotExistsInternal(getDatabase(id));
     }
 
-    private Mono createDatabaseIfNotExistsInternal(CosmosDatabase database){
+    private Mono createDatabaseIfNotExistsInternal(CosmosAsyncDatabase database){
         return database.read().onErrorResume(exception -> {
             if (exception instanceof CosmosClientException) {
                 CosmosClientException cosmosClientException = (CosmosClientException) exception;
-                if (cosmosClientException.statusCode() == HttpConstants.StatusCodes.NOTFOUND) {
-                    return createDatabase(new CosmosDatabaseProperties(database.id()), new CosmosDatabaseRequestOptions());
+                if (cosmosClientException.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND) {
+                    return createDatabase(new CosmosDatabaseProperties(database.getId()), new CosmosDatabaseRequestOptions());
                 }
             }
             return Mono.error(exception);
@@ -190,15 +194,15 @@ private Mono createDatabaseIfNotExistsInternal(CosmosDat
      * @param options {@link CosmosDatabaseRequestOptions}
      * @return an {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(CosmosDatabaseProperties databaseSettings,
-                                                       CosmosDatabaseRequestOptions options) {
+    public Mono createDatabase(CosmosDatabaseProperties databaseSettings,
+                                                            CosmosDatabaseRequestOptions options) {
         if (options == null) {
             options = new CosmosDatabaseRequestOptions();
         }
         Database wrappedDatabase = new Database();
-        wrappedDatabase.id(databaseSettings.id());
+        wrappedDatabase.setId(databaseSettings.getId());
         return asyncDocumentClient.createDatabase(wrappedDatabase, options.toRequestOptions()).map(databaseResourceResponse ->
-                new CosmosDatabaseResponse(databaseResourceResponse, this)).single();
+                new CosmosAsyncDatabaseResponse(databaseResourceResponse, this)).single();
     }
 
     /**
@@ -212,7 +216,7 @@ public Mono createDatabase(CosmosDatabaseProperties data
      * @param databaseSettings {@link CosmosDatabaseProperties}
      * @return an {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(CosmosDatabaseProperties databaseSettings) {
+    public Mono createDatabase(CosmosDatabaseProperties databaseSettings) {
         return createDatabase(databaseSettings, new CosmosDatabaseRequestOptions());
     }
 
@@ -227,7 +231,7 @@ public Mono createDatabase(CosmosDatabaseProperties data
      * @param id id of the database
      * @return a {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(String id) {
+    public Mono createDatabase(String id) {
         return createDatabase(new CosmosDatabaseProperties(id), new CosmosDatabaseRequestOptions());
     }
 
@@ -244,17 +248,17 @@ public Mono createDatabase(String id) {
      * @param options {@link CosmosDatabaseRequestOptions}
      * @return an {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(CosmosDatabaseProperties databaseSettings,
-                                                       int throughput,
-                                                       CosmosDatabaseRequestOptions options) {
+    public Mono createDatabase(CosmosDatabaseProperties databaseSettings,
+                                                            int throughput,
+                                                            CosmosDatabaseRequestOptions options) {
         if (options == null) {
             options = new CosmosDatabaseRequestOptions();
         }
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         Database wrappedDatabase = new Database();
-        wrappedDatabase.id(databaseSettings.id());
+        wrappedDatabase.setId(databaseSettings.getId());
         return asyncDocumentClient.createDatabase(wrappedDatabase, options.toRequestOptions()).map(databaseResourceResponse ->
-                new CosmosDatabaseResponse(databaseResourceResponse, this)).single();
+                new CosmosAsyncDatabaseResponse(databaseResourceResponse, this)).single();
     }
 
     /**
@@ -269,9 +273,9 @@ public Mono createDatabase(CosmosDatabaseProperties data
      * @param throughput the throughput for the database
      * @return an {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(CosmosDatabaseProperties databaseSettings, int throughput) {
+    public Mono createDatabase(CosmosDatabaseProperties databaseSettings, int throughput) {
         CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions();
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         return createDatabase(databaseSettings, options);
     }
 
@@ -287,9 +291,9 @@ public Mono createDatabase(CosmosDatabaseProperties data
      * @param throughput the throughput for the database
      * @return a {@link Mono} containing the single cosmos database response with the created database or an error.
      */
-    public Mono createDatabase(String id, int throughput) {
+    public Mono createDatabase(String id, int throughput) {
         CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions();
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         return createDatabase(new CosmosDatabaseProperties(id), options);
     }
 
@@ -305,8 +309,8 @@ public Mono createDatabase(String id, int throughput) {
      */
     public Flux> readAllDatabases(FeedOptions options) {
         return getDocClientWrapper().readDatabases(options)
-                                    .map(response-> BridgeInternal.createFeedResponse(CosmosDatabaseProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                                    .map(response-> BridgeInternal.createFeedResponse(CosmosDatabaseProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
@@ -352,8 +356,8 @@ public Flux> queryDatabases(String query,
     public Flux> queryDatabases(SqlQuerySpec querySpec, FeedOptions options){
         return getDocClientWrapper().queryDatabases(querySpec, options)
                                     .map(response-> BridgeInternal.createFeedResponse(
-                        CosmosDatabaseProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                        CosmosDatabaseProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     public Mono readDatabaseAccount() {
@@ -364,14 +368,14 @@ public Mono readDatabaseAccount() {
      * Gets a database object without making a service call.
      *
      * @param id name of the database
-     * @return {@link CosmosDatabase}
+     * @return {@link CosmosAsyncDatabase}
      */
-    public CosmosDatabase getDatabase(String id) {
-        return new CosmosDatabase(id, this);
+    public CosmosAsyncDatabase getDatabase(String id) {
+        return new CosmosAsyncDatabase(id, this);
     }
 
     /**
-     * Close this {@link CosmosClient} instance and cleans up the resources.
+     * Close this {@link CosmosAsyncClient} instance and cleans up the resources.
      */
     @Override
     public void close() {
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflict.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflict.java
similarity index 73%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflict.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflict.java
index 4531cf4e3480..fde73bbc78b7 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflict.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflict.java
@@ -10,9 +10,9 @@
 /**
  * Read and delete conflicts
  */
-public class CosmosConflict {
+public class CosmosAsyncConflict {
 
-    private CosmosContainer container;
+    private CosmosAsyncContainer container;
     private String id;
 
     /**
@@ -21,27 +21,27 @@ public class CosmosConflict {
      * @param id        the conflict id
      * @param container the container
      */
-    CosmosConflict(String id, CosmosContainer container) {
+    CosmosAsyncConflict(String id, CosmosAsyncContainer container) {
         this.id = id;
         this.container = container;
     }
 
     /**
-     * Get the id of the {@link CosmosConflict}
+     * Get the id of the {@link CosmosAsyncConflict}
      * 
-     * @return the id of the {@link CosmosConflict}
+     * @return the id of the {@link CosmosAsyncConflict}
      */
-    public String id() {
+    public String getId() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosConflict}
+     * Set the id of the {@link CosmosAsyncConflict}
      * 
-     * @param id the id of the {@link CosmosConflict}
-     * @return the same {@link CosmosConflict} that had the id set
+     * @param id the id of the {@link CosmosAsyncConflict}
+     * @return the same {@link CosmosAsyncConflict} that had the id set
      */
-    CosmosConflict id(String id) {
+    CosmosAsyncConflict setId(String id) {
         this.id = id;
         return this;
     }
@@ -57,13 +57,13 @@ CosmosConflict id(String id) {
      * @return a {@link Mono} containing the single resource response with the read
      *         conflict or an error.
      */
-    public Mono read(CosmosConflictRequestOptions options) {
+    public Mono read(CosmosConflictRequestOptions options) {
         if (options == null) {
             options = new CosmosConflictRequestOptions();
         }
         RequestOptions requestOptions = options.toRequestOptions();
         return this.container.getDatabase().getDocClientWrapper().readConflict(getLink(), requestOptions)
-                .map(response -> new CosmosConflictResponse(response, container)).single();
+                .map(response -> new CosmosAsyncConflictResponse(response, container)).single();
 
     }
 
@@ -78,13 +78,13 @@ public Mono read(CosmosConflictRequestOptions options) {
      * @return a {@link Mono} containing one or several feed response pages of the
      *         read conflicts or an error.
      */
-    public Mono delete(CosmosConflictRequestOptions options) {
+    public Mono delete(CosmosConflictRequestOptions options) {
         if (options == null) {
             options = new CosmosConflictRequestOptions();
         }
         RequestOptions requestOptions = options.toRequestOptions();
         return this.container.getDatabase().getDocClientWrapper().deleteConflict(getLink(), requestOptions)
-                .map(response -> new CosmosConflictResponse(response, container)).single();
+                .map(response -> new CosmosAsyncConflictResponse(response, container)).single();
     }
 
     String URIPathSegment() {
@@ -101,7 +101,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflictResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflictResponse.java
new file mode 100644
index 000000000000..9beee6b6a2be
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncConflictResponse.java
@@ -0,0 +1,42 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.Conflict;
+import com.azure.data.cosmos.internal.ResourceResponse;
+
+public class CosmosAsyncConflictResponse extends CosmosResponse {
+    private CosmosAsyncContainer container;
+    private CosmosAsyncConflict conflictClient;
+
+    CosmosAsyncConflictResponse(ResourceResponse response, CosmosAsyncContainer container) {
+        super(response);
+        this.container = container;
+        if(response.getResource() == null){
+            super.setProperties(null);
+        }else{
+            super.setProperties(new CosmosConflictProperties(response.getResource().toJson()));
+            conflictClient = new CosmosAsyncConflict(response.getResource().getId(), container);
+        }
+    }
+
+    CosmosAsyncContainer getContainer() {
+        return container;
+    }
+
+    /**
+     * Get conflict client
+     * @return the cosmos conflict client
+     */
+    public CosmosAsyncConflict getConflict() {
+        return conflictClient;
+    }
+
+    /**
+     * Get conflict properties object representing the resource on the server
+     * @return the conflict properties
+     */
+    public CosmosConflictProperties getProperties() {
+        return this.getProperties();
+    }
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainer.java
similarity index 82%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainer.java
index a529ec140e10..526aab0a1b98 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainer.java
@@ -15,33 +15,33 @@
  * Provides methods for reading, deleting, and replacing existing Containers.
  * Provides methods for interacting with child resources (Items, Scripts, Conflicts)
  */
-public class CosmosContainer {
+public class CosmosAsyncContainer {
 
-    private CosmosDatabase database;
+    private CosmosAsyncDatabase database;
     private String id;
-    private CosmosScripts scripts;
+    private CosmosAsyncScripts scripts;
 
-    CosmosContainer(String id, CosmosDatabase database) {
+    CosmosAsyncContainer(String id, CosmosAsyncDatabase database) {
         this.id = id;
         this.database = database;
     }
 
     /**
-     * Get the id of the {@link CosmosContainer}
+     * Get the id of the {@link CosmosAsyncContainer}
      * 
-     * @return the id of the {@link CosmosContainer}
+     * @return the id of the {@link CosmosAsyncContainer}
      */
-    public String id() {
+    public String getId() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosContainer}
+     * Set the id of the {@link CosmosAsyncContainer}
      * 
-     * @param id the id of the {@link CosmosContainer}
-     * @return the same {@link CosmosContainer} that had the id set
+     * @param id the id of the {@link CosmosAsyncContainer}
+     * @return the same {@link CosmosAsyncContainer} that had the id set
      */
-    CosmosContainer id(String id) {
+    CosmosAsyncContainer setId(String id) {
         this.id = id;
         return this;
     }
@@ -56,7 +56,7 @@ CosmosContainer id(String id) {
      * @return an {@link Mono} containing the single cosmos container response with
      *         the read container or an error.
      */
-    public Mono read() {
+    public Mono read() {
         return read(new CosmosContainerRequestOptions());
     }
 
@@ -71,12 +71,12 @@ public Mono read() {
      * @return an {@link Mono} containing the single cosmos container response with
      *         the read container or an error.
      */
-    public Mono read(CosmosContainerRequestOptions options) {
+    public Mono read(CosmosContainerRequestOptions options) {
         if (options == null) {
             options = new CosmosContainerRequestOptions();
         }
         return database.getDocClientWrapper().readCollection(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosContainerResponse(response, database)).single();
+                .map(response -> new CosmosAsyncContainerResponse(response, database)).single();
     }
 
     /**
@@ -90,12 +90,12 @@ public Mono read(CosmosContainerRequestOptions options)
      * @return an {@link Mono} containing the single cosmos container response for
      *         the deleted database or an error.
      */
-    public Mono delete(CosmosContainerRequestOptions options) {
+    public Mono delete(CosmosContainerRequestOptions options) {
         if (options == null) {
             options = new CosmosContainerRequestOptions();
         }
         return database.getDocClientWrapper().deleteCollection(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosContainerResponse(response, database)).single();
+                .map(response -> new CosmosAsyncContainerResponse(response, database)).single();
     }
 
     /**
@@ -108,7 +108,7 @@ public Mono delete(CosmosContainerRequestOptions option
      * @return an {@link Mono} containing the single cosmos container response for
      *         the deleted container or an error.
      */
-    public Mono delete() {
+    public Mono delete() {
         return delete(new CosmosContainerRequestOptions());
     }
 
@@ -124,7 +124,7 @@ public Mono delete() {
      * @return an {@link Mono} containing the single cosmos container response with
      *         the replaced document container or an error.
      */
-    public Mono replace(CosmosContainerProperties containerSettings) {
+    public Mono replace(CosmosContainerProperties containerSettings) {
         return replace(containerSettings, null);
     }
 
@@ -141,18 +141,18 @@ public Mono replace(CosmosContainerProperties container
      * @return an {@link Mono} containing the single cosmos container response with
      *         the replaced document container or an error.
      */
-    public Mono replace(CosmosContainerProperties containerSettings,
-            CosmosContainerRequestOptions options) {
+    public Mono replace(CosmosContainerProperties containerSettings,
+                                                      CosmosContainerRequestOptions options) {
         validateResource(containerSettings);
         if (options == null) {
             options = new CosmosContainerRequestOptions();
         }
         return database.getDocClientWrapper()
                 .replaceCollection(containerSettings.getV2Collection(), options.toRequestOptions())
-                .map(response -> new CosmosContainerResponse(response, database)).single();
+                .map(response -> new CosmosAsyncContainerResponse(response, database)).single();
     }
 
-    /* CosmosItem operations */
+    /* CosmosAsyncItem operations */
 
     /**
      * Creates a cosmos item.
@@ -165,7 +165,7 @@ public Mono replace(CosmosContainerProperties container
      * @return an {@link Mono} containing the single resource response with the
      *         created cosmos item or an error.
      */
-    public Mono createItem(Object item) {
+    public Mono createItem(Object item) {
         return createItem(item, new CosmosItemRequestOptions());
     }
 
@@ -181,14 +181,14 @@ public Mono createItem(Object item) {
      * @return an {@link Mono} containing the single resource response with the
      *         created cosmos item or an error.
      */
-    public Mono createItem(Object item, CosmosItemRequestOptions options) {
+    public Mono createItem(Object item, CosmosItemRequestOptions options) {
         if (options == null) {
             options = new CosmosItemRequestOptions();
         }
         RequestOptions requestOptions = options.toRequestOptions();
         return database.getDocClientWrapper()
                 .createDocument(getLink(), CosmosItemProperties.fromObject(item), requestOptions, true)
-                .map(response -> new CosmosItemResponse(response, requestOptions.getPartitionKey(), this)).single();
+                .map(response -> new CosmosAsyncItemResponse(response, requestOptions.getPartitionKey(), this)).single();
     }
 
     /**
@@ -202,7 +202,7 @@ public Mono createItem(Object item, CosmosItemRequestOptions
      * @return an {@link Mono} containing the single resource response with the
      *         upserted document or an error.
      */
-    public Mono upsertItem(Object item) {
+    public Mono upsertItem(Object item) {
         return upsertItem(item, null);
     }
 
@@ -218,7 +218,7 @@ public Mono upsertItem(Object item) {
      * @return an {@link Mono} containing the single resource response with the
      *         upserted document or an error.
      */
-    public Mono upsertItem(Object item, CosmosItemRequestOptions options) {
+    public Mono upsertItem(Object item, CosmosItemRequestOptions options) {
         if (options == null) {
             options = new CosmosItemRequestOptions();
         }
@@ -226,7 +226,7 @@ public Mono upsertItem(Object item, CosmosItemRequestOptions
 
         return this.getDatabase().getDocClientWrapper()
                 .upsertDocument(this.getLink(), CosmosItemProperties.fromObject(item), options.toRequestOptions(), true)
-                .map(response -> new CosmosItemResponse(response, requestOptions.getPartitionKey(), this)).single();
+                .map(response -> new CosmosAsyncItemResponse(response, requestOptions.getPartitionKey(), this)).single();
     }
 
     /**
@@ -256,8 +256,8 @@ public Flux> readAllItems() {
      */
     public Flux> readAllItems(FeedOptions options) {
         return getDatabase().getDocClientWrapper().readDocuments(getLink(), options).map(
-                response -> BridgeInternal.createFeedResponse(CosmosItemProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                response -> BridgeInternal.createFeedResponse(CosmosItemProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
@@ -321,7 +321,7 @@ public Flux> queryItems(SqlQuerySpec querySpe
     public Flux> queryItems(SqlQuerySpec querySpec, FeedOptions options) {
         return getDatabase().getDocClientWrapper().queryDocuments(getLink(), querySpec, options)
                 .map(response -> BridgeInternal.createFeedResponseWithQueryMetrics(
-                        CosmosItemProperties.getFromV2Results(response.results()), response.responseHeaders(),
+                        CosmosItemProperties.getFromV2Results(response.getResults()), response.getResponseHeaders(),
                         response.queryMetrics()));
     }
 
@@ -339,23 +339,23 @@ public Flux> queryItems(SqlQuerySpec querySpe
     public Flux> queryChangeFeedItems(ChangeFeedOptions changeFeedOptions) {
         return getDatabase().getDocClientWrapper().queryDocumentChangeFeed(getLink(), changeFeedOptions)
                 .map(response -> new FeedResponse(
-                        CosmosItemProperties.getFromV2Results(response.results()), response.responseHeaders(), false));
+                        CosmosItemProperties.getFromV2Results(response.getResults()), response.getResponseHeaders(), false));
     }
 
     /**
-     * Gets a CosmosItem object without making a service call
+     * Gets a CosmosAsyncItem object without making a service call
      *
      * @param id           id of the item
      * @param partitionKey the partition key
      * @return a cosmos item
      */
-    public CosmosItem getItem(String id, Object partitionKey) {
-        return new CosmosItem(id, partitionKey, this);
+    public CosmosAsyncItem getItem(String id, Object partitionKey) {
+        return new CosmosAsyncItem(id, partitionKey, this);
     }
 
-    public CosmosScripts getScripts() {
+    public CosmosAsyncScripts getScripts() {
         if (this.scripts == null) {
-            this.scripts = new CosmosScripts(this);
+            this.scripts = new CosmosAsyncScripts(this);
         }
         return this.scripts;
     }
@@ -370,7 +370,7 @@ public CosmosScripts getScripts() {
     public Flux> readAllConflicts(FeedOptions options) {
         return database.getDocClientWrapper().readConflicts(getLink(), options)
                 .map(response -> BridgeInternal.createFeedResponse(
-                        CosmosConflictProperties.getFromV2Results(response.results()), response.responseHeaders()));
+                        CosmosConflictProperties.getFromV2Results(response.getResults()), response.getResponseHeaders()));
     }
 
     /**
@@ -395,17 +395,17 @@ public Flux> queryConflicts(String query)
     public Flux> queryConflicts(String query, FeedOptions options) {
         return database.getDocClientWrapper().queryConflicts(getLink(), query, options)
                 .map(response -> BridgeInternal.createFeedResponse(
-                        CosmosConflictProperties.getFromV2Results(response.results()), response.responseHeaders()));
+                        CosmosConflictProperties.getFromV2Results(response.getResults()), response.getResponseHeaders()));
     }
 
     /**
-     * Gets a CosmosConflict object without making a service call
+     * Gets a CosmosAsyncConflict object without making a service call
      * 
      * @param id id of the cosmos conflict
      * @return a cosmos conflict
      */
-    public CosmosConflict getConflict(String id) {
-        return new CosmosConflict(id, this);
+    public CosmosAsyncConflict getConflict(String id) {
+        return new CosmosAsyncConflict(id, this);
     }
 
     /**
@@ -416,13 +416,13 @@ public CosmosConflict getConflict(String id) {
     public Mono readProvisionedThroughput() {
         return this.read().flatMap(cosmosContainerResponse -> database.getDocClientWrapper()
                 .queryOffers("select * from c where c.offerResourceId = '"
-                        + cosmosContainerResponse.resourceSettings().resourceId() + "'", new FeedOptions())
+                        + cosmosContainerResponse.getProperties().getResourceId() + "'", new FeedOptions())
                 .single()).flatMap(offerFeedResponse -> {
-                    if (offerFeedResponse.results().isEmpty()) {
+                    if (offerFeedResponse.getResults().isEmpty()) {
                         return Mono.error(BridgeInternal.createCosmosClientException(HttpConstants.StatusCodes.BADREQUEST,
                                 "No offers found for the resource"));
                     }
-                    return database.getDocClientWrapper().readOffer(offerFeedResponse.results().get(0).selfLink())
+                    return database.getDocClientWrapper().readOffer(offerFeedResponse.getResults().get(0).getSelfLink())
                             .single();
                 }).map(cosmosOfferResponse -> cosmosOfferResponse.getResource().getThroughput());
     }
@@ -438,13 +438,13 @@ public Mono readProvisionedThroughput() {
     public Mono replaceProvisionedThroughput(int requestUnitsPerSecond) {
         return this.read().flatMap(cosmosContainerResponse -> database.getDocClientWrapper()
                 .queryOffers("select * from c where c.offerResourceId = '"
-                        + cosmosContainerResponse.resourceSettings().resourceId() + "'", new FeedOptions())
+                        + cosmosContainerResponse.getProperties().getResourceId() + "'", new FeedOptions())
                 .single()).flatMap(offerFeedResponse -> {
-                    if (offerFeedResponse.results().isEmpty()) {
+                    if (offerFeedResponse.getResults().isEmpty()) {
                         return Mono.error(BridgeInternal.createCosmosClientException(HttpConstants.StatusCodes.BADREQUEST,
                                 "No offers found for the resource"));
                     }
-                    Offer offer = offerFeedResponse.results().get(0);
+                    Offer offer = offerFeedResponse.getResults().get(0);
                     offer.setThroughput(requestUnitsPerSecond);
                     return database.getDocClientWrapper().replaceOffer(offer).single();
                 }).map(offerResourceResponse -> offerResourceResponse.getResource().getThroughput());
@@ -453,9 +453,9 @@ public Mono replaceProvisionedThroughput(int requestUnitsPerSecond) {
     /**
      * Gets the parent Database
      *
-     * @return the {@link CosmosDatabase}
+     * @return the {@link CosmosAsyncDatabase}
      */
-    public CosmosDatabase getDatabase() {
+    public CosmosAsyncDatabase getDatabase() {
         return database;
     }
 
@@ -473,7 +473,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainerResponse.java
similarity index 59%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainerResponse.java
index 4078532bb288..a95620d54435 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncContainerResponse.java
@@ -5,17 +5,17 @@
 import com.azure.data.cosmos.internal.DocumentCollection;
 import com.azure.data.cosmos.internal.ResourceResponse;
 
-public class CosmosContainerResponse extends CosmosResponse {
+public class CosmosAsyncContainerResponse extends CosmosResponse {
 
-    private CosmosContainer container;
+    private CosmosAsyncContainer container;
 
-    CosmosContainerResponse(ResourceResponse response, CosmosDatabase database) {
+    CosmosAsyncContainerResponse(ResourceResponse response, CosmosAsyncDatabase database) {
         super(response);
         if(response.getResource() == null){
-            super.resourceSettings(null);
+            super.setProperties(null);
         }else{
-            super.resourceSettings(new CosmosContainerProperties(response));
-            container = new CosmosContainer(resourceSettings().id(), database);
+            super.setProperties(new CosmosContainerProperties(response));
+            container = new CosmosAsyncContainer(this.getProperties().getId(), database);
         }
     }
 
@@ -24,7 +24,7 @@ public class CosmosContainerResponse extends CosmosResponse read() {
+    public Mono read() {
         return read(new CosmosDatabaseRequestOptions());
     }
 
@@ -69,12 +69,12 @@ public Mono read() {
      * @return an {@link Mono} containing the single cosmos database response with
      *         the read database or an error.
      */
-    public Mono read(CosmosDatabaseRequestOptions options) {
+    public Mono read(CosmosDatabaseRequestOptions options) {
         if (options == null) {
             options = new CosmosDatabaseRequestOptions();
         }
         return getDocClientWrapper().readDatabase(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosDatabaseResponse(response, getClient())).single();
+                .map(response -> new CosmosAsyncDatabaseResponse(response, getClient())).single();
     }
 
     /**
@@ -86,7 +86,7 @@ public Mono read(CosmosDatabaseRequestOptions options) {
      *
      * @return an {@link Mono} containing the single cosmos database response
      */
-    public Mono delete() {
+    public Mono delete() {
         return delete(new CosmosDatabaseRequestOptions());
     }
 
@@ -100,15 +100,15 @@ public Mono delete() {
      * @param options the request options
      * @return an {@link Mono} containing the single cosmos database response
      */
-    public Mono delete(CosmosDatabaseRequestOptions options) {
+    public Mono delete(CosmosDatabaseRequestOptions options) {
         if (options == null) {
             options = new CosmosDatabaseRequestOptions();
         }
         return getDocClientWrapper().deleteDatabase(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosDatabaseResponse(response, getClient())).single();
+                .map(response -> new CosmosAsyncDatabaseResponse(response, getClient())).single();
     }
 
-    /* CosmosContainer operations */
+    /* CosmosAsyncContainer operations */
 
     /**
      * Creates a document container.
@@ -121,7 +121,7 @@ public Mono delete(CosmosDatabaseRequestOptions options)
      * @return an {@link Flux} containing the single cosmos container response with
      *         the created container or an error.
      */
-    public Mono createContainer(CosmosContainerProperties containerSettings) {
+    public Mono createContainer(CosmosContainerProperties containerSettings) {
         return createContainer(containerSettings, new CosmosContainerRequestOptions());
     }
 
@@ -137,13 +137,13 @@ public Mono createContainer(CosmosContainerProperties c
      * @return an {@link Flux} containing the single cosmos container response with
      *         the created container or an error.
      */
-    public Mono createContainer(CosmosContainerProperties containerProperties, int throughput) {
+    public Mono createContainer(CosmosContainerProperties containerProperties, int throughput) {
         if (containerProperties == null) {
             throw new IllegalArgumentException("containerProperties");
         }
         validateResource(containerProperties);
         CosmosContainerRequestOptions options =  new CosmosContainerRequestOptions();
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         return createContainer(containerProperties, options);
     }
 
@@ -159,8 +159,8 @@ public Mono createContainer(CosmosContainerProperties c
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainer(CosmosContainerProperties containerProperties,
-            CosmosContainerRequestOptions options) {
+    public Mono createContainer(CosmosContainerProperties containerProperties,
+                                                              CosmosContainerRequestOptions options) {
         if (containerProperties == null) {
             throw new IllegalArgumentException("containerProperties");
         }
@@ -170,7 +170,7 @@ public Mono createContainer(CosmosContainerProperties c
         }
         return getDocClientWrapper()
                 .createCollection(this.getLink(), containerProperties.getV2Collection(), options.toRequestOptions())
-                .map(response -> new CosmosContainerResponse(response, this)).single();
+                .map(response -> new CosmosAsyncContainerResponse(response, this)).single();
     }
 
     /**
@@ -186,13 +186,13 @@ public Mono createContainer(CosmosContainerProperties c
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainer(CosmosContainerProperties containerProperties,
-                                                         int throughput,
-                                                         CosmosContainerRequestOptions options) {
+    public Mono createContainer(CosmosContainerProperties containerProperties,
+                                                              int throughput,
+                                                              CosmosContainerRequestOptions options) {
         if (options == null) {
             options = new CosmosContainerRequestOptions();
         }
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         return createContainer(containerProperties, options);
     }
 
@@ -208,7 +208,7 @@ public Mono createContainer(CosmosContainerProperties c
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainer(String id, String partitionKeyPath) {
+    public Mono createContainer(String id, String partitionKeyPath) {
         return createContainer(new CosmosContainerProperties(id, partitionKeyPath));
     }
 
@@ -225,9 +225,9 @@ public Mono createContainer(String id, String partition
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainer(String id, String partitionKeyPath, int throughput) {
+    public Mono createContainer(String id, String partitionKeyPath, int throughput) {
         CosmosContainerRequestOptions options = new CosmosContainerRequestOptions();
-        options.offerThroughput(throughput);
+        options.setOfferThroughput(throughput);
         return createContainer(new CosmosContainerProperties(id, partitionKeyPath), options);
     }
 
@@ -243,8 +243,8 @@ public Mono createContainer(String id, String partition
      * @return a {@link Mono} containing the cosmos container response with the
      *         created or existing container or an error.
      */
-    public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties) {
-        CosmosContainer container = getContainer(containerProperties.id());
+    public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties) {
+        CosmosAsyncContainer container = getContainer(containerProperties.getId());
         return createContainerIfNotExistsInternal(containerProperties, container, null);
     }
 
@@ -261,10 +261,10 @@ public Mono createContainerIfNotExists(CosmosContainerP
      * @return a {@link Mono} containing the cosmos container response with the
      *         created or existing container or an error.
      */
-    public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties, int throughput) {
+    public Mono createContainerIfNotExists(CosmosContainerProperties containerProperties, int throughput) {
         CosmosContainerRequestOptions options = new CosmosContainerRequestOptions();
-        options.offerThroughput(throughput);
-        CosmosContainer container = getContainer(containerProperties.id());
+        options.setOfferThroughput(throughput);
+        CosmosAsyncContainer container = getContainer(containerProperties.getId());
         return createContainerIfNotExistsInternal(containerProperties, container, options);
     }
 
@@ -280,8 +280,8 @@ public Mono createContainerIfNotExists(CosmosContainerP
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainerIfNotExists(String id, String partitionKeyPath) {
-        CosmosContainer container = getContainer(id);
+    public Mono createContainerIfNotExists(String id, String partitionKeyPath) {
+        CosmosAsyncContainer container = getContainer(id);
         return createContainerIfNotExistsInternal(new CosmosContainerProperties(id, partitionKeyPath), container, null);
     }
 
@@ -298,19 +298,19 @@ public Mono createContainerIfNotExists(String id, Strin
      * @return an {@link Flux} containing the cosmos container response with the
      *         created container or an error.
      */
-    public Mono createContainerIfNotExists(String id, String partitionKeyPath, int throughput) {
+    public Mono createContainerIfNotExists(String id, String partitionKeyPath, int throughput) {
         CosmosContainerRequestOptions options = new CosmosContainerRequestOptions();
-        options.offerThroughput(throughput);
-        CosmosContainer container = getContainer(id);
+        options.setOfferThroughput(throughput);
+        CosmosAsyncContainer container = getContainer(id);
         return createContainerIfNotExistsInternal(new CosmosContainerProperties(id, partitionKeyPath), container, options);
     }
 
-    private Mono createContainerIfNotExistsInternal(
-            CosmosContainerProperties containerProperties, CosmosContainer container, CosmosContainerRequestOptions options) {
+    private Mono createContainerIfNotExistsInternal(
+        CosmosContainerProperties containerProperties, CosmosAsyncContainer container, CosmosContainerRequestOptions options) {
         return container.read(options).onErrorResume(exception -> {
             if (exception instanceof CosmosClientException) {
                 CosmosClientException cosmosClientException = (CosmosClientException) exception;
-                if (cosmosClientException.statusCode() == HttpConstants.StatusCodes.NOTFOUND) {
+                if (cosmosClientException.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND) {
                     return createContainer(containerProperties, options);
                 }
             }
@@ -332,7 +332,7 @@ private Mono createContainerIfNotExistsInternal(
     public Flux> readAllContainers(FeedOptions options) {
         return getDocClientWrapper().readCollections(getLink(), options)
                 .map(response -> BridgeInternal.createFeedResponse(
-                        CosmosContainerProperties.getFromV2Results(response.results()), response.responseHeaders()));
+                        CosmosContainerProperties.getFromV2Results(response.getResults()), response.getResponseHeaders()));
     }
 
     /**
@@ -410,17 +410,17 @@ public Flux> queryContainers(SqlQuerySpe
     public Flux> queryContainers(SqlQuerySpec querySpec, FeedOptions options) {
         return getDocClientWrapper().queryCollections(getLink(), querySpec, options)
                 .map(response -> BridgeInternal.createFeedResponse(
-                        CosmosContainerProperties.getFromV2Results(response.results()), response.responseHeaders()));
+                        CosmosContainerProperties.getFromV2Results(response.getResults()), response.getResponseHeaders()));
     }
 
     /**
-     * Gets a CosmosContainer object without making a service call
+     * Gets a CosmosAsyncContainer object without making a service call
      *
      * @param id id of the container
      * @return Cosmos Container
      */
-    public CosmosContainer getContainer(String id) {
-        return new CosmosContainer(id, this);
+    public CosmosAsyncContainer getContainer(String id) {
+        return new CosmosAsyncContainer(id, this);
     }
 
     /** User operations **/
@@ -435,9 +435,9 @@ public CosmosContainer getContainer(String id) {
      * @return an {@link Mono} containing the single resource response with the
      *         created cosmos user or an error.
      */
-    public Mono createUser(CosmosUserProperties settings) {
+    public Mono createUser(CosmosUserProperties settings) {
         return getDocClientWrapper().createUser(this.getLink(), settings.getV2User(), null)
-                .map(response -> new CosmosUserResponse(response, this)).single();
+                .map(response -> new CosmosAsyncUserResponse(response, this)).single();
     }
 
 
@@ -452,9 +452,9 @@ public Mono createUser(CosmosUserProperties settings) {
      * @return an {@link Mono} containing the single resource response with the
      *         upserted user or an error.
      */
-    public Mono upsertUser(CosmosUserProperties settings) {
+    public Mono upsertUser(CosmosUserProperties settings) {
         return getDocClientWrapper().upsertUser(this.getLink(), settings.getV2User(), null)
-                .map(response -> new CosmosUserResponse(response, this)).single();
+                .map(response -> new CosmosAsyncUserResponse(response, this)).single();
     }
 
     /**
@@ -484,7 +484,7 @@ public Flux> readAllUsers() {
      */
     public Flux> readAllUsers(FeedOptions options) {
         return getDocClientWrapper().readUsers(getLink(), options).map(response -> BridgeInternal.createFeedResponse(
-                CosmosUserProperties.getFromV2Results(response.results()), response.responseHeaders()));
+                CosmosUserProperties.getFromV2Results(response.getResults()), response.getResponseHeaders()));
     }
 
     /**
@@ -548,12 +548,12 @@ public Flux> queryUsers(SqlQuerySpec querySpe
     public Flux> queryUsers(SqlQuerySpec querySpec, FeedOptions options) {
         return getDocClientWrapper().queryUsers(getLink(), querySpec, options)
                 .map(response -> BridgeInternal.createFeedResponseWithQueryMetrics(
-                        CosmosUserProperties.getFromV2Results(response.results()), response.responseHeaders(),
+                        CosmosUserProperties.getFromV2Results(response.getResults()), response.getResponseHeaders(),
                         response.queryMetrics()));
     }
 
-    public CosmosUser getUser(String id) {
-        return new CosmosUser(id, this);
+    public CosmosAsyncUser getUser(String id) {
+        return new CosmosAsyncUser(id, this);
     }
 
     /**
@@ -564,13 +564,13 @@ public CosmosUser getUser(String id) {
     public Mono readProvisionedThroughput() {
         return this.read().flatMap(cosmosDatabaseResponse -> getDocClientWrapper()
                 .queryOffers("select * from c where c.offerResourceId = '"
-                        + cosmosDatabaseResponse.resourceSettings().resourceId() + "'", new FeedOptions())
+                        + cosmosDatabaseResponse.getProperties().getResourceId() + "'", new FeedOptions())
                 .single().flatMap(offerFeedResponse -> {
-                    if (offerFeedResponse.results().isEmpty()) {
+                    if (offerFeedResponse.getResults().isEmpty()) {
                         return Mono.error(BridgeInternal.createCosmosClientException(HttpConstants.StatusCodes.BADREQUEST,
                                 "No offers found for the resource"));
                     }
-                    return getDocClientWrapper().readOffer(offerFeedResponse.results().get(0).selfLink()).single();
+                    return getDocClientWrapper().readOffer(offerFeedResponse.getResults().get(0).getSelfLink()).single();
                 }).map(cosmosContainerResponse1 -> cosmosContainerResponse1.getResource().getThroughput()));
     }
 
@@ -585,19 +585,19 @@ public Mono readProvisionedThroughput() {
     public Mono replaceProvisionedThroughput(int requestUnitsPerSecond) {
         return this.read().flatMap(cosmosDatabaseResponse -> this.getDocClientWrapper()
                 .queryOffers("select * from c where c.offerResourceId = '"
-                        + cosmosDatabaseResponse.resourceSettings().resourceId() + "'", new FeedOptions())
+                        + cosmosDatabaseResponse.getProperties().getResourceId() + "'", new FeedOptions())
                 .single().flatMap(offerFeedResponse -> {
-                    if (offerFeedResponse.results().isEmpty()) {
+                    if (offerFeedResponse.getResults().isEmpty()) {
                         return Mono.error(BridgeInternal.createCosmosClientException(HttpConstants.StatusCodes.BADREQUEST,
                                 "No offers found for the resource"));
                     }
-                    Offer offer = offerFeedResponse.results().get(0);
+                    Offer offer = offerFeedResponse.getResults().get(0);
                     offer.setThroughput(requestUnitsPerSecond);
                     return this.getDocClientWrapper().replaceOffer(offer).single();
                 }).map(offerResourceResponse -> offerResourceResponse.getResource().getThroughput()));
     }
 
-    CosmosClient getClient() {
+    CosmosAsyncClient getClient() {
         return client;
     }
 
@@ -619,7 +619,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncDatabaseResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncDatabaseResponse.java
new file mode 100644
index 000000000000..053c577105ac
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncDatabaseResponse.java
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.Database;
+import com.azure.data.cosmos.internal.ResourceResponse;
+
+public class CosmosAsyncDatabaseResponse extends CosmosResponse{
+    private CosmosAsyncDatabase database;
+
+    CosmosAsyncDatabaseResponse(ResourceResponse response, CosmosAsyncClient client) {
+        super(response);
+        if(response.getResource() == null){
+            super.setProperties(null);
+        }else{
+            super.setProperties(new CosmosDatabaseProperties(response));
+            database = new CosmosAsyncDatabase(this.getProperties().getId(), client);
+        }
+    }
+
+    /**
+     * Gets the CosmosAsyncDatabase object
+     *
+     * @return {@link CosmosAsyncDatabase}
+     */
+    public CosmosAsyncDatabase getDatabase() {
+        return database;
+    }
+
+    /**
+     * Gets the cosmos database properties
+     *
+     * @return the cosmos database properties
+     */
+    public CosmosDatabaseProperties getProperties() {
+        return super.getProperties();
+    }
+
+    /**
+     * Gets the Max Quota.
+     *
+     * @return the getDatabase quota.
+     */
+    public long getDatabaseQuota(){
+        return resourceResponseWrapper.getDatabaseQuota();
+    }
+
+    /**
+     * Gets the current Usage.
+     *
+     * @return the current getDatabase usage.
+     */
+    public long getDatabaseUsage(){
+        return resourceResponseWrapper.getDatabaseUsage();
+    }
+
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItem.java
similarity index 78%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItem.java
index a91ca5f959e8..ecc9f1f80fa3 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItem.java
@@ -7,31 +7,31 @@
 import com.azure.data.cosmos.internal.RequestOptions;
 import reactor.core.publisher.Mono;
 
-public class CosmosItem {
+public class CosmosAsyncItem {
     private Object partitionKey;
-    private CosmosContainer container;
+    private CosmosAsyncContainer container;
     private String id;
 
-    CosmosItem(String id, Object partitionKey, CosmosContainer container) {
+    CosmosAsyncItem(String id, Object partitionKey, CosmosAsyncContainer container) {
         this.id = id;
         this.partitionKey = partitionKey;
         this.container = container;
     }
 
     /**
-     * Get the id of the {@link CosmosItem}
-     * @return the id of the {@link CosmosItem}
+     * Get the id of the {@link CosmosAsyncItem}
+     * @return the id of the {@link CosmosAsyncItem}
      */
-    public String id() {
+    public String getId() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosItem}
-     * @param id the id of the {@link CosmosItem}
-     * @return the same {@link CosmosItem} that had the id set
+     * Set the id of the {@link CosmosAsyncItem}
+     * @param id the id of the {@link CosmosAsyncItem}
+     * @return the same {@link CosmosAsyncItem} that had the id set
      */
-    CosmosItem id(String id) {
+    CosmosAsyncItem setId(String id) {
         this.id = id;
         return this;
     }
@@ -45,7 +45,7 @@ CosmosItem id(String id) {
      *
      * @return an {@link Mono} containing the cosmos item response with the read item or an error
      */
-    public Mono read() {
+    public Mono read() {
         return read(new CosmosItemRequestOptions(partitionKey));
     }
 
@@ -59,14 +59,14 @@ public Mono read() {
      * @param options the request comosItemRequestOptions
      * @return an {@link Mono} containing the cosmos item response with the read item or an error
      */
-    public Mono read(CosmosItemRequestOptions options) {
+    public Mono read(CosmosItemRequestOptions options) {
         if (options == null) {
             options = new CosmosItemRequestOptions();
         }
         RequestOptions requestOptions = options.toRequestOptions();
         return container.getDatabase().getDocClientWrapper()
                 .readDocument(getLink(), requestOptions)
-                .map(response -> new CosmosItemResponse(response, requestOptions.getPartitionKey(), container))
+                .map(response -> new CosmosAsyncItemResponse(response, requestOptions.getPartitionKey(), container))
                 .single();
     }
 
@@ -80,7 +80,7 @@ public Mono read(CosmosItemRequestOptions options) {
      * @param item the item to replace (containing the document id).
      * @return an {@link Mono} containing the  cosmos item resource response with the replaced item or an error.
      */
-    public Mono replace(Object item){
+    public Mono replace(Object item){
         return replace(item, new CosmosItemRequestOptions(partitionKey));
     }
 
@@ -95,7 +95,7 @@ public Mono replace(Object item){
      * @param options the request comosItemRequestOptions
      * @return an {@link Mono} containing the  cosmos item resource response with the replaced item or an error.
      */
-    public Mono replace(Object item, CosmosItemRequestOptions options){
+    public Mono replace(Object item, CosmosItemRequestOptions options){
         Document doc = CosmosItemProperties.fromObject(item);
         if (options == null) {
             options = new CosmosItemRequestOptions();
@@ -104,7 +104,7 @@ public Mono replace(Object item, CosmosItemRequestOptions op
         return container.getDatabase()
                 .getDocClientWrapper()
                 .replaceDocument(getLink(), doc, requestOptions)
-                .map(response -> new CosmosItemResponse(response, requestOptions.getPartitionKey(), container))
+                .map(response -> new CosmosAsyncItemResponse(response, requestOptions.getPartitionKey(), container))
                 .single();
     }
 
@@ -116,7 +116,7 @@ public Mono replace(Object item, CosmosItemRequestOptions op
      * In case of failure the {@link Mono} will error.
      * @return an {@link Mono} containing the  cosmos item resource response.
      */
-    public Mono delete() {
+    public Mono delete() {
         return delete(new CosmosItemRequestOptions(partitionKey));
     }
 
@@ -130,7 +130,7 @@ public Mono delete() {
      * @param options the request options
      * @return an {@link Mono} containing the  cosmos item resource response.
      */
-    public Mono delete(CosmosItemRequestOptions options){
+    public Mono delete(CosmosItemRequestOptions options){
         if (options == null) {
             options = new CosmosItemRequestOptions();
         }
@@ -138,11 +138,11 @@ public Mono delete(CosmosItemRequestOptions options){
         return container.getDatabase()
                         .getDocClientWrapper()
                         .deleteDocument(getLink(), requestOptions)
-                        .map(response -> new CosmosItemResponse(response, requestOptions.getPartitionKey(), container))
+                        .map(response -> new CosmosAsyncItemResponse(response, requestOptions.getPartitionKey(), container))
                         .single();
     }
     
-    void setContainer(CosmosContainer container) {
+    void setContainer(CosmosAsyncContainer container) {
         this.container = container;
     }
 
@@ -160,7 +160,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItemResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItemResponse.java
new file mode 100644
index 000000000000..0e957344aeae
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncItemResponse.java
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.Document;
+import com.azure.data.cosmos.internal.ResourceResponse;
+
+public class CosmosAsyncItemResponse extends CosmosResponse{
+    private CosmosAsyncItem itemClient;
+
+    CosmosAsyncItemResponse(ResourceResponse response, PartitionKey partitionKey, CosmosAsyncContainer container) {
+        super(response);
+        if(response.getResource() == null){
+            super.setProperties(null);
+        }else{
+            super.setProperties(new CosmosItemProperties(response.getResource().toJson()));
+            itemClient = new CosmosAsyncItem(response.getResource().getId(),partitionKey, container);
+        }
+    }
+
+    /**
+     * Gets the itemSettings
+     * @return the itemSettings
+     */
+    public CosmosItemProperties getProperties() {
+        return super.getProperties();
+    }
+
+    /**
+     * Gets the CosmosAsyncItem
+     * @return the cosmos item
+     */
+    public CosmosAsyncItem getItem() {
+        return itemClient;
+    }
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermission.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermission.java
similarity index 73%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermission.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermission.java
index 05e8b79fac63..2e1cf517b4d5 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermission.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermission.java
@@ -6,30 +6,30 @@
 import com.azure.data.cosmos.internal.RequestOptions;
 import reactor.core.publisher.Mono;
 
-public class CosmosPermission {
+public class CosmosAsyncPermission {
 
-    private final CosmosUser cosmosUser;
+    private final CosmosAsyncUser cosmosUser;
     private String id;
 
-    CosmosPermission(String id, CosmosUser user){
+    CosmosAsyncPermission(String id, CosmosAsyncUser user){
         this.id = id;
         this.cosmosUser = user; 
     }
 
     /**
-     * Get the id of the {@link CosmosPermission}
-     * @return the id of the {@link CosmosPermission}
+     * Get the id of the {@link CosmosAsyncPermission}
+     * @return the id of the {@link CosmosAsyncPermission}
      */
     public String id() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosPermission}
-     * @param id the id of the {@link CosmosPermission}
-     * @return the same {@link CosmosPermission} that had the id set
+     * Set the id of the {@link CosmosAsyncPermission}
+     * @param id the id of the {@link CosmosAsyncPermission}
+     * @return the same {@link CosmosAsyncPermission} that had the id set
      */
-    CosmosPermission id(String id) {
+    CosmosAsyncPermission id(String id) {
         this.id = id;
         return this;
     }
@@ -44,12 +44,12 @@ CosmosPermission id(String id) {
      * @param options        the request options.
      * @return an {@link Mono} containing the single resource response with the read permission or an error.
      */
-    public Mono read(RequestOptions options) {
+    public Mono read(RequestOptions options) {
 
         return cosmosUser.getDatabase()
                 .getDocClientWrapper()
                 .readPermission(getLink(),options)
-                .map(response -> new CosmosPermissionResponse(response, cosmosUser))
+                .map(response -> new CosmosAsyncPermissionResponse(response, cosmosUser))
                 .single();
     }
 
@@ -64,12 +64,12 @@ public Mono read(RequestOptions options) {
      * @param options    the request options.
      * @return an {@link Mono} containing the single resource response with the replaced permission or an error.
      */
-    public Mono replace(CosmosPermissionProperties permissionSettings, RequestOptions options) {
+    public Mono replace(CosmosPermissionProperties permissionSettings, RequestOptions options) {
         
         return cosmosUser.getDatabase()
                 .getDocClientWrapper()
                 .replacePermission(permissionSettings.getV2Permissions(), options)
-                .map(response -> new CosmosPermissionResponse(response, cosmosUser))
+                .map(response -> new CosmosAsyncPermissionResponse(response, cosmosUser))
                 .single();
     }
 
@@ -83,14 +83,14 @@ public Mono replace(CosmosPermissionProperties permiss
      * @param options        the request options.
      * @return an {@link Mono} containing the single resource response for the deleted permission or an error.
      */
-    public Mono delete(CosmosPermissionRequestOptions options) {
+    public Mono delete(CosmosPermissionRequestOptions options) {
         if(options == null){
             options = new CosmosPermissionRequestOptions();
         }
         return cosmosUser.getDatabase()
                 .getDocClientWrapper()
                 .deletePermission(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosPermissionResponse(response, cosmosUser))
+                .map(response -> new CosmosAsyncPermissionResponse(response, cosmosUser))
                 .single();
     }
 
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermissionResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermissionResponse.java
new file mode 100644
index 000000000000..ae9bf1292935
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncPermissionResponse.java
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.Permission;
+import com.azure.data.cosmos.internal.ResourceResponse;
+
+public class CosmosAsyncPermissionResponse extends CosmosResponse {
+    CosmosAsyncPermission permissionClient;
+    
+    CosmosAsyncPermissionResponse(ResourceResponse response, CosmosAsyncUser cosmosUser) {
+        super(response);
+        if(response.getResource() == null){
+            super.setProperties(null);
+        }else{
+            super.setProperties(new CosmosPermissionProperties(response.getResource().toJson()));
+            permissionClient = new CosmosAsyncPermission(response.getResource().getId(), cosmosUser);
+        }
+    }
+
+    /**
+     * Get the permission properties
+     *
+     * @return the permission properties
+     */
+    public CosmosPermissionProperties getProperties() {
+        return super.getProperties();
+    }
+
+    /**
+     * Gets the CosmosAsyncPermission
+     *
+     * @return the cosmos permission
+     */
+    public CosmosAsyncPermission getPermission() {
+        return permissionClient;
+    }
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncScripts.java
similarity index 81%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncScripts.java
index 687405a0178b..f8c61bdd1f38 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncScripts.java
@@ -8,15 +8,15 @@
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
-public class CosmosScripts {
-    private final CosmosContainer container;
-    private final CosmosDatabase database;
+public class CosmosAsyncScripts {
+    private final CosmosAsyncContainer container;
+    private final CosmosAsyncDatabase database;
 
-    CosmosScripts(CosmosContainer container) {
+    CosmosAsyncScripts(CosmosAsyncContainer container) {
         this.container = container;
         this.database = container.getDatabase();
     }
-    /* CosmosStoredProcedure operations */
+    /* CosmosAsyncStoredProcedure operations */
 
     /**
      * Creates a cosmos stored procedure.
@@ -29,7 +29,7 @@ public class CosmosScripts {
      * @param properties  the cosmos stored procedure properties.
      * @return an {@link Mono} containing the single cosmos stored procedure resource response or an error.
      */
-    public Mono createStoredProcedure(CosmosStoredProcedureProperties properties){
+    public Mono createStoredProcedure(CosmosStoredProcedureProperties properties){
         return this.createStoredProcedure(properties, new CosmosStoredProcedureRequestOptions());
     }
 
@@ -45,17 +45,17 @@ public Mono createStoredProcedure(CosmosStoredPro
      * @param options the stored procedure request options.
      * @return an {@link Mono} containing the single cosmos stored procedure resource response or an error.
      */
-    public Mono createStoredProcedure(CosmosStoredProcedureProperties properties,
-                                                                     CosmosStoredProcedureRequestOptions options){
+    public Mono createStoredProcedure(CosmosStoredProcedureProperties properties,
+                                                                          CosmosStoredProcedureRequestOptions options){
         if(options == null){
             options = new CosmosStoredProcedureRequestOptions();
         }
         StoredProcedure sProc = new StoredProcedure();
-        sProc.id(properties.id());
-        sProc.setBody(properties.body());
+        sProc.setId(properties.getId());
+        sProc.setBody(properties.getBody());
         return database.getDocClientWrapper()
                 .createStoredProcedure(container.getLink(), sProc, options.toRequestOptions())
-                .map(response -> new CosmosStoredProcedureResponse(response, this.container))
+                .map(response -> new CosmosAsyncStoredProcedureResponse(response, this.container))
                 .single();
     }
 
@@ -73,8 +73,8 @@ public Mono createStoredProcedure(CosmosStoredPro
     public Flux> readAllStoredProcedures(FeedOptions options){
         return database.getDocClientWrapper()
                 .readStoredProcedures(container.getLink(), options)
-                .map(response -> BridgeInternal.createFeedResponse(CosmosStoredProcedureProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse(CosmosStoredProcedureProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
@@ -110,17 +110,17 @@ public Flux> queryStoredProcedures
                                                                                    FeedOptions options){
         return database.getDocClientWrapper()
                 .queryStoredProcedures(container.getLink(), querySpec,options)
-                .map(response -> BridgeInternal.createFeedResponse( CosmosStoredProcedureProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse( CosmosStoredProcedureProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
-     * Gets a CosmosStoredProcedure object without making a service call
+     * Gets a CosmosAsyncStoredProcedure object without making a service call
      * @param id id of the stored procedure
      * @return a cosmos stored procedure
      */
-    public CosmosStoredProcedure getStoredProcedure(String id){
-        return new CosmosStoredProcedure(id, this.container);
+    public CosmosAsyncStoredProcedure getStoredProcedure(String id){
+        return new CosmosAsyncStoredProcedure(id, this.container);
     }
 
 
@@ -136,14 +136,14 @@ public CosmosStoredProcedure getStoredProcedure(String id){
      * @param properties       the cosmos user defined function properties
      * @return an {@link Mono} containing the single resource response with the created user defined function or an error.
      */
-    public Mono createUserDefinedFunction(CosmosUserDefinedFunctionProperties properties){
+    public Mono createUserDefinedFunction(CosmosUserDefinedFunctionProperties properties){
         UserDefinedFunction udf = new UserDefinedFunction();
-        udf.id(properties.id());
-        udf.setBody(properties.body());
+        udf.setId(properties.getId());
+        udf.setBody(properties.getBody());
 
         return database.getDocClientWrapper()
                 .createUserDefinedFunction(container.getLink(), udf, null)
-                .map(response -> new CosmosUserDefinedFunctionResponse(response, this.container)).single();
+                .map(response -> new CosmosAsyncUserDefinedFunctionResponse(response, this.container)).single();
     }
 
     /**
@@ -159,8 +159,8 @@ public Mono createUserDefinedFunction(CosmosU
     public Flux> readAllUserDefinedFunctions(FeedOptions options){
         return database.getDocClientWrapper()
                 .readUserDefinedFunctions(container.getLink(), options)
-                .map(response -> BridgeInternal.createFeedResponse(CosmosUserDefinedFunctionProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse(CosmosUserDefinedFunctionProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
@@ -194,17 +194,17 @@ public Flux> queryUserDefinedF
                                                                                            FeedOptions options){
         return database.getDocClientWrapper()
                 .queryUserDefinedFunctions(container.getLink(),querySpec, options)
-                .map(response -> BridgeInternal.createFeedResponse(CosmosUserDefinedFunctionProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse(CosmosUserDefinedFunctionProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
-     * Gets a CosmosUserDefinedFunction object without making a service call
+     * Gets a CosmosAsyncUserDefinedFunction object without making a service call
      * @param id id of the user defined function
      * @return a cosmos user defined function
      */
-    public CosmosUserDefinedFunction getUserDefinedFunction(String id){
-        return new CosmosUserDefinedFunction(id, this.container);
+    public CosmosAsyncUserDefinedFunction getUserDefinedFunction(String id){
+        return new CosmosAsyncUserDefinedFunction(id, this.container);
     }
 
     /* Trigger Operations */
@@ -218,12 +218,12 @@ public CosmosUserDefinedFunction getUserDefinedFunction(String id){
      * @param properties the cosmos trigger properties
      * @return an {@link Mono} containing the single resource response with the created trigger or an error.
      */
-    public Mono createTrigger(CosmosTriggerProperties properties){
+    public Mono createTrigger(CosmosTriggerProperties properties){
         Trigger trigger = new Trigger(properties.toJson());
 
         return database.getDocClientWrapper()
                 .createTrigger(container.getLink(), trigger, null)
-                .map(response -> new CosmosTriggerResponse(response, this.container))
+                .map(response -> new CosmosAsyncTriggerResponse(response, this.container))
                 .single();
     }
 
@@ -240,8 +240,8 @@ public Mono createTrigger(CosmosTriggerProperties propert
     public Flux> readAllTriggers(FeedOptions options){
         return database.getDocClientWrapper()
                 .readTriggers(container.getLink(), options)
-                .map(response -> BridgeInternal.createFeedResponse(CosmosTriggerProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse(CosmosTriggerProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
@@ -274,17 +274,17 @@ public Flux> queryTriggers(SqlQuerySpec qu
                                                                    FeedOptions options){
         return database.getDocClientWrapper()
                 .queryTriggers(container.getLink(), querySpec, options)
-                .map(response -> BridgeInternal.createFeedResponse(CosmosTriggerProperties.getFromV2Results(response.results()),
-                        response.responseHeaders()));
+                .map(response -> BridgeInternal.createFeedResponse(CosmosTriggerProperties.getFromV2Results(response.getResults()),
+                        response.getResponseHeaders()));
     }
 
     /**
-     * Gets a CosmosTrigger object without making a service call
+     * Gets a CosmosAsyncTrigger object without making a service call
      * @param id id of the cosmos trigger
      * @return a cosmos trigger
      */
-    public CosmosTrigger getTrigger(String id){
-        return new CosmosTrigger(id, this.container);
+    public CosmosAsyncTrigger getTrigger(String id){
+        return new CosmosAsyncTrigger(id, this.container);
     }
 
 }
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedure.java
similarity index 76%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedure.java
index ff43932c1bdb..e0986c586717 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedure.java
@@ -6,30 +6,30 @@
 import com.azure.data.cosmos.internal.StoredProcedure;
 import reactor.core.publisher.Mono;
 
-public class CosmosStoredProcedure {
+public class CosmosAsyncStoredProcedure {
 
-    private CosmosContainer cosmosContainer;
+    private CosmosAsyncContainer cosmosContainer;
     private String id;
 
-    CosmosStoredProcedure(String id, CosmosContainer cosmosContainer) {
+    CosmosAsyncStoredProcedure(String id, CosmosAsyncContainer cosmosContainer) {
         this.id = id;
         this.cosmosContainer = cosmosContainer;
     }
 
     /**
-     * Get the id of the {@link CosmosStoredProcedure}
-     * @return the id of the {@link CosmosStoredProcedure}
+     * Get the id of the {@link CosmosAsyncStoredProcedure}
+     * @return the id of the {@link CosmosAsyncStoredProcedure}
      */
     public String id() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosStoredProcedure}
-     * @param id the id of the {@link CosmosStoredProcedure}
-     * @return the same {@link CosmosStoredProcedure} that had the id set
+     * Set the id of the {@link CosmosAsyncStoredProcedure}
+     * @param id the id of the {@link CosmosAsyncStoredProcedure}
+     * @return the same {@link CosmosAsyncStoredProcedure} that had the id set
      */
-    CosmosStoredProcedure id(String id) {
+    CosmosAsyncStoredProcedure id(String id) {
         this.id = id;
         return this;
     }
@@ -44,7 +44,7 @@ CosmosStoredProcedure id(String id) {
      *
      * @return an {@link Mono} containing the single resource response with the read stored procedure or an error.
      */
-    public Mono read() {
+    public Mono read() {
         return read(null);
     }
 
@@ -59,12 +59,12 @@ public Mono read() {
      * @param options the request options.
      * @return an {@link Mono} containing the single resource response with the read stored procedure or an error.
      */
-    public Mono read(CosmosStoredProcedureRequestOptions options) {
+    public Mono read(CosmosStoredProcedureRequestOptions options) {
         if(options == null) {
             options = new CosmosStoredProcedureRequestOptions();
         }
         return cosmosContainer.getDatabase().getDocClientWrapper().readStoredProcedure(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosStoredProcedureResponse(response, cosmosContainer)).single();
+                .map(response -> new CosmosAsyncStoredProcedureResponse(response, cosmosContainer)).single();
     }
 
     /**
@@ -76,7 +76,7 @@ public Mono read(CosmosStoredProcedureRequestOpti
      *
      * @return an {@link Mono} containing the single resource response for the deleted stored procedure or an error.
      */
-    public Mono delete() {
+    public Mono delete() {
         return delete(null);
     }
 
@@ -90,14 +90,14 @@ public Mono delete() {
      * @param options the request options.
      * @return an {@link Mono} containing the single resource response for the deleted stored procedure or an error.
      */
-    public Mono delete(CosmosStoredProcedureRequestOptions options) {
+    public Mono delete(CosmosStoredProcedureRequestOptions options) {
         if(options == null) {
             options = new CosmosStoredProcedureRequestOptions();
         }
         return cosmosContainer.getDatabase()
                 .getDocClientWrapper()
                 .deleteStoredProcedure(getLink(), options.toRequestOptions())
-                .map(response -> new CosmosResponse(response.getResource()))
+                .map(response -> new CosmosAsyncStoredProcedureResponse(response, cosmosContainer))
                 .single();
     }
 
@@ -112,14 +112,14 @@ public Mono delete(CosmosStoredProcedureRequestOptions options)
      * @param options         the request options.
      * @return an {@link Mono} containing the single resource response with the stored procedure response or an error.
      */
-    public Mono execute(Object[] procedureParams, CosmosStoredProcedureRequestOptions options) {
+    public Mono execute(Object[] procedureParams, CosmosStoredProcedureRequestOptions options) {
         if(options == null) {
             options = new CosmosStoredProcedureRequestOptions();
         }
         return cosmosContainer.getDatabase()
                 .getDocClientWrapper()
                 .executeStoredProcedure(getLink(), options.toRequestOptions(), procedureParams)
-                .map(response -> new CosmosStoredProcedureResponse(response, cosmosContainer))
+                .map(response -> new CosmosAsyncStoredProcedureResponse(response, cosmosContainer))
                 .single();
     }
 
@@ -133,7 +133,7 @@ public Mono execute(Object[] procedureParams, Cos
      * @param storedProcedureSettings the stored procedure properties
      * @return an {@link Mono} containing the single resource response with the replaced stored procedure or an error.
      */
-    public Mono replace(CosmosStoredProcedureProperties storedProcedureSettings) {
+    public Mono replace(CosmosStoredProcedureProperties storedProcedureSettings) {
         return replace(storedProcedureSettings, null);
     }
 
@@ -148,15 +148,15 @@ public Mono replace(CosmosStoredProcedureProperti
      * @param options                 the request options.
      * @return an {@link Mono} containing the single resource response with the replaced stored procedure or an error.
      */
-    public Mono replace(CosmosStoredProcedureProperties storedProcedureSettings,
-                                                       CosmosStoredProcedureRequestOptions options) {
+    public Mono replace(CosmosStoredProcedureProperties storedProcedureSettings,
+                                                            CosmosStoredProcedureRequestOptions options) {
         if(options == null) {
             options = new CosmosStoredProcedureRequestOptions();
         }
         return cosmosContainer.getDatabase()
                 .getDocClientWrapper()
                 .replaceStoredProcedure(new StoredProcedure(storedProcedureSettings.toJson()), options.toRequestOptions())
-                .map(response -> new CosmosStoredProcedureResponse(response, cosmosContainer))
+                .map(response -> new CosmosAsyncStoredProcedureResponse(response, cosmosContainer))
                 .single();
     }
 
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedureResponse.java
similarity index 67%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedureResponse.java
index 197cae05eec2..d1fa533eda1c 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncStoredProcedureResponse.java
@@ -6,20 +6,20 @@
 import com.azure.data.cosmos.internal.StoredProcedure;
 import com.azure.data.cosmos.internal.StoredProcedureResponse;
 
-public class CosmosStoredProcedureResponse extends CosmosResponse {
+public class CosmosAsyncStoredProcedureResponse extends CosmosResponse {
 
-    private CosmosStoredProcedure storedProcedure;
+    private CosmosAsyncStoredProcedure storedProcedure;
     private StoredProcedureResponse storedProcedureResponse;
 
-    CosmosStoredProcedureResponse(ResourceResponse response, CosmosContainer cosmosContainer) {
+    CosmosAsyncStoredProcedureResponse(ResourceResponse response, CosmosAsyncContainer cosmosContainer) {
         super(response);
         if(response.getResource() != null){
-            super.resourceSettings(new CosmosStoredProcedureProperties(response));
-            storedProcedure = new CosmosStoredProcedure(resourceSettings().id(), cosmosContainer);
+            super.setProperties(new CosmosStoredProcedureProperties(response));
+            storedProcedure = new CosmosAsyncStoredProcedure(this.getProperties().getId(), cosmosContainer);
         }
     }
 
-    CosmosStoredProcedureResponse(StoredProcedureResponse response, CosmosContainer cosmosContainer) {
+    CosmosAsyncStoredProcedureResponse(StoredProcedureResponse response, CosmosAsyncContainer cosmosContainer) {
         super(response);
         this.storedProcedureResponse = response;
     }
@@ -28,15 +28,15 @@ public class CosmosStoredProcedureResponse extends CosmosResponse read() {
+    public Mono read() {
         return container.getDatabase()
                 .getDocClientWrapper()
                 .readTrigger(getLink(), null)
-                .map(response -> new CosmosTriggerResponse(response, container))
+                .map(response -> new CosmosAsyncTriggerResponse(response, container))
                 .single();
     }
 
@@ -62,11 +62,11 @@ public Mono read() {
      * @param triggerSettings the cosmos trigger properties.
      * @return an {@link Mono} containing the single resource response with the replaced cosmos trigger or an error.
      */
-    public Mono replace(CosmosTriggerProperties triggerSettings) {
+    public Mono replace(CosmosTriggerProperties triggerSettings) {
         return container.getDatabase()
                 .getDocClientWrapper()
                 .replaceTrigger(new Trigger(triggerSettings.toJson()), null)
-                .map(response -> new CosmosTriggerResponse(response, container))
+                .map(response -> new CosmosAsyncTriggerResponse(response, container))
                 .single();
     }
 
@@ -79,11 +79,11 @@ public Mono replace(CosmosTriggerProperties triggerSettin
      *
      * @return an {@link Mono} containing the single resource response for the deleted cosmos trigger or an error.
      */
-    public Mono delete() {
+    public Mono delete() {
         return container.getDatabase()
                 .getDocClientWrapper()
                 .deleteTrigger(getLink(), null)
-                .map(response -> new CosmosResponse(response.getResource()))
+                .map(response -> new CosmosAsyncTriggerResponse(response, container))
                 .single();
     }
 
@@ -101,7 +101,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncTriggerResponse.java
similarity index 57%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncTriggerResponse.java
index f08b3e3bd98d..ccecc5d131dc 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncTriggerResponse.java
@@ -5,17 +5,17 @@
 import com.azure.data.cosmos.internal.ResourceResponse;
 import com.azure.data.cosmos.internal.Trigger;
 
-public class CosmosTriggerResponse extends CosmosResponse {
+public class CosmosAsyncTriggerResponse extends CosmosResponse {
 
     private CosmosTriggerProperties cosmosTriggerProperties;
-    private CosmosTrigger cosmosTrigger;
+    private CosmosAsyncTrigger cosmosTrigger;
 
-    CosmosTriggerResponse(ResourceResponse response, CosmosContainer container) {
+    CosmosAsyncTriggerResponse(ResourceResponse response, CosmosAsyncContainer container) {
         super(response);
         if(response.getResource() != null) {
-            super.resourceSettings(new CosmosTriggerProperties(response));
+            super.setProperties(new CosmosTriggerProperties(response));
             cosmosTriggerProperties = new CosmosTriggerProperties(response);
-            cosmosTrigger = new CosmosTrigger(cosmosTriggerProperties.id(), container);
+            cosmosTrigger = new CosmosAsyncTrigger(cosmosTriggerProperties.getId(), container);
         }
     }
 
@@ -24,16 +24,16 @@ public class CosmosTriggerResponse extends CosmosResponse read() {
+    public Mono read() {
         return this.database.getDocClientWrapper()
                 .readUser(getLink(), null)
-                .map(response -> new CosmosUserResponse(response, database)).single();
+                .map(response -> new CosmosAsyncUserResponse(response, database)).single();
     }
 
     /**
@@ -51,10 +51,10 @@ public Mono read() {
      * @param userSettings the user properties to use
      * @return a {@link Mono} containing the single resource response with the replaced user or an error.
      */
-    public Mono replace(CosmosUserProperties userSettings) {
+    public Mono replace(CosmosUserProperties userSettings) {
         return this.database.getDocClientWrapper()
                 .replaceUser(userSettings.getV2User(), null)
-                .map(response -> new CosmosUserResponse(response, database)).single();
+                .map(response -> new CosmosAsyncUserResponse(response, database)).single();
     }
 
     /**
@@ -62,10 +62,10 @@ public Mono replace(CosmosUserProperties userSettings) {
      *
      * @return a {@link Mono} containing the single resource response with the deleted user or an error.
      */
-    public Mono delete() {
+    public Mono delete() {
         return this.database.getDocClientWrapper()
                 .deleteUser(getLink(), null)
-                .map(response -> new CosmosUserResponse(response, database)).single();
+                .map(response -> new CosmosAsyncUserResponse(response, database)).single();
     }
 
     /**
@@ -79,14 +79,14 @@ public Mono delete() {
      * @param options    the request options.
      * @return an {@link Mono} containing the single resource response with the created permission or an error.
      */
-    public Mono createPermission(CosmosPermissionProperties permissionSettings, CosmosPermissionRequestOptions options) {
+    public Mono createPermission(CosmosPermissionProperties permissionSettings, CosmosPermissionRequestOptions options) {
         if(options == null){
             options = new CosmosPermissionRequestOptions();
         }
         Permission permission = permissionSettings.getV2Permissions();
         return database.getDocClientWrapper()
                 .createPermission(getLink(), permission, options.toRequestOptions())
-                .map(response -> new CosmosPermissionResponse(response, this))
+                .map(response -> new CosmosAsyncPermissionResponse(response, this))
                 .single();
     }
 
@@ -101,14 +101,14 @@ public Mono createPermission(CosmosPermissionPropertie
      * @param options    the request options.
      * @return an {@link Mono} containing the single resource response with the upserted permission or an error.
      */
-    public Mono upsertPermission(CosmosPermissionProperties permissionSettings, CosmosPermissionRequestOptions options) {
+    public Mono upsertPermission(CosmosPermissionProperties permissionSettings, CosmosPermissionRequestOptions options) {
         Permission permission = permissionSettings.getV2Permissions();
         if(options == null){
             options = new CosmosPermissionRequestOptions();
         }
         return database.getDocClientWrapper()
                 .upsertPermission(getLink(), permission, options.toRequestOptions())
-                .map(response -> new CosmosPermissionResponse(response, this))
+                .map(response -> new CosmosAsyncPermissionResponse(response, this))
                 .single();
     }
 
@@ -126,8 +126,8 @@ public Mono upsertPermission(CosmosPermissionPropertie
     public Flux> readAllPermissions(FeedOptions options) {
         return getDatabase().getDocClientWrapper()
                         .readPermissions(getLink(), options)
-                        .map(response-> BridgeInternal.createFeedResponse(CosmosPermissionProperties.getFromV2Results(response.results()),
-                                response.responseHeaders()));
+                        .map(response-> BridgeInternal.createFeedResponse(CosmosPermissionProperties.getFromV2Results(response.getResults()),
+                                response.getResponseHeaders()));
     }
 
     /**
@@ -158,8 +158,8 @@ public Flux> queryPermissions(String qu
     public Flux> queryPermissions(String query, FeedOptions options) {
         return getDatabase().getDocClientWrapper()
                         .queryPermissions(getLink(), query, options)
-                        .map(response-> BridgeInternal.createFeedResponse(CosmosPermissionProperties.getFromV2Results(response.results()),
-                                response.responseHeaders()));
+                        .map(response-> BridgeInternal.createFeedResponse(CosmosPermissionProperties.getFromV2Results(response.getResults()),
+                                response.getResponseHeaders()));
     }
 
     /**
@@ -167,8 +167,8 @@ public Flux> queryPermissions(String qu
      * @param id the id
      * @return the cosmos permission
      */
-    public CosmosPermission getPermission(String id){
-        return new CosmosPermission(id, this);
+    public CosmosAsyncPermission getPermission(String id){
+        return new CosmosAsyncPermission(id, this);
     }
 
     String URIPathSegment() {
@@ -185,16 +185,16 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 
     /**
      * Gets the parent Database
      *
-     * @return the (@link CosmosDatabase)
+     * @return the (@link CosmosAsyncDatabase)
      */
-    public CosmosDatabase getDatabase() {
+    public CosmosAsyncDatabase getDatabase() {
         return database;
     }
-}
\ No newline at end of file
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunction.java
similarity index 70%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunction.java
index 8df6bbcf4df8..8b1326b06ff6 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunction.java
@@ -6,30 +6,30 @@
 import com.azure.data.cosmos.internal.UserDefinedFunction;
 import reactor.core.publisher.Mono;
 
-public class CosmosUserDefinedFunction {
+public class CosmosAsyncUserDefinedFunction {
 
-    private CosmosContainer container;
+    private CosmosAsyncContainer container;
     private String id;
 
-    CosmosUserDefinedFunction(String id, CosmosContainer container) {
+    CosmosAsyncUserDefinedFunction(String id, CosmosAsyncContainer container) {
         this.id = id;
         this.container = container;
     }
 
     /**
-     * Get the id of the {@link CosmosUserDefinedFunction}
-     * @return the id of the {@link CosmosUserDefinedFunction}
+     * Get the id of the {@link CosmosAsyncUserDefinedFunction}
+     * @return the id of the {@link CosmosAsyncUserDefinedFunction}
      */
-    public String id() {
+    public String getId() {
         return id;
     }
 
     /**
-     * Set the id of the {@link CosmosUserDefinedFunction}
-     * @param id the id of the {@link CosmosUserDefinedFunction}
-     * @return the same {@link CosmosUserDefinedFunction} that had the id set
+     * Set the id of the {@link CosmosAsyncUserDefinedFunction}
+     * @param id the id of the {@link CosmosAsyncUserDefinedFunction}
+     * @return the same {@link CosmosAsyncUserDefinedFunction} that had the id set
      */
-    CosmosUserDefinedFunction id(String id) {
+    CosmosAsyncUserDefinedFunction setId(String id) {
         this.id = id;
         return this;
     }
@@ -44,9 +44,9 @@ CosmosUserDefinedFunction id(String id) {
      *
      * @return an {@link Mono} containing the single resource response for the read user defined function or an error.
      */
-    public Mono read() {
+    public Mono read() {
         return container.getDatabase().getDocClientWrapper().readUserDefinedFunction(getLink(), null)
-                .map(response -> new CosmosUserDefinedFunctionResponse(response, container)).single();
+                .map(response -> new CosmosAsyncUserDefinedFunctionResponse(response, container)).single();
     }
 
     /**
@@ -61,12 +61,12 @@ public Mono read() {
      * @return an {@link Mono} containing the single resource response with the replaced cosmos user defined function
      * or an error.
      */
-    public Mono replace(CosmosUserDefinedFunctionProperties udfSettings) {
+    public Mono replace(CosmosUserDefinedFunctionProperties udfSettings) {
         return container.getDatabase()
                 .getDocClientWrapper()
                 .replaceUserDefinedFunction(new UserDefinedFunction(udfSettings.toJson())
                         , null)
-                .map(response -> new CosmosUserDefinedFunctionResponse(response, container))
+                .map(response -> new CosmosAsyncUserDefinedFunctionResponse(response, container))
                 .single();
     }
 
@@ -80,11 +80,11 @@ public Mono replace(CosmosUserDefinedFunction
      * @return an {@link Mono} containing the single resource response for the deleted cosmos user defined function or
      * an error.
      */
-    public Mono delete() {
+    public Mono delete() {
         return container.getDatabase()
                 .getDocClientWrapper()
                 .deleteUserDefinedFunction(this.getLink(), null)
-                .map(response -> new CosmosResponse(response.getResource()))
+                .map(response -> new CosmosAsyncUserDefinedFunctionResponse(response, container))
                 .single();
     }
 
@@ -102,7 +102,7 @@ String getLink() {
         builder.append("/");
         builder.append(URIPathSegment());
         builder.append("/");
-        builder.append(id());
+        builder.append(getId());
         return builder.toString();
     }
 }
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunctionResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunctionResponse.java
new file mode 100644
index 000000000000..72dc995db3d1
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserDefinedFunctionResponse.java
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.ResourceResponse;
+import com.azure.data.cosmos.internal.UserDefinedFunction;
+
+public class CosmosAsyncUserDefinedFunctionResponse extends CosmosResponse {
+
+    private CosmosUserDefinedFunctionProperties cosmosUserDefinedFunctionProperties;
+    private CosmosAsyncUserDefinedFunction cosmosUserDefinedFunction;
+
+    CosmosAsyncUserDefinedFunctionResponse(ResourceResponse response, CosmosAsyncContainer container) {
+        super(response);
+        if(response.getResource() != null) {
+            super.setProperties(new CosmosUserDefinedFunctionProperties(response));
+            cosmosUserDefinedFunctionProperties = new CosmosUserDefinedFunctionProperties(response);
+            cosmosUserDefinedFunction = new CosmosAsyncUserDefinedFunction(cosmosUserDefinedFunctionProperties.getId(), container);
+        }
+    }
+
+    /**
+     * Gets the cosmos getUser defined function getProperties
+     * @return the cosmos getUser defined function getProperties
+     */
+    public CosmosUserDefinedFunctionProperties getProperties() {
+        return cosmosUserDefinedFunctionProperties;
+    }
+
+    /**
+     * Gets the cosmos user defined function object
+     * @return the cosmos user defined function object
+     */
+    public CosmosAsyncUserDefinedFunction getUserDefinedFunction() {
+        return cosmosUserDefinedFunction;
+    }
+}
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserResponse.java
new file mode 100644
index 000000000000..f107d6d543ef
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosAsyncUserResponse.java
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.data.cosmos;
+
+import com.azure.data.cosmos.internal.ResourceResponse;
+import com.azure.data.cosmos.internal.User;
+
+public class CosmosAsyncUserResponse extends CosmosResponse {
+    private CosmosAsyncUser user;
+
+    CosmosAsyncUserResponse(ResourceResponse response, CosmosAsyncDatabase database) {
+        super(response);
+        if(response.getResource() == null){
+            super.setProperties(null);
+        }else{
+            super.setProperties(new CosmosUserProperties(response));
+            this.user = new CosmosAsyncUser(this.getProperties().getId(), database);
+        }
+    }
+
+    /**
+     * Get cosmos user
+     *
+     * @return {@link CosmosAsyncUser}
+     */
+    public CosmosAsyncUser getUser() {
+        return user;
+    }
+
+    /**
+     * Gets the cosmos user properties
+     *
+     * @return {@link CosmosUserProperties}
+     */
+    public CosmosUserProperties getProperties(){
+        return super.getProperties();
+    }
+}
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java
similarity index 57%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java
index a1725f6dcb98..fb1a552167e1 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosBridgeInternal.java
@@ -16,27 +16,27 @@ public static DocumentCollection toDocumentCollection(CosmosContainerProperties
         return new DocumentCollection(cosmosContainerProperties.toJson());
     }
 
-    public static AsyncDocumentClient getAsyncDocumentClient(CosmosClient client) {
+    public static AsyncDocumentClient getAsyncDocumentClient(CosmosAsyncClient client) {
         return client.getDocClientWrapper();
     }
 
-    public static CosmosDatabase getCosmosDatabaseWithNewClient(CosmosDatabase cosmosDatabase, CosmosClient client) {
-        return new CosmosDatabase(cosmosDatabase.id(), client);
+    public static CosmosAsyncDatabase getCosmosDatabaseWithNewClient(CosmosAsyncDatabase cosmosDatabase, CosmosAsyncClient client) {
+        return new CosmosAsyncDatabase(cosmosDatabase.getId(), client);
     }
 
-    public static CosmosContainer getCosmosContainerWithNewClient(CosmosContainer cosmosContainer, CosmosDatabase cosmosDatabase, CosmosClient client) {
-        return new CosmosContainer(cosmosContainer.id(), CosmosBridgeInternal.getCosmosDatabaseWithNewClient(cosmosDatabase, client));
+    public static CosmosAsyncContainer getCosmosContainerWithNewClient(CosmosAsyncContainer cosmosContainer, CosmosAsyncDatabase cosmosDatabase, CosmosAsyncClient client) {
+        return new CosmosAsyncContainer(cosmosContainer.getId(), CosmosBridgeInternal.getCosmosDatabaseWithNewClient(cosmosDatabase, client));
     }
 
-    public static Mono getDatabaseAccount(CosmosClient client) {
+    public static Mono getDatabaseAccount(CosmosAsyncClient client) {
         return client.readDatabaseAccount();
     }
 
-    public static AsyncDocumentClient getContextClient(CosmosDatabase database) {
+    public static AsyncDocumentClient getContextClient(CosmosAsyncDatabase database) {
         return database.getClient().getContextClient();
     }
 
-    public static AsyncDocumentClient getContextClient(CosmosContainer container) {
+    public static AsyncDocumentClient getContextClient(CosmosAsyncContainer container) {
         return container.getDatabase().getClient().getContextClient();
     }
 }
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java
similarity index 64%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncClient.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java
index 57dbbb762a75..7403a86e48b3 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncClient.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClient.java
@@ -1,17 +1,9 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
 
-package com.azure.data.cosmos.sync;
-
-import com.azure.data.cosmos.CosmosClient;
-import com.azure.data.cosmos.CosmosClientBuilder;
-import com.azure.data.cosmos.CosmosClientException;
-import com.azure.data.cosmos.CosmosDatabaseProperties;
-import com.azure.data.cosmos.CosmosDatabaseRequestOptions;
-import com.azure.data.cosmos.CosmosDatabaseResponse;
-import com.azure.data.cosmos.FeedOptions;
-import com.azure.data.cosmos.FeedResponse;
-import com.azure.data.cosmos.SqlQuerySpec;
+package com.azure.data.cosmos;
+
+import com.azure.core.implementation.annotation.ServiceClient;
 import reactor.core.Exceptions;
 import reactor.core.publisher.Mono;
 
@@ -21,15 +13,16 @@
  * Provides a client-side logical representation of the Azure Cosmos database service.
  * SyncClient is used to perform operations in a synchronous way
  */
-public class CosmosSyncClient implements AutoCloseable {
-    private final CosmosClient asyncClientWrapper;
+@ServiceClient(builder=CosmosClientBuilder.class)
+public class CosmosClient implements AutoCloseable {
+    private final CosmosAsyncClient asyncClientWrapper;
 
-    public CosmosSyncClient(CosmosClientBuilder builder) {
-        this.asyncClientWrapper = builder.build();
+    public CosmosClient(CosmosClientBuilder builder) {
+        this.asyncClientWrapper = builder.buildAsyncClient();
     }
     
     /**
-     * Instantiate the cosmos client builder to build cosmos client
+     * Instantiate the cosmos client builder to buildAsyncClient cosmos client
      * @return {@link CosmosClientBuilder}
      */
     public static CosmosClientBuilder builder(){
@@ -40,10 +33,10 @@ public static CosmosClientBuilder builder(){
      * Create a Database if it does not already exist on the service
      *
      * @param databaseProperties {@link CosmosDatabaseProperties} the database properties
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception.
      */
-    public CosmosSyncDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProperties databaseProperties)
+    public CosmosDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProperties databaseProperties)
             throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabaseIfNotExists(databaseProperties));
     }
@@ -52,10 +45,10 @@ public CosmosSyncDatabaseResponse createDatabaseIfNotExists(CosmosDatabaseProper
      * Create a Database if it does not already exist on the service
      *
      * @param id the id of the database
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception.
      */
-    public CosmosSyncDatabaseResponse createDatabaseIfNotExists(String id) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabaseIfNotExists(String id) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabaseIfNotExists(id));
     }
 
@@ -65,11 +58,11 @@ public CosmosSyncDatabaseResponse createDatabaseIfNotExists(String id) throws Co
      *
      * @param databaseProperties {@link CosmosDatabaseProperties} the database properties.
      * @param options the request options.
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception.
      */
-    public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
-                                                     CosmosDatabaseRequestOptions options) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
+                                                 CosmosDatabaseRequestOptions options) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(databaseProperties, options));
     }
 
@@ -77,10 +70,10 @@ public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databa
      * Creates a database.
      *
      * @param databaseProperties {@link CosmosDatabaseProperties} the database properties.
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception.
      */
-    public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(databaseProperties));
     }
 
@@ -88,10 +81,10 @@ public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databa
      * Creates a database.
      *
      * @param id the id of the database
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception.
      */
-    public CosmosSyncDatabaseResponse createDatabase(String id) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(String id) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(id));
 
     }
@@ -102,12 +95,12 @@ public CosmosSyncDatabaseResponse createDatabase(String id) throws CosmosClientE
      * @param databaseProperties {@link CosmosDatabaseProperties} the database properties.
      * @param throughput the throughput
      * @param options {@link CosmosDatabaseRequestOptions} the request options
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception
      */
-    public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
-                                                     int throughput,
-                                                     CosmosDatabaseRequestOptions options) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
+                                                 int throughput,
+                                                 CosmosDatabaseRequestOptions options) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(databaseProperties, throughput, options));
     }
 
@@ -116,11 +109,11 @@ public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databa
      *
      * @param databaseProperties {@link CosmosDatabaseProperties} the database properties.
      * @param throughput the throughput
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception
      */
-    public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
-                                                     int throughput) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(CosmosDatabaseProperties databaseProperties,
+                                                 int throughput) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(databaseProperties, throughput));
     }
 
@@ -130,14 +123,14 @@ public CosmosSyncDatabaseResponse createDatabase(CosmosDatabaseProperties databa
      *
      * @param id the id of the database
      * @param throughput the throughput
-     * @return the {@link CosmosSyncDatabaseResponse} with the created database.
+     * @return the {@link CosmosDatabaseResponse} with the created database.
      * @throws CosmosClientException the cosmos client exception
      */
-    public CosmosSyncDatabaseResponse createDatabase(String id, int throughput) throws CosmosClientException {
+    public CosmosDatabaseResponse createDatabase(String id, int throughput) throws CosmosClientException {
         return mapDatabaseResponseAndBlock(asyncClientWrapper.createDatabase(id, throughput));
     }
 
-    CosmosSyncDatabaseResponse mapDatabaseResponseAndBlock(Mono databaseMono)
+    CosmosDatabaseResponse mapDatabaseResponseAndBlock(Mono databaseMono)
             throws CosmosClientException {
         try {
             return databaseMono
@@ -206,22 +199,22 @@ public Iterator> queryDatabases(SqlQueryS
      * Gets the database client
      *
      * @param id the id of the database
-     * @return {@link CosmosSyncDatabase} the cosmos sync database
+     * @return {@link CosmosDatabase} the cosmos sync database
      */
-    public CosmosSyncDatabase getDatabase(String id) {
-        return new CosmosSyncDatabase(id, this, asyncClientWrapper.getDatabase(id));
+    public CosmosDatabase getDatabase(String id) {
+        return new CosmosDatabase(id, this, asyncClientWrapper.getDatabase(id));
     }
 
-    CosmosSyncDatabaseResponse convertResponse(CosmosDatabaseResponse response) {
-        return new CosmosSyncDatabaseResponse(response, this);
+    CosmosDatabaseResponse convertResponse(CosmosAsyncDatabaseResponse response) {
+        return new CosmosDatabaseResponse(response, this);
     }
 
-    CosmosClient asyncClient() {
+    CosmosAsyncClient asyncClient() {
         return this.asyncClientWrapper;
     }
 
     /**
-     * Close this {@link CosmosSyncClient} instance
+     * Close this {@link CosmosClient} instance
      */
     public void close() {
         asyncClientWrapper.close();
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java
similarity index 71%
rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java
rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java
index c42b5c78bd42..d83ac68177df 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientBuilder.java
@@ -2,30 +2,31 @@
 // Licensed under the MIT License.
 package com.azure.data.cosmos;
 
+import com.azure.core.implementation.annotation.ServiceClientBuilder;
 import com.azure.data.cosmos.internal.Configs;
 import com.azure.data.cosmos.internal.Permission;
-import com.azure.data.cosmos.sync.CosmosSyncClient;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.List;
 
 /**
- * Helper class to build {@link CosmosClient} instances
+ * Helper class to buildAsyncClient {@link CosmosAsyncClient} instances
  * as logical representation of the Azure Cosmos database service.
  *
  * 
  * {@code
- * ConnectionPolicy connectionPolicy = new ConnectionPolicy();
- * connectionPolicy.connectionMode(ConnectionMode.DIRECT);
- * CosmonsClient client = new CosmosClient.builder()
- *         .endpoint(serviceEndpoint)
- *         .key(key)
- *         .connectionPolicy(connectionPolicy)
- *         .consistencyLevel(ConsistencyLevel.SESSION)
- *         .build();
+ * ConnectionPolicy getConnectionPolicy = new ConnectionPolicy();
+ * getConnectionPolicy.getConnectionMode(ConnectionMode.DIRECT);
+ * CosmonsClient client = new CosmosAsyncClient.builder()
+ *         .getEndpoint(serviceEndpoint)
+ *         .getKey(getKey)
+ *         .getConnectionPolicy(getConnectionPolicy)
+ *         .getConsistencyLevel(ConsistencyLevel.SESSION)
+ *         .buildAsyncClient();
  * }
  * 
*/ +@ServiceClientBuilder(serviceClients = {CosmosClient.class, CosmosAsyncClient.class}) public class CosmosClientBuilder { private Configs configs = new Configs(); @@ -44,7 +45,7 @@ public CosmosClientBuilder() { * Gets the token resolver * @return the token resolver */ - public TokenResolver tokenResolver() { + public TokenResolver getTokenResolver() { return tokenResolver; } @@ -53,7 +54,7 @@ public TokenResolver tokenResolver() { * @param tokenResolver * @return current builder */ - public CosmosClientBuilder tokenResolver(TokenResolver tokenResolver) { + public CosmosClientBuilder setTokenResolver(TokenResolver tokenResolver) { this.tokenResolver = tokenResolver; return this; } @@ -62,7 +63,7 @@ public CosmosClientBuilder tokenResolver(TokenResolver tokenResolver) { * Gets the Azure Cosmos DB endpoint the SDK will connect to * @return the endpoint */ - public String endpoint() { + public String getEndpoint() { return serviceEndpoint; } @@ -71,7 +72,7 @@ public String endpoint() { * @param endpoint the service endpoint * @return current Builder */ - public CosmosClientBuilder endpoint(String endpoint) { + public CosmosClientBuilder setEndpoint(String endpoint) { this.serviceEndpoint = endpoint; return this; } @@ -81,7 +82,7 @@ public CosmosClientBuilder endpoint(String endpoint) { * for accessing resource. * @return the key */ - public String key() { + public String getKey() { return keyOrResourceToken; } @@ -92,7 +93,7 @@ public String key() { * @param key master or readonly key * @return current Builder. */ - public CosmosClientBuilder key(String key) { + public CosmosClientBuilder setKey(String key) { this.keyOrResourceToken = key; return this; } @@ -102,7 +103,7 @@ public CosmosClientBuilder key(String key) { * for accessing resource. * @return the resourceToken */ - public String resourceToken() { + public String getResourceToken() { return keyOrResourceToken; } @@ -113,7 +114,7 @@ public String resourceToken() { * @param resourceToken resourceToken for authentication * @return current Builder. */ - public CosmosClientBuilder resourceToken(String resourceToken) { + public CosmosClientBuilder setResourceToken(String resourceToken) { this.keyOrResourceToken = resourceToken; return this; } @@ -123,7 +124,7 @@ public CosmosClientBuilder resourceToken(String resourceToken) { * resource tokens needed to access resources. * @return the permission list */ - public List permissions() { + public List getPermissions() { return permissions; } @@ -134,7 +135,7 @@ public List permissions() { * @param permissions Permission list for authentication. * @return current Builder. */ - public CosmosClientBuilder permissions(List permissions) { + public CosmosClientBuilder setPermissions(List permissions) { this.permissions = permissions; return this; } @@ -143,7 +144,7 @@ public CosmosClientBuilder permissions(List permissions) { * Gets the {@link ConsistencyLevel} to be used * @return the consistency level */ - public ConsistencyLevel consistencyLevel() { + public ConsistencyLevel getConsistencyLevel() { return this.desiredConsistencyLevel; } @@ -152,7 +153,7 @@ public ConsistencyLevel consistencyLevel() { * @param desiredConsistencyLevel {@link ConsistencyLevel} * @return current Builder */ - public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyLevel) { + public CosmosClientBuilder setConsistencyLevel(ConsistencyLevel desiredConsistencyLevel) { this.desiredConsistencyLevel = desiredConsistencyLevel; return this; } @@ -161,7 +162,7 @@ public CosmosClientBuilder consistencyLevel(ConsistencyLevel desiredConsistencyL * Gets the (@link ConnectionPolicy) to be used * @return the connection policy */ - public ConnectionPolicy connectionPolicy() { + public ConnectionPolicy getConnectionPolicy() { return connectionPolicy; } @@ -170,7 +171,7 @@ public ConnectionPolicy connectionPolicy() { * @param connectionPolicy {@link ConnectionPolicy} * @return current Builder */ - public CosmosClientBuilder connectionPolicy(ConnectionPolicy connectionPolicy) { + public CosmosClientBuilder setConnectionPolicy(ConnectionPolicy connectionPolicy) { this.connectionPolicy = connectionPolicy; return this; } @@ -179,7 +180,7 @@ public CosmosClientBuilder connectionPolicy(ConnectionPolicy connectionPolicy) { * Gets the {@link CosmosKeyCredential} to be used * @return cosmosKeyCredential */ - public CosmosKeyCredential cosmosKeyCredential() { + public CosmosKeyCredential getCosmosKeyCredential() { return cosmosKeyCredential; } @@ -188,39 +189,39 @@ public CosmosKeyCredential cosmosKeyCredential() { * @param cosmosKeyCredential {@link CosmosKeyCredential} * @return current builder */ - public CosmosClientBuilder cosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) { + public CosmosClientBuilder setCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) { this.cosmosKeyCredential = cosmosKeyCredential; return this; } /** * Builds a cosmos configuration object with the provided properties - * @return CosmosClient + * @return CosmosAsyncClient */ - public CosmosClient build() { + public CosmosAsyncClient buildAsyncClient() { validateConfig(); - return new CosmosClient(this); + return new CosmosAsyncClient(this); } private void validateConfig() { - ifThrowIllegalArgException(this.serviceEndpoint == null, "cannot build client without service endpoint"); + ifThrowIllegalArgException(this.serviceEndpoint == null, "cannot buildAsyncClient client without service endpoint"); ifThrowIllegalArgException( this.keyOrResourceToken == null && (permissions == null || permissions.isEmpty()) && this.tokenResolver == null && this.cosmosKeyCredential == null, - "cannot build client without any one of key, resource token, permissions, token resolver, and cosmos key credential"); - ifThrowIllegalArgException(cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.key()), - "cannot build client without key credential"); + "cannot buildAsyncClient client without any one of key, resource token, permissions, token resolver, and cosmos key credential"); + ifThrowIllegalArgException(cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.getKey()), + "cannot buildAsyncClient client without key credential"); } /** * Builds a cosmos sync client object with the provided properties - * @return CosmosSyncClient + * @return CosmosClient */ - public CosmosSyncClient buildSyncClient() { + public CosmosClient buildClient() { validateConfig(); - return new CosmosSyncClient(this); + return new CosmosClient(this); } Configs configs() { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java index cf4c22abae08..f2269bef9210 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosClientException.java @@ -132,7 +132,7 @@ public String getMessage() { * * @return the activity ID. */ - public String message() { + public String getActivityId() { if (this.responseHeaders != null) { return this.responseHeaders.get(HttpConstants.HttpHeaders.ACTIVITY_ID); } @@ -145,7 +145,7 @@ public String message() { * * @return the status code. */ - public int statusCode() { + public int getStatusCode() { return this.statusCode; } @@ -154,7 +154,7 @@ public int statusCode() { * * @return the status code. */ - public int subStatusCode() { + public int getSubStatusCode() { int code = HttpConstants.SubStatusCodes.UNKNOWN; if (this.responseHeaders != null) { String subStatusString = this.responseHeaders.get(HttpConstants.HttpHeaders.SUB_STATUS); @@ -175,11 +175,11 @@ public int subStatusCode() { * * @return the error. */ - public CosmosError error() { + public CosmosError getError() { return this.cosmosError; } - void error(CosmosError cosmosError) { + void setError(CosmosError cosmosError) { this.cosmosError = cosmosError; } @@ -190,7 +190,7 @@ void error(CosmosError cosmosError) { * @return the recommended time interval after which the client can retry failed * requests. */ - public long retryAfterInMilliseconds() { + public long getRetryAfterInMilliseconds() { long retryIntervalInMilliseconds = 0; if (this.responseHeaders != null) { @@ -216,7 +216,7 @@ public long retryAfterInMilliseconds() { * * @return the response headers */ - public Map responseHeaders() { + public Map getResponseHeaders() { return this.responseHeaders; } @@ -234,11 +234,11 @@ String getResourceAddress() { * * @return Cosmos Response Diagnostic Statistics associated with this exception. */ - public CosmosResponseDiagnostics cosmosResponseDiagnostics() { + public CosmosResponseDiagnostics getCosmosResponseDiagnostics() { return cosmosResponseDiagnostics; } - CosmosClientException cosmosResponseDiagnostics(CosmosResponseDiagnostics cosmosResponseDiagnostics) { + CosmosClientException setCosmosResponseDiagnostics(CosmosResponseDiagnostics cosmosResponseDiagnostics) { this.cosmosResponseDiagnostics = cosmosResponseDiagnostics; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java index e135f867ad26..627a91050381 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictProperties.java @@ -33,7 +33,7 @@ public class CosmosConflictProperties extends Resource { * * @return the operation kind. */ - public String operationKind() { + public String getOperationKind() { return super.getString(Constants.Properties.OPERATION_TYPE); } @@ -42,7 +42,7 @@ public String operationKind() { * * @return the resource type. */ - public String resourceType() { + public String getResourceType() { return super.getString(Constants.Properties.RESOURCE_TYPE); } @@ -50,7 +50,7 @@ public String resourceType() { * Gets the resource ID for the conflict in the Azure Cosmos DB service. * @return resource Id for the conflict. */ - String sourceResourceId() { + String getSourceResourceId() { return super.getString(Constants.Properties.SOURCE_RESOURCE_ID); } @@ -79,4 +79,4 @@ static List getFromV2Results(List results) { return results.stream().map(conflict -> new CosmosConflictProperties(conflict.toJson())) .collect(Collectors.toList()); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java index ea7e01f91ad9..d26dc5ef2b7f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictRequestOptions.java @@ -12,7 +12,7 @@ public class CosmosConflictRequestOptions { * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -22,7 +22,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosConflictRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosConflictRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } @@ -32,4 +32,4 @@ RequestOptions toRequestOptions() { requestOptions.setAccessCondition(accessCondition); return requestOptions; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java similarity index 72% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java index 256eae410adf..4d38f529c2e6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainer.java @@ -1,19 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; +package com.azure.data.cosmos; -import com.azure.data.cosmos.ChangeFeedOptions; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; import reactor.core.Exceptions; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -24,12 +13,12 @@ * Provides synchronous methods for reading, deleting, and replacing existing Containers * Provides methods for interacting with child resources (Items, Scripts, Conflicts) */ -public class CosmosSyncContainer { +public class CosmosContainer { - private final CosmosContainer containerWrapper; - private final CosmosSyncDatabase database; + private final CosmosAsyncContainer containerWrapper; + private final CosmosDatabase database; private final String id; - private CosmosSyncScripts scripts; + private CosmosScripts scripts; /** * Instantiates a new Cosmos sync container. @@ -38,7 +27,7 @@ public class CosmosSyncContainer { * @param database the database * @param container the container */ - CosmosSyncContainer(String id, CosmosSyncDatabase database, CosmosContainer container) { + CosmosContainer(String id, CosmosDatabase database, CosmosAsyncContainer container) { this.id = id; this.database = database; this.containerWrapper = container; @@ -49,7 +38,7 @@ public class CosmosSyncContainer { * * @return the string */ - public String id() { + public String getId() { return id; } @@ -59,7 +48,7 @@ public String id() { * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse read() throws CosmosClientException { + public CosmosContainerResponse read() throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.read()); } @@ -70,7 +59,7 @@ public CosmosSyncContainerResponse read() throws CosmosClientException { * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse read(CosmosContainerRequestOptions options) throws CosmosClientException { + public CosmosContainerResponse read(CosmosContainerRequestOptions options) throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.read(options)); } @@ -81,7 +70,7 @@ public CosmosSyncContainerResponse read(CosmosContainerRequestOptions options) t * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse delete(CosmosContainerRequestOptions options) throws CosmosClientException { + public CosmosContainerResponse delete(CosmosContainerRequestOptions options) throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.delete(options)); } @@ -91,7 +80,7 @@ public CosmosSyncContainerResponse delete(CosmosContainerRequestOptions options) * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse delete() throws CosmosClientException { + public CosmosContainerResponse delete() throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.delete()); } @@ -102,7 +91,7 @@ public CosmosSyncContainerResponse delete() throws CosmosClientException { * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse replace(CosmosContainerProperties containerProperties) throws CosmosClientException { + public CosmosContainerResponse replace(CosmosContainerProperties containerProperties) throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.replace(containerProperties)); } @@ -114,8 +103,8 @@ public CosmosSyncContainerResponse replace(CosmosContainerProperties containerPr * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse replace(CosmosContainerProperties containerProperties, - CosmosContainerRequestOptions options) throws CosmosClientException { + public CosmosContainerResponse replace(CosmosContainerProperties containerProperties, + CosmosContainerRequestOptions options) throws CosmosClientException { return database.mapContainerResponseAndBlock(this.containerWrapper.replace(containerProperties, options)); } @@ -126,7 +115,7 @@ public CosmosSyncContainerResponse replace(CosmosContainerProperties containerPr * @throws CosmosClientException the cosmos client exception */ public Integer readProvisionedThroughput() throws CosmosClientException { - return CosmosSyncDatabase.throughputResponseToBlock(this.containerWrapper.readProvisionedThroughput()); + return CosmosDatabase.throughputResponseToBlock(this.containerWrapper.readProvisionedThroughput()); } /** @@ -137,11 +126,11 @@ public Integer readProvisionedThroughput() throws CosmosClientException { * @throws CosmosClientException the cosmos client exception */ public Integer replaceProvisionedThroughput(int requestUnitsPerSecond) throws CosmosClientException { - return CosmosSyncDatabase.throughputResponseToBlock(this.containerWrapper.replaceProvisionedThroughput(requestUnitsPerSecond)); + return CosmosDatabase.throughputResponseToBlock(this.containerWrapper.replaceProvisionedThroughput(requestUnitsPerSecond)); } - /* CosmosItem operations */ + /* CosmosAsyncItem operations */ /** * Create item cosmos sync item response. @@ -150,7 +139,7 @@ public Integer replaceProvisionedThroughput(int requestUnitsPerSecond) throws Co * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse createItem(Object item) throws CosmosClientException { + public CosmosItemResponse createItem(Object item) throws CosmosClientException { return this.mapItemResponseAndBlock(this.containerWrapper.createItem(item)); } @@ -162,7 +151,7 @@ public CosmosSyncItemResponse createItem(Object item) throws CosmosClientExcepti * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse createItem(Object item, CosmosItemRequestOptions options) throws CosmosClientException { + public CosmosItemResponse createItem(Object item, CosmosItemRequestOptions options) throws CosmosClientException { return this.mapItemResponseAndBlock(this.containerWrapper.createItem(item, options)); } @@ -173,7 +162,7 @@ public CosmosSyncItemResponse createItem(Object item, CosmosItemRequestOptions o * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse upsertItem(Object item) throws CosmosClientException { + public CosmosItemResponse upsertItem(Object item) throws CosmosClientException { return this.mapItemResponseAndBlock(this.containerWrapper.upsertItem(item)); } @@ -185,7 +174,7 @@ public CosmosSyncItemResponse upsertItem(Object item) throws CosmosClientExcepti * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse upsertItem(Object item, CosmosItemRequestOptions options) throws CosmosClientException { + public CosmosItemResponse upsertItem(Object item, CosmosItemRequestOptions options) throws CosmosClientException { return this.mapItemResponseAndBlock(this.containerWrapper.createItem(item, options)); } @@ -196,7 +185,7 @@ public CosmosSyncItemResponse upsertItem(Object item, CosmosItemRequestOptions o * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - CosmosSyncItemResponse mapItemResponseAndBlock(Mono itemMono) + CosmosItemResponse mapItemResponseAndBlock(Mono itemMono) throws CosmosClientException { try { return itemMono @@ -261,8 +250,8 @@ public Iterator> queryChangeFeedItems(ChangeF * @param partitionKey the partition key * @return the item */ - public CosmosSyncItem getItem(String id, Object partitionKey) { - return new CosmosSyncItem(id, + public CosmosItem getItem(String id, Object partitionKey) { + return new CosmosItem(id, partitionKey, this, containerWrapper.getItem(id, partitionKey)); @@ -273,22 +262,22 @@ public CosmosSyncItem getItem(String id, Object partitionKey) { * * @return the cosmos sync scripts */ - public CosmosSyncScripts getScripts(){ + public CosmosScripts getScripts(){ if (this.scripts == null) { - this.scripts = new CosmosSyncScripts(this, containerWrapper.getScripts()); + this.scripts = new CosmosScripts(this, containerWrapper.getScripts()); } return this.scripts; } - // TODO: should make partitionkey public in CosmosItem and fix the below call + // TODO: should make partitionkey public in CosmosAsyncItem and fix the below call /** * Convert response cosmos sync item response. * * @param response the cosmos item response * @return the cosmos sync item response */ - private CosmosSyncItemResponse convertResponse(CosmosItemResponse response) { - return new CosmosSyncItemResponse(response, null, this); + private CosmosItemResponse convertResponse(CosmosAsyncItemResponse response) { + return new CosmosItemResponse(response, null, this); } private Iterator> getFeedIterator(Flux> itemFlux) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java index 6f53467e2e2b..a7c8041c0a89 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerProperties.java @@ -30,12 +30,12 @@ public class CosmosContainerProperties extends Resource { * @param partitionKeyPath partition key path */ public CosmosContainerProperties(String id, String partitionKeyPath) { - super.id(id); + super.setId(id); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add(partitionKeyPath); - partitionKeyDef.paths(paths); - partitionKeyDefinition(partitionKeyDef); + partitionKeyDef.setPaths(paths); + setPartitionKeyDefinition(partitionKeyDef); } /** @@ -44,8 +44,8 @@ public CosmosContainerProperties(String id, String partitionKeyPath) { * @param partitionKeyDefinition the {@link PartitionKeyDefinition} */ public CosmosContainerProperties(String id, PartitionKeyDefinition partitionKeyDefinition) { - super.id(id); - partitionKeyDefinition(partitionKeyDefinition); + super.setId(id); + setPartitionKeyDefinition(partitionKeyDefinition); } CosmosContainerProperties(ResourceResponse response) { @@ -66,7 +66,7 @@ static List getFromV2Results(List * * @return the indexing policy. */ - public IndexingPolicy indexingPolicy() { + public IndexingPolicy getIndexingPolicy() { if (this.indexingPolicy == null) { if (super.has(Constants.Properties.INDEXING_POLICY)) { this.indexingPolicy = super.getObject(Constants.Properties.INDEXING_POLICY, IndexingPolicy.class); @@ -84,7 +84,7 @@ public IndexingPolicy indexingPolicy() { * @param indexingPolicy {@link IndexingPolicy} the indexing policy * @return the CosmosContainerProperties. */ - public CosmosContainerProperties indexingPolicy(IndexingPolicy indexingPolicy) { + public CosmosContainerProperties setIndexingPolicy(IndexingPolicy indexingPolicy) { if (indexingPolicy == null) { throw new IllegalArgumentException("IndexingPolicy cannot be null."); } @@ -98,7 +98,7 @@ public CosmosContainerProperties indexingPolicy(IndexingPolicy indexingPolicy) { * * @return the unique key policy */ - public UniqueKeyPolicy uniqueKeyPolicy() { + public UniqueKeyPolicy getUniqueKeyPolicy() { // Thread safe lazy initialization for case when collection is cached (and is basically readonly). if (this.uniqueKeyPolicy == null) { @@ -118,7 +118,7 @@ public UniqueKeyPolicy uniqueKeyPolicy() { * @param uniqueKeyPolicy the unique key policy * @return the CosmosContainerProperties. */ - public CosmosContainerProperties uniqueKeyPolicy(UniqueKeyPolicy uniqueKeyPolicy) { + public CosmosContainerProperties setUniqueKeyPolicy(UniqueKeyPolicy uniqueKeyPolicy) { if (uniqueKeyPolicy == null) { throw new IllegalArgumentException("uniqueKeyPolicy cannot be null."); } @@ -133,7 +133,7 @@ public CosmosContainerProperties uniqueKeyPolicy(UniqueKeyPolicy uniqueKeyPolicy * * @return the partition key definition. */ - public PartitionKeyDefinition partitionKeyDefinition() { + public PartitionKeyDefinition getPartitionKeyDefinition() { if (this.partitionKeyDefinition == null) { if (super.has(Constants.Properties.PARTITION_KEY)) { @@ -152,7 +152,7 @@ public PartitionKeyDefinition partitionKeyDefinition() { * @param partitionKeyDefinition the partition key definition. * @return the CosmosContainerProperties. */ - public CosmosContainerProperties partitionKeyDefinition(PartitionKeyDefinition partitionKeyDefinition) { + public CosmosContainerProperties setPartitionKeyDefinition(PartitionKeyDefinition partitionKeyDefinition) { if (partitionKeyDefinition == null) { throw new IllegalArgumentException("partitionKeyDefinition cannot be null."); } @@ -167,7 +167,7 @@ public CosmosContainerProperties partitionKeyDefinition(PartitionKeyDefinition p * * @return ConflictResolutionPolicy */ - public ConflictResolutionPolicy conflictResolutionPolicy() { + public ConflictResolutionPolicy getConflictResolutionPolicy() { return super.getObject(Constants.Properties.CONFLICT_RESOLUTION_POLICY, ConflictResolutionPolicy.class); } @@ -178,7 +178,7 @@ public ConflictResolutionPolicy conflictResolutionPolicy() { * @param value ConflictResolutionPolicy to be used. * @return the CosmosContainerProperties. */ - public CosmosContainerProperties conflictResolutionPolicy(ConflictResolutionPolicy value) { + public CosmosContainerProperties setConflictResolutionPolicy(ConflictResolutionPolicy value) { if (value == null) { throw new IllegalArgumentException("CONFLICT_RESOLUTION_POLICY cannot be null."); } @@ -189,8 +189,8 @@ public CosmosContainerProperties conflictResolutionPolicy(ConflictResolutionPoli DocumentCollection getV2Collection(){ DocumentCollection collection = new DocumentCollection(this.toJson()); - collection.setPartitionKey(this.partitionKeyDefinition()); - collection.setIndexingPolicy(this.indexingPolicy()); + collection.setPartitionKey(this.getPartitionKeyDefinition()); + collection.setIndexingPolicy(this.getIndexingPolicy()); return collection; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java similarity index 84% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java index f23b5a63c5a0..a4b1eb1ba59b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerRequestOptions.java @@ -19,7 +19,7 @@ public class CosmosContainerRequestOptions { * * @return the throughput value. */ - Integer offerThroughput() { + Integer getOfferThroughput() { return offerThroughput; } @@ -29,7 +29,7 @@ Integer offerThroughput() { * @param offerThroughput the throughput value. * @return the current request options */ - CosmosContainerRequestOptions offerThroughput(Integer offerThroughput) { + CosmosContainerRequestOptions setOfferThroughput(Integer offerThroughput) { this.offerThroughput = offerThroughput; return this; } @@ -41,7 +41,7 @@ CosmosContainerRequestOptions offerThroughput(Integer offerThroughput) { * * @return true if PopulateQuotaInfo is enabled */ - public boolean populateQuotaInfo() { + public boolean getPopulateQuotaInfo() { return populateQuotaInfo; } @@ -53,7 +53,7 @@ public boolean populateQuotaInfo() { * @param populateQuotaInfo a boolean value indicating whether PopulateQuotaInfo is enabled or not * @return the current request options */ - public CosmosContainerRequestOptions populateQuotaInfo(boolean populateQuotaInfo) { + public CosmosContainerRequestOptions setPopulateQuotaInfo(boolean populateQuotaInfo) { this.populateQuotaInfo = populateQuotaInfo; return this; } @@ -63,7 +63,7 @@ public CosmosContainerRequestOptions populateQuotaInfo(boolean populateQuotaInfo * * @return the consistency level. */ - public ConsistencyLevel consistencyLevel() { + public ConsistencyLevel getConsistencyLevel() { return consistencyLevel; } @@ -73,7 +73,7 @@ public ConsistencyLevel consistencyLevel() { * @param consistencyLevel the consistency level. * @return the current request options */ - public CosmosContainerRequestOptions consistencyLevel(ConsistencyLevel consistencyLevel) { + public CosmosContainerRequestOptions setConsistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } @@ -83,7 +83,7 @@ public CosmosContainerRequestOptions consistencyLevel(ConsistencyLevel consisten * * @return the session token. */ - public String sessionToken() { + public String getSessionToken() { return sessionToken; } @@ -93,7 +93,7 @@ public String sessionToken() { * @param sessionToken the session token. * @return the current request options */ - public CosmosContainerRequestOptions sessionToken(String sessionToken) { + public CosmosContainerRequestOptions setSessionToken(String sessionToken) { this.sessionToken = sessionToken; return this; } @@ -103,7 +103,7 @@ public CosmosContainerRequestOptions sessionToken(String sessionToken) { * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -113,7 +113,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosContainerRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosContainerRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } @@ -127,4 +127,4 @@ RequestOptions toRequestOptions() { options.setConsistencyLevel(consistencyLevel); return options; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java new file mode 100644 index 000000000000..b702bb56eadf --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosContainerResponse.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos; + +/** + * The synchronous cosmos container response + */ +public class CosmosContainerResponse extends CosmosResponse { + + private final CosmosAsyncContainerResponse responseWrapper; + private final CosmosContainer container; + + CosmosContainerResponse(CosmosAsyncContainerResponse response, CosmosDatabase database, CosmosClient client) { + super(response.getProperties()); + this.responseWrapper = response; + if (responseWrapper.getContainer() != null) { + this.container = new CosmosContainer(responseWrapper.getContainer().getId(), database, responseWrapper.getContainer()); + } else { + // Delete will have null container client in response + this.container = null; + } + } + + /** + * Gets the progress of an index transformation, if one is underway. + * + * @return the progress of an index transformation. + */ + public long getIndexTransformationProgress() { + return responseWrapper.getIndexTransformationProgress(); + } + + /** + * Gets the container properties + * + * @return the cosmos container properties + */ + public CosmosContainerProperties getProperties() { + return responseWrapper.getProperties(); + } + + /** + * Gets the Container object + * + * @return the Cosmos container object + */ + public CosmosContainer getContainer() { + return container; + } +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabase.java similarity index 73% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabase.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabase.java index 5e41a32d534b..b94d729f0dd4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabase.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabase.java @@ -1,19 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.CosmosUserResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import reactor.core.Exceptions; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -24,10 +13,10 @@ * Perform read and delete databases, update database throughput, and perform operations on child resources in * a synchronous way */ -public class CosmosSyncDatabase { +public class CosmosDatabase { - private final CosmosDatabase databaseWrapper; - private final CosmosSyncClient client; + private final CosmosAsyncDatabase databaseWrapper; + private final CosmosClient client; private final String id; /** @@ -37,28 +26,28 @@ public class CosmosSyncDatabase { * @param client the client * @param database the database */ - CosmosSyncDatabase(String id, CosmosSyncClient client, CosmosDatabase database) { + CosmosDatabase(String id, CosmosClient client, CosmosAsyncDatabase database) { this.id = id; this.client = client; this.databaseWrapper = database; } /** - * Get the id of the CosmosDatabase + * Get the id of the CosmosAsyncDatabase * * @return the id of the database */ - public String id() { + public String getId() { return id; } /** * Reads a database * - * @return the {@link CosmosSyncDatabaseResponse} + * @return the {@link CosmosDatabaseResponse} * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncDatabaseResponse read() throws CosmosClientException { + public CosmosDatabaseResponse read() throws CosmosClientException { return client.mapDatabaseResponseAndBlock((databaseWrapper.read())); } @@ -66,20 +55,20 @@ public CosmosSyncDatabaseResponse read() throws CosmosClientException { * Reads a database. * * @param options the {@link CosmosDatabaseRequestOptions} request options. - * @return the {@link CosmosSyncDatabaseResponse} + * @return the {@link CosmosDatabaseResponse} * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncDatabaseResponse read(CosmosDatabaseRequestOptions options) throws CosmosClientException { + public CosmosDatabaseResponse read(CosmosDatabaseRequestOptions options) throws CosmosClientException { return client.mapDatabaseResponseAndBlock(databaseWrapper.read(options)); } /** * Delete a database. * - * @return the {@link CosmosSyncDatabaseResponse} + * @return the {@link CosmosDatabaseResponse} * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncDatabaseResponse delete() throws CosmosClientException { + public CosmosDatabaseResponse delete() throws CosmosClientException { return client.mapDatabaseResponseAndBlock(databaseWrapper.delete()); } @@ -87,23 +76,23 @@ public CosmosSyncDatabaseResponse delete() throws CosmosClientException { * Delete a database. * * @param options the {@link CosmosDatabaseRequestOptions} request options. - * @return the {@link CosmosSyncDatabaseResponse} + * @return the {@link CosmosDatabaseResponse} * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncDatabaseResponse delete(CosmosDatabaseRequestOptions options) throws CosmosClientException { + public CosmosDatabaseResponse delete(CosmosDatabaseRequestOptions options) throws CosmosClientException { return client.mapDatabaseResponseAndBlock(databaseWrapper.delete(options)); } - /* CosmosContainer operations */ + /* CosmosAsyncContainer operations */ /** * Creates a cosmos container. * * @param containerProperties the {@link CosmosContainerProperties} - * @return the {@link CosmosSyncContainerResponse} with the created container. + * @return the {@link CosmosContainerResponse} with the created container. * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(CosmosContainerProperties containerProperties) throws CosmosClientException { + public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(containerProperties)); } @@ -112,11 +101,11 @@ public CosmosSyncContainerResponse createContainer(CosmosContainerProperties con * * @param containerProperties the {@link CosmosContainerProperties} * @param throughput the throughput - * @return the {@link CosmosSyncContainerResponse} with the created container. + * @return the {@link CosmosContainerResponse} with the created container. * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(CosmosContainerProperties containerProperties, - int throughput) throws CosmosClientException { + public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, + int throughput) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(containerProperties, throughput)); } @@ -125,11 +114,11 @@ public CosmosSyncContainerResponse createContainer(CosmosContainerProperties con * * @param containerProperties the {@link CosmosContainerProperties} * @param options the {@link CosmosContainerProperties} - * @return the {@link CosmosSyncContainerResponse} with the created container. + * @return the {@link CosmosContainerResponse} with the created container. * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(CosmosContainerProperties containerProperties, - CosmosContainerRequestOptions options) throws CosmosClientException { + public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, + CosmosContainerRequestOptions options) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(containerProperties, options)); } @@ -139,12 +128,12 @@ public CosmosSyncContainerResponse createContainer(CosmosContainerProperties con * @param containerProperties the {@link CosmosContainerProperties} * @param throughput the throughput * @param options the {@link CosmosContainerProperties} - * @return the {@link CosmosSyncContainerResponse} with the created container. + * @return the {@link CosmosContainerResponse} with the created container. * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(CosmosContainerProperties containerProperties, - int throughput, - CosmosContainerRequestOptions options) throws CosmosClientException { + public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, + int throughput, + CosmosContainerRequestOptions options) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(containerProperties, throughput, options)); @@ -158,7 +147,7 @@ public CosmosSyncContainerResponse createContainer(CosmosContainerProperties con * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(String id, String partitionKeyPath) throws CosmosClientException { + public CosmosContainerResponse createContainer(String id, String partitionKeyPath) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(id, partitionKeyPath)); } @@ -171,7 +160,7 @@ public CosmosSyncContainerResponse createContainer(String id, String partitionKe * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainer(String id, String partitionKeyPath, int throughput) throws CosmosClientException { + public CosmosContainerResponse createContainer(String id, String partitionKeyPath, int throughput) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(id, partitionKeyPath, throughput)); } @@ -182,7 +171,7 @@ public CosmosSyncContainerResponse createContainer(String id, String partitionKe * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties) + public CosmosContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainerIfNotExists(containerProperties)); } @@ -195,8 +184,8 @@ public CosmosSyncContainerResponse createContainerIfNotExists(CosmosContainerPro * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties, - int throughput) throws CosmosClientException { + public CosmosContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties, + int throughput) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainerIfNotExists(containerProperties, throughput)); } @@ -208,8 +197,8 @@ public CosmosSyncContainerResponse createContainerIfNotExists(CosmosContainerPro * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainerIfNotExists(String id, - String partitionKeyPath) throws CosmosClientException { + public CosmosContainerResponse createContainerIfNotExists(String id, + String partitionKeyPath) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainerIfNotExists(id, partitionKeyPath)); } @@ -222,8 +211,8 @@ public CosmosSyncContainerResponse createContainerIfNotExists(String id, * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncContainerResponse createContainerIfNotExists(String id, String partitionKeyPath, - int throughput) throws CosmosClientException { + public CosmosContainerResponse createContainerIfNotExists(String id, String partitionKeyPath, + int throughput) throws CosmosClientException { return this.mapContainerResponseAndBlock(databaseWrapper.createContainerIfNotExists(id, partitionKeyPath, throughput)); @@ -236,7 +225,7 @@ public CosmosSyncContainerResponse createContainerIfNotExists(String id, String * @return the cosmos sync container response * @throws CosmosClientException the cosmos client exception */ - CosmosSyncContainerResponse mapContainerResponseAndBlock(Mono containerMono) + CosmosContainerResponse mapContainerResponseAndBlock(Mono containerMono) throws CosmosClientException { try { return containerMono @@ -326,13 +315,13 @@ public Iterator> queryContainers(SqlQuer } /** - * Gets a CosmosSyncContainer object without making a service call + * Gets a CosmosContainer object without making a service call * * @param id id of the container * @return Cosmos Container */ - public CosmosSyncContainer getContainer(String id) { - return new CosmosSyncContainer(id, this, databaseWrapper.getContainer(id)); + public CosmosContainer getContainer(String id) { + return new CosmosContainer(id, this, databaseWrapper.getContainer(id)); } /** @@ -341,8 +330,8 @@ public CosmosSyncContainer getContainer(String id) { * @param response the response * @return the cosmos sync container response */ - CosmosSyncContainerResponse convertResponse(CosmosContainerResponse response) { - return new CosmosSyncContainerResponse(response, this, client); + CosmosContainerResponse convertResponse(CosmosAsyncContainerResponse response) { + return new CosmosContainerResponse(response, this, client); } /* Users */ @@ -354,7 +343,7 @@ CosmosSyncContainerResponse convertResponse(CosmosContainerResponse response) { * @return the cosmos sync user response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserResponse createUser(CosmosUserProperties settings) throws CosmosClientException { + public CosmosUserResponse createUser(CosmosUserProperties settings) throws CosmosClientException { return mapUserResponseAndBlock(databaseWrapper.createUser(settings)); } @@ -365,7 +354,7 @@ public CosmosSyncUserResponse createUser(CosmosUserProperties settings) throws C * @return the cosmos sync user response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserResponse upsertUser(CosmosUserProperties settings) throws CosmosClientException { + public CosmosUserResponse upsertUser(CosmosUserProperties settings) throws CosmosClientException { return mapUserResponseAndBlock(databaseWrapper.upsertUser(settings)); } @@ -436,11 +425,11 @@ public Iterator> queryUsers(SqlQuerySpec quer * @param id the id * @return the user */ - public CosmosSyncUser getUser(String id) { - return new CosmosSyncUser(databaseWrapper.getUser(id), this, id); + public CosmosUser getUser(String id) { + return new CosmosUser(databaseWrapper.getUser(id), this, id); } - CosmosSyncUserResponse mapUserResponseAndBlock(Mono containerMono) + CosmosUserResponse mapUserResponseAndBlock(Mono containerMono) throws CosmosClientException { try { return containerMono.map(this::convertUserResponse).block(); @@ -454,8 +443,8 @@ CosmosSyncUserResponse mapUserResponseAndBlock(Mono containe } } - private CosmosSyncUserResponse convertUserResponse(CosmosUserResponse response) { - return new CosmosSyncUserResponse(response, this); + private CosmosUserResponse convertUserResponse(CosmosAsyncUserResponse response) { + return new CosmosUserResponse(response, this); } /** diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java index 554add12d504..eb3652bcad5a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseProperties.java @@ -9,7 +9,7 @@ import java.util.stream.Collectors; /** - * Represents a CosmosDatabase in the Azure Cosmos database service. A cosmos database manages users, permissions and a set of containers + * Represents a CosmosAsyncDatabase in the Azure Cosmos database service. A cosmos database manages users, permissions and a set of containers *

* Each Azure Cosmos DB Service is able to support multiple independent named databases, with the database being the * logical container for data. Each Database consists of one or more cosmos containers, each of which in turn contain one or @@ -23,7 +23,7 @@ public class CosmosDatabaseProperties extends Resource { * @param id id of the database */ public CosmosDatabaseProperties(String id) { - super.id(id); + super.setId(id); } CosmosDatabaseProperties(ResourceResponse response) { @@ -38,4 +38,4 @@ public CosmosDatabaseProperties(String id) { static List getFromV2Results(List results){ return results.stream().map(CosmosDatabaseProperties::new).collect(Collectors.toList()); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java index 2ad9771b2ecc..679a15a1f6f0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseRequestOptions.java @@ -16,7 +16,7 @@ public class CosmosDatabaseRequestOptions{ * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -26,7 +26,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosDatabaseRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosDatabaseRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } @@ -36,7 +36,7 @@ public CosmosDatabaseRequestOptions accessCondition(AccessCondition accessCondit * * @return the throughput value. */ - Integer offerThroughput() { + Integer getOfferThroughput() { return offerThroughput; } @@ -46,7 +46,7 @@ Integer offerThroughput() { * @param offerThroughput the throughput value. * @return the current request options */ - CosmosDatabaseRequestOptions offerThroughput(Integer offerThroughput) { + CosmosDatabaseRequestOptions setOfferThroughput(Integer offerThroughput) { this.offerThroughput = offerThroughput; return this; } @@ -57,4 +57,4 @@ RequestOptions toRequestOptions() { options.setOfferThroughput(offerThroughput); return options; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java new file mode 100644 index 000000000000..a92205d2b64e --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos; + +public class CosmosDatabaseResponse extends CosmosResponse { + private final CosmosAsyncDatabaseResponse responseWrapper; + private final CosmosDatabase database; + + CosmosDatabaseResponse(CosmosAsyncDatabaseResponse response, CosmosClient client) { + super(response.getProperties()); + this.responseWrapper = response; + if (responseWrapper.getDatabase() != null) { + this.database = new CosmosDatabase(responseWrapper.getDatabase().getId(), client, responseWrapper.getDatabase()); + } else { + this.database = null; + } + } + + /** + * Gets the CosmosAsyncDatabase object + * + * @return {@link CosmosDatabase} + */ + public CosmosDatabase getDatabase() { + return database; + } + + /** + * Gets the cosmos database properties + * + * @return the cosmos database properties + */ + public CosmosDatabaseProperties getProperties() { + return responseWrapper.getProperties(); + } + + /** + * Gets the Max Quota. + * + * @return the database quota. + */ + public long getDatabaseQuota() { + return responseWrapper.getDatabaseQuota(); + } + + /** + * Gets the current Usage. + * + * @return the current database usage. + */ + public long getDatabaseUsage() { + return responseWrapper.getDatabaseUsage(); + } + +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosError.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosError.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosError.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosError.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItem.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java similarity index 62% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItem.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java index 1c459cc69921..b71374d9e8bd 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItem.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItem.java @@ -1,18 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemRequestOptions; +package com.azure.data.cosmos; /** * The Cosmos synchronous item. */ -public class CosmosSyncItem { - private final CosmosSyncContainer container; - private final CosmosItem asyncItem; +public class CosmosItem { + private final CosmosContainer container; + private final CosmosAsyncItem asyncItem; private final String id; private final Object partitionKey; @@ -21,13 +17,13 @@ public class CosmosSyncItem { * * @param id the id * @param partitionKey the partition key - * @param cosmosSyncContainer the cosmos sync container + * @param cosmosContainer the cosmos sync container * @param item the item */ - CosmosSyncItem(String id, Object partitionKey, CosmosSyncContainer cosmosSyncContainer, CosmosItem item) { + CosmosItem(String id, Object partitionKey, CosmosContainer cosmosContainer, CosmosAsyncItem item) { this.id = id; this.partitionKey = partitionKey; - this.container = cosmosSyncContainer; + this.container = cosmosContainer; this.asyncItem = item; } @@ -36,16 +32,16 @@ public class CosmosSyncItem { * * @return the string */ - public String id() { + public String getId() { return id; } /** - * Partition key object. + * Partition getKey object. * * @return the object */ - public Object partitionKey() { + public Object getPartitionKey() { return partitionKey; } @@ -56,7 +52,7 @@ public Object partitionKey() { * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse read(CosmosItemRequestOptions options) throws CosmosClientException { + public CosmosItemResponse read(CosmosItemRequestOptions options) throws CosmosClientException { return container.mapItemResponseAndBlock(asyncItem.read(options)); } @@ -68,7 +64,7 @@ public CosmosSyncItemResponse read(CosmosItemRequestOptions options) throws Cosm * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse replace(Object item, CosmosItemRequestOptions options) throws CosmosClientException { + public CosmosItemResponse replace(Object item, CosmosItemRequestOptions options) throws CosmosClientException { return container.mapItemResponseAndBlock(asyncItem.replace(item, options)); } @@ -79,7 +75,7 @@ public CosmosSyncItemResponse replace(Object item, CosmosItemRequestOptions opti * @return the cosmos sync item response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncItemResponse delete(CosmosItemRequestOptions options) throws CosmosClientException { + public CosmosItemResponse delete(CosmosItemRequestOptions options) throws CosmosClientException { return container.mapItemResponseAndBlock(asyncItem.delete(options)); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java index 441b872f3f1d..b91234a6f058 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemProperties.java @@ -26,8 +26,8 @@ public CosmosItemProperties() { * @param id the name of the resource. * @return the cosmos item properties with id set */ - public CosmosItemProperties id(String id) { - super.id(id); + public CosmosItemProperties setId(String id) { + super.setId(id); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java similarity index 78% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java index 188db483dca0..757fbf27ef9a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemRequestOptions.java @@ -32,9 +32,9 @@ public CosmosItemRequestOptions(){ public CosmosItemRequestOptions(Object partitionKey){ super(); if (partitionKey instanceof PartitionKey) { - partitionKey((PartitionKey) partitionKey); + setPartitionKey((PartitionKey) partitionKey); } else { - partitionKey(new PartitionKey(partitionKey)); + setPartitionKey(new PartitionKey(partitionKey)); } } @@ -43,7 +43,7 @@ public CosmosItemRequestOptions(Object partitionKey){ * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -53,7 +53,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosItemRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosItemRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } @@ -63,7 +63,7 @@ public CosmosItemRequestOptions accessCondition(AccessCondition accessCondition) * * @return the consistency level. */ - public ConsistencyLevel consistencyLevel() { + public ConsistencyLevel getConsistencyLevel() { return consistencyLevel; } @@ -73,7 +73,7 @@ public ConsistencyLevel consistencyLevel() { * @param consistencyLevel the consistency level. * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions consistencyLevel(ConsistencyLevel consistencyLevel) { + public CosmosItemRequestOptions setConsistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } @@ -83,7 +83,7 @@ public CosmosItemRequestOptions consistencyLevel(ConsistencyLevel consistencyLev * * @return the indexing directive. */ - public IndexingDirective indexingDirective() { + public IndexingDirective getIndexingDirective() { return indexingDirective; } @@ -93,7 +93,7 @@ public IndexingDirective indexingDirective() { * @param indexingDirective the indexing directive. * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions indexingDirective(IndexingDirective indexingDirective) { + public CosmosItemRequestOptions setIndexingDirective(IndexingDirective indexingDirective) { this.indexingDirective = indexingDirective; return this; } @@ -103,7 +103,7 @@ public CosmosItemRequestOptions indexingDirective(IndexingDirective indexingDire * * @return the triggers to be invoked before the operation. */ - public List preTriggerInclude() { + public List getPreTriggerInclude() { return preTriggerInclude; } @@ -113,7 +113,7 @@ public List preTriggerInclude() { * @param preTriggerInclude the triggers to be invoked before the operation. * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions preTriggerInclude(List preTriggerInclude) { + public CosmosItemRequestOptions setPreTriggerInclude(List preTriggerInclude) { this.preTriggerInclude = preTriggerInclude; return this; } @@ -123,7 +123,7 @@ public CosmosItemRequestOptions preTriggerInclude(List preTriggerInclude * * @return the triggers to be invoked after the operation. */ - public List postTriggerInclude() { + public List getPostTriggerInclude() { return postTriggerInclude; } @@ -133,7 +133,7 @@ public List postTriggerInclude() { * @param postTriggerInclude the triggers to be invoked after the operation. * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions postTriggerInclude(List postTriggerInclude) { + public CosmosItemRequestOptions setPostTriggerInclude(List postTriggerInclude) { this.postTriggerInclude = postTriggerInclude; return this; } @@ -143,7 +143,7 @@ public CosmosItemRequestOptions postTriggerInclude(List postTriggerInclu * * @return the session token. */ - public String sessionToken() { + public String getSessionToken() { return sessionToken; } @@ -153,7 +153,7 @@ public String sessionToken() { * @param sessionToken the session token. * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions sessionToken(String sessionToken) { + public CosmosItemRequestOptions setSessionToken(String sessionToken) { this.sessionToken = sessionToken; return this; } @@ -163,7 +163,7 @@ public CosmosItemRequestOptions sessionToken(String sessionToken) { * @param partitionKey the partition key * @return the CosmosItemRequestOptions. */ - public CosmosItemRequestOptions partitionKey(PartitionKey partitionKey) { + public CosmosItemRequestOptions setPartitionKey(PartitionKey partitionKey) { this.partitionKey = partitionKey; return this; } @@ -172,7 +172,7 @@ public CosmosItemRequestOptions partitionKey(PartitionKey partitionKey) { * Gets the partition key * @return the partition key */ - public PartitionKey partitionKey() { + public PartitionKey getPartitionKey() { return partitionKey; } @@ -180,8 +180,8 @@ RequestOptions toRequestOptions() { //TODO: Should we set any default values instead of nulls? RequestOptions requestOptions = new RequestOptions(); requestOptions.setAccessCondition(accessCondition); - requestOptions.setAccessCondition(accessCondition()); - requestOptions.setConsistencyLevel(consistencyLevel()); + requestOptions.setAccessCondition(getAccessCondition()); + requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setIndexingDirective(indexingDirective); requestOptions.setPreTriggerInclude(preTriggerInclude); requestOptions.setPostTriggerInclude(postTriggerInclude); @@ -189,4 +189,4 @@ RequestOptions toRequestOptions() { requestOptions.setPartitionKey(partitionKey); return requestOptions; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java new file mode 100644 index 000000000000..7924b35dd7a4 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos; + +public class CosmosItemResponse extends CosmosResponse { + private final CosmosAsyncItemResponse responseWrapper; + private final CosmosItem item; + + + CosmosItemResponse(CosmosAsyncItemResponse response, PartitionKey partitionKey, CosmosContainer container) { + super(response.getProperties()); + this.responseWrapper = response; + if (responseWrapper.getItem() != null) { + this.item = new CosmosItem(responseWrapper.getItem().getId(), partitionKey, container, responseWrapper.getItem()); + } else { + // Delete will have null container client in response + this.item = null; + } + } + + /** + * Gets the itemSettings + * + * @return the itemSettings + */ + public CosmosItemProperties getProperties() { + return responseWrapper.getProperties(); + } + + /** + * Gets the CosmosAsyncItem + * + * @return the cosmos item + */ + public CosmosItem getItem() { + return item; + } +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java index 6ada00a4db5b..4e82cfdab18e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosKeyCredential.java @@ -6,7 +6,7 @@ * Cosmos Key Credential is used to store key credentials, in order to support dynamic key rotation. * Singleton instance should be used to support multiple keys. * Azure client library for Cosmos ensures to use the updated key provided in the same singleton instance - * which was used when building {@link CosmosClient} + * which was used when building {@link CosmosAsyncClient} */ public class CosmosKeyCredential { @@ -24,7 +24,7 @@ public CosmosKeyCredential(String key) { * Returns the key stored in Cosmos Key Credential * @return key */ - public String key() { + public String getKey() { return key; } @@ -33,7 +33,7 @@ public String key() { * @param key key to be used in CosmosKeyCredential * @return current CosmosKeyCredential */ - public CosmosKeyCredential key(String key) { + public CosmosKeyCredential setKey(String key) { this.key = key; this.keyHashCode = key.hashCode(); return this; @@ -43,7 +43,7 @@ public CosmosKeyCredential key(String key) { * CosmosKeyCredential stores the computed hashcode of the key for performance improvements. * @return hashcode of the key */ - public int keyHashCode() { + public int getKeyHashCode() { return this.keyHashCode; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java index 6abfd0dc3772..058029500a05 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionProperties.java @@ -28,15 +28,15 @@ public CosmosPermissionProperties() { * @param id the name of the resource. * @return the current {@link CosmosPermissionProperties} object */ - public CosmosPermissionProperties id(String id) { - super.id(id); + public CosmosPermissionProperties setId(String id) { + super.setId(id); return this; } /** * Initialize a permission object from json string. * - * @param jsonString the json string that represents the permission. + * @param jsonString the json string that represents the getPermission. */ CosmosPermissionProperties(String jsonString) { super(jsonString); @@ -47,7 +47,7 @@ public CosmosPermissionProperties id(String id) { * * @return the resource link. */ - public String resourceLink() { + public String getResourceLink() { return super.getString(Constants.Properties.RESOURCE_LINK); } @@ -57,7 +57,7 @@ public String resourceLink() { * @param resourceLink the resource link. * @return the current {@link CosmosPermissionProperties} object */ - public CosmosPermissionProperties resourceLink(String resourceLink) { + public CosmosPermissionProperties setResourceLink(String resourceLink) { super.set(Constants.Properties.RESOURCE_LINK, resourceLink); return this; } @@ -67,7 +67,7 @@ public CosmosPermissionProperties resourceLink(String resourceLink) { * * @return the permission mode. */ - public PermissionMode permissionMode() { + public PermissionMode getPermissionMode() { String value = super.getString(Constants.Properties.PERMISSION_MODE); return PermissionMode.valueOf(StringUtils.upperCase(value)); } @@ -78,7 +78,7 @@ public PermissionMode permissionMode() { * @param permissionMode the permission mode. * @return the current {@link CosmosPermissionProperties} object */ - public CosmosPermissionProperties permissionMode(PermissionMode permissionMode) { + public CosmosPermissionProperties setPermissionMode(PermissionMode permissionMode) { this.set(Constants.Properties.PERMISSION_MODE, permissionMode.toString().toLowerCase()); return this; @@ -107,7 +107,7 @@ public CosmosPermissionProperties permissionMode(PermissionMode permissionMode) * @param partitionKey the partition key. * @return the current {@link CosmosPermissionProperties} object */ - public CosmosPermissionProperties resourcePartitionKey(PartitionKey partitionKey) { + public CosmosPermissionProperties setResourcePartitionKey(PartitionKey partitionKey) { super.set(Constants.Properties.RESOURCE_PARTITION_KEY, partitionKey.getInternalPartitionKey().toJson()); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java similarity index 83% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java index b721d9252ba0..c95ab001dd35 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionRequestOptions.java @@ -5,7 +5,7 @@ import com.azure.data.cosmos.internal.RequestOptions; /** - * Contains the request options of CosmosPermission + * Contains the request options of CosmosAsyncPermission */ public class CosmosPermissionRequestOptions { //TODO: Need to add respective options @@ -16,7 +16,7 @@ public class CosmosPermissionRequestOptions { * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -26,7 +26,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosPermissionRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosPermissionRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResourceType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResourceType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResourceType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResourceType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java similarity index 76% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java index c47c7ded05ae..331691e59ffa 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponse.java @@ -9,27 +9,27 @@ import java.util.Map; public class CosmosResponse { - private T resourceSettings; + private T properties; ResourceResponse resourceResponseWrapper; CosmosResponse(ResourceResponse resourceResponse){ this.resourceResponseWrapper = resourceResponse; } - CosmosResponse(T resourceSettings){ - this.resourceSettings = resourceSettings; + CosmosResponse(T properties){ + this.properties = properties; } - // Only used in CosmosStoredProcedureResponse compatibility with StoredProcedureResponse + // Only used in CosmosAsyncStoredProcedureResponse compatibility with StoredProcedureResponse CosmosResponse(StoredProcedureResponse response) { } - T resourceSettings() { - return resourceSettings; + public T getProperties() { + return properties; } - CosmosResponse resourceSettings(T resourceSettings){ - this.resourceSettings = resourceSettings; + CosmosResponse setProperties(T resourceSettings){ + this.properties = resourceSettings; return this; } @@ -39,7 +39,7 @@ CosmosResponse resourceSettings(T resourceSettings){ * * @return the max resource quota. */ - public String maxResourceQuota() { + public String getMaxResourceQuota() { return resourceResponseWrapper.getMaxResourceQuota(); } @@ -48,16 +48,16 @@ public String maxResourceQuota() { * * @return the current resource quota usage. */ - public String currentResourceQuotaUsage() { + public String getCurrentResourceQuotaUsage() { return resourceResponseWrapper.getCurrentResourceQuotaUsage(); } /** * Gets the Activity ID for the request. * - * @return the activity id. + * @return the activity getId. */ - public String activityId() { + public String getActivityId() { return resourceResponseWrapper.getActivityId(); } @@ -66,7 +66,7 @@ public String activityId() { * * @return the request charge. */ - public double requestCharge() { + public double getRequestCharge() { return resourceResponseWrapper.getRequestCharge(); } @@ -75,7 +75,7 @@ public double requestCharge() { * * @return the status code. */ - public int statusCode() { + public int getStatusCode() { return resourceResponseWrapper.getStatusCode(); } @@ -84,7 +84,7 @@ public int statusCode() { * * @return the session token. */ - public String sessionToken(){ + public String getSessionToken(){ return resourceResponseWrapper.getSessionToken(); } @@ -93,7 +93,7 @@ public String sessionToken(){ * * @return the response headers. */ - public Map responseHeaders() { + public Map getResponseHeaders() { return resourceResponseWrapper.getResponseHeaders(); } @@ -102,7 +102,7 @@ public Map responseHeaders() { * * @return diagnostics information for the current request to Azure Cosmos DB service. */ - public CosmosResponseDiagnostics cosmosResponseDiagnosticsString() { + public CosmosResponseDiagnostics getCosmosResponseDiagnosticsString() { return resourceResponseWrapper.getCosmosResponseDiagnostics(); } @@ -111,7 +111,7 @@ public CosmosResponseDiagnostics cosmosResponseDiagnosticsString() { * * @return end-to-end request latency for the current request to Azure Cosmos DB service. */ - public Duration requestLatency() { + public Duration getRequestLatency() { return resourceResponseWrapper.getRequestLatency(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java index 3d7268eef5bb..cae7015a4bd4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java @@ -37,7 +37,7 @@ public String toString() { * Retrieves latency related to the completion of the request * @return request completion latency */ - public Duration requestLatency() { + public Duration getRequestLatency() { return this.clientSideRequestStatistics.getRequestLatency(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncScripts.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java similarity index 69% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncScripts.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java index 7d4fafff6faf..9afc676ab7b1 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncScripts.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosScripts.java @@ -1,21 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosScripts; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.CosmosStoredProcedureResponse; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.CosmosTriggerResponse; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; -import com.azure.data.cosmos.CosmosUserDefinedFunctionResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import reactor.core.Exceptions; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -25,9 +12,9 @@ /** * The type Cosmos sync scripts. */ -public class CosmosSyncScripts { - private final CosmosSyncContainer container; - private final CosmosScripts asyncScripts; +public class CosmosScripts { + private final CosmosContainer container; + private final CosmosAsyncScripts asyncScripts; /** * Instantiates a new Cosmos sync scripts. @@ -35,11 +22,11 @@ public class CosmosSyncScripts { * @param container the container * @param asyncScripts the async scripts */ - CosmosSyncScripts(CosmosSyncContainer container, CosmosScripts asyncScripts) { + CosmosScripts(CosmosContainer container, CosmosAsyncScripts asyncScripts) { this.container = container; this.asyncScripts = asyncScripts; } - /* CosmosStoredProcedure operations */ + /* CosmosAsyncStoredProcedure operations */ /** * Create stored procedure @@ -48,7 +35,7 @@ public class CosmosSyncScripts { * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse createStoredProcedure(CosmosStoredProcedureProperties properties) + public CosmosStoredProcedureResponse createStoredProcedure(CosmosStoredProcedureProperties properties) throws CosmosClientException { return mapStoredProcedureResponseAndBlock(asyncScripts.createStoredProcedure(properties, new CosmosStoredProcedureRequestOptions())); @@ -62,8 +49,8 @@ public CosmosSyncStoredProcedureResponse createStoredProcedure(CosmosStoredProce * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse createStoredProcedure(CosmosStoredProcedureProperties properties, - CosmosStoredProcedureRequestOptions options) throws CosmosClientException { + public CosmosStoredProcedureResponse createStoredProcedure(CosmosStoredProcedureProperties properties, + CosmosStoredProcedureRequestOptions options) throws CosmosClientException { return mapStoredProcedureResponseAndBlock(asyncScripts.createStoredProcedure(properties, options)); } @@ -109,8 +96,8 @@ public Iterator> queryStoredProced * @param id the id * @return the stored procedure */ - public CosmosSyncStoredProcedure getStoredProcedure(String id) { - return new CosmosSyncStoredProcedure(id, + public CosmosStoredProcedure getStoredProcedure(String id) { + return new CosmosStoredProcedure(id, this.container, asyncScripts.getStoredProcedure(id)); } @@ -125,7 +112,7 @@ public CosmosSyncStoredProcedure getStoredProcedure(String id) { * @return the cosmos sync user defined function response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserDefinedFunctionResponse createUserDefinedFunction(CosmosUserDefinedFunctionProperties properties) throws CosmosClientException { + public CosmosUserDefinedFunctionResponse createUserDefinedFunction(CosmosUserDefinedFunctionProperties properties) throws CosmosClientException { return mapUDFResponseAndBlock(asyncScripts.createUserDefinedFunction(properties)); } @@ -169,8 +156,8 @@ public Iterator> queryUserDefi * @param id the id * @return the user defined function */ - public CosmosSyncUserDefinedFunction getUserDefinedFunction(String id) { - return new CosmosSyncUserDefinedFunction(id, + public CosmosUserDefinedFunction getUserDefinedFunction(String id) { + return new CosmosUserDefinedFunction(id, this.container, asyncScripts.getUserDefinedFunction(id)); } @@ -183,7 +170,7 @@ public CosmosSyncUserDefinedFunction getUserDefinedFunction(String id) { * @throws CosmosClientException the cosmos client exception */ /* Trigger Operations */ - public CosmosSyncTriggerResponse createTrigger(CosmosTriggerProperties properties) throws CosmosClientException { + public CosmosTriggerResponse createTrigger(CosmosTriggerProperties properties) throws CosmosClientException { return mapTriggerResponseAndBlock(asyncScripts.createTrigger(properties)); } @@ -226,8 +213,8 @@ public Iterator> queryTriggers(SqlQuerySpe * @param id the id * @return the trigger */ - public CosmosSyncTrigger getTrigger(String id) { - return new CosmosSyncTrigger(id, + public CosmosTrigger getTrigger(String id) { + return new CosmosTrigger(id, this.container, asyncScripts.getTrigger(id)); } @@ -239,7 +226,7 @@ public CosmosSyncTrigger getTrigger(String id) { * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - CosmosSyncStoredProcedureResponse mapStoredProcedureResponseAndBlock(Mono storedProcedureResponseMono) + CosmosStoredProcedureResponse mapStoredProcedureResponseAndBlock(Mono storedProcedureResponseMono) throws CosmosClientException { try { return storedProcedureResponseMono @@ -255,47 +242,14 @@ CosmosSyncStoredProcedureResponse mapStoredProcedureResponseAndBlock(Mono responseMono) - throws CosmosClientException { - try { - return responseMono - .map(this::convertDeleteResponse) - .block(); - } catch (Exception ex) { - final Throwable throwable = Exceptions.unwrap(ex); - if (throwable instanceof CosmosClientException) { - throw (CosmosClientException) throwable; - } else { - throw ex; - } - } - } - - /** - * Convert delete response cosmos sync response. - * - * @param response the response - * @return the cosmos sync response - */ - CosmosSyncResponse convertDeleteResponse(CosmosResponse response) { - return new CosmosSyncResponse(response); - } - /** * Convert response cosmos sync stored procedure response. * * @param response the response * @return the cosmos sync stored procedure response */ - CosmosSyncStoredProcedureResponse convertResponse(CosmosStoredProcedureResponse response) { - return new CosmosSyncStoredProcedureResponse(response, getStoredProcedure(response.storedProcedure().id())); + CosmosStoredProcedureResponse convertResponse(CosmosAsyncStoredProcedureResponse response) { + return new CosmosStoredProcedureResponse(response, getStoredProcedure(response.getStoredProcedure().id())); } /** @@ -305,7 +259,7 @@ CosmosSyncStoredProcedureResponse convertResponse(CosmosStoredProcedureResponse * @return the cosmos sync user defined function response * @throws CosmosClientException the cosmos client exception */ - CosmosSyncUserDefinedFunctionResponse mapUDFResponseAndBlock(Mono responseMono) + CosmosUserDefinedFunctionResponse mapUDFResponseAndBlock(Mono responseMono) throws CosmosClientException { try { return responseMono @@ -327,9 +281,9 @@ CosmosSyncUserDefinedFunctionResponse mapUDFResponseAndBlock(Mono responseMono) + CosmosTriggerResponse mapTriggerResponseAndBlock(Mono responseMono) throws CosmosClientException { try { return responseMono @@ -363,9 +317,9 @@ CosmosSyncTriggerResponse mapTriggerResponseAndBlock(Mono * @param response the response * @return the cosmos sync trigger response */ - CosmosSyncTriggerResponse convertResponse(CosmosTriggerResponse response) { - return new CosmosSyncTriggerResponse(response, - getTrigger(response.trigger().id())); + CosmosTriggerResponse convertResponse(CosmosAsyncTriggerResponse response) { + return new CosmosTriggerResponse(response, + getTrigger(response.getTrigger().getId())); } private Iterator> getFeedIterator(Flux> itemFlux) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedure.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java similarity index 64% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedure.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java index a6a16a518bc8..9aa57b3366e0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedure.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedure.java @@ -1,20 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosStoredProcedure; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; +package com.azure.data.cosmos; /** * The type Cosmos sync stored procedure. */ -public class CosmosSyncStoredProcedure { +public class CosmosStoredProcedure { private final String id; - private final CosmosSyncContainer container; - private final CosmosStoredProcedure storedProcedure; + private final CosmosContainer container; + private final CosmosAsyncStoredProcedure storedProcedure; /** * Instantiates a new Cosmos sync stored procedure. @@ -23,7 +18,7 @@ public class CosmosSyncStoredProcedure { * @param container the container * @param storedProcedure the stored procedure */ - public CosmosSyncStoredProcedure(String id, CosmosSyncContainer container, CosmosStoredProcedure storedProcedure) { + public CosmosStoredProcedure(String id, CosmosContainer container, CosmosAsyncStoredProcedure storedProcedure) { this.id = id; this.container = container; @@ -35,7 +30,7 @@ public CosmosSyncStoredProcedure(String id, CosmosSyncContainer container, Cosmo * * @return the string */ - public String id() { + public String getId() { return id; } @@ -45,7 +40,7 @@ public String id() { * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse read() throws CosmosClientException { + public CosmosStoredProcedureResponse read() throws CosmosClientException { return container.getScripts() .mapStoredProcedureResponseAndBlock(storedProcedure.read()); } @@ -57,7 +52,7 @@ public CosmosSyncStoredProcedureResponse read() throws CosmosClientException { * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse read(CosmosStoredProcedureRequestOptions options) throws CosmosClientException { + public CosmosStoredProcedureResponse read(CosmosStoredProcedureRequestOptions options) throws CosmosClientException { return container.getScripts() .mapStoredProcedureResponseAndBlock(storedProcedure.read(options)); } @@ -68,9 +63,9 @@ public CosmosSyncStoredProcedureResponse read(CosmosStoredProcedureRequestOption * @return the cosmos sync response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncResponse delete() throws CosmosClientException { + public CosmosStoredProcedureResponse delete() throws CosmosClientException { return container.getScripts() - .mapDeleteResponseAndBlock(storedProcedure.delete()); + .mapStoredProcedureResponseAndBlock(storedProcedure.delete()); } /** @@ -80,9 +75,9 @@ public CosmosSyncResponse delete() throws CosmosClientException { * @return the cosmos sync response * @throws CosmosClientException the cosmos client exception */ - CosmosSyncResponse delete(CosmosStoredProcedureRequestOptions options) throws CosmosClientException { + CosmosStoredProcedureResponse delete(CosmosStoredProcedureRequestOptions options) throws CosmosClientException { return container.getScripts() - .mapDeleteResponseAndBlock(storedProcedure.delete(options)); + .mapStoredProcedureResponseAndBlock(storedProcedure.delete(options)); } /** @@ -93,8 +88,8 @@ CosmosSyncResponse delete(CosmosStoredProcedureRequestOptions options) throws Co * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse execute(Object[] procedureParams, - CosmosStoredProcedureRequestOptions options) throws CosmosClientException { + public CosmosStoredProcedureResponse execute(Object[] procedureParams, + CosmosStoredProcedureRequestOptions options) throws CosmosClientException { return container.getScripts() .mapStoredProcedureResponseAndBlock(storedProcedure.execute(procedureParams, options)); } @@ -106,7 +101,7 @@ public CosmosSyncStoredProcedureResponse execute(Object[] procedureParams, * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse replace(CosmosStoredProcedureProperties storedProcedureSettings) + public CosmosStoredProcedureResponse replace(CosmosStoredProcedureProperties storedProcedureSettings) throws CosmosClientException { return container.getScripts() .mapStoredProcedureResponseAndBlock(storedProcedure.replace(storedProcedureSettings)); @@ -120,8 +115,8 @@ public CosmosSyncStoredProcedureResponse replace(CosmosStoredProcedureProperties * @return the cosmos sync stored procedure response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncStoredProcedureResponse replace(CosmosStoredProcedureProperties storedProcedureSettings, - CosmosStoredProcedureRequestOptions options) throws CosmosClientException { + public CosmosStoredProcedureResponse replace(CosmosStoredProcedureProperties storedProcedureSettings, + CosmosStoredProcedureRequestOptions options) throws CosmosClientException { return container.getScripts() .mapStoredProcedureResponseAndBlock(storedProcedure.replace(storedProcedureSettings, options)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java index 49a0f0533c03..1ad49015c1f4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureProperties.java @@ -24,8 +24,8 @@ public CosmosStoredProcedureProperties() { * @param id the name of the resource. * @return return the Cosmos stored procedure properties with id set */ - public CosmosStoredProcedureProperties id(String id){ - super.id(id); + public CosmosStoredProcedureProperties setId(String id){ + super.setId(id); return this; } @@ -46,8 +46,8 @@ public CosmosStoredProcedureProperties id(String id){ */ public CosmosStoredProcedureProperties(String id, String body) { super(); - super.id(id); - this.body(body); + super.setId(id); + this.setBody(body); } CosmosStoredProcedureProperties(ResourceResponse response) { @@ -59,7 +59,7 @@ public CosmosStoredProcedureProperties(String id, String body) { * * @return the body of the stored procedure. */ - public String body() { + public String getBody() { return super.getString(Constants.Properties.BODY); } @@ -68,7 +68,7 @@ public String body() { * * @param body the body of the stored procedure. */ - public void body(String body) { + public void setBody(String body) { super.set(Constants.Properties.BODY, body); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java index 5710749adc63..e23bcff76e31 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureRequestOptions.java @@ -18,7 +18,7 @@ public class CosmosStoredProcedureRequestOptions { * * @return the access condition. */ - public AccessCondition accessCondition() { + public AccessCondition getAccessCondition() { return accessCondition; } @@ -28,7 +28,7 @@ public AccessCondition accessCondition() { * @param accessCondition the access condition. * @return the current request options */ - public CosmosStoredProcedureRequestOptions accessCondition(AccessCondition accessCondition) { + public CosmosStoredProcedureRequestOptions setAccessCondition(AccessCondition accessCondition) { this.accessCondition = accessCondition; return this; } @@ -37,7 +37,7 @@ public CosmosStoredProcedureRequestOptions accessCondition(AccessCondition acces * * @return the consistency level. */ - public ConsistencyLevel consistencyLevel() { + public ConsistencyLevel getConsistencyLevel() { return consistencyLevel; } @@ -47,7 +47,7 @@ public ConsistencyLevel consistencyLevel() { * @param consistencyLevel the consistency level. * @return the CosmosStoredProcedureRequestOptions. */ - public CosmosStoredProcedureRequestOptions consistencyLevel(ConsistencyLevel consistencyLevel) { + public CosmosStoredProcedureRequestOptions setConsistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; return this; } @@ -57,7 +57,7 @@ public CosmosStoredProcedureRequestOptions consistencyLevel(ConsistencyLevel con * * @return the partition key value. */ - public PartitionKey partitionKey() { + public PartitionKey getPartitionKey() { return partitionKey; } @@ -67,7 +67,7 @@ public PartitionKey partitionKey() { * @param partitionKey the partition key value. * @return the CosmosStoredProcedureRequestOptions. */ - public CosmosStoredProcedureRequestOptions partitionKey(PartitionKey partitionKey) { + public CosmosStoredProcedureRequestOptions setPartitionKey(PartitionKey partitionKey) { this.partitionKey = partitionKey; return this; } @@ -77,7 +77,7 @@ public CosmosStoredProcedureRequestOptions partitionKey(PartitionKey partitionKe * * @return the session token. */ - public String sessionToken() { + public String getSessionToken() { return sessionToken; } @@ -87,7 +87,7 @@ public String sessionToken() { * @param sessionToken the session token. * @return the CosmosStoredProcedureRequestOptions. */ - public CosmosStoredProcedureRequestOptions sessionToken(String sessionToken) { + public CosmosStoredProcedureRequestOptions setSessionToken(String sessionToken) { this.sessionToken = sessionToken; return this; } @@ -95,7 +95,7 @@ public CosmosStoredProcedureRequestOptions sessionToken(String sessionToken) { RequestOptions toRequestOptions() { RequestOptions requestOptions = new RequestOptions(); requestOptions.setAccessCondition(accessCondition); - requestOptions.setConsistencyLevel(consistencyLevel()); + requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setPartitionKey(partitionKey); requestOptions.setSessionToken(sessionToken); return requestOptions; diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java new file mode 100644 index 000000000000..d694b83e6481 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosStoredProcedureResponse.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.data.cosmos; + + +/** + * The type Cosmos sync stored procedure response. + */ +public class CosmosStoredProcedureResponse extends CosmosResponse { + private final CosmosStoredProcedure cosmosStoredProcedure; + private final CosmosAsyncStoredProcedureResponse asyncResponse; + + /** + * Instantiates a new Cosmos sync stored procedure response. + * + * @param resourceResponse the resource response + * @param storedProcedure the stored procedure + */ + CosmosStoredProcedureResponse(CosmosAsyncStoredProcedureResponse resourceResponse, + CosmosStoredProcedure storedProcedure) { + super(resourceResponse.getProperties()); + this.asyncResponse = resourceResponse; + this.cosmosStoredProcedure = storedProcedure; + } + + /** + * Gets cosmos stored procedure properties. + * + * @return the cosmos stored procedure properties + */ + public CosmosStoredProcedureProperties getProperties() { + return asyncResponse.getProperties(); + } + + /** + * Gets cosmos sync stored procedure. + * + * @return the cosmos sync stored procedure + */ + public CosmosStoredProcedure getStoredProcedure() { + return cosmosStoredProcedure; + } + + @Override + public String getActivityId() { + return asyncResponse.getActivityId(); + } + + @Override + public String getSessionToken() { + return asyncResponse.getSessionToken(); + } + + @Override + public int getStatusCode() { + return asyncResponse.getStatusCode(); + } + + @Override + public double getRequestCharge() { + return asyncResponse.getRequestCharge(); + } + + /** + * Response as string string. + * + * @return the string + */ + public String responseAsString() { + return asyncResponse.getResponseAsString(); + } + + /** + * Script log string. + * + * @return the string + */ + public String scriptLog() { + return asyncResponse.getScriptLog(); + } + + +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTrigger.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTrigger.java similarity index 61% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTrigger.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTrigger.java index 01ee1f975ce5..bca385756101 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTrigger.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTrigger.java @@ -1,19 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosTrigger; -import com.azure.data.cosmos.CosmosTriggerProperties; +package com.azure.data.cosmos; /** * The type Cosmos sync trigger. */ -public class CosmosSyncTrigger { +public class CosmosTrigger { private final String id; - private final CosmosSyncContainer container; - private final CosmosTrigger trigger; + private final CosmosContainer container; + private final CosmosAsyncTrigger trigger; /** * Instantiates a new Cosmos sync trigger. @@ -22,18 +18,18 @@ public class CosmosSyncTrigger { * @param container the container * @param trigger the trigger */ - CosmosSyncTrigger(String id, CosmosSyncContainer container, CosmosTrigger trigger) { + CosmosTrigger(String id, CosmosContainer container, CosmosAsyncTrigger trigger) { this.id = id; this.container = container; this.trigger = trigger; } /** - * Gets id. + * Gets getId. * * @return the string */ - public String id() { + public String getId() { return id; } @@ -43,7 +39,7 @@ public String id() { * @return the cosmos sync trigger response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncTriggerResponse read() throws CosmosClientException { + public CosmosTriggerResponse read() throws CosmosClientException { return container.getScripts().mapTriggerResponseAndBlock(trigger.read()); } @@ -54,7 +50,7 @@ public CosmosSyncTriggerResponse read() throws CosmosClientException { * @return the cosmos sync trigger response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncTriggerResponse replace(CosmosTriggerProperties triggerSettings) throws CosmosClientException { + public CosmosTriggerResponse replace(CosmosTriggerProperties triggerSettings) throws CosmosClientException { return container.getScripts().mapTriggerResponseAndBlock(trigger.replace(triggerSettings)); } @@ -64,8 +60,8 @@ public CosmosSyncTriggerResponse replace(CosmosTriggerProperties triggerSettings * @return the cosmos sync response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncResponse delete() throws CosmosClientException { - return container.getScripts().mapDeleteResponseAndBlock(trigger.delete()); + public CosmosTriggerResponse delete() throws CosmosClientException { + return container.getScripts().mapTriggerResponseAndBlock(trigger.delete()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java index ef9ce947c090..32a7322f8c33 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerProperties.java @@ -38,8 +38,8 @@ public CosmosTriggerProperties(){ * @param id the name of the resource. * @return the current cosmos trigger properties instance */ - public CosmosTriggerProperties id(String id) { - super.id(id); + public CosmosTriggerProperties setId(String id) { + super.setId(id); return this; } @@ -48,7 +48,7 @@ public CosmosTriggerProperties id(String id) { * * @return the body of the trigger. */ - public String body() { + public String getBody() { return super.getString(Constants.Properties.BODY); } @@ -58,7 +58,7 @@ public String body() { * @param body the body of the trigger. * @return the CosmosTriggerProperties. */ - public CosmosTriggerProperties body(String body) { + public CosmosTriggerProperties setBody(String body) { super.set(Constants.Properties.BODY, body); return this; } @@ -68,7 +68,7 @@ public CosmosTriggerProperties body(String body) { * * @return the trigger type. */ - public TriggerType triggerType() { + public TriggerType getTriggerType() { TriggerType result = TriggerType.PRE; try { result = TriggerType.valueOf( @@ -86,7 +86,7 @@ public TriggerType triggerType() { * @param triggerType the trigger type. * @return the CosmosTriggerProperties. */ - public CosmosTriggerProperties triggerType(TriggerType triggerType) { + public CosmosTriggerProperties setTriggerType(TriggerType triggerType) { super.set(Constants.Properties.TRIGGER_TYPE, triggerType.toString()); return this; } @@ -96,7 +96,7 @@ public CosmosTriggerProperties triggerType(TriggerType triggerType) { * * @return the trigger operation. */ - public TriggerOperation triggerOperation() { + public TriggerOperation getTriggerOperation() { TriggerOperation result = TriggerOperation.CREATE; try { result = TriggerOperation.valueOf( @@ -114,7 +114,7 @@ public TriggerOperation triggerOperation() { * @param triggerOperation the trigger operation. * @return the CosmosTriggerProperties. */ - public CosmosTriggerProperties triggerOperation(TriggerOperation triggerOperation) { + public CosmosTriggerProperties setTriggerOperation(TriggerOperation triggerOperation) { super.set(Constants.Properties.TRIGGER_OPERATION, triggerOperation.toString()); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTriggerResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java similarity index 51% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTriggerResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java index 7b4756a196ab..4b56edfaf9ad 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncTriggerResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosTriggerResponse.java @@ -1,18 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.CosmosTriggerResponse; +package com.azure.data.cosmos; /** * The type Cosmos sync trigger response. */ -public class CosmosSyncTriggerResponse extends CosmosSyncResponse { +public class CosmosTriggerResponse extends CosmosResponse { - private final CosmosSyncTrigger syncTrigger; - private final CosmosTriggerResponse asyncResponse; + private final CosmosTrigger syncTrigger; + private final CosmosAsyncTriggerResponse asyncResponse; /** * Instantiates a new Cosmos sync trigger response. @@ -20,9 +17,9 @@ public class CosmosSyncTriggerResponse extends CosmosSyncResponse { * @param asyncResponse the async response * @param syncTrigger the sync trigger */ - CosmosSyncTriggerResponse(CosmosTriggerResponse asyncResponse, - CosmosSyncTrigger syncTrigger) { - super(asyncResponse); + CosmosTriggerResponse(CosmosAsyncTriggerResponse asyncResponse, + CosmosTrigger syncTrigger) { + super(asyncResponse.getProperties()); this.asyncResponse = asyncResponse; this.syncTrigger = syncTrigger; } @@ -32,8 +29,8 @@ public class CosmosSyncTriggerResponse extends CosmosSyncResponse { * * @return the cosmos trigger properties */ - public CosmosTriggerProperties properties() { - return asyncResponse.properties(); + public CosmosTriggerProperties getProperties() { + return asyncResponse.getProperties(); } /** @@ -41,7 +38,7 @@ public CosmosTriggerProperties properties() { * * @return the cosmos sync trigger */ - public CosmosSyncTrigger trigger() { + public CosmosTrigger getTrigger() { return syncTrigger; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUser.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUser.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUser.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUser.java index 393df1fa6270..112b22093173 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUser.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUser.java @@ -1,18 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosUser; -import com.azure.data.cosmos.CosmosUserProperties; +package com.azure.data.cosmos; /** * The type Cosmos sync user. */ -public class CosmosSyncUser { - private final CosmosUser asyncUser; - private final CosmosSyncDatabase database; +public class CosmosUser { + private final CosmosAsyncUser asyncUser; + private final CosmosDatabase database; private final String id; /** @@ -22,7 +18,7 @@ public class CosmosSyncUser { * @param database the database * @param id the id */ - CosmosSyncUser(CosmosUser asyncUser, CosmosSyncDatabase database, String id) { + CosmosUser(CosmosAsyncUser asyncUser, CosmosDatabase database, String id) { this.asyncUser = asyncUser; this.database = database; this.id = id; @@ -33,7 +29,7 @@ public class CosmosSyncUser { * * @return the string */ - public String id() { + public String getId() { return id; } @@ -43,7 +39,7 @@ public String id() { * @return the cosmos sync user response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserResponse read() throws CosmosClientException { + public CosmosUserResponse read() throws CosmosClientException { return database.mapUserResponseAndBlock(asyncUser.read()); } @@ -54,7 +50,7 @@ public CosmosSyncUserResponse read() throws CosmosClientException { * @return the cosmos sync user response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserResponse replace(CosmosUserProperties userProperties) throws CosmosClientException { + public CosmosUserResponse replace(CosmosUserProperties userProperties) throws CosmosClientException { return database.mapUserResponseAndBlock(asyncUser.replace(userProperties)); } @@ -64,7 +60,7 @@ public CosmosSyncUserResponse replace(CosmosUserProperties userProperties) throw * @return the cosmos sync user response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserResponse delete() throws CosmosClientException { + public CosmosUserResponse delete() throws CosmosClientException { return database.mapUserResponseAndBlock(asyncUser.delete()); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunction.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java similarity index 62% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunction.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java index fbea2b3fcc5f..346980c853e9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunction.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunction.java @@ -1,19 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosUserDefinedFunction; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; +package com.azure.data.cosmos; /** * The type Cosmos sync user defined function. */ -public class CosmosSyncUserDefinedFunction { +public class CosmosUserDefinedFunction { private final String id; - private final CosmosSyncContainer container; - private final CosmosUserDefinedFunction userDefinedFunction; + private final CosmosContainer container; + private final CosmosAsyncUserDefinedFunction userDefinedFunction; /** * Instantiates a new Cosmos sync user defined function. @@ -22,7 +18,7 @@ public class CosmosSyncUserDefinedFunction { * @param container the container * @param userDefinedFunction the user defined function */ - CosmosSyncUserDefinedFunction(String id, CosmosSyncContainer container, CosmosUserDefinedFunction userDefinedFunction) { + CosmosUserDefinedFunction(String id, CosmosContainer container, CosmosAsyncUserDefinedFunction userDefinedFunction) { this.id = id; this.container = container; @@ -34,7 +30,7 @@ public class CosmosSyncUserDefinedFunction { * * @return the string */ - public String id() { + public String getId() { return id; } @@ -44,7 +40,7 @@ public String id() { * @return the cosmos sync user defined function response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserDefinedFunctionResponse read() throws CosmosClientException { + public CosmosUserDefinedFunctionResponse read() throws CosmosClientException { return container.getScripts().mapUDFResponseAndBlock(userDefinedFunction.read()); } @@ -55,7 +51,7 @@ public CosmosSyncUserDefinedFunctionResponse read() throws CosmosClientException * @return the cosmos sync user defined function response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncUserDefinedFunctionResponse replace(CosmosUserDefinedFunctionProperties udfSettings) + public CosmosUserDefinedFunctionResponse replace(CosmosUserDefinedFunctionProperties udfSettings) throws CosmosClientException { return container.getScripts().mapUDFResponseAndBlock(userDefinedFunction.replace(udfSettings)); } @@ -66,7 +62,7 @@ public CosmosSyncUserDefinedFunctionResponse replace(CosmosUserDefinedFunctionPr * @return the cosmos sync response * @throws CosmosClientException the cosmos client exception */ - public CosmosSyncResponse delete() throws CosmosClientException { - return container.getScripts().mapDeleteResponseAndBlock(userDefinedFunction.delete()); + public CosmosUserDefinedFunctionResponse delete() throws CosmosClientException { + return container.getScripts().mapUDFResponseAndBlock(userDefinedFunction.delete()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java index 577e2b163ade..d2b20d164721 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionProperties.java @@ -36,8 +36,8 @@ public CosmosUserDefinedFunctionProperties(){ * @param id the name of the resource. * @return the current instance of cosmos user defined function properties */ - public CosmosUserDefinedFunctionProperties id(String id) { - super.id(id); + public CosmosUserDefinedFunctionProperties setId(String id) { + super.setId(id); return this; } @@ -46,7 +46,7 @@ public CosmosUserDefinedFunctionProperties id(String id) { * * @return the body. */ - public String body() { + public String getBody() { return super.getString(Constants.Properties.BODY); } @@ -56,7 +56,7 @@ public String body() { * @param body the body. * @return the CosmosUserDefinedFunctionProperties. */ - public CosmosUserDefinedFunctionProperties body(String body) { + public CosmosUserDefinedFunctionProperties setBody(String body) { super.set(Constants.Properties.BODY, body); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunctionResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java similarity index 50% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunctionResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java index b9c6f728fc8e..bb8009b4f3a6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserDefinedFunctionResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java @@ -1,18 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; -import com.azure.data.cosmos.CosmosUserDefinedFunctionResponse; +package com.azure.data.cosmos; /** * The type Cosmos sync user defined function response. */ -public class CosmosSyncUserDefinedFunctionResponse extends CosmosSyncResponse { +public class CosmosUserDefinedFunctionResponse extends CosmosResponse { - private final CosmosSyncUserDefinedFunction userDefinedFunction; - private CosmosUserDefinedFunctionResponse asyncResponse; + private final CosmosUserDefinedFunction userDefinedFunction; + private CosmosAsyncUserDefinedFunctionResponse asyncResponse; /** * Instantiates a new Cosmos sync user defined function response. @@ -20,9 +17,9 @@ public class CosmosSyncUserDefinedFunctionResponse extends CosmosSyncResponse { * @param resourceResponse the resource response * @param userDefinedFunction the user defined function */ - CosmosSyncUserDefinedFunctionResponse(CosmosUserDefinedFunctionResponse resourceResponse, - CosmosSyncUserDefinedFunction userDefinedFunction) { - super(resourceResponse); + CosmosUserDefinedFunctionResponse(CosmosAsyncUserDefinedFunctionResponse resourceResponse, + CosmosUserDefinedFunction userDefinedFunction) { + super(resourceResponse.getProperties()); this.asyncResponse = resourceResponse; this.userDefinedFunction = userDefinedFunction; } @@ -32,8 +29,8 @@ public class CosmosSyncUserDefinedFunctionResponse extends CosmosSyncResponse { * * @return the cosmos user defined function properties */ - public CosmosUserDefinedFunctionProperties properties() { - return asyncResponse.properties(); + public CosmosUserDefinedFunctionProperties getProperties() { + return asyncResponse.getProperties(); } /** @@ -41,7 +38,7 @@ public CosmosUserDefinedFunctionProperties properties() { * * @return the cosmos sync user defined function */ - public CosmosSyncUserDefinedFunction userDefinedFunction() { + public CosmosUserDefinedFunction getUserDefinedFunction() { return userDefinedFunction; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java index f0da50e952d7..84da36231a27 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserProperties.java @@ -22,8 +22,8 @@ public CosmosUserProperties() { * Gets the id * @return the id of the user */ - public String id() { - return super.id(); + public String getId() { + return super.getId(); } /** @@ -31,8 +31,8 @@ public String id() { * @param id the name of the resource. * @return the current instance of cosmos user properties */ - public CosmosUserProperties id(String id) { - return (CosmosUserProperties) super.id(id); + public CosmosUserProperties setId(String id) { + return (CosmosUserProperties) super.setId(id); } /** @@ -59,7 +59,7 @@ public CosmosUserProperties id(String id) { * @return the permissions link. */ String getPermissionsLink() { - String selfLink = this.selfLink(); + String selfLink = this.getSelfLink(); if (selfLink.endsWith("/")) { return selfLink + super.getString(Constants.Properties.PERMISSIONS_LINK); } else { @@ -74,4 +74,4 @@ public User getV2User() { static List getFromV2Results(List results) { return results.stream().map(CosmosUserProperties::new).collect(Collectors.toList()); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java similarity index 50% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java index 4d9e3c701db5..741b75a99de0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncUserResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java @@ -1,17 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.CosmosUserResponse; +package com.azure.data.cosmos; /** * The type Cosmos sync user response. */ -public class CosmosSyncUserResponse extends CosmosSyncResponse { - private final CosmosUserResponse asyncResponse; - private final CosmosSyncUser user; +public class CosmosUserResponse extends CosmosResponse { + private final CosmosAsyncUserResponse asyncResponse; + private final CosmosUser user; /** * Instantiates a new Cosmos sync user response. @@ -19,11 +16,11 @@ public class CosmosSyncUserResponse extends CosmosSyncResponse { * @param response the response * @param database the database */ - CosmosSyncUserResponse(CosmosUserResponse response, CosmosSyncDatabase database) { - super(response); + CosmosUserResponse(CosmosAsyncUserResponse response, CosmosDatabase database) { + super(response.getProperties()); this.asyncResponse = response; - if (response.user() != null) { - this.user = new CosmosSyncUser(response.user(), database, response.user().id()); + if (response.getUser() != null) { + this.user = new CosmosUser(response.getUser(), database, response.getUser().getId()); } else { // delete has null user client this.user = null; @@ -35,7 +32,7 @@ public class CosmosSyncUserResponse extends CosmosSyncResponse { * * @return the cosmos sync user */ - public CosmosSyncUser user() { + public CosmosUser getUser() { return this.user; } @@ -44,7 +41,7 @@ public CosmosSyncUser user() { * * @return the cosmos user properties */ - public CosmosUserProperties properties() { - return asyncResponse.properties(); + public CosmosUserProperties getProperties() { + return asyncResponse.getProperties(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DataType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DataType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DataType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DataType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java index 92f4d3628031..0924591140da 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccount.java @@ -214,7 +214,7 @@ Map getQueryEngineConfiguration() { * * @return the list of writable locations. */ - public Iterable writableLocations() { + public Iterable getWritableLocations() { return super.getCollection(Constants.Properties.WRITABLE_LOCATIONS, DatabaseAccountLocation.class); } @@ -234,7 +234,7 @@ void setWritableLocations(Iterable locations) { * * @return the list of readable locations. */ - public Iterable readableLocations() { + public Iterable getReadableLocations() { return super.getCollection(Constants.Properties.READABLE_LOCATIONS, DatabaseAccountLocation.class); } @@ -249,7 +249,7 @@ void setReadableLocations(Iterable locations) { setProperty(this, Constants.Properties.READABLE_LOCATIONS, locations); } - public boolean enableMultipleWriteLocations() { + public boolean getEnableMultipleWriteLocations() { return ObjectUtils.defaultIfNull(super.getBoolean(Constants.Properties.ENABLE_MULTIPLE_WRITE_LOCATIONS), false); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java index 449af8cb538f..64b13f8d6da6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/DatabaseAccountLocation.java @@ -36,7 +36,7 @@ public DatabaseAccountLocation(String jsonString) { * * @return the name of the database account location. */ - public String name() { + public String getName() { return super.getString(Constants.Properties.Name); } @@ -54,7 +54,7 @@ void setName(String name) { * * @return the endpoint of the database account location. */ - public String endpoint() { + public String getEndpoint() { return super.getString(Constants.Properties.DATABASE_ACCOUNT_ENDPOINT); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java index 4f45e3fd9c8f..c81791593c31 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ExcludedPath.java @@ -31,7 +31,7 @@ public ExcludedPath() { * * @return the path. */ - public String path() { + public String getPath() { return super.getString(Constants.Properties.PATH); } @@ -41,7 +41,7 @@ public String path() { * @param path the path. * @return the Exculded path. */ - public ExcludedPath path(String path) { + public ExcludedPath setPath(String path) { super.set(Constants.Properties.PATH, path); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java index 56ea0eb15cb8..b215a6722a10 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedOptions.java @@ -47,7 +47,7 @@ public FeedOptions(FeedOptions options) { * * @return the partitionKeyRangeId. */ - String partitionKeyRangeIdInternal() { + String getPartitionKeyRangeIdInternal() { return this.partitionKeyRangeId; } @@ -57,7 +57,7 @@ String partitionKeyRangeIdInternal() { * @param partitionKeyRangeId the partitionKeyRangeId. * @return the FeedOptions. */ - FeedOptions partitionKeyRangeIdInternal(String partitionKeyRangeId) { + FeedOptions setPartitionKeyRangeIdInternal(String partitionKeyRangeId) { this.partitionKeyRangeId = partitionKeyRangeId; return this; } @@ -67,7 +67,7 @@ FeedOptions partitionKeyRangeIdInternal(String partitionKeyRangeId) { * * @return the session token. */ - public String sessionToken() { + public String getSessionToken() { return this.sessionToken; } @@ -77,7 +77,7 @@ public String sessionToken() { * @param sessionToken the session token. * @return the FeedOptions. */ - public FeedOptions sessionToken(String sessionToken) { + public FeedOptions setSessionToken(String sessionToken) { this.sessionToken = sessionToken; return this; } @@ -88,7 +88,7 @@ public FeedOptions sessionToken(String sessionToken) { * * @return the option of enable scan in query. */ - public Boolean enableScanInQuery() { + public Boolean getEnableScanInQuery() { return this.enableScanInQuery; } @@ -99,7 +99,7 @@ public Boolean enableScanInQuery() { * @param enableScanInQuery the option of enable scan in query. * @return the FeedOptions. */ - public FeedOptions enableScanInQuery(Boolean enableScanInQuery) { + public FeedOptions setEnableScanInQuery(Boolean enableScanInQuery) { this.enableScanInQuery = enableScanInQuery; return this; } @@ -110,7 +110,7 @@ public FeedOptions enableScanInQuery(Boolean enableScanInQuery) { * * @return the emit verbose traces in query. */ - public Boolean emitVerboseTracesInQuery() { + public Boolean getEmitVerboseTracesInQuery() { return this.emitVerboseTracesInQuery; } @@ -121,7 +121,7 @@ public Boolean emitVerboseTracesInQuery() { * @param emitVerboseTracesInQuery the emit verbose traces in query. * @return the FeedOptions. */ - public FeedOptions emitVerboseTracesInQuery(Boolean emitVerboseTracesInQuery) { + public FeedOptions setEmitVerboseTracesInQuery(Boolean emitVerboseTracesInQuery) { this.emitVerboseTracesInQuery = emitVerboseTracesInQuery; return this; } @@ -133,7 +133,7 @@ public FeedOptions emitVerboseTracesInQuery(Boolean emitVerboseTracesInQuery) { * @return whether to allow queries to run across all partitions of the * collection. */ - public Boolean enableCrossPartitionQuery() { + public Boolean getEnableCrossPartitionQuery() { return this.enableCrossPartitionQuery; } @@ -145,7 +145,7 @@ public Boolean enableCrossPartitionQuery() { * partitions of the collection. * @return the FeedOptions. */ - public FeedOptions enableCrossPartitionQuery(Boolean enableCrossPartitionQuery) { + public FeedOptions setEnableCrossPartitionQuery(Boolean enableCrossPartitionQuery) { this.enableCrossPartitionQuery = enableCrossPartitionQuery; return this; } @@ -157,7 +157,7 @@ public FeedOptions enableCrossPartitionQuery(Boolean enableCrossPartitionQuery) * @return number of concurrent operations run client side during parallel query * execution. */ - public int maxDegreeOfParallelism() { + public int getMaxDegreeOfParallelism() { return maxDegreeOfParallelism; } @@ -168,7 +168,7 @@ public int maxDegreeOfParallelism() { * @param maxDegreeOfParallelism number of concurrent operations. * @return the FeedOptions. */ - public FeedOptions maxDegreeOfParallelism(int maxDegreeOfParallelism) { + public FeedOptions setMaxDegreeOfParallelism(int maxDegreeOfParallelism) { this.maxDegreeOfParallelism = maxDegreeOfParallelism; return this; } @@ -180,7 +180,7 @@ public FeedOptions maxDegreeOfParallelism(int maxDegreeOfParallelism) { * @return maximum number of items that can be buffered client side during * parallel query execution. */ - public int maxBufferedItemCount() { + public int getMaxBufferedItemCount() { return maxBufferedItemCount; } @@ -191,7 +191,7 @@ public int maxBufferedItemCount() { * @param maxBufferedItemCount maximum number of items. * @return the FeedOptions. */ - public FeedOptions maxBufferedItemCount(int maxBufferedItemCount) { + public FeedOptions setMaxBufferedItemCount(int maxBufferedItemCount) { this.maxBufferedItemCount = maxBufferedItemCount; return this; } @@ -216,7 +216,7 @@ public FeedOptions maxBufferedItemCount(int maxBufferedItemCount) { * @param limitInKb continuation token size limit. * @return the FeedOptions. */ - public FeedOptions responseContinuationTokenLimitInKb(int limitInKb) { + public FeedOptions getResponseContinuationTokenLimitInKb(int limitInKb) { this.responseContinuationTokenLimitInKb = limitInKb; return this; } @@ -230,7 +230,7 @@ public FeedOptions responseContinuationTokenLimitInKb(int limitInKb) { * * @return return set ResponseContinuationTokenLimitInKb, or 0 if not set */ - public int responseContinuationTokenLimitInKb() { + public int setResponseContinuationTokenLimitInKb() { return responseContinuationTokenLimitInKb; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java index fb4ab994ce9f..dbab545b16ce 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponse.java @@ -62,7 +62,7 @@ private FeedResponse( * * @return the list of results. */ - public List results() { + public List getResults() { return results; } @@ -71,7 +71,7 @@ public List results() { * * @return The maximum quota for the account. */ - public long databaseQuota() { + public long getDatabaseQuota() { return this.maxQuotaHeader(Constants.Quota.DATABASE); } @@ -80,7 +80,7 @@ public long databaseQuota() { * * @return The current number of databases. */ - public long databaseUsage() { + public long getDatabaseUsage() { return this.currentQuotaHeader(Constants.Quota.DATABASE); } @@ -89,7 +89,7 @@ public long databaseUsage() { * * @return The maximum quota for the account. */ - public long collectionQuota() { + public long getCollectionQuota() { return this.maxQuotaHeader(Constants.Quota.COLLECTION); } @@ -98,7 +98,7 @@ public long collectionQuota() { * * @return The current number of collections. */ - public long collectionUsage() { + public long getCollectionUsage() { return this.currentQuotaHeader(Constants.Quota.COLLECTION); } @@ -107,7 +107,7 @@ public long collectionUsage() { * * @return The maximum quota for the account. */ - public long userQuota() { + public long getUserQuota() { return this.maxQuotaHeader(Constants.Quota.USER); } @@ -116,7 +116,7 @@ public long userQuota() { * * @return The current number of users. */ - public long userUsage() { + public long getUserUsage() { return this.currentQuotaHeader(Constants.Quota.USER); } @@ -125,7 +125,7 @@ public long userUsage() { * * @return The maximum quota for the account. */ - public long permissionQuota() { + public long getPermissionQuota() { return this.maxQuotaHeader(Constants.Quota.PERMISSION); } @@ -134,7 +134,7 @@ public long permissionQuota() { * * @return The current number of permissions. */ - public long permissionUsage() { + public long getPermissionUsage() { return this.currentQuotaHeader(Constants.Quota.PERMISSION); } @@ -143,7 +143,7 @@ public long permissionUsage() { * * @return The maximum quota in kilobytes. */ - public long collectionSizeQuota() { + public long getCollectionSizeQuota() { return this.maxQuotaHeader(Constants.Quota.COLLECTION_SIZE); } @@ -152,7 +152,7 @@ public long collectionSizeQuota() { * * @return The current size of a collection in kilobytes. */ - public long collectionSizeUsage() { + public long getCollectionSizeUsage() { return this.currentQuotaHeader(Constants.Quota.COLLECTION_SIZE); } @@ -161,7 +161,7 @@ public long collectionSizeUsage() { * * @return The maximum stored procedure quota. */ - public long storedProceduresQuota() { + public long getStoredProceduresQuota() { return this.maxQuotaHeader(Constants.Quota.STORED_PROCEDURE); } @@ -170,7 +170,7 @@ public long storedProceduresQuota() { * * @return The current number of stored procedures. */ - public long storedProceduresUsage() { + public long getStoredProceduresUsage() { return this.currentQuotaHeader(Constants.Quota.STORED_PROCEDURE); } @@ -179,7 +179,7 @@ public long storedProceduresUsage() { * * @return The maximum triggers quota. */ - public long triggersQuota() { + public long getTriggersQuota() { return this.maxQuotaHeader(Constants.Quota.TRIGGER); } @@ -188,7 +188,7 @@ public long triggersQuota() { * * @return The current number of triggers. */ - public long triggersUsage() { + public long getTriggersUsage() { return this.currentQuotaHeader(Constants.Quota.TRIGGER); } @@ -197,7 +197,7 @@ public long triggersUsage() { * * @return The maximum user defined functions quota. */ - public long userDefinedFunctionsQuota() { + public long getUserDefinedFunctionsQuota() { return this.maxQuotaHeader(Constants.Quota.USER_DEFINED_FUNCTION); } @@ -206,7 +206,7 @@ public long userDefinedFunctionsQuota() { * * @return the current number of user defined functions. */ - public long userDefinedFunctionsUsage() { + public long getUserDefinedFunctionsUsage() { return this.currentQuotaHeader(Constants.Quota.USER_DEFINED_FUNCTION); } @@ -216,7 +216,7 @@ public long userDefinedFunctionsUsage() { * @return the maximum size limit for this entity. * Measured in kilobytes for document resources and in counts for other resources. */ - public String maxResourceQuota() { + public String getMaxResourceQuota() { return getValueOrNull(header, HttpConstants.HttpHeaders.MAX_RESOURCE_QUOTA); } @@ -227,7 +227,7 @@ public String maxResourceQuota() { * @return the current size for this entity. Measured in kilobytes for document resources * and in counts for other resources. */ - public String currentResourceQuotaUsage() { + public String getCurrentResourceQuotaUsage() { return getValueOrNull(header, HttpConstants.HttpHeaders.CURRENT_RESOURCE_QUOTA_USAGE); } @@ -237,7 +237,7 @@ public String currentResourceQuotaUsage() { * * @return the request charge. */ - public double requestCharge() { + public double getRequestCharge() { String value = getValueOrNull(header, HttpConstants.HttpHeaders.REQUEST_CHARGE); if (StringUtils.isEmpty(value)) { @@ -251,7 +251,7 @@ public double requestCharge() { * * @return the activity id. */ - public String activityId() { + public String getActivityId() { return getValueOrNull(header, HttpConstants.HttpHeaders.ACTIVITY_ID); } @@ -260,7 +260,7 @@ public String activityId() { * * @return the response continuation. */ - public String continuationToken() { + public String getContinuationToken() { String headerName = useEtagAsContinuation ? HttpConstants.HttpHeaders.E_TAG : HttpConstants.HttpHeaders.CONTINUATION; @@ -272,7 +272,7 @@ public String continuationToken() { * * @return the session token. */ - public String sessionToken() { + public String getSessionToken() { return getValueOrNull(header, HttpConstants.HttpHeaders.SESSION_TOKEN); } @@ -281,12 +281,12 @@ public String sessionToken() { * * @return the response headers. */ - public Map responseHeaders() { + public Map getResponseHeaders() { return header; } - private String queryMetricsString(){ - return getValueOrNull(responseHeaders(), + private String getQueryMetricsString(){ + return getValueOrNull(getResponseHeaders(), HttpConstants.HttpHeaders.QUERY_METRICS); } @@ -294,7 +294,7 @@ private String queryMetricsString(){ * Gets the feed response diagnostics * @return Feed response diagnostics */ - public FeedResponseDiagnostics feedResponseDiagnostics() { + public FeedResponseDiagnostics getFeedResponseDiagnostics() { return this.feedResponseDiagnostics; } @@ -304,9 +304,9 @@ ConcurrentMap queryMetrics() { } //We parse query metrics for un-partitioned collection here - if (!StringUtils.isEmpty(queryMetricsString())) { - String qm = queryMetricsString(); - qm += String.format(";%s=%.2f", QueryMetricsConstants.RequestCharge, requestCharge()); + if (!StringUtils.isEmpty(getQueryMetricsString())) { + String qm = getQueryMetricsString(); + qm += String.format(";%s=%.2f", QueryMetricsConstants.RequestCharge, getRequestCharge()); queryMetricsMap.put(DefaultPartition, QueryMetrics.createFromDelimitedString(qm)); } return queryMetricsMap; @@ -317,9 +317,9 @@ ConcurrentMap queryMetricsMap(){ } private long currentQuotaHeader(String headerName) { - if (this.usageHeaders.size() == 0 && !StringUtils.isEmpty(this.maxResourceQuota()) && - !StringUtils.isEmpty(this.currentResourceQuotaUsage())) { - this.populateQuotaHeader(this.maxResourceQuota(), this.currentResourceQuotaUsage()); + if (this.usageHeaders.size() == 0 && !StringUtils.isEmpty(this.getMaxResourceQuota()) && + !StringUtils.isEmpty(this.getCurrentResourceQuotaUsage())) { + this.populateQuotaHeader(this.getMaxResourceQuota(), this.getCurrentResourceQuotaUsage()); } if (this.usageHeaders.containsKey(headerName)) { @@ -331,9 +331,9 @@ private long currentQuotaHeader(String headerName) { private long maxQuotaHeader(String headerName) { if (this.quotaHeaders.size() == 0 && - !StringUtils.isEmpty(this.maxResourceQuota()) && - !StringUtils.isEmpty(this.currentResourceQuotaUsage())) { - this.populateQuotaHeader(this.maxResourceQuota(), this.currentResourceQuotaUsage()); + !StringUtils.isEmpty(this.getMaxResourceQuota()) && + !StringUtils.isEmpty(this.getCurrentResourceQuotaUsage())) { + this.populateQuotaHeader(this.getMaxResourceQuota(), this.getCurrentResourceQuotaUsage()); } if (this.quotaHeaders.containsKey(headerName)) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java index a90f3c8586ec..9de9ee470b33 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java @@ -16,11 +16,11 @@ public class FeedResponseDiagnostics { this.queryMetricsMap = queryMetricsMap; } - Map queryMetricsMap() { + Map getQueryMetricsMap() { return queryMetricsMap; } - FeedResponseDiagnostics queryMetricsMap(Map queryMetricsMap) { + FeedResponseDiagnostics setQueryMetricsMap(Map queryMetricsMap) { this.queryMetricsMap = queryMetricsMap; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ForbiddenException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ForbiddenException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ForbiddenException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ForbiddenException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/GoneException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/GoneException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/GoneException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/GoneException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java index 20939e41f652..754ba9b54b03 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/HashIndex.java @@ -27,7 +27,7 @@ public final class HashIndex extends Index { */ public HashIndex(DataType dataType) { super(IndexKind.HASH); - this.dataType(dataType); + this.setDataType(dataType); } /** @@ -47,8 +47,8 @@ public HashIndex(DataType dataType) { */ public HashIndex(DataType dataType, int precision) { super(IndexKind.HASH); - this.dataType(dataType); - this.precision(precision); + this.setDataType(dataType); + this.setPrecision(precision); } /** @@ -58,7 +58,7 @@ public HashIndex(DataType dataType, int precision) { */ HashIndex(String jsonString) { super(jsonString, IndexKind.HASH); - if (this.dataType() == null) { + if (this.getDataType() == null) { throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'."); } } @@ -68,7 +68,7 @@ public HashIndex(DataType dataType, int precision) { * * @return the data type. */ - public DataType dataType() { + public DataType getDataType() { DataType result = null; try { result = DataType.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.DATA_TYPE))); @@ -85,7 +85,7 @@ public DataType dataType() { * @param dataType the data type. * @return the Hash Index. */ - public HashIndex dataType(DataType dataType) { + public HashIndex setDataType(DataType dataType) { super.set(Constants.Properties.DATA_TYPE, dataType.toString()); return this; } @@ -95,7 +95,7 @@ public HashIndex dataType(DataType dataType) { * * @return the precision. */ - public int precision() { + public int getPrecision() { return super.getInt(Constants.Properties.PRECISION); } @@ -105,7 +105,7 @@ public int precision() { * @param precision the precision. * @return the Hash Index. */ - public HashIndex precision(int precision) { + public HashIndex setPrecision(int precision) { super.set(Constants.Properties.PRECISION, precision); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java index f96f408ee03b..f728a689f460 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IncludedPath.java @@ -39,7 +39,7 @@ public IncludedPath(String jsonString) { * * @return the path. */ - public String path() { + public String getPath() { return super.getString(Constants.Properties.PATH); } @@ -49,7 +49,7 @@ public String path() { * @param path the path. * @return the Included Path. */ - public IncludedPath path(String path) { + public IncludedPath setPath(String path) { super.set(Constants.Properties.PATH, path); return this; } @@ -59,9 +59,9 @@ public IncludedPath path(String path) { * * @return the included paths. */ - public Collection indexes() { + public Collection getIndexes() { if (this.indexes == null) { - this.indexes = this.indexCollection(); + this.indexes = this.getIndexCollection(); if (this.indexes == null) { this.indexes = new ArrayList(); @@ -71,12 +71,12 @@ public Collection indexes() { return this.indexes; } - public IncludedPath indexes(Collection indexes) { + public IncludedPath setIndexes(Collection indexes) { this.indexes = indexes; return this; } - private Collection indexCollection() { + private Collection getIndexCollection() { if (this.propertyBag != null && this.propertyBag.has(Constants.Properties.INDEXES)) { ArrayNode jsonArray = (ArrayNode) this.propertyBag.get(Constants.Properties.INDEXES); Collection result = new ArrayList(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java index 8519e8383abb..e91d478c3c76 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Index.java @@ -18,7 +18,7 @@ public abstract class Index extends JsonSerializable { */ Index(IndexKind indexKind) { super(); - this.kind(indexKind); + this.setKind(indexKind); } /** @@ -29,7 +29,7 @@ public abstract class Index extends JsonSerializable { */ Index(String jsonString, IndexKind indexKind) { super(jsonString); - this.kind(indexKind); + this.setKind(indexKind); } /** @@ -123,7 +123,7 @@ public static SpatialIndex Spatial(DataType dataType) { * * @return the index kind. */ - public IndexKind kind() { + public IndexKind getKind() { IndexKind result = null; try { result = IndexKind.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.INDEX_KIND))); @@ -139,7 +139,7 @@ public IndexKind kind() { * * @param indexKind the index kind. */ - private Index kind(IndexKind indexKind) { + private Index setKind(IndexKind indexKind) { super.set(Constants.Properties.INDEX_KIND, indexKind.toString()); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexKind.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexKind.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexKind.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexKind.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingDirective.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingDirective.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingDirective.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingDirective.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingMode.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingMode.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingMode.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java index c9c8fbd2dd66..fd3cdfcd823e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/IndexingPolicy.java @@ -27,8 +27,8 @@ public final class IndexingPolicy extends JsonSerializable { * Constructor. */ public IndexingPolicy() { - this.automatic(true); - this.indexingMode(IndexingMode.CONSISTENT); + this.setAutomatic(true); + this.setIndexingMode(IndexingMode.CONSISTENT); } /** @@ -65,9 +65,9 @@ public IndexingPolicy(Index[] defaultIndexOverrides) { } IncludedPath includedPath = new IncludedPath(); - includedPath.path(IndexingPolicy.DEFAULT_PATH); - includedPath.indexes(new ArrayList(Arrays.asList(defaultIndexOverrides))); - this.includedPaths().add(includedPath); + includedPath.setPath(IndexingPolicy.DEFAULT_PATH); + includedPath.setIndexes(new ArrayList(Arrays.asList(defaultIndexOverrides))); + this.getIncludedPaths().add(includedPath); } /** @@ -87,7 +87,7 @@ public IndexingPolicy(Index[] defaultIndexOverrides) { * * @return the automatic */ - public Boolean automatic() { + public Boolean getAutomatic() { return super.getBoolean(Constants.Properties.AUTOMATIC); } @@ -100,7 +100,7 @@ public Boolean automatic() { * @param automatic the automatic * @return the Indexing Policy. */ - public IndexingPolicy automatic(boolean automatic) { + public IndexingPolicy setAutomatic(boolean automatic) { super.set(Constants.Properties.AUTOMATIC, automatic); return this; } @@ -110,7 +110,7 @@ public IndexingPolicy automatic(boolean automatic) { * * @return the indexing mode. */ - public IndexingMode indexingMode() { + public IndexingMode getIndexingMode() { IndexingMode result = IndexingMode.LAZY; try { result = IndexingMode.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.INDEXING_MODE))); @@ -126,7 +126,7 @@ public IndexingMode indexingMode() { * @param indexingMode the indexing mode. * @return the Indexing Policy. */ - public IndexingPolicy indexingMode(IndexingMode indexingMode) { + public IndexingPolicy setIndexingMode(IndexingMode indexingMode) { super.set(Constants.Properties.INDEXING_MODE, indexingMode.toString()); return this; } @@ -136,7 +136,7 @@ public IndexingPolicy indexingMode(IndexingMode indexingMode) { * * @return the included paths. */ - public List includedPaths() { + public List getIncludedPaths() { if (this.includedPaths == null) { this.includedPaths = super.getList(Constants.Properties.INCLUDED_PATHS, IncludedPath.class); @@ -157,7 +157,7 @@ public void setIncludedPaths(List includedPaths) { * * @return the excluded paths. */ - public List excludedPaths() { + public List getExcludedPaths() { if (this.excludedPaths == null) { this.excludedPaths = super.getList(Constants.Properties.EXCLUDED_PATHS, ExcludedPath.class); @@ -169,7 +169,7 @@ public List excludedPaths() { return this.excludedPaths; } - public IndexingPolicy excludedPaths(List excludedPaths) { + public IndexingPolicy setExcludedPaths(List excludedPaths) { this.excludedPaths = excludedPaths; return this; } @@ -179,7 +179,7 @@ public IndexingPolicy excludedPaths(List excludedPaths) { * * @return the composite indexes. */ - public List> compositeIndexes() { + public List> getCompositeIndexes() { if (this.compositeIndexes == null) { this.compositeIndexes = new ArrayList<>(); ArrayNode compositeIndexes = (ArrayNode) super.get(Constants.Properties.COMPOSITE_INDEXES); @@ -203,7 +203,7 @@ public List> compositeIndexes() { * @param compositeIndexes the composite indexes. * @return the Indexing Policy. */ - public IndexingPolicy compositeIndexes(List> compositeIndexes) { + public IndexingPolicy setCompositeIndexes(List> compositeIndexes) { this.compositeIndexes = compositeIndexes; super.set(Constants.Properties.COMPOSITE_INDEXES, this.compositeIndexes); return this; @@ -214,7 +214,7 @@ public IndexingPolicy compositeIndexes(List> compositeIndexe * * @return the spatial indexes. */ - public List spatialIndexes() { + public List getSpatialIndexes() { if (this.spatialIndexes == null) { this.spatialIndexes = super.getList(Constants.Properties.SPATIAL_INDEXES, SpatialSpec.class); @@ -232,7 +232,7 @@ public List spatialIndexes() { * @param spatialIndexes the spatial indexes. * @return the Indexing Policy. */ - public IndexingPolicy spatialIndexes(List spatialIndexes) { + public IndexingPolicy setSpatialIndexes(List spatialIndexes) { this.spatialIndexes = spatialIndexes; super.set(Constants.Properties.SPATIAL_INDEXES, this.spatialIndexes); return this; @@ -241,11 +241,11 @@ public IndexingPolicy spatialIndexes(List spatialIndexes) { @Override void populatePropertyBag() { // If indexing mode is not 'none' and not paths are set, set them to the defaults - if (this.indexingMode() != IndexingMode.NONE && this.includedPaths().size() == 0 && - this.excludedPaths().size() == 0) { + if (this.getIndexingMode() != IndexingMode.NONE && this.getIncludedPaths().size() == 0 && + this.getExcludedPaths().size() == 0) { IncludedPath includedPath = new IncludedPath(); - includedPath.path(IndexingPolicy.DEFAULT_PATH); - this.includedPaths().add(includedPath); + includedPath.setPath(IndexingPolicy.DEFAULT_PATH); + this.getIncludedPaths().add(includedPath); } if (this.includedPaths != null) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/InternalServerErrorException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/InternalServerErrorException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/InternalServerErrorException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/InternalServerErrorException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java index 645e708f94c0..eab7fb4821c4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/InvalidPartitionException.java @@ -60,8 +60,8 @@ public InvalidPartitionException(String message, HttpHeaders headers, String req } private void setSubStatus() { - this.responseHeaders().put( + this.getResponseHeaders().put( WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.NAME_CACHE_IS_STALE)); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/JsonSerializable.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/JsonSerializable.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/JsonSerializable.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/JsonSerializable.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/LockedException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/LockedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/LockedException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/LockedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/MethodNotAllowedException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/MethodNotAllowedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/MethodNotAllowedException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/MethodNotAllowedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/NotFoundException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/NotFoundException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/NotFoundException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/NotFoundException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java index 52d4e777caca..ff87c738c2b6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionIsMigratingException.java @@ -60,8 +60,8 @@ public PartitionIsMigratingException(String message, HttpHeaders headers, String } private void setSubStatus() { - this.responseHeaders().put( + this.getResponseHeaders().put( WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.COMPLETING_PARTITION_MIGRATION)); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKey.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKey.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKey.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKey.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java index ca4dc91ae6dd..95d18c5a6c4b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinition.java @@ -25,7 +25,7 @@ public final class PartitionKeyDefinition extends JsonSerializable { * Constructor. Creates a new instance of the PartitionKeyDefinition object. */ public PartitionKeyDefinition() { - this.kind(PartitionKind.HASH); + this.setKind(PartitionKind.HASH); } /** @@ -43,7 +43,7 @@ public PartitionKeyDefinition() { * * @return the partition algorithm. */ - public PartitionKind kind() { + public PartitionKind getKind() { if (this.kind == null) { this.kind = super.getObject(Constants.Properties.PARTITION_KIND, PartitionKind.class, true); } @@ -57,12 +57,12 @@ public PartitionKind kind() { * @param kind the partition algorithm. * @return this PartitionKeyDefinition. */ - public PartitionKeyDefinition kind(PartitionKind kind) { + public PartitionKeyDefinition setKind(PartitionKind kind) { this.kind = kind; return this; } - public PartitionKeyDefinitionVersion version() { + public PartitionKeyDefinitionVersion getVersion() { if (this.version == null) { Object versionObject = super.getObject(Constants.Properties.PARTITION_KEY_DEFINITION_VERSION, Object.class); if (versionObject == null) { @@ -82,7 +82,7 @@ public PartitionKeyDefinitionVersion version() { return this.version; } - public PartitionKeyDefinition version(PartitionKeyDefinitionVersion version) { + public PartitionKeyDefinition setVersion(PartitionKeyDefinitionVersion version) { this.version = version; return this; } @@ -92,7 +92,7 @@ public PartitionKeyDefinition version(PartitionKeyDefinitionVersion version) { * * @return the paths to the document properties that form the partition key. */ - public List paths() { + public List getPaths() { if (this.paths == null) { if (super.has(Constants.Properties.PARTITION_KEY_PATHS)) { paths = super.getList(Constants.Properties.PARTITION_KEY_PATHS, String.class); @@ -110,9 +110,9 @@ public List paths() { * @param paths the paths to document properties that form the partition key. * @return this PartitionKeyDefinition. */ - public PartitionKeyDefinition paths(List paths) { + public PartitionKeyDefinition setPaths(List paths) { if (paths == null || paths.size() == 0) { - throw new IllegalArgumentException("paths must not be null or empty."); + throw new IllegalArgumentException("getPaths must not be null or empty."); } this.paths = paths; @@ -137,7 +137,7 @@ Boolean isSystemKey() { } PartitionKeyInternal getNonePartitionKeyValue() { - if (this.paths().size() == 0 || this.isSystemKey()) { + if (this.getPaths().size() == 0 || this.isSystemKey()) { return PartitionKeyInternal.Empty; } else { return PartitionKeyInternal.UndefinedPartitionKey; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinitionVersion.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinitionVersion.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinitionVersion.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyDefinitionVersion.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java index 08b3a4c5e9a1..b4cdb661a272 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeGoneException.java @@ -55,6 +55,6 @@ public PartitionKeyRangeGoneException(String message, HttpHeaders headers, Strin } private void setSubstatus() { - this.responseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.PARTITION_KEY_RANGE_GONE)); + this.getResponseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.PARTITION_KEY_RANGE_GONE)); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java index 84c9bc5ea07d..8de6782bbd5a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKeyRangeIsSplittingException.java @@ -60,8 +60,8 @@ public PartitionKeyRangeIsSplittingException(String message, HttpHeaders headers } private void setSubStatus() { - this.responseHeaders().put( + this.getResponseHeaders().put( WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.COMPLETING_SPLIT)); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKind.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKind.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKind.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PartitionKind.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PermissionMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PermissionMode.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PermissionMode.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PermissionMode.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PreconditionFailedException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PreconditionFailedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/PreconditionFailedException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/PreconditionFailedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java index ce7e5124a7c1..43172cbb91f5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RangeIndex.java @@ -27,7 +27,7 @@ public final class RangeIndex extends Index { */ public RangeIndex(DataType dataType) { super(IndexKind.RANGE); - this.dataType(dataType); + this.setDataType(dataType); } /** @@ -44,8 +44,8 @@ public RangeIndex(DataType dataType) { */ public RangeIndex(DataType dataType, int precision) { super(IndexKind.RANGE); - this.dataType(dataType); - this.precision(precision); + this.setDataType(dataType); + this.setPrecision(precision); } /** @@ -55,7 +55,7 @@ public RangeIndex(DataType dataType, int precision) { */ RangeIndex(String jsonString) { super(jsonString, IndexKind.RANGE); - if (this.dataType() == null) { + if (this.getDataType() == null) { throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'."); } } @@ -65,7 +65,7 @@ public RangeIndex(DataType dataType, int precision) { * * @return the data type. */ - public DataType dataType() { + public DataType getDataType() { DataType result = null; try { result = DataType.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.DATA_TYPE))); @@ -81,7 +81,7 @@ public DataType dataType() { * @param dataType the data type. * @return the RangeIndex. */ - public RangeIndex dataType(DataType dataType) { + public RangeIndex setDataType(DataType dataType) { super.set(Constants.Properties.DATA_TYPE, dataType.toString()); return this; } @@ -91,7 +91,7 @@ public RangeIndex dataType(DataType dataType) { * * @return the precision. */ - public int precision() { + public int getPrecision() { return super.getInt(Constants.Properties.PRECISION); } @@ -101,7 +101,7 @@ public int precision() { * @param precision the precision. * @return the RangeIndex. */ - public RangeIndex precision(int precision) { + public RangeIndex setPrecision(int precision) { super.set(Constants.Properties.PRECISION, precision); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestEntityTooLargeException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestEntityTooLargeException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestEntityTooLargeException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestEntityTooLargeException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestRateTooLargeException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestRateTooLargeException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestRateTooLargeException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestRateTooLargeException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestTimeoutException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestTimeoutException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RequestTimeoutException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RequestTimeoutException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java similarity index 80% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java index 970463f94784..7b2631b6e845 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/Resource.java @@ -19,13 +19,13 @@ public class Resource extends JsonSerializable { private String altLink; static void validateResource(Resource resource) { - if (!StringUtils.isEmpty(resource.id())) { - if (resource.id().indexOf('/') != -1 || resource.id().indexOf('\\') != -1 || - resource.id().indexOf('?') != -1 || resource.id().indexOf('#') != -1) { + if (!StringUtils.isEmpty(resource.getId())) { + if (resource.getId().indexOf('/') != -1 || resource.getId().indexOf('\\') != -1 || + resource.getId().indexOf('?') != -1 || resource.getId().indexOf('#') != -1) { throw new IllegalArgumentException("Id contains illegal chars."); } - if (resource.id().endsWith(" ")) { + if (resource.getId().endsWith(" ")) { throw new IllegalArgumentException("Id ends with a space."); } } @@ -37,12 +37,12 @@ static void validateResource(Resource resource) { * @param resource resource to by copied. */ protected Resource(Resource resource) { - this.id(resource.id()); - this.resourceId(resource.resourceId()); - this.selfLink(resource.selfLink()); - this.altLink(resource.altLink()); - this.timestamp(resource.timestamp()); - this.etag(resource.etag()); + this.setId(resource.getId()); + this.setResourceId(resource.getResourceId()); + this.setSelfLink(resource.getSelfLink()); + this.setAltLink(resource.getAltLink()); + this.setTimestamp(resource.getTimestamp()); + this.setETag(resource.getETag()); } /** @@ -87,7 +87,7 @@ protected Resource(String jsonString) { * * @return the name of the resource. */ - public String id() { + public String getId() { return super.getString(Constants.Properties.ID); } @@ -97,7 +97,7 @@ public String id() { * @param id the name of the resource. * @return the resource. */ - public Resource id(String id) { + public Resource setId(String id) { super.set(Constants.Properties.ID, id); return this; } @@ -107,7 +107,7 @@ public Resource id(String id) { * * @return the ID associated with the resource. */ - public String resourceId() { + public String getResourceId() { return super.getString(Constants.Properties.R_ID); } @@ -118,7 +118,7 @@ public String resourceId() { * @param resourceId the ID associated with the resource. * @return the resource. */ - public Resource resourceId(String resourceId) { + public Resource setResourceId(String resourceId) { super.set(Constants.Properties.R_ID, resourceId); return this; } @@ -128,7 +128,7 @@ public Resource resourceId(String resourceId) { * * @return the self link. */ - public String selfLink() { + public String getSelfLink() { return super.getString(Constants.Properties.SELF_LINK); } @@ -137,7 +137,7 @@ public String selfLink() { * * @param selfLink the self link. */ - Resource selfLink(String selfLink) { + Resource setSelfLink(String selfLink) { super.set(Constants.Properties.SELF_LINK, selfLink); return this; } @@ -147,7 +147,7 @@ Resource selfLink(String selfLink) { * * @return the timestamp. */ - public OffsetDateTime timestamp() { + public OffsetDateTime getTimestamp() { Long seconds = super.getLong(Constants.Properties.LAST_MODIFIED); if (seconds == null) return null; @@ -159,7 +159,7 @@ public OffsetDateTime timestamp() { * * @param timestamp the timestamp. */ - Resource timestamp(OffsetDateTime timestamp) { + Resource setTimestamp(OffsetDateTime timestamp) { long seconds = timestamp.toEpochSecond(); super.set(Constants.Properties.LAST_MODIFIED, seconds); return this; @@ -170,7 +170,7 @@ Resource timestamp(OffsetDateTime timestamp) { * * @return the e tag. */ - public String etag() { + public String getETag() { return super.getString(Constants.Properties.E_TAG); } @@ -179,7 +179,7 @@ public String etag() { * * @param eTag the e tag. */ - Resource etag(String eTag) { + Resource setETag(String eTag) { super.set(Constants.Properties.E_TAG, eTag); return this; } @@ -190,7 +190,7 @@ Resource etag(String eTag) { * * @param altLink */ - Resource altLink(String altLink) { + Resource setAltLink(String altLink) { this.altLink = altLink; return this; } @@ -199,7 +199,7 @@ Resource altLink(String altLink) { * Gets the alt-link associated with the resource from the Azure Cosmos DB * service. */ - String altLink() { + String getAltLink() { return this.altLink; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java index 24ae164fec1f..240a69139e31 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RetryOptions.java @@ -25,7 +25,7 @@ public RetryOptions() { * * @return the maximum number of retries. */ - public int maxRetryAttemptsOnThrottledRequests() { + public int getMaxRetryAttemptsOnThrottledRequests() { return this.maxRetryAttemptsOnThrottledRequests; } @@ -47,7 +47,7 @@ public int maxRetryAttemptsOnThrottledRequests() { * throttle error. * @return the RetryOptions. */ - public RetryOptions maxRetryAttemptsOnThrottledRequests(int maxRetryAttemptsOnThrottledRequests) { + public RetryOptions setMaxRetryAttemptsOnThrottledRequests(int maxRetryAttemptsOnThrottledRequests) { if (maxRetryAttemptsOnThrottledRequests < 0) { throw new IllegalArgumentException("maxRetryAttemptsOnThrottledRequests value must be a positive integer."); } @@ -61,7 +61,7 @@ public RetryOptions maxRetryAttemptsOnThrottledRequests(int maxRetryAttemptsOnTh * * @return the maximum retry time in seconds. */ - public int maxRetryWaitTimeInSeconds() { + public int getMaxRetryWaitTimeInSeconds() { return this.maxRetryWaitTimeInSeconds; } @@ -80,7 +80,7 @@ public int maxRetryWaitTimeInSeconds() { * @param maxRetryWaitTimeInSeconds the maximum number of seconds a request will be retried. * @return the RetryOptions. */ - public RetryOptions maxRetryWaitTimeInSeconds(int maxRetryWaitTimeInSeconds) { + public RetryOptions setMaxRetryWaitTimeInSeconds(int maxRetryWaitTimeInSeconds) { if (maxRetryWaitTimeInSeconds < 0 || maxRetryWaitTimeInSeconds > Integer.MAX_VALUE / 1000) { throw new IllegalArgumentException( "value must be a positive integer between the range of 0 to " + Integer.MAX_VALUE / 1000); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RetryWithException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RetryWithException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/RetryWithException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/RetryWithException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SerializationFormattingPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SerializationFormattingPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SerializationFormattingPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SerializationFormattingPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ServiceUnavailableException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ServiceUnavailableException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ServiceUnavailableException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/ServiceUnavailableException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java index 7f88321a1fde..9d1e15d10a75 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialIndex.java @@ -27,7 +27,7 @@ final class SpatialIndex extends Index { */ SpatialIndex(DataType dataType) { super(IndexKind.SPATIAL); - this.dataType(dataType); + this.setDataType(dataType); } /** @@ -37,7 +37,7 @@ final class SpatialIndex extends Index { */ SpatialIndex(String jsonString) { super(jsonString, IndexKind.SPATIAL); - if (this.dataType() == null) { + if (this.getDataType() == null) { throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'."); } } @@ -47,7 +47,7 @@ final class SpatialIndex extends Index { * * @return the data type. */ - public DataType dataType() { + public DataType getDataType() { DataType result = null; try { result = DataType.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.DATA_TYPE))); @@ -63,7 +63,7 @@ public DataType dataType() { * @param dataType the data type. * @return the SpatialIndex. */ - public SpatialIndex dataType(DataType dataType) { + public SpatialIndex setDataType(DataType dataType) { super.set(Constants.Properties.DATA_TYPE, dataType.toString()); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java index 1c579937a98d..ad6dc9d45df6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialSpec.java @@ -35,7 +35,7 @@ public SpatialSpec() { * * @return the path. */ - public String path() { + public String getPath() { return super.getString(Constants.Properties.PATH); } @@ -45,7 +45,7 @@ public String path() { * @param path the path. * @return the SpatialSpec. */ - public SpatialSpec path(String path) { + public SpatialSpec setPath(String path) { super.set(Constants.Properties.PATH, path); return this; } @@ -55,7 +55,7 @@ public SpatialSpec path(String path) { * * @return the collection of spatial types. */ - public List spatialTypes() { + public List getSpatialTypes() { if (this.spatialTypes == null) { this.spatialTypes = super.getList(Constants.Properties.TYPES, SpatialType.class, true); @@ -73,7 +73,7 @@ public List spatialTypes() { * @param spatialTypes the collection of spatial types. * @return the SpatialSpec. */ - public SpatialSpec spatialTypes(List spatialTypes) { + public SpatialSpec setSpatialTypes(List spatialTypes) { this.spatialTypes = spatialTypes; Collection spatialTypeNames = new ArrayList(); for (SpatialType spatialType : this.spatialTypes) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SpatialType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java index e6c9f8f0d0dc..ad1175de826c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameter.java @@ -24,8 +24,8 @@ public SqlParameter() { */ public SqlParameter(String name, Object value) { super(); - this.name(name); - this.value(value); + this.setName(name); + this.setValue(value); } /** @@ -33,7 +33,7 @@ public SqlParameter(String name, Object value) { * * @return the name of the parameter. */ - public String name() { + public String getName() { return super.getString("name"); } @@ -43,7 +43,7 @@ public String name() { * @param name the name of the parameter. * @return the SqlParameter. */ - public SqlParameter name(String name) { + public SqlParameter setName(String name) { super.set("name", name); return this; } @@ -55,7 +55,7 @@ public SqlParameter name(String name) { * @param the type of the parameter * @return the value of the parameter. */ - public Object value(Class c) { + public Object getValue(Class c) { return super.getObject("value", c); } @@ -65,7 +65,7 @@ public Object value(Class c) { * @param value the value of the parameter. * @return the SqlParameter. */ - public SqlParameter value(Object value) { + public SqlParameter setValue(Object value) { super.set("value", value); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameterList.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameterList.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameterList.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlParameterList.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java index 2c7b94a1e5b3..5665bac34dfe 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/SqlQuerySpec.java @@ -29,7 +29,7 @@ public SqlQuerySpec() { */ public SqlQuerySpec(String queryText) { super(); - this.queryText(queryText); + this.setQueryText(queryText); } /** @@ -41,7 +41,7 @@ public SqlQuerySpec(String queryText) { */ public SqlQuerySpec(String queryText, SqlParameterList parameters) { super(); - this.queryText(queryText); + this.setQueryText(queryText); this.parameters = parameters; } @@ -50,7 +50,7 @@ public SqlQuerySpec(String queryText, SqlParameterList parameters) { * * @return the query text. */ - public String queryText() { + public String getQueryText() { return super.getString("query"); } @@ -61,7 +61,7 @@ public String queryText() { * the query text. * @return the SqlQuerySpec. */ - public SqlQuerySpec queryText(String queryText) { + public SqlQuerySpec setQueryText(String queryText) { super.set("query", queryText); return this; } @@ -71,7 +71,7 @@ public SqlQuerySpec queryText(String queryText) { * * @return the query parameters. */ - public SqlParameterList parameters() { + public SqlParameterList getParameters() { if (this.parameters == null) { Collection sqlParameters = super.getCollection("parameters", SqlParameter.class); if (sqlParameters == null) { @@ -91,7 +91,7 @@ public SqlParameterList parameters() { * the query parameters. * @return the SqlQuerySpec. */ - public SqlQuerySpec parameters(SqlParameterList parameters) { + public SqlQuerySpec setParameters(SqlParameterList parameters) { this.parameters = parameters; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TokenResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TokenResolver.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TokenResolver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TokenResolver.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerOperation.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerOperation.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerOperation.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerOperation.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/TriggerType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UnauthorizedException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UnauthorizedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UnauthorizedException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UnauthorizedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java index a32a1540235e..52719c20af4b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKey.java @@ -35,7 +35,7 @@ public UniqueKey() { * * @return the unique paths. */ - public Collection paths() { + public Collection getPaths() { if (this.paths == null) { this.paths = super.getList(Constants.Properties.PATHS, String.class); @@ -57,7 +57,7 @@ public Collection paths() { * @param paths the unique paths. * @return the Unique Key. */ - public UniqueKey paths(List paths) { + public UniqueKey setPaths(List paths) { this.paths = paths; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKeyPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKeyPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKeyPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/UniqueKeyPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java index b58914e96a98..3267758bffca 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AsyncDocumentClient.java @@ -42,14 +42,14 @@ * .withMasterKeyOrResourceToken(masterKey) * .withConnectionPolicy(connectionPolicy) * .withConsistencyLevel(ConsistencyLevel.SESSION) - * .build(); + * .buildAsyncClient(); * } *

*/ public interface AsyncDocumentClient { /** - * Helper class to build {@link AsyncDocumentClient} instances + * Helper class to buildAsyncClient {@link AsyncDocumentClient} instances * as logical representation of the Azure Cosmos DB database service. * *
@@ -61,7 +61,7 @@ public interface AsyncDocumentClient {
      *         .withMasterKeyOrResourceToken(masterKey)
      *         .withConnectionPolicy(connectionPolicy)
      *         .withConsistencyLevel(ConsistencyLevel.SESSION)
-     *         .build();
+     *         .buildAsyncClient();
      * }
      * 
*/ @@ -139,8 +139,8 @@ public Builder withConnectionPolicy(ConnectionPolicy connectionPolicy) { } public Builder withCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) { - if (cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.key())) { - throw new IllegalArgumentException("Cannot build client with empty key credential"); + if (cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.getKey())) { + throw new IllegalArgumentException("Cannot buildAsyncClient client with empty key credential"); } this.cosmosKeyCredential = cosmosKeyCredential; return this; @@ -165,14 +165,14 @@ private void ifThrowIllegalArgException(boolean value, String error) { public AsyncDocumentClient build() { - ifThrowIllegalArgException(this.serviceEndpoint == null, "cannot build client without service endpoint"); + ifThrowIllegalArgException(this.serviceEndpoint == null, "cannot buildAsyncClient client without service endpoint"); ifThrowIllegalArgException( this.masterKeyOrResourceToken == null && (permissionFeed == null || permissionFeed.isEmpty()) && this.tokenResolver == null && this.cosmosKeyCredential == null, - "cannot build client without any one of masterKey, " + + "cannot buildAsyncClient client without any one of masterKey, " + "resource token, permissionFeed, tokenResolver and cosmos key credential"); - ifThrowIllegalArgException(cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.key()), - "cannot build client without key credential"); + ifThrowIllegalArgException(cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.getKey()), + "cannot buildAsyncClient client without key credential"); RxDocumentClientImpl client = new RxDocumentClientImpl(serviceEndpoint, masterKeyOrResourceToken, diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenProvider.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenProvider.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/AuthorizationTokenType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BackoffRetryUtility.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BackoffRetryUtility.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BackoffRetryUtility.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BackoffRetryUtility.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java index 51ea66597f35..484306fc2b61 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseAuthorizationTokenProvider.java @@ -117,7 +117,7 @@ public String generateKeyAuthorizationSignature(String verb, throw new IllegalArgumentException("headers"); } - if (StringUtils.isEmpty(this.cosmosKeyCredential.key())) { + if (StringUtils.isEmpty(this.cosmosKeyCredential.getKey())) { throw new IllegalArgumentException("key credentials cannot be empty"); } @@ -243,11 +243,11 @@ private String generateKeyAuthorizationSignatureNew(String verb, String resource } private Mac getMacInstance() { - int masterKeyLatestHashCode = this.cosmosKeyCredential.keyHashCode(); + int masterKeyLatestHashCode = this.cosmosKeyCredential.getKeyHashCode(); // Master key has changed, or this is the first time we are getting mac instance if (masterKeyLatestHashCode != this.masterKeyHashCode) { - byte[] masterKeyBytes = this.cosmosKeyCredential.key().getBytes(); + byte[] masterKeyBytes = this.cosmosKeyCredential.getKey().getBytes(); byte[] masterKeyDecodedBytes = Utils.Base64Decoder.decode(masterKeyBytes); SecretKey signingKey = new SecretKeySpec(masterKeyDecodedBytes, "HMACSHA256"); try { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java index 76f62c035250..b62e9f6b6242 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/BaseDatabaseAccountConfigurationProvider.java @@ -20,7 +20,7 @@ public BaseDatabaseAccountConfigurationProvider(DatabaseAccount databaseAccount, } public ConsistencyLevel getStoreConsistencyPolicy() { - ConsistencyLevel databaseAccountConsistency = BridgeInternal.getConsistencyPolicy(this.databaseAccount).defaultConsistencyLevel(); + ConsistencyLevel databaseAccountConsistency = BridgeInternal.getConsistencyPolicy(this.databaseAccount).getDefaultConsistencyLevel(); if (this.desiredConsistencyLevel == null) { return databaseAccountConsistency; } else if (!Utils.isValidConsistency(databaseAccountConsistency, this.desiredConsistencyLevel)) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Bytes.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Bytes.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Bytes.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Bytes.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java index e31964bbe35c..b4a5dc38405d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ChangeFeedQueryImpl.java @@ -40,11 +40,11 @@ public ChangeFeedQueryImpl(RxDocumentClientImpl client, changeFeedOptions = changeFeedOptions != null ? changeFeedOptions: new ChangeFeedOptions(); - if (resourceType.isPartitioned() && partitionKeyRangeIdInternal(changeFeedOptions) == null && changeFeedOptions.partitionKey() == null) { + if (resourceType.isPartitioned() && partitionKeyRangeIdInternal(changeFeedOptions) == null && changeFeedOptions.getPartitionKey() == null) { throw new IllegalArgumentException(RMResources.PartitionKeyRangeIdOrPartitionKeyMustBeSpecified); } - if (changeFeedOptions.partitionKey() != null && + if (changeFeedOptions.getPartitionKey() != null && !Strings.isNullOrEmpty(partitionKeyRangeIdInternal(changeFeedOptions))) { throw new IllegalArgumentException(String.format( @@ -55,16 +55,16 @@ public ChangeFeedQueryImpl(RxDocumentClientImpl client, String initialNextIfNoneMatch = null; boolean canUseStartFromBeginning = true; - if (changeFeedOptions.requestContinuation() != null) { - initialNextIfNoneMatch = changeFeedOptions.requestContinuation(); + if (changeFeedOptions.getRequestContinuation() != null) { + initialNextIfNoneMatch = changeFeedOptions.getRequestContinuation(); canUseStartFromBeginning = false; } - if(changeFeedOptions.startDateTime() != null){ + if(changeFeedOptions.getStartDateTime() != null){ canUseStartFromBeginning = false; } - if (canUseStartFromBeginning && !changeFeedOptions.startFromBeginning()) { + if (canUseStartFromBeginning && !changeFeedOptions.getStartFromBeginning()) { initialNextIfNoneMatch = IfNonMatchAllHeaderValue; } @@ -74,8 +74,8 @@ public ChangeFeedQueryImpl(RxDocumentClientImpl client, private RxDocumentServiceRequest createDocumentServiceRequest(String continuationToken, int pageSize) { Map headers = new HashMap<>(); - if (options.maxItemCount() != null) { - headers.put(HttpConstants.HttpHeaders.PAGE_SIZE, String.valueOf(options.maxItemCount())); + if (options.getMaxItemCount() != null) { + headers.put(HttpConstants.HttpHeaders.PAGE_SIZE, String.valueOf(options.getMaxItemCount())); } // On REST level, change feed is using IF_NONE_MATCH/ETag instead of continuation. @@ -85,13 +85,13 @@ private RxDocumentServiceRequest createDocumentServiceRequest(String continuatio headers.put(HttpConstants.HttpHeaders.A_IM, HttpConstants.A_IMHeaderValues.INCREMENTAL_FEED); - if (options.partitionKey() != null) { - PartitionKeyInternal partitionKey = options.partitionKey().getInternalPartitionKey(); + if (options.getPartitionKey() != null) { + PartitionKeyInternal partitionKey = options.getPartitionKey().getInternalPartitionKey(); headers.put(HttpConstants.HttpHeaders.PARTITION_KEY, partitionKey.toJson()); } - if(options.startDateTime() != null){ - String dateTimeInHttpFormat = Utils.zonedDateTimeAsUTCRFC1123(options.startDateTime()); + if(options.getStartDateTime() != null){ + String dateTimeInHttpFormat = Utils.zonedDateTimeAsUTCRFC1123(options.getStartDateTime()); headers.put(HttpConstants.HttpHeaders.IF_MODIFIED_SINCE, dateTimeInHttpFormat); } @@ -111,7 +111,7 @@ private RxDocumentServiceRequest createDocumentServiceRequest(String continuatio private ChangeFeedOptions getChangeFeedOptions(ChangeFeedOptions options, String continuationToken) { ChangeFeedOptions newOps = new ChangeFeedOptions(options); - newOps.requestContinuation(continuationToken); + newOps.setRequestContinuation(continuationToken); return newOps; } @@ -121,7 +121,7 @@ public Flux> executeAsync() { Function>> executeFunc = this::executeRequestAsync; - return Paginator.getPaginatedChangeFeedQueryResultAsObservable(options, createRequestFunc, executeFunc, klass, options.maxItemCount() != null ? options.maxItemCount(): -1); + return Paginator.getPaginatedChangeFeedQueryResultAsObservable(options, createRequestFunc, executeFunc, klass, options.getMaxItemCount() != null ? options.getMaxItemCount(): -1); } private Flux> executeRequestAsync(RxDocumentServiceRequest request) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClearingSessionContainerClientRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClearingSessionContainerClientRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClearingSessionContainerClientRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClearingSessionContainerClientRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java index b0f7adf8ec42..60ad46edca80 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ClientRetryPolicy.java @@ -45,8 +45,8 @@ public ClientRetryPolicy(GlobalEndpointManager globalEndpointManager, RetryOptions retryOptions) { this.throttlingRetry = new ResourceThrottleRetryPolicy( - retryOptions.maxRetryAttemptsOnThrottledRequests(), - retryOptions.maxRetryWaitTimeInSeconds()); + retryOptions.getMaxRetryAttemptsOnThrottledRequests(), + retryOptions.getMaxRetryWaitTimeInSeconds()); this.globalEndpointManager = globalEndpointManager; this.failoverRetryCount = 0; this.enableEndpointDiscovery = enableEndpointDiscovery; @@ -67,8 +67,8 @@ public Mono shouldRetry(Exception e) { this.retryContext = null; // Received 403.3 on write region, initiate the endpoint re-discovery CosmosClientException clientException = Utils.as(e, CosmosClientException.class); - if (clientException != null && clientException.cosmosResponseDiagnostics() != null) { - this.cosmosResponseDiagnostics = clientException.cosmosResponseDiagnostics(); + if (clientException != null && clientException.getCosmosResponseDiagnostics() != null) { + this.cosmosResponseDiagnostics = clientException.getCosmosResponseDiagnostics(); } if (clientException != null && Exceptions.isStatusCode(clientException, HttpConstants.StatusCodes.FORBIDDEN) && diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Configs.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Configs.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Configs.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Configs.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Conflict.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Conflict.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Conflict.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Conflict.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Constants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Constants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Constants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Constants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ContentSerializationFormat.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ContentSerializationFormat.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ContentSerializationFormat.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ContentSerializationFormat.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java index 614e06986ac1..77b520eff5e6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Database.java @@ -28,8 +28,8 @@ public Database() { * @param id the name of the resource. * @return the current instance of Database */ - public Database id(String id){ - super.id(id); + public Database setId(String id){ + super.setId(id); return this; } @@ -49,7 +49,7 @@ public Database(String jsonString) { */ public String getCollectionsLink() { return String.format("%s/%s", - StringUtils.stripEnd(super.selfLink(), "/"), + StringUtils.stripEnd(super.getSelfLink(), "/"), super.getString(Constants.Properties.COLLECTIONS_LINK)); } @@ -60,7 +60,7 @@ public String getCollectionsLink() { */ public String getUsersLink() { return String.format("%s/%s", - StringUtils.stripEnd(super.selfLink(), "/"), + StringUtils.stripEnd(super.getSelfLink(), "/"), super.getString(Constants.Properties.USERS_LINK)); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountConfigurationProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountConfigurationProvider.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountConfigurationProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountConfigurationProvider.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountManagerInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountManagerInternal.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountManagerInternal.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseAccountManagerInternal.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java index f793efcefbb4..72f0cd23eaf8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DatabaseForTest.java @@ -46,11 +46,11 @@ public static String generateId() { } private static DatabaseForTest from(Database db) { - if (db == null || db.id() == null || db.selfLink() == null) { + if (db == null || db.getId() == null || db.getSelfLink() == null) { return null; } - String id = db.id(); + String id = db.getId(); if (id == null) { return null; } @@ -73,7 +73,7 @@ private static DatabaseForTest from(Database db) { public static DatabaseForTest create(DatabaseManager client) { Database dbDef = new Database(); - dbDef.id(generateId()); + dbDef.setId(generateId()); Database db = client.createDatabase(dbDef).single().block().getResource(); DatabaseForTest dbForTest = DatabaseForTest.from(db); @@ -86,16 +86,16 @@ public static void cleanupStaleTestDatabases(DatabaseManager client) { List dbs = client.queryDatabases( new SqlQuerySpec("SELECT * FROM c WHERE STARTSWITH(c.id, @PREFIX)", new SqlParameterList(new SqlParameter("@PREFIX", DatabaseForTest.SHARED_DB_ID_PREFIX)))) - .flatMap(page -> Flux.fromIterable(page.results())).collectList().block(); + .flatMap(page -> Flux.fromIterable(page.getResults())).collectList().block(); for (Database db : dbs) { - assert(db.id().startsWith(DatabaseForTest.SHARED_DB_ID_PREFIX)); + assert(db.getId().startsWith(DatabaseForTest.SHARED_DB_ID_PREFIX)); DatabaseForTest dbForTest = DatabaseForTest.from(db); if (db != null && dbForTest.isStale()) { - logger.info("Deleting database {}", db.id()); - client.deleteDatabase(db.id()).single().block(); + logger.info("Deleting database {}", db.getId()); + client.deleteDatabase(db.getId()).single().block(); } } } @@ -105,4 +105,4 @@ public interface DatabaseManager { Flux> createDatabase(Database databaseDefinition); Flux> deleteDatabase(String id); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java index fc32659f06c5..7cdd45e32493 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Document.java @@ -33,8 +33,8 @@ public Document() { * @param id the name of the resource. * @return the current instance of the Document */ - public Document id(String id){ - super.id(id); + public Document setId(String id){ + super.setId(id); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java index c259caa06534..e099925f555a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentCollection.java @@ -39,8 +39,8 @@ public DocumentCollection() { * @param id the name of the resource. * @return */ - public DocumentCollection id(String id){ - super.id(id); + public DocumentCollection setId(String id){ + super.setId(id); return this; } @@ -213,7 +213,7 @@ public void setConflictResolutionPolicy(ConflictResolutionPolicy value) { */ public String getDocumentsLink() { return String.format("%s/%s", - StringUtils.stripEnd(super.selfLink(), "/"), + StringUtils.stripEnd(super.getSelfLink(), "/"), super.getString(Constants.Properties.DOCUMENTS_LINK)); } @@ -224,7 +224,7 @@ public String getDocumentsLink() { */ public String getStoredProceduresLink() { return String.format("%s/%s", - StringUtils.stripEnd(super.selfLink(), "/"), + StringUtils.stripEnd(super.getSelfLink(), "/"), super.getString(Constants.Properties.STORED_PROCEDURES_LINK)); } @@ -234,7 +234,7 @@ public String getStoredProceduresLink() { * @return the trigger link. */ public String getTriggersLink() { - return StringUtils.removeEnd(this.selfLink(), "/") + + return StringUtils.removeEnd(this.getSelfLink(), "/") + "/" + super.getString(Constants.Properties.TRIGGERS_LINK); } @@ -244,7 +244,7 @@ public String getTriggersLink() { * @return the user defined functions link. */ public String getUserDefinedFunctionsLink() { - return StringUtils.removeEnd(this.selfLink(), "/") + + return StringUtils.removeEnd(this.getSelfLink(), "/") + "/" + super.getString(Constants.Properties.USER_DEFINED_FUNCTIONS_LINK); } @@ -254,7 +254,7 @@ public String getUserDefinedFunctionsLink() { * @return the conflicts link. */ public String getConflictsLink() { - return StringUtils.removeEnd(this.selfLink(), "/") + + return StringUtils.removeEnd(this.getSelfLink(), "/") + "/" + super.getString(Constants.Properties.CONFLICTS_LINK); } @@ -284,12 +284,12 @@ public boolean equals(Object obj) { } DocumentCollection typedObj = (DocumentCollection) obj; - return typedObj.resourceId().equals(this.resourceId()); + return typedObj.getResourceId().equals(this.getResourceId()); } @Override public int hashCode() { - return this.resourceId().hashCode(); + return this.getResourceId().hashCode(); } @Override @@ -297,4 +297,4 @@ public String toJson() { this.populatePropertyBag(); return super.toJson(); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentServiceRequestContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentServiceRequestContext.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentServiceRequestContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/DocumentServiceRequestContext.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/EnumerationDirection.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/EnumerationDirection.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/EnumerationDirection.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/EnumerationDirection.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java index e3bd9a3fc8b6..f72f0cc183a0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Exceptions.java @@ -11,11 +11,11 @@ public class Exceptions { public static boolean isStatusCode(CosmosClientException e, int status) { - return status == e.statusCode(); + return status == e.getStatusCode(); } public static boolean isSubStatusCode(CosmosClientException e, int subStatus) { - return subStatus == e.subStatusCode(); + return subStatus == e.getSubStatusCode(); } public static boolean isPartitionSplit(CosmosClientException e) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/FanoutOperationState.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/FanoutOperationState.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/FanoutOperationState.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/FanoutOperationState.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java index 22643869cbaa..04d2e41bc5bf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/GlobalEndpointManager.java @@ -49,12 +49,12 @@ public GlobalEndpointManager(DatabaseAccountManagerInternal owner, ConnectionPol this.backgroundRefreshLocationTimeIntervalInMS = configs.getUnavailableLocationsExpirationTimeInSeconds() * 1000; try { this.locationCache = new LocationCache( - new ArrayList<>(connectionPolicy.preferredLocations() != null ? - connectionPolicy.preferredLocations(): + new ArrayList<>(connectionPolicy.getPreferredLocations() != null ? + connectionPolicy.getPreferredLocations(): Collections.emptyList() ), owner.getServiceEndpoint().toURL(), - connectionPolicy.enableEndpointDiscovery(), + connectionPolicy.getEnableEndpointDiscovery(), BridgeInternal.getUseMultipleWriteLocations(connectionPolicy), configs); @@ -159,7 +159,7 @@ private Mono refreshLocationPrivateAsync(DatabaseAccount databaseAccount) Mono databaseAccountObs = getDatabaseAccountFromAnyLocationsAsync( this.defaultEndpoint, - new ArrayList<>(this.connectionPolicy.preferredLocations()), + new ArrayList<>(this.connectionPolicy.getPreferredLocations()), this::getDatabaseAccountAsync); return databaseAccountObs.map(dbAccount -> { @@ -211,7 +211,7 @@ private Mono startRefreshLocationTimerAsync(boolean initialization) { } logger.debug("startRefreshLocationTimerAsync() - Invoking refresh, I was registered on [{}]", now); - Mono databaseAccountObs = GlobalEndpointManager.getDatabaseAccountFromAnyLocationsAsync(this.defaultEndpoint, new ArrayList<>(this.connectionPolicy.preferredLocations()), + Mono databaseAccountObs = GlobalEndpointManager.getDatabaseAccountFromAnyLocationsAsync(this.defaultEndpoint, new ArrayList<>(this.connectionPolicy.getPreferredLocations()), this::getDatabaseAccountAsync); return databaseAccountObs.flatMap(dbAccount -> { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java index 8530ba2816e4..4f926800cbd5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/HttpConstants.java @@ -252,7 +252,7 @@ public static class Versions { // TODO: FIXME we can use maven plugin for generating a version file // @see // https://stackoverflow.com/questions/2469922/generate-a-version-java-file-in-maven - public static final String SDK_VERSION = "3.2.0"; + public static final String SDK_VERSION = "4.0.0-preview.4"; public static final String SDK_NAME = "cosmosdb-java-sdk"; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IAuthorizationTokenProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IAuthorizationTokenProvider.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IAuthorizationTokenProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IAuthorizationTokenProvider.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ICollectionRoutingMapCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ICollectionRoutingMapCache.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ICollectionRoutingMapCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ICollectionRoutingMapCache.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IDocumentClientRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IDocumentClientRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IDocumentClientRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IDocumentClientRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicyFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicyFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicyFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRetryPolicyFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRoutingMapProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRoutingMapProvider.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRoutingMapProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/IRoutingMapProvider.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionContainer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionContainer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionContainer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ISessionToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Integers.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Integers.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Integers.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Integers.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InternalConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InternalConstants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InternalConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InternalConstants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InvalidPartitionExceptionRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InvalidPartitionExceptionRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InvalidPartitionExceptionRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/InvalidPartitionExceptionRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/JavaStreamUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/JavaStreamUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/JavaStreamUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/JavaStreamUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/LifeCycleUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/LifeCycleUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/LifeCycleUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/LifeCycleUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Lists.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Lists.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Lists.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Lists.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Longs.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Longs.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Longs.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Longs.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MigrateCollectionDirective.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MigrateCollectionDirective.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MigrateCollectionDirective.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MigrateCollectionDirective.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MutableVolatile.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MutableVolatile.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MutableVolatile.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/MutableVolatile.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ObservableHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ObservableHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ObservableHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ObservableHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Offer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Offer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Offer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Offer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java index 47d5c1d50db8..5b87499b9bda 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/OperationType.java @@ -50,4 +50,4 @@ public boolean isWriteOperation() { this == Upsert || this == Update; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyMismatchRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyMismatchRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyMismatchRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyMismatchRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java index 4bedd8738b37..0b5f77629e95 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRange.java @@ -40,21 +40,21 @@ public PartitionKeyRange(String jsonString) { * @param id the name of the resource. * @return the partition key range */ - public PartitionKeyRange id(String id) { - super.id(id); + public PartitionKeyRange setId(String id) { + super.setId(id); return this; } public PartitionKeyRange(String id, String minInclusive, String maxExclusive) { super(); - this.id(id); + this.setId(id); this.setMinInclusive(minInclusive); this.setMaxExclusive(maxExclusive); } public PartitionKeyRange(String id, String minInclusive, String maxExclusive, List parents) { super(); - this.id(id); + this.setId(id); this.setMinInclusive(minInclusive); this.setMaxExclusive(maxExclusive); this.setParents(parents); @@ -88,7 +88,7 @@ public boolean equals(Object obj) { PartitionKeyRange otherRange = (PartitionKeyRange) obj; - return this.id().compareTo(otherRange.id()) == 0 + return this.getId().compareTo(otherRange.getId()) == 0 && this.getMinInclusive().compareTo(otherRange.getMinInclusive()) == 0 && this.getMaxExclusive().compareTo(otherRange.getMaxExclusive()) == 0; } @@ -96,7 +96,7 @@ public boolean equals(Object obj) { @Override public int hashCode() { int hash = 0; - hash = (hash * 397) ^ this.id().hashCode(); + hash = (hash * 397) ^ this.getId().hashCode(); hash = (hash * 397) ^ this.getMinInclusive().hashCode(); hash = (hash * 397) ^ this.getMaxExclusive().hashCode(); return hash; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java index 7bedc56d484f..a2ced808b2ef 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PartitionKeyRangeGoneRetryPolicy.java @@ -68,12 +68,12 @@ public Mono shouldRetry(Exception exception) { return collectionObs.flatMap(collection -> { - Mono routingMapObs = this.partitionKeyRangeCache.tryLookupAsync(collection.resourceId(), null, request.properties); + Mono routingMapObs = this.partitionKeyRangeCache.tryLookupAsync(collection.getResourceId(), null, request.properties); Mono refreshedRoutingMapObs = routingMapObs.flatMap(routingMap -> { // Force refresh. return this.partitionKeyRangeCache.tryLookupAsync( - collection.resourceId(), + collection.getResourceId(), routingMap, request.properties); }).switchIfEmpty(Mono.defer(Mono::empty)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java index 1c3f15ab5362..bccbf8ba9354 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathInfo.java @@ -18,4 +18,4 @@ public PathInfo(boolean isFeed, String resourcePath, String resourceIdOrFullName this.resourceIdOrFullName = resourceIdOrFullName; this.isNameBased = isNameBased; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathParser.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathParser.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathParser.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathParser.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Paths.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Paths.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Paths.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Paths.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathsHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathsHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathsHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/PathsHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java index 6c328b383063..e6955665f839 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Permission.java @@ -35,8 +35,8 @@ public Permission(String jsonString) { * @param id the name of the resource. * @return the current instance of permission */ - public Permission id(String id){ - super.id(id); + public Permission setId(String id){ + super.setId(id); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Quadruple.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Quadruple.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Quadruple.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Quadruple.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java index f8663aa47a85..0ef0346870cb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryCompatibilityMode.java @@ -11,4 +11,4 @@ public enum QueryCompatibilityMode { Default, Query, SqlQuery -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java index cb7abb32fa77..b44b1d65045a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetrics.java @@ -292,4 +292,4 @@ public static QueryMetrics createFromDelimitedStringAndClientSideMetrics(String public String toString() { return toTextString(0); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsConstants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsConstants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryMetricsUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryPreparationTimes.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryPreparationTimes.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryPreparationTimes.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/QueryPreparationTimes.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RMResources.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RMResources.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RMResources.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RMResources.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReadFeedKeyType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReadFeedKeyType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReadFeedKeyType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReadFeedKeyType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RemoteStorageType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RemoteStorageType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RemoteStorageType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RemoteStorageType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java index 06ec1be94708..437ab00aac5f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicy.java @@ -64,7 +64,7 @@ public Mono shouldRetry(Exception e) { Mono collectionObs = this.collectionCache.resolveCollectionAsync(request); return collectionObs.flatMap(collectionInfo -> { - if (!StringUtils.isEmpty(oldCollectionRid) && !StringUtils.isEmpty(collectionInfo.resourceId())) { + if (!StringUtils.isEmpty(oldCollectionRid) && !StringUtils.isEmpty(collectionInfo.getResourceId())) { return Mono.just(ShouldRetryResult.retryAfter(Duration.ZERO)); } return Mono.just(shouldRetryResult); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicatedResourceClientUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicatedResourceClientUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicatedResourceClientUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicatedResourceClientUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicationPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicationPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicationPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ReplicationPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java index 2923e505087c..71755e7860f8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestChargeTracker.java @@ -23,4 +23,4 @@ public void addCharge(double ruUsage) { public double getAndResetCharge() { return (double) this.totalRUs.getAndSet(0) / NUMBER_OF_DECIMAL_POINT_TO_RESERVE_FACTOR; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestOptions.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestOptions.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RequestOptions.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResetSessionTokenRetryPolicyFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResetSessionTokenRetryPolicyFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResetSessionTokenRetryPolicyFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResetSessionTokenRetryPolicyFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceId.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceId.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceId.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceId.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java index 01a2a9215333..441a02ad02a2 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceResponse.java @@ -336,7 +336,7 @@ public Duration getRequestLatency() { return Duration.ZERO; } - return cosmosResponseDiagnostics.requestLatency(); + return cosmosResponseDiagnostics.getRequestLatency(); } /** diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java index 8a84c7bc32a8..5a849eeab5ee 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceThrottleRetryPolicy.java @@ -89,7 +89,7 @@ private Duration checkIfRetryNeeded(Exception exception) { if (dce != null){ if (Exceptions.isStatusCode(dce, HttpConstants.StatusCodes.TOO_MANY_REQUESTS)) { - retryDelay = Duration.ofMillis(dce.retryAfterInMilliseconds()); + retryDelay = Duration.ofMillis(dce.getRetryAfterInMilliseconds()); if (this.backoffDelayFactor > 1) { retryDelay = Duration.ofNanos(retryDelay.toNanos() * this.backoffDelayFactor); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceTokenAuthorizationHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceTokenAuthorizationHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceTokenAuthorizationHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceTokenAuthorizationHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/ResourceType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java index ad8d2de3a4b1..ee8cf2e72df3 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryPolicy.java @@ -18,9 +18,9 @@ public class RetryPolicy implements IRetryPolicyFactory { private final RetryOptions retryOptions; public RetryPolicy(GlobalEndpointManager globalEndpointManager, ConnectionPolicy connectionPolicy) { - this.enableEndpointDiscovery = connectionPolicy.enableEndpointDiscovery(); + this.enableEndpointDiscovery = connectionPolicy.getEnableEndpointDiscovery(); this.globalEndpointManager = globalEndpointManager; - this.retryOptions = connectionPolicy.retryOptions(); + this.retryOptions = connectionPolicy.getRetryOptions(); } @Override diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RetryUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeConstants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeConstants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeExecutionTimes.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeExecutionTimes.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeExecutionTimes.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RuntimeExecutionTimes.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java index 3e0bcc0d1506..29cd4f267f8c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentClientImpl.java @@ -214,7 +214,7 @@ private RxDocumentClientImpl(URI serviceEndpoint, this.userAgentContainer = new UserAgentContainer(); - String userAgentSuffix = this.connectionPolicy.userAgentSuffix(); + String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix(); if (userAgentSuffix != null && userAgentSuffix.length() > 0) { userAgentContainer.setSuffix(userAgentSuffix); } @@ -244,7 +244,7 @@ private void initializeGatewayConfigurationReader() { this.reactorHttpClient); DatabaseAccount databaseAccount = this.gatewayConfigurationReader.initializeReaderAsync().block(); - this.useMultipleWriteLocations = this.connectionPolicy.usingMultipleWriteLocations() && BridgeInternal.isEnableMultipleWriteLocations(databaseAccount); + this.useMultipleWriteLocations = this.connectionPolicy.getUsingMultipleWriteLocations() && BridgeInternal.isEnableMultipleWriteLocations(databaseAccount); // TODO: add support for openAsync // https://msdata.visualstudio.com/CosmosDB/_workitems/edit/332589 @@ -270,7 +270,7 @@ public void init() { this.partitionKeyRangeCache = new RxPartitionKeyRangeCache(RxDocumentClientImpl.this, collectionCache); - if (this.connectionPolicy.connectionMode() == ConnectionMode.GATEWAY) { + if (this.connectionPolicy.getConnectionMode() == ConnectionMode.GATEWAY) { this.storeModel = this.gatewayProxy; } else { this.initializeDirectConnectivity(); @@ -281,7 +281,7 @@ private void initializeDirectConnectivity() { this.storeClientFactory = new StoreClientFactory( this.configs, - this.connectionPolicy.requestTimeoutInMillis() / 1000, + this.connectionPolicy.getRequestTimeoutInMillis() / 1000, // this.maxConcurrentConnectionOpenRequests, 0, this.userAgentContainer @@ -341,10 +341,10 @@ RxGatewayStoreModel createRxGatewayProxy(ISessionContainer sessionContainer, private HttpClient httpClient() { HttpClientConfig httpClientConfig = new HttpClientConfig(this.configs) - .withMaxIdleConnectionTimeoutInMillis(this.connectionPolicy.idleConnectionTimeoutInMillis()) - .withPoolSize(this.connectionPolicy.maxPoolSize()) - .withHttpProxy(this.connectionPolicy.proxy()) - .withRequestTimeoutInMillis(this.connectionPolicy.requestTimeoutInMillis()); + .withMaxIdleConnectionTimeoutInMillis(this.connectionPolicy.getIdleConnectionTimeoutInMillis()) + .withPoolSize(this.connectionPolicy.getMaxPoolSize()) + .withHttpProxy(this.connectionPolicy.getProxy()) + .withRequestTimeoutInMillis(this.connectionPolicy.getRequestTimeoutInMillis()); return HttpClient.createFixed(httpClientConfig); } @@ -411,7 +411,7 @@ private Flux> createDatabaseInternal(Database databas throw new IllegalArgumentException("Database"); } - logger.debug("Creating a Database. id: [{}]", database.id()); + logger.debug("Creating a Database. id: [{}]", database.getId()); validateResource(database); Map requestHeaders = this.getRequestHeaders(options); @@ -574,7 +574,7 @@ private Flux> createCollectionInternal(Stri } logger.debug("Creating a Collection. databaseLink: [{}], Collection id: [{}]", databaseLink, - collection.id()); + collection.getId()); validateResource(collection); String path = Utils.joinPath(databaseLink, Paths.COLLECTIONS_PATH_SEGMENT); @@ -589,7 +589,7 @@ private Flux> createCollectionInternal(Stri return this.create(request).map(response -> toResourceResponse(response, DocumentCollection.class)) .doOnNext(resourceResponse -> { // set the session token - this.sessionContainer.setSessionToken(resourceResponse.getResource().resourceId(), + this.sessionContainer.setSessionToken(resourceResponse.getResource().getResourceId(), getAltLink(resourceResponse.getResource()), resourceResponse.getResponseHeaders()); }); @@ -613,10 +613,10 @@ private Flux> replaceCollectionInternal(Doc throw new IllegalArgumentException("collection"); } - logger.debug("Replacing a Collection. id: [{}]", collection.id()); + logger.debug("Replacing a Collection. id: [{}]", collection.getId()); validateResource(collection); - String path = Utils.joinPath(collection.selfLink(), null); + String path = Utils.joinPath(collection.getSelfLink(), null); Map requestHeaders = this.getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, @@ -632,7 +632,7 @@ private Flux> replaceCollectionInternal(Doc .doOnNext(resourceResponse -> { if (resourceResponse.getResource() != null) { // set the session token - this.sessionContainer.setSessionToken(resourceResponse.getResource().resourceId(), + this.sessionContainer.setSessionToken(resourceResponse.getResource().getResourceId(), getAltLink(resourceResponse.getResource()), resourceResponse.getResponseHeaders()); } @@ -782,13 +782,13 @@ private static String serializeProcedureParams(Object[] objectArray) { } private static void validateResource(Resource resource) { - if (!StringUtils.isEmpty(resource.id())) { - if (resource.id().indexOf('/') != -1 || resource.id().indexOf('\\') != -1 || - resource.id().indexOf('?') != -1 || resource.id().indexOf('#') != -1) { + if (!StringUtils.isEmpty(resource.getId())) { + if (resource.getId().indexOf('/') != -1 || resource.getId().indexOf('\\') != -1 || + resource.getId().indexOf('?') != -1 || resource.getId().indexOf('#') != -1) { throw new IllegalArgumentException("Id contains illegal chars."); } - if (resource.id().endsWith(" ")) { + if (resource.getId().endsWith(" ")) { throw new IllegalArgumentException("Id ends with a space."); } } @@ -815,10 +815,10 @@ private Map getRequestHeaders(RequestOptions options) { } if (options.getAccessCondition() != null) { - if (options.getAccessCondition().type() == AccessConditionType.IF_MATCH) { - headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getAccessCondition().condition()); + if (options.getAccessCondition().getType() == AccessConditionType.IF_MATCH) { + headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getAccessCondition().getCondition()); } else { - headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getAccessCondition().condition()); + headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getAccessCondition().getCondition()); } } @@ -895,7 +895,7 @@ private void addPartitionKeyInformation(RxDocumentServiceRequest request, Docume partitionKeyInternal = BridgeInternal.getNonePartitionKey(partitionKeyDefinition); } else if (options != null && options.getPartitionKey() != null) { partitionKeyInternal = options.getPartitionKey().getInternalPartitionKey(); - } else if (partitionKeyDefinition == null || partitionKeyDefinition.paths().size() == 0) { + } else if (partitionKeyDefinition == null || partitionKeyDefinition.getPaths().size() == 0) { // For backward compatibility, if collection doesn't have partition key defined, we assume all documents // have empty value for it and user doesn't need to specify it explicitly. partitionKeyInternal = PartitionKeyInternal.getEmpty(); @@ -925,7 +925,7 @@ private static PartitionKeyInternal extractPartitionKeyValueFromDocument( Document document, PartitionKeyDefinition partitionKeyDefinition) { if (partitionKeyDefinition != null) { - String path = partitionKeyDefinition.paths().iterator().next(); + String path = partitionKeyDefinition.getPaths().iterator().next(); List parts = PathParser.getPathParts(path); if (parts.size() >= 1) { Object value = document.getObjectByPath(parts); @@ -958,10 +958,10 @@ private Mono getCreateDocumentRequest(String documentC RxDocumentClientImpl.validateResource(typedDocument); - if (typedDocument.id() == null && !disableAutomaticIdGeneration) { + if (typedDocument.getId() == null && !disableAutomaticIdGeneration) { // We are supposed to use GUID. Basically UUID is the same as GUID // when represented as a string. - typedDocument.id(UUID.randomUUID().toString()); + typedDocument.setId(UUID.randomUUID().toString()); } String path = Utils.joinPath(documentCollectionLink, Paths.DOCUMENTS_PATH_SEGMENT); Map requestHeaders = this.getRequestHeaders(options); @@ -1180,7 +1180,7 @@ private Flux> replaceDocumentInternal(String document public Flux> replaceDocument(Document document, RequestOptions options) { IDocumentClientRetryPolicy requestRetryPolicy = this.resetSessionTokenRetryPolicy.getRequestPolicy(); if (options == null || options.getPartitionKey() == null) { - String collectionLink = document.selfLink(); + String collectionLink = document.getSelfLink(); requestRetryPolicy = new PartitionKeyMismatchRetryPolicy(collectionCache, requestRetryPolicy, collectionLink, options); } IDocumentClientRetryPolicy finalRequestRetryPolicy = requestRetryPolicy; @@ -1194,7 +1194,7 @@ private Flux> replaceDocumentInternal(Document docume throw new IllegalArgumentException("document"); } - return this.replaceDocumentInternal(document.selfLink(), document, options, retryPolicyInstance); + return this.replaceDocumentInternal(document.getSelfLink(), document, options, retryPolicyInstance); } catch (Exception e) { logger.debug("Failure in replacing a database due to [{}]", e.getMessage()); @@ -1451,7 +1451,7 @@ private Flux> createStoredProcedureInternal(St try { logger.debug("Creating a StoredProcedure. collectionLink: [{}], storedProcedure id [{}]", - collectionLink, storedProcedure.id()); + collectionLink, storedProcedure.getId()); RxDocumentServiceRequest request = getStoredProcedureRequest(collectionLink, storedProcedure, options, OperationType.Create); if (retryPolicyInstance != null) { @@ -1483,7 +1483,7 @@ private Flux> upsertStoredProcedureInternal(St try { logger.debug("Upserting a StoredProcedure. collectionLink: [{}], storedProcedure id [{}]", - collectionLink, storedProcedure.id()); + collectionLink, storedProcedure.getId()); RxDocumentServiceRequest request = getStoredProcedureRequest(collectionLink, storedProcedure, options, OperationType.Upsert); if (retryPolicyInstance != null) { @@ -1513,11 +1513,11 @@ private Flux> replaceStoredProcedureInternal(S if (storedProcedure == null) { throw new IllegalArgumentException("storedProcedure"); } - logger.debug("Replacing a StoredProcedure. storedProcedure id [{}]", storedProcedure.id()); + logger.debug("Replacing a StoredProcedure. storedProcedure id [{}]", storedProcedure.getId()); RxDocumentClientImpl.validateResource(storedProcedure); - String path = Utils.joinPath(storedProcedure.selfLink(), null); + String path = Utils.joinPath(storedProcedure.getSelfLink(), null); Map requestHeaders = getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.StoredProcedure, path, storedProcedure, requestHeaders, options); @@ -1687,7 +1687,7 @@ private Flux> createTriggerInternal(String collectionL try { logger.debug("Creating a Trigger. collectionLink [{}], trigger id [{}]", collectionLink, - trigger.id()); + trigger.getId()); RxDocumentServiceRequest request = getTriggerRequest(collectionLink, trigger, options, OperationType.Create); if (retryPolicyInstance != null){ @@ -1714,7 +1714,7 @@ private Flux> upsertTriggerInternal(String collectionL try { logger.debug("Upserting a Trigger. collectionLink [{}], trigger id [{}]", collectionLink, - trigger.id()); + trigger.getId()); RxDocumentServiceRequest request = getTriggerRequest(collectionLink, trigger, options, OperationType.Upsert); if (retryPolicyInstance != null){ @@ -1762,10 +1762,10 @@ private Flux> replaceTriggerInternal(Trigger trigger, throw new IllegalArgumentException("trigger"); } - logger.debug("Replacing a Trigger. trigger id [{}]", trigger.id()); + logger.debug("Replacing a Trigger. trigger id [{}]", trigger.getId()); RxDocumentClientImpl.validateResource(trigger); - String path = Utils.joinPath(trigger.selfLink(), null); + String path = Utils.joinPath(trigger.getSelfLink(), null); Map requestHeaders = getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.Trigger, path, trigger, requestHeaders, options); @@ -1881,7 +1881,7 @@ private Flux> createUserDefinedFunctionInt // session) try { logger.debug("Creating a UserDefinedFunction. collectionLink [{}], udf id [{}]", collectionLink, - udf.id()); + udf.getId()); RxDocumentServiceRequest request = getUserDefinedFunctionRequest(collectionLink, udf, options, OperationType.Create); if (retryPolicyInstance != null){ @@ -1912,7 +1912,7 @@ private Flux> upsertUserDefinedFunctionInt // session) try { logger.debug("Upserting a UserDefinedFunction. collectionLink [{}], udf id [{}]", collectionLink, - udf.id()); + udf.getId()); RxDocumentServiceRequest request = getUserDefinedFunctionRequest(collectionLink, udf, options, OperationType.Upsert); if (retryPolicyInstance != null){ @@ -1946,10 +1946,10 @@ private Flux> replaceUserDefinedFunctionIn throw new IllegalArgumentException("udf"); } - logger.debug("Replacing a UserDefinedFunction. udf id [{}]", udf.id()); + logger.debug("Replacing a UserDefinedFunction. udf id [{}]", udf.getId()); validateResource(udf); - String path = Utils.joinPath(udf.selfLink(), null); + String path = Utils.joinPath(udf.getSelfLink(), null); Map requestHeaders = this.getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.UserDefinedFunction, path, udf, requestHeaders, options); @@ -2164,7 +2164,7 @@ public Flux> createUser(String databaseLink, User user, R private Flux> createUserInternal(String databaseLink, User user, RequestOptions options) { try { - logger.debug("Creating a User. databaseLink [{}], user id [{}]", databaseLink, user.id()); + logger.debug("Creating a User. databaseLink [{}], user id [{}]", databaseLink, user.getId()); RxDocumentServiceRequest request = getUserRequest(databaseLink, user, options, OperationType.Create); return this.create(request).map(response -> toResourceResponse(response, User.class)); @@ -2183,7 +2183,7 @@ public Flux> upsertUser(String databaseLink, User user, R private Flux> upsertUserInternal(String databaseLink, User user, RequestOptions options, IDocumentClientRetryPolicy retryPolicyInstance) { try { - logger.debug("Upserting a User. databaseLink [{}], user id [{}]", databaseLink, user.id()); + logger.debug("Upserting a User. databaseLink [{}], user id [{}]", databaseLink, user.getId()); RxDocumentServiceRequest request = getUserRequest(databaseLink, user, options, OperationType.Upsert); if (retryPolicyInstance != null) { retryPolicyInstance.onBeforeSendRequest(request); @@ -2227,10 +2227,10 @@ private Flux> replaceUserInternal(User user, RequestOptio if (user == null) { throw new IllegalArgumentException("user"); } - logger.debug("Replacing a User. user id [{}]", user.id()); + logger.debug("Replacing a User. user id [{}]", user.getId()); RxDocumentClientImpl.validateResource(user); - String path = Utils.joinPath(user.selfLink(), null); + String path = Utils.joinPath(user.getSelfLink(), null); Map requestHeaders = getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.User, path, user, requestHeaders, options); @@ -2336,7 +2336,7 @@ private Flux> createPermissionInternal(String userL RequestOptions options) { try { - logger.debug("Creating a Permission. userLink [{}], permission id [{}]", userLink, permission.id()); + logger.debug("Creating a Permission. userLink [{}], permission id [{}]", userLink, permission.getId()); RxDocumentServiceRequest request = getPermissionRequest(userLink, permission, options, OperationType.Create); return this.create(request).map(response -> toResourceResponse(response, Permission.class)); @@ -2358,7 +2358,7 @@ private Flux> upsertPermissionInternal(String userL RequestOptions options, IDocumentClientRetryPolicy retryPolicyInstance) { try { - logger.debug("Upserting a Permission. userLink [{}], permission id [{}]", userLink, permission.id()); + logger.debug("Upserting a Permission. userLink [{}], permission id [{}]", userLink, permission.getId()); RxDocumentServiceRequest request = getPermissionRequest(userLink, permission, options, OperationType.Upsert); if (retryPolicyInstance != null) { @@ -2403,10 +2403,10 @@ private Flux> replacePermissionInternal(Permission if (permission == null) { throw new IllegalArgumentException("permission"); } - logger.debug("Replacing a Permission. permission id [{}]", permission.id()); + logger.debug("Replacing a Permission. permission id [{}]", permission.getId()); RxDocumentClientImpl.validateResource(permission); - String path = Utils.joinPath(permission.selfLink(), null); + String path = Utils.joinPath(permission.getSelfLink(), null); Map requestHeaders = getRequestHeaders(options); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.Permission, path, permission, requestHeaders, options); @@ -2515,10 +2515,10 @@ private Flux> replaceOfferInternal(Offer offer) { if (offer == null) { throw new IllegalArgumentException("offer"); } - logger.debug("Replacing an Offer. offer id [{}]", offer.id()); + logger.debug("Replacing an Offer. offer id [{}]", offer.getId()); RxDocumentClientImpl.validateResource(offer); - String path = Utils.joinPath(offer.selfLink(), null); + String path = Utils.joinPath(offer.getSelfLink(), null); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.Offer, path, offer, null, null); return this.replace(request).map(response -> toResourceResponse(response, Offer.class)); @@ -2681,7 +2681,7 @@ public Flux getDatabaseAccountFromEndpoint(URI endpoint) { logger.warn(message); }).map(rsp -> rsp.getResource(DatabaseAccount.class)) .doOnNext(databaseAccount -> { - this.useMultipleWriteLocations = this.connectionPolicy.usingMultipleWriteLocations() + this.useMultipleWriteLocations = this.connectionPolicy.getUsingMultipleWriteLocations() && BridgeInternal.isEnableMultipleWriteLocations(databaseAccount); }); }); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java index 8687dcceb840..2d1b513dbb38 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceRequest.java @@ -442,14 +442,14 @@ public static RxDocumentServiceRequest create(ResourceType resourceType, String queryText; switch (queryCompatibilityMode) { case SqlQuery: - if (querySpec.parameters() != null && querySpec.parameters().size() > 0) { + if (querySpec.getParameters() != null && querySpec.getParameters().size() > 0) { throw new IllegalArgumentException( String.format("Unsupported argument in query compatibility mode '{%s}'", queryCompatibilityMode.toString())); } operation = OperationType.SqlQuery; - queryText = querySpec.queryText(); + queryText = querySpec.getQueryText(); break; case Default: @@ -1021,7 +1021,7 @@ private static Map getProperties(Object options) { } else if (options instanceof FeedOptions) { return ((FeedOptions) options).properties(); } else if (options instanceof ChangeFeedOptions) { - return ((ChangeFeedOptions) options).properties(); + return ((ChangeFeedOptions) options).getProperties(); } else { return null; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java index e7d134931b99..18eaf7d79774 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxDocumentServiceResponse.java @@ -101,7 +101,7 @@ public T getResource(Class c) { throw new IllegalStateException("Failed to instantiate class object.", e); } if(PathsHelper.isPublicResource(resource)) { - BridgeInternal.setAltLink(resource, PathsHelper.generatePathForNameBased(resource, this.getOwnerFullName(),resource.id())); + BridgeInternal.setAltLink(resource, PathsHelper.generatePathForNameBased(resource, this.getOwnerFullName(),resource.getId())); } return resource; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java index d76d639d5036..ea951d56f794 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxGatewayStoreModel.java @@ -411,7 +411,7 @@ private Flux invokeAsyncInternal(RxDocumentServiceReq case Query: return this.query(request); default: - throw new IllegalStateException("Unknown operation type " + request.getOperationType()); + throw new IllegalStateException("Unknown operation setType " + request.getOperationType()); } } @@ -436,13 +436,13 @@ public Flux processMessage(RxDocumentServiceRequest r } if ((!ReplicatedResourceClientUtils.isMasterResource(request.getResourceType())) && - (dce.statusCode() == HttpConstants.StatusCodes.PRECONDITION_FAILED || - dce.statusCode() == HttpConstants.StatusCodes.CONFLICT || + (dce.getStatusCode() == HttpConstants.StatusCodes.PRECONDITION_FAILED || + dce.getStatusCode() == HttpConstants.StatusCodes.CONFLICT || ( - dce.statusCode() == HttpConstants.StatusCodes.NOTFOUND && + dce.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND && !Exceptions.isSubStatusCode(dce, HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE)))) { - this.captureSessionToken(request, dce.responseHeaders()); + this.captureSessionToken(request, dce.getResponseHeaders()); } return Flux.error(dce); @@ -498,4 +498,4 @@ private void applySessionToken(RxDocumentServiceRequest request) { headers.put(HttpConstants.HttpHeaders.SESSION_TOKEN, sessionToken); } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxStoreModel.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxStoreModel.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxStoreModel.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/RxStoreModel.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionContainer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionContainer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionContainer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java index aac7089214b5..ebb09a508dfd 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/SessionTokenHelper.java @@ -36,7 +36,7 @@ public static void setOriginalSessionToken(RxDocumentServiceRequest request, Str public static void setPartitionLocalSessionToken(RxDocumentServiceRequest request, ISessionContainer sessionContainer) throws CosmosClientException { String originalSessionToken = request.getHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); - String partitionKeyRangeId = request.requestContext.resolvedPartitionKeyRange.id(); + String partitionKeyRangeId = request.requestContext.resolvedPartitionKeyRange.getId(); if (Strings.isNullOrEmpty(partitionKeyRangeId)) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java index 698183c88b7f..e4dfaee1af9d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedure.java @@ -36,8 +36,8 @@ public StoredProcedure(String jsonString) { * @param id the name of the resource. * @return the current stored procedure */ - public StoredProcedure id(String id){ - super.id(id); + public StoredProcedure setId(String id){ + super.setId(id); return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedureResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedureResponse.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedureResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/StoredProcedureResponse.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Strings.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Strings.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Strings.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Strings.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/TestConfigurations.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/TestConfigurations.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/TestConfigurations.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/TestConfigurations.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Trigger.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Trigger.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Trigger.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Trigger.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Undefined.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Undefined.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Undefined.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Undefined.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java index bc1f77e8778a..412fc44a1e7d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/User.java @@ -31,8 +31,8 @@ public User(String jsonString) { * @param id the name of the resource. * @return the current instance of User */ - public User id(String id){ - super.id(id); + public User setId(String id){ + super.setId(id); return this; } @@ -42,7 +42,7 @@ public User id(String id){ * @return the permissions link. */ public String getPermissionsLink() { - String selfLink = this.selfLink(); + String selfLink = this.getSelfLink(); if (selfLink.endsWith("/")) { return selfLink + super.getString(Constants.Properties.PERMISSIONS_LINK); } else { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserAgentContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserAgentContainer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserAgentContainer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserAgentContainer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserDefinedFunction.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserDefinedFunction.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserDefinedFunction.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/UserDefinedFunction.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java index 5f7d08012be4..8139279de910 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/Utils.java @@ -310,8 +310,8 @@ public static Boolean isCollectionPartitioned(DocumentCollection collection) { } return collection.getPartitionKey() != null - && collection.getPartitionKey().paths() != null - && collection.getPartitionKey().paths().size() > 0; + && collection.getPartitionKey().getPaths() != null + && collection.getPartitionKey().getPaths().size() > 0; } public static boolean isCollectionChild(ResourceType type) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/VectorSessionToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/VectorSessionToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/VectorSessionToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/VectorSessionToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/WebExceptionRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/WebExceptionRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/WebExceptionRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/WebExceptionRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncCache.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncCache.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncLazy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncLazy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncLazy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/AsyncLazy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IEqualityComparer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IEqualityComparer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IEqualityComparer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IEqualityComparer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IPartitionKeyRangeCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IPartitionKeyRangeCache.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IPartitionKeyRangeCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/IPartitionKeyRangeCache.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxClientCollectionCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxClientCollectionCache.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxClientCollectionCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxClientCollectionCache.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java index a3c707a02f80..3ba229bd85e6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxCollectionCache.java @@ -60,12 +60,12 @@ public Mono resolveCollectionAsync( return collectionInfoRes.flatMap(collection -> { // TODO: how to async log this? // logger.debug( - // "Mapped resourceName {} to resourceId {}.", + // "Mapped resourceName {} to getResourceId {}.", // request.getResourceAddress(), - // collectionInfo.resourceId()); + // collectionInfo.getResourceId()); - request.setResourceId(collection.resourceId()); - request.requestContext.resolvedCollectionRid = collection.resourceId(); + request.setResourceId(collection.getResourceId()); + request.requestContext.resolvedCollectionRid = collection.getResourceId(); return Mono.just(collection); }); @@ -91,7 +91,7 @@ public void refresh(String resourceAddress, Map properties) { resourceFullName, () -> { Mono collectionObs = this.getByNameAsync(resourceFullName, properties); - return collectionObs.doOnSuccess(collection -> this.collectionInfoByIdCache.set(collection.resourceId(), collection)); + return collectionObs.doOnSuccess(collection -> this.collectionInfoByIdCache.set(collection.getResourceId(), collection)); }); } } @@ -140,7 +140,7 @@ private Mono resolveByNameAsync( null, () -> { Mono collectionObs = this.getByNameAsync(resourceFullName, properties); - return collectionObs.doOnSuccess(collection -> this.collectionInfoByIdCache.set(collection.resourceId(), collection)); + return collectionObs.doOnSuccess(collection -> this.collectionInfoByIdCache.set(collection.getResourceId(), collection)); }); } @@ -153,7 +153,7 @@ private Mono refreshAsync(RxDocumentServiceRequest request) { if (request.requestContext.resolvedCollectionRid != null) { // Here we will issue backend call only if cache wasn't already refreshed (if whatever is there corresponds to previously resolved collection rid). DocumentCollection obsoleteValue = new DocumentCollection(); - obsoleteValue.resourceId(request.requestContext.resolvedCollectionRid); + obsoleteValue.setResourceId(request.requestContext.resolvedCollectionRid); mono = this.collectionInfoByNameCache.getAsync( resourceFullName, @@ -161,7 +161,7 @@ private Mono refreshAsync(RxDocumentServiceRequest request) { () -> { Mono collectionObs = this.getByNameAsync(resourceFullName, request.properties); return collectionObs.doOnSuccess(collection -> { - this.collectionInfoByIdCache.set(collection.resourceId(), collection); + this.collectionInfoByIdCache.set(collection.getResourceId(), collection); }); }).then(); } else { @@ -183,7 +183,7 @@ public boolean areEqual(DocumentCollection left, DocumentCollection right) { return false; } - return StringUtils.equals(left.resourceId(), right.resourceId()); + return StringUtils.equals(left.getResourceId(), right.getResourceId()); } } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java index 92d0c6f90ec6..cfa43b4ac31b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/caches/RxPartitionKeyRangeCache.java @@ -166,7 +166,7 @@ private Mono getRoutingMapForCollectionAsync( Set goneRanges = new HashSet<>(ranges.stream().flatMap(range -> CollectionUtils.emptyIfNull(range.getParents()).stream()).collect(Collectors.toSet())); routingMap = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap( - rangesTuples.stream().filter(tuple -> !goneRanges.contains(tuple.left.id())).collect(Collectors.toList()), + rangesTuples.stream().filter(tuple -> !goneRanges.contains(tuple.left.getId())).collect(Collectors.toList()), collectionRid); } else @@ -201,9 +201,9 @@ private Mono> getPartitionKeyRange(String collectionRid, if (properties != null) { feedOptions.properties(properties); } - return client.readPartitionKeyRanges(coll.selfLink(), feedOptions) - // maxConcurrent = 1 to makes it in the right order - .flatMap(p -> Flux.fromIterable(p.results()), 1).collectList(); + return client.readPartitionKeyRanges(coll.getSelfLink(), feedOptions) + // maxConcurrent = 1 to makes it in the right getOrder + .flatMap(p -> Flux.fromIterable(p.getResults()), 1).collectList(); }); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Bootstrapper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Bootstrapper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Bootstrapper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Bootstrapper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationTokenSource.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationTokenSource.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationTokenSource.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CancellationTokenSource.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java similarity index 69% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java index fb97b0cf5510..731bfd96de24 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedContextClient.java @@ -2,21 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed; -import com.azure.data.cosmos.ChangeFeedOptions; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.CosmosDatabaseResponse; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.PartitionKeyRange; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -43,7 +30,7 @@ public interface ChangeFeedContextClient { * @param feedOptions The options for processing the query results feed. * @return an {@link Flux} containing one or several feed response pages of the obtained items or an error. */ - Flux> createDocumentChangeFeedQuery(CosmosContainer collectionLink, ChangeFeedOptions feedOptions); + Flux> createDocumentChangeFeedQuery(CosmosAsyncContainer collectionLink, ChangeFeedOptions feedOptions); /** * Reads a database. @@ -52,19 +39,19 @@ public interface ChangeFeedContextClient { * @param options the {@link CosmosContainerRequestOptions} for this request; it can be set as null. * @return an {@link Mono} containing the single cosmos database response with the read database or an error. */ - Mono readDatabase(CosmosDatabase database, CosmosDatabaseRequestOptions options); + Mono readDatabase(CosmosAsyncDatabase database, CosmosDatabaseRequestOptions options); /** - * Reads a {@link CosmosContainer}. + * Reads a {@link CosmosAsyncContainer}. * * @param containerLink a reference to the container. * @param options the {@link CosmosContainerRequestOptions} for this request; it can be set as null. * @return an {@link Mono} containing the single cosmos container response with the read container or an error. */ - Mono readContainer(CosmosContainer containerLink, CosmosContainerRequestOptions options); + Mono readContainer(CosmosAsyncContainer containerLink, CosmosContainerRequestOptions options); /** - * Creates a {@link CosmosItem}. + * Creates a {@link CosmosAsyncItem}. * * @param containerLink the reference to the parent container. * @param document the document represented as a POJO or Document object. @@ -72,36 +59,36 @@ public interface ChangeFeedContextClient { * @param disableAutomaticIdGeneration the flag for disabling automatic id generation. * @return an {@link Mono} containing the single resource response with the created cosmos item or an error. */ - Mono createItem(CosmosContainer containerLink, Object document, CosmosItemRequestOptions options, - boolean disableAutomaticIdGeneration); + Mono createItem(CosmosAsyncContainer containerLink, Object document, CosmosItemRequestOptions options, + boolean disableAutomaticIdGeneration); /** - * DELETE a {@link CosmosItem}. + * DELETE a {@link CosmosAsyncItem}. * * @param itemLink the item reference. * @param options the request options. * @return an {@link Mono} containing the cosmos item resource response with the deleted item or an error. */ - Mono deleteItem(CosmosItem itemLink, CosmosItemRequestOptions options); + Mono deleteItem(CosmosAsyncItem itemLink, CosmosItemRequestOptions options); /** - * Replaces a {@link CosmosItem}. + * Replaces a {@link CosmosAsyncItem}. * * @param itemLink the item reference. * @param document the document represented as a POJO or Document object. * @param options the request options. * @return an {@link Mono} containing the cosmos item resource response with the replaced item or an error. */ - Mono replaceItem(CosmosItem itemLink, Object document, CosmosItemRequestOptions options); + Mono replaceItem(CosmosAsyncItem itemLink, Object document, CosmosItemRequestOptions options); /** - * Reads a {@link CosmosItem} + * Reads a {@link CosmosAsyncItem} * * @param itemLink the item reference. * @param options the request options. * @return an {@link Mono} containing the cosmos item resource response with the read item or an error. */ - Mono readItem(CosmosItem itemLink, CosmosItemRequestOptions options); + Mono readItem(CosmosAsyncItem itemLink, CosmosItemRequestOptions options); /** * Query for items in a document container. @@ -111,7 +98,7 @@ Mono createItem(CosmosContainer containerLink, Object docume * @param options the feed options. * @return an {@link Flux} containing one or several feed response pages of the obtained items or an error. */ - Flux> queryItems(CosmosContainer containerLink, SqlQuerySpec querySpec, FeedOptions options); + Flux> queryItems(CosmosAsyncContainer containerLink, SqlQuerySpec querySpec, FeedOptions options); /** * @return the Cosmos client's service endpoint. @@ -125,17 +112,17 @@ Mono createItem(CosmosContainer containerLink, Object docume * @param options the {@link CosmosContainerRequestOptions} for this request; it can be set as null. * @return an {@link Mono} containing the read container properties. */ - Mono readContainerSettings(CosmosContainer containerLink, CosmosContainerRequestOptions options); + Mono readContainerSettings(CosmosAsyncContainer containerLink, CosmosContainerRequestOptions options); /** * @return the Cosmos container client. */ - CosmosContainer getContainerClient(); + CosmosAsyncContainer getContainerClient(); /** * @return the Cosmos database client. */ - CosmosDatabase getDatabaseClient(); + CosmosAsyncDatabase getDatabaseClient(); /** * Closes the document client instance and cleans up the resources. diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserver.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserver.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverCloseReason.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverCloseReason.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverCloseReason.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverCloseReason.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverContext.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverContext.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ChangeFeedObserverFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CheckpointFrequency.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CheckpointFrequency.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CheckpointFrequency.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/CheckpointFrequency.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitor.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitor.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitor.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitor.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitoringRecord.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitoringRecord.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitoringRecord.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/HealthMonitoringRecord.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Lease.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Lease.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Lease.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/Lease.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseCheckpointer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseCheckpointer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseCheckpointer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseCheckpointer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseContainer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseContainer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseContainer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseManager.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseManager.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseManager.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseManager.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseRenewer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseRenewer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseRenewer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseRenewer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStore.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStore.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStore.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStore.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java index 25faa43d6519..b196dc8e4ca5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManager.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed; -import com.azure.data.cosmos.CosmosContainer; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.changefeed.implementation.LeaseStoreManagerImpl; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -15,7 +15,7 @@ public interface LeaseStoreManager extends LeaseContainer, LeaseManager, LeaseStore, LeaseCheckpointer { /** - * Provides flexible way to build lease manager constructor parameters. + * Provides flexible way to buildAsyncClient lease manager constructor parameters. * For the actual creation of lease manager instance, delegates to lease manager factory. */ interface LeaseStoreManagerBuilderDefinition { @@ -23,7 +23,7 @@ interface LeaseStoreManagerBuilderDefinition { LeaseStoreManagerBuilderDefinition leasePrefix(String leasePrefix); - LeaseStoreManagerBuilderDefinition leaseCollectionLink(CosmosContainer leaseCollectionLink); + LeaseStoreManagerBuilderDefinition leaseCollectionLink(CosmosAsyncContainer leaseCollectionLink); LeaseStoreManagerBuilderDefinition requestOptionsFactory(RequestOptionsFactory requestOptionsFactory); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java similarity index 83% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java index ae8f6ca544d7..456e42489d96 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/LeaseStoreManagerSettings.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed; -import com.azure.data.cosmos.CosmosContainer; +import com.azure.data.cosmos.CosmosAsyncContainer; /** * Captures LeaseStoreManager properties. @@ -10,7 +10,7 @@ public class LeaseStoreManagerSettings { String containerNamePrefix; - CosmosContainer leaseCollectionLink; + CosmosAsyncContainer leaseCollectionLink; String hostName; @@ -23,11 +23,11 @@ public LeaseStoreManagerSettings withContainerNamePrefix(String containerNamePre return this; } - public CosmosContainer getLeaseCollectionLink() { + public CosmosAsyncContainer getLeaseCollectionLink() { return this.leaseCollectionLink; } - public LeaseStoreManagerSettings withLeaseCollectionLink(CosmosContainer collectionLink) { + public LeaseStoreManagerSettings withLeaseCollectionLink(CosmosAsyncContainer collectionLink) { this.leaseCollectionLink = collectionLink; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionCheckpointer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionCheckpointer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionCheckpointer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionCheckpointer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionController.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionController.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionController.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionController.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancingStrategy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancingStrategy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancingStrategy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionLoadBalancingStrategy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionManager.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionManager.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionManager.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionManager.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessor.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessor.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessor.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessor.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessorFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessorFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessorFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionProcessorFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisor.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisor.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisor.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisor.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisorFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisorFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisorFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSupervisorFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSynchronizer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSynchronizer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSynchronizer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/PartitionSynchronizer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java index 20894cd7ad51..7fcf643a28f5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ProcessorSettings.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed; -import com.azure.data.cosmos.CosmosContainer; +import com.azure.data.cosmos.CosmosAsyncContainer; import java.time.Duration; import java.time.OffsetDateTime; @@ -11,7 +11,7 @@ * Implementation for the partition processor properties. */ public class ProcessorSettings { - private CosmosContainer collectionSelfLink; + private CosmosAsyncContainer collectionSelfLink; private String partitionKeyRangeId; private Integer maxItemCount; private Duration feedPollDelay; @@ -19,11 +19,11 @@ public class ProcessorSettings { private OffsetDateTime startTime; // private STRING sessionToken; - public CosmosContainer getCollectionSelfLink() { + public CosmosAsyncContainer getCollectionSelfLink() { return this.collectionSelfLink; } - public ProcessorSettings withCollectionLink(CosmosContainer collectionLink) { + public ProcessorSettings withCollectionLink(CosmosAsyncContainer collectionLink) { this.collectionSelfLink = collectionLink; return this; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingPartitionWork.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingPartitionWork.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingPartitionWork.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingPartitionWork.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingWorkEstimator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingWorkEstimator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingWorkEstimator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RemainingWorkEstimator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RequestOptionsFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RequestOptionsFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RequestOptionsFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/RequestOptionsFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java index c989c823b5d0..5cb1f912d904 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLease.java @@ -193,8 +193,8 @@ public String getConcurrencyToken() { public static ServiceItemLease fromDocument(Document document) { ServiceItemLease lease = new ServiceItemLease() - .withId(document.id()) - .withEtag(document.etag()) + .withId(document.getId()) + .withEtag(document.getETag()) .withTs(document.getString(Constants.Properties.LAST_MODIFIED)) .withOwner(document.getString("Owner")) .withLeaseToken(document.getString("LeaseToken")) @@ -210,8 +210,8 @@ public static ServiceItemLease fromDocument(Document document) { public static ServiceItemLease fromDocument(CosmosItemProperties document) { ServiceItemLease lease = new ServiceItemLease() - .withId(document.id()) - .withEtag(document.etag()) + .withId(document.getId()) + .withEtag(document.getETag()) .withTs(document.getString(Constants.Properties.LAST_MODIFIED)) .withOwner(document.getString("Owner")) .withLeaseToken(document.getString("LeaseToken")) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java similarity index 65% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java index 2dfbca01ff7d..a87582279e47 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/ServiceItemLeaseUpdater.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed; -import com.azure.data.cosmos.CosmosItem; +import com.azure.data.cosmos.CosmosAsyncItem; import com.azure.data.cosmos.CosmosItemRequestOptions; import reactor.core.publisher.Mono; @@ -12,5 +12,5 @@ * Interface for service lease updater. */ public interface ServiceItemLeaseUpdater { - Mono updateLease(Lease cachedLease, CosmosItem itemLink, CosmosItemRequestOptions requestOptions, Function updateLease); + Mono updateLease(Lease cachedLease, CosmosAsyncItem itemLink, CosmosItemRequestOptions requestOptions, Function updateLease); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/LeaseLostException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/LeaseLostException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/LeaseLostException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/LeaseLostException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/ObserverException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/ObserverException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/ObserverException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/ObserverException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionNotFoundException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionNotFoundException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionNotFoundException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionNotFoundException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionSplitException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionSplitException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionSplitException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/PartitionSplitException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/TaskCancelledException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/TaskCancelledException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/TaskCancelledException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/exceptions/TaskCancelledException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/AutoCheckpointer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/AutoCheckpointer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/AutoCheckpointer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/AutoCheckpointer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/BootstrapperImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/BootstrapperImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/BootstrapperImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/BootstrapperImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java similarity index 65% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java index 0f28122fa5be..2815df4e6a52 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedContextClientImpl.java @@ -2,22 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; +import com.azure.data.cosmos.*; import com.azure.data.cosmos.internal.AsyncDocumentClient; -import com.azure.data.cosmos.ChangeFeedOptions; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.CosmosDatabaseResponse; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.PartitionKeyRange; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; import org.slf4j.Logger; @@ -38,14 +25,14 @@ public class ChangeFeedContextClientImpl implements ChangeFeedContextClient { private final Logger logger = LoggerFactory.getLogger(ChangeFeedContextClientImpl.class); private final AsyncDocumentClient documentClient; - private final CosmosContainer cosmosContainer; + private final CosmosAsyncContainer cosmosContainer; private Scheduler rxScheduler; /** * Initializes a new instance of the {@link ChangeFeedContextClient} interface. * @param cosmosContainer existing client. */ - public ChangeFeedContextClientImpl(CosmosContainer cosmosContainer) { + public ChangeFeedContextClientImpl(CosmosAsyncContainer cosmosContainer) { if (cosmosContainer == null) { throw new IllegalArgumentException("cosmosContainer"); } @@ -60,7 +47,7 @@ public ChangeFeedContextClientImpl(CosmosContainer cosmosContainer) { * @param cosmosContainer existing client. * @param rxScheduler the RX Java scheduler to observe on. */ - public ChangeFeedContextClientImpl(CosmosContainer cosmosContainer, Scheduler rxScheduler) { + public ChangeFeedContextClientImpl(CosmosAsyncContainer cosmosContainer, Scheduler rxScheduler) { if (cosmosContainer == null) { throw new IllegalArgumentException("cosmosContainer"); } @@ -78,25 +65,25 @@ public Flux> readPartitionKeyRangeFeed(String pa } @Override - public Flux> createDocumentChangeFeedQuery(CosmosContainer collectionLink, ChangeFeedOptions feedOptions) { + public Flux> createDocumentChangeFeedQuery(CosmosAsyncContainer collectionLink, ChangeFeedOptions feedOptions) { return collectionLink.queryChangeFeedItems(feedOptions) .publishOn(this.rxScheduler); } @Override - public Mono readDatabase(CosmosDatabase database, CosmosDatabaseRequestOptions options) { + public Mono readDatabase(CosmosAsyncDatabase database, CosmosDatabaseRequestOptions options) { return database.read() .publishOn(this.rxScheduler); } @Override - public Mono readContainer(CosmosContainer containerLink, CosmosContainerRequestOptions options) { + public Mono readContainer(CosmosAsyncContainer containerLink, CosmosContainerRequestOptions options) { return containerLink.read(options) .publishOn(this.rxScheduler); } @Override - public Mono createItem(CosmosContainer containerLink, Object document, CosmosItemRequestOptions options, boolean disableAutomaticIdGeneration) { + public Mono createItem(CosmosAsyncContainer containerLink, Object document, CosmosItemRequestOptions options, boolean disableAutomaticIdGeneration) { if (options != null) { return containerLink.createItem(document, options) .publishOn(this.rxScheduler); @@ -107,25 +94,25 @@ public Mono createItem(CosmosContainer containerLink, Object } @Override - public Mono deleteItem(CosmosItem itemLink, CosmosItemRequestOptions options) { + public Mono deleteItem(CosmosAsyncItem itemLink, CosmosItemRequestOptions options) { return itemLink.delete(options) .publishOn(this.rxScheduler); } @Override - public Mono replaceItem(CosmosItem itemLink, Object document, CosmosItemRequestOptions options) { + public Mono replaceItem(CosmosAsyncItem itemLink, Object document, CosmosItemRequestOptions options) { return itemLink.replace(document, options) .publishOn(this.rxScheduler); } @Override - public Mono readItem(CosmosItem itemLink, CosmosItemRequestOptions options) { + public Mono readItem(CosmosAsyncItem itemLink, CosmosItemRequestOptions options) { return itemLink.read(options) .publishOn(this.rxScheduler); } @Override - public Flux> queryItems(CosmosContainer containerLink, SqlQuerySpec querySpec, FeedOptions options) { + public Flux> queryItems(CosmosAsyncContainer containerLink, SqlQuerySpec querySpec, FeedOptions options) { return containerLink.queryItems(querySpec, options) .publishOn(this.rxScheduler); } @@ -136,18 +123,18 @@ public URI getServiceEndpoint() { } @Override - public Mono readContainerSettings(CosmosContainer containerLink, CosmosContainerRequestOptions options) { + public Mono readContainerSettings(CosmosAsyncContainer containerLink, CosmosContainerRequestOptions options) { return containerLink.read(options) - .map(cosmosContainerResponse -> cosmosContainerResponse.properties()); + .map(cosmosContainerResponse -> cosmosContainerResponse.getProperties()); } @Override - public CosmosContainer getContainerClient() { + public CosmosAsyncContainer getContainerClient() { return this.cosmosContainer; } @Override - public CosmosDatabase getDatabaseClient() { + public CosmosAsyncDatabase getDatabaseClient() { return this.cosmosContainer.getDatabase(); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java index d15d45a486c0..440cb3c88eb4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverContextImpl.java @@ -41,7 +41,7 @@ public ChangeFeedObserverContextImpl(String leaseToken, FeedResponse checkpoint() { - this.responseContinuation = this.feedResponse.continuationToken(); + this.responseContinuation = this.feedResponse.getContinuationToken(); return this.checkpointer.checkpointPartition(this.responseContinuation); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverFactoryImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverFactoryImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverFactoryImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedObserverFactoryImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java index dfcbaddadcf1..31d4f407861c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ChangeFeedProcessorBuilderImpl.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.ChangeFeedProcessor; import com.azure.data.cosmos.ChangeFeedProcessorOptions; -import com.azure.data.cosmos.CosmosContainer; import com.azure.data.cosmos.CosmosItemProperties; import com.azure.data.cosmos.internal.changefeed.Bootstrapper; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; @@ -31,20 +31,20 @@ import java.util.function.Consumer; /** - * Helper class to build {@link ChangeFeedProcessor} instances + * Helper class to buildAsyncClient {@link ChangeFeedProcessor} instances * as logical representation of the Azure Cosmos DB database service. * *
  * {@code
  *  ChangeFeedProcessor.Builder()
- *     .hostName(hostName)
- *     .feedContainer(feedContainer)
- *     .leaseContainer(leaseContainer)
- *     .handleChanges(docs -> {
+ *     .setHostName(setHostName)
+ *     .setFeedContainer(setFeedContainer)
+ *     .setLeaseContainer(setLeaseContainer)
+ *     .setHandleChanges(docs -> {
  *         // Implementation for handling and processing CosmosItemProperties list goes here
  *      })
  *     .observer(SampleObserverImpl.class)
- *     .build();
+ *     .buildAsyncClient();
  * }
  * 
*/ @@ -114,19 +114,19 @@ public Mono stop() { * @return current Builder. */ @Override - public ChangeFeedProcessorBuilderImpl hostName(String hostName) { + public ChangeFeedProcessorBuilderImpl setHostName(String hostName) { this.hostName = hostName; return this; } /** - * Sets and existing {@link CosmosContainer} to be used to read from the monitored collection. + * Sets and existing {@link CosmosAsyncContainer} to be used to read from the monitored collection. * - * @param feedDocumentClient the instance of {@link CosmosContainer} to be used. + * @param feedDocumentClient the instance of {@link CosmosAsyncContainer} to be used. * @return current Builder. */ @Override - public ChangeFeedProcessorBuilderImpl feedContainer(CosmosContainer feedDocumentClient) { + public ChangeFeedProcessorBuilderImpl setFeedContainer(CosmosAsyncContainer feedDocumentClient) { if (feedDocumentClient == null) { throw new IllegalArgumentException("feedContextClient"); } @@ -142,7 +142,7 @@ public ChangeFeedProcessorBuilderImpl feedContainer(CosmosContainer feedDocument * @return current Builder. */ @Override - public ChangeFeedProcessorBuilderImpl options(ChangeFeedProcessorOptions changeFeedProcessorOptions) { + public ChangeFeedProcessorBuilderImpl setOptions(ChangeFeedProcessorOptions changeFeedProcessorOptions) { if (changeFeedProcessorOptions == null) { throw new IllegalArgumentException("changeFeedProcessorOptions"); } @@ -183,7 +183,7 @@ public ChangeFeedProcessorBuilderImpl observer(Class> consumer) { + public ChangeFeedProcessorBuilderImpl setHandleChanges(Consumer> consumer) { return this.observerFactory(new DefaultObserverFactory(consumer)); } @@ -209,13 +209,13 @@ public ChangeFeedProcessorBuilderImpl withCollectionResourceId(String collection } /** - * Sets an existing {@link CosmosContainer} to be used to read from the leases collection. + * Sets an existing {@link CosmosAsyncContainer} to be used to read from the leases collection. * - * @param leaseDocumentClient the instance of {@link CosmosContainer} to use. + * @param leaseDocumentClient the instance of {@link CosmosAsyncContainer} to use. * @return current Builder. */ @Override - public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosContainer leaseDocumentClient) { + public ChangeFeedProcessorBuilderImpl setLeaseContainer(CosmosAsyncContainer leaseDocumentClient) { if (leaseDocumentClient == null) { throw new IllegalArgumentException("leaseContextClient"); } @@ -323,13 +323,13 @@ private Mono initializeCollectionPropertiesForBuild() { return this.feedContextClient .readDatabase(this.feedContextClient.getDatabaseClient(), null) .map( databaseResourceResponse -> { - this.databaseResourceId = databaseResourceResponse.database().id(); + this.databaseResourceId = databaseResourceResponse.getDatabase().getId(); return this.databaseResourceId; }) .flatMap( id -> this.feedContextClient .readContainer(this.feedContextClient.getContainerClient(), null) .map(documentCollectionResourceResponse -> { - this.collectionResourceId = documentCollectionResourceResponse.container().id(); + this.collectionResourceId = documentCollectionResourceResponse.getContainer().getId(); return this; })); } @@ -340,10 +340,10 @@ private Mono getLeaseStoreManager() { return this.leaseContextClient.readContainerSettings(this.leaseContextClient.getContainerClient(), null) .flatMap( collectionSettings -> { boolean isPartitioned = - collectionSettings.partitionKeyDefinition() != null && - collectionSettings.partitionKeyDefinition().paths() != null && - collectionSettings.partitionKeyDefinition().paths().size() > 0; - if (!isPartitioned || (collectionSettings.partitionKeyDefinition().paths().size() != 1 || !collectionSettings.partitionKeyDefinition().paths().get(0).equals("/id"))) { + collectionSettings.getPartitionKeyDefinition() != null && + collectionSettings.getPartitionKeyDefinition().getPaths() != null && + collectionSettings.getPartitionKeyDefinition().getPaths().size() > 0; + if (!isPartitioned || (collectionSettings.getPartitionKeyDefinition().getPaths().size() != 1 || !collectionSettings.getPartitionKeyDefinition().getPaths().get(0).equals("/id"))) { // throw new IllegalArgumentException("The lease collection, if partitioned, must have partition key equal to id."); return Mono.error(new IllegalArgumentException("The lease collection must have partition key equal to id.")); } @@ -370,7 +370,7 @@ private Mono getLeaseStoreManager() { } private String getLeasePrefix() { - String optionsPrefix = this.changeFeedProcessorOptions.leasePrefix(); + String optionsPrefix = this.changeFeedProcessorOptions.getLeasePrefix(); if (optionsPrefix == null) { optionsPrefix = ""; @@ -414,9 +414,9 @@ private Mono buildPartitionManager(LeaseStoreManager leaseStor if (this.loadBalancingStrategy == null) { this.loadBalancingStrategy = new EqualPartitionsBalancingStrategy( this.hostName, - this.changeFeedProcessorOptions.minScaleCount(), - this.changeFeedProcessorOptions.maxScaleCount(), - this.changeFeedProcessorOptions.leaseExpirationInterval()); + this.changeFeedProcessorOptions.getMinScaleCount(), + this.changeFeedProcessorOptions.getMaxScaleCount(), + this.changeFeedProcessorOptions.getLeaseExpirationInterval()); } PartitionController partitionController = new PartitionControllerImpl(leaseStoreManager, leaseStoreManager, partitionSupervisorFactory, synchronizer, scheduler); @@ -431,7 +431,7 @@ private Mono buildPartitionManager(LeaseStoreManager leaseStor partitionController2, leaseStoreManager, this.loadBalancingStrategy, - this.changeFeedProcessorOptions.leaseAcquireInterval(), + this.changeFeedProcessorOptions.getLeaseAcquireInterval(), this.scheduler ); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/CheckpointerObserverFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/CheckpointerObserverFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/CheckpointerObserverFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/CheckpointerObserverFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/Constants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/Constants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/Constants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/Constants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserver.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserver.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserverFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserverFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserverFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DefaultObserverFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java similarity index 76% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java index 8e29ae6f4112..0e78b0784dca 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseStore.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; -import com.azure.data.cosmos.AccessCondition; -import com.azure.data.cosmos.AccessConditionType; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; import com.azure.data.cosmos.internal.changefeed.LeaseStore; import com.azure.data.cosmos.internal.changefeed.RequestOptionsFactory; @@ -24,7 +18,7 @@ class DocumentServiceLeaseStore implements LeaseStore { private ChangeFeedContextClient client; private String containerNamePrefix; - private CosmosContainer leaseCollectionLink; + private CosmosAsyncContainer leaseCollectionLink; private RequestOptionsFactory requestOptionsFactory; private volatile String lockETag; @@ -32,7 +26,7 @@ class DocumentServiceLeaseStore implements LeaseStore { public DocumentServiceLeaseStore( ChangeFeedContextClient client, String containerNamePrefix, - CosmosContainer leaseCollectionLink, + CosmosAsyncContainer leaseCollectionLink, RequestOptionsFactory requestOptionsFactory) { this.client = client; @@ -46,18 +40,18 @@ public Mono isInitialized() { String markerDocId = this.getStoreMarkerName(); CosmosItemProperties doc = new CosmosItemProperties(); - doc.id(markerDocId); + doc.setId(markerDocId); CosmosItemRequestOptions requestOptions = this.requestOptionsFactory.createRequestOptions( ServiceItemLease.fromDocument(doc)); - CosmosItem docItem = this.client.getContainerClient().getItem(markerDocId, "/id"); + CosmosAsyncItem docItem = this.client.getContainerClient().getItem(markerDocId, "/id"); return this.client.readItem(docItem, requestOptions) - .flatMap(documentResourceResponse -> Mono.just(documentResourceResponse.item() != null)) + .flatMap(documentResourceResponse -> Mono.just(documentResourceResponse.getItem() != null)) .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) throwable; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { return Mono.just(false); } } @@ -69,14 +63,14 @@ public Mono isInitialized() { public Mono markInitialized() { String markerDocId = this.getStoreMarkerName(); CosmosItemProperties containerDocument = new CosmosItemProperties(); - containerDocument.id(markerDocId); + containerDocument.setId(markerDocId); return this.client.createItem(this.leaseCollectionLink, containerDocument, null, false) .map( item -> true) .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) throwable; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { return Mono.just(true); } } @@ -88,13 +82,13 @@ public Mono markInitialized() { public Mono acquireInitializationLock(Duration lockExpirationTime) { String lockId = this.getStoreLockName(); CosmosItemProperties containerDocument = new CosmosItemProperties(); - containerDocument.id(lockId); + containerDocument.setId(lockId); BridgeInternal.setProperty(containerDocument, com.azure.data.cosmos.internal.Constants.Properties.TTL, Long.valueOf(lockExpirationTime.getSeconds()).intValue()); return this.client.createItem(this.leaseCollectionLink, containerDocument, null, false) .map(documentResourceResponse -> { - if (documentResourceResponse.item() != null) { - this.lockETag = documentResourceResponse.properties().etag(); + if (documentResourceResponse.getItem() != null) { + this.lockETag = documentResourceResponse.getProperties().getETag(); return true; } else { return false; @@ -103,7 +97,7 @@ public Mono acquireInitializationLock(Duration lockExpirationTime) { .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) throwable; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { return Mono.just(false); } } @@ -115,7 +109,7 @@ public Mono acquireInitializationLock(Duration lockExpirationTime) { public Mono releaseInitializationLock() { String lockId = this.getStoreLockName(); CosmosItemProperties doc = new CosmosItemProperties(); - doc.id(lockId); + doc.setId(lockId); CosmosItemRequestOptions requestOptions = this.requestOptionsFactory.createRequestOptions( ServiceItemLease.fromDocument(doc)); @@ -125,14 +119,14 @@ public Mono releaseInitializationLock() { } AccessCondition accessCondition = new AccessCondition(); - accessCondition.type(AccessConditionType.IF_MATCH); - accessCondition.condition(this.lockETag); - requestOptions.accessCondition(accessCondition); + accessCondition.setType(AccessConditionType.IF_MATCH); + accessCondition.setCondition(this.lockETag); + requestOptions.setAccessCondition(accessCondition); - CosmosItem docItem = this.client.getContainerClient().getItem(lockId, "/id"); + CosmosAsyncItem docItem = this.client.getContainerClient().getItem(lockId, "/id"); return this.client.deleteItem(docItem, requestOptions) .map(documentResourceResponse -> { - if (documentResourceResponse.item() != null) { + if (documentResourceResponse.getItem() != null) { this.lockETag = null; return true; } else { @@ -142,7 +136,7 @@ public Mono releaseInitializationLock() { .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) throwable; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { return Mono.just(false); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java index e28c13cbf500..fda514eaf3d8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java @@ -2,12 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; -import com.azure.data.cosmos.AccessCondition; -import com.azure.data.cosmos.AccessConditionType; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncItem; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; import com.azure.data.cosmos.internal.changefeed.Lease; import com.azure.data.cosmos.internal.changefeed.ServiceItemLease; @@ -42,7 +38,7 @@ public DocumentServiceLeaseUpdaterImpl(ChangeFeedContextClient client) { } @Override - public Mono updateLease(Lease cachedLease, CosmosItem itemLink, CosmosItemRequestOptions requestOptions, Function updateLease) { + public Mono updateLease(Lease cachedLease, CosmosAsyncItem itemLink, CosmosItemRequestOptions requestOptions, Function updateLease) { Lease arrayLease[] = {cachedLease}; arrayLease[0] = updateLease.apply(cachedLease); @@ -67,7 +63,7 @@ public Mono updateLease(Lease cachedLease, CosmosItem itemLink, CosmosIte .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException ex = (CosmosClientException) throwable; - if (ex.statusCode() == HTTP_STATUS_CODE_NOT_FOUND) { + if (ex.getStatusCode() == HTTP_STATUS_CODE_NOT_FOUND) { // Partition lease no longer exists throw new LeaseLostException(arrayLease[0]); } @@ -75,7 +71,7 @@ public Mono updateLease(Lease cachedLease, CosmosItem itemLink, CosmosIte return Mono.error(throwable); }) .map(cosmosItemResponse -> { - CosmosItemProperties document = cosmosItemResponse.properties(); + CosmosItemProperties document = cosmosItemResponse.getProperties(); ServiceItemLease serverLease = ServiceItemLease.fromDocument(document); logger.info( "Partition {} update failed because the lease with token '{}' was updated by host '{}' with token '{}'.", @@ -96,13 +92,13 @@ public Mono updateLease(Lease cachedLease, CosmosItem itemLink, CosmosIte }); } - private Mono tryReplaceLease(Lease lease, CosmosItem itemLink) throws LeaseLostException { + private Mono tryReplaceLease(Lease lease, CosmosAsyncItem itemLink) throws LeaseLostException { return this.client.replaceItem(itemLink, lease, this.getCreateIfMatchOptions(lease)) - .map(cosmosItemResponse -> cosmosItemResponse.properties()) + .map(cosmosItemResponse -> cosmosItemResponse.getProperties()) .onErrorResume(re -> { if (re instanceof CosmosClientException) { CosmosClientException ex = (CosmosClientException) re; - switch (ex.statusCode()) { + switch (ex.getStatusCode()) { case HTTP_STATUS_CODE_PRECONDITION_FAILED: { return Mono.empty(); } @@ -123,11 +119,11 @@ private Mono tryReplaceLease(Lease lease, CosmosItem itemL private CosmosItemRequestOptions getCreateIfMatchOptions(Lease lease) { AccessCondition ifMatchCondition = new AccessCondition(); - ifMatchCondition.type(AccessConditionType.IF_MATCH); - ifMatchCondition.condition(lease.getConcurrencyToken()); + ifMatchCondition.setType(AccessConditionType.IF_MATCH); + ifMatchCondition.setCondition(lease.getConcurrencyToken()); CosmosItemRequestOptions createIfMatchOptions = new CosmosItemRequestOptions(); - createIfMatchOptions.accessCondition(ifMatchCondition); + createIfMatchOptions.setAccessCondition(ifMatchCondition); return createIfMatchOptions; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/EqualPartitionsBalancingStrategy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java similarity index 68% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java index cdf19f79d55d..bb3050f01d71 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ExceptionClassifier.java @@ -21,17 +21,17 @@ class ExceptionClassifier { public static StatusCodeErrorType classifyClientException(CosmosClientException clientException) { - Integer subStatusCode = clientException.subStatusCode(); + Integer subStatusCode = clientException.getSubStatusCode(); - if (clientException.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND && subStatusCode != SubStatusCode_ReadSessionNotAvailable) { + if (clientException.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND && subStatusCode != SubStatusCode_ReadSessionNotAvailable) { return StatusCodeErrorType.PARTITION_NOT_FOUND; } - if (clientException.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_GONE && (subStatusCode == SubStatusCode_PartitionKeyRangeGone || subStatusCode == SubStatusCode_Splitting)) { + if (clientException.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_GONE && (subStatusCode == SubStatusCode_PartitionKeyRangeGone || subStatusCode == SubStatusCode_Splitting)) { return StatusCodeErrorType.PARTITION_SPLIT; } - if (clientException.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_TOO_MANY_REQUESTS || clientException.statusCode() >= ChangeFeedHelper.HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR) { + if (clientException.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_TOO_MANY_REQUESTS || clientException.getStatusCode() >= ChangeFeedHelper.HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR) { return StatusCodeErrorType.TRANSIENT_ERROR; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/HealthMonitoringPartitionControllerDecorator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/HealthMonitoringPartitionControllerDecorator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/HealthMonitoringPartitionControllerDecorator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/HealthMonitoringPartitionControllerDecorator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseRenewerImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java index 593860803120..5208862325ef 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/LeaseStoreManagerImpl.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; +import com.azure.data.cosmos.CosmosAsyncContainer; +import com.azure.data.cosmos.CosmosAsyncItem; import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItem; import com.azure.data.cosmos.CosmosItemProperties; import com.azure.data.cosmos.FeedResponse; import com.azure.data.cosmos.SqlParameter; @@ -27,7 +27,7 @@ import java.time.Duration; /** - * Provides flexible way to build lease manager constructor parameters. + * Provides flexible way to buildAsyncClient lease manager constructor parameters. * For the actual creation of lease manager instance, delegates to lease manager factory. */ public class LeaseStoreManagerImpl implements LeaseStoreManager, LeaseStoreManager.LeaseStoreManagerBuilderDefinition { @@ -70,7 +70,7 @@ public LeaseStoreManagerBuilderDefinition leasePrefix(String leasePrefix) { } @Override - public LeaseStoreManagerBuilderDefinition leaseCollectionLink(CosmosContainer leaseCollectionLink) { + public LeaseStoreManagerBuilderDefinition leaseCollectionLink(CosmosAsyncContainer leaseCollectionLink) { if (leaseCollectionLink == null) { throw new IllegalArgumentException("leaseCollectionLink"); } @@ -174,7 +174,7 @@ public Mono createLeaseIfNotExist(String leaseToken, String continuationT .onErrorResume( ex -> { if (ex instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) ex; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_CONFLICT) { logger.info("Some other host created lease for {}.", leaseToken); return Mono.empty(); } @@ -187,13 +187,13 @@ public Mono createLeaseIfNotExist(String leaseToken, String continuationT return null; } - CosmosItemProperties document = documentResourceResponse.properties(); + CosmosItemProperties document = documentResourceResponse.getProperties(); logger.info("Created lease for partition {}.", leaseToken); return documentServiceLease - .withId(document.id()) - .withEtag(document.etag()) + .withId(document.getId()) + .withEtag(document.getETag()) .withTs(document.getString(Constants.Properties.LAST_MODIFIED)); }); } @@ -204,14 +204,14 @@ public Mono delete(Lease lease) { throw new IllegalArgumentException("lease"); } - CosmosItem itemForLease = this.createItemForLease(lease.getId()); + CosmosAsyncItem itemForLease = this.createItemForLease(lease.getId()); return this.leaseDocumentClient .deleteItem(itemForLease, this.requestOptionsFactory.createRequestOptions(lease)) .onErrorResume( ex -> { if (ex instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) ex; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { // Ignore - document was already deleted. return Mono.empty(); } @@ -254,13 +254,13 @@ public Mono release(Lease lease) { throw new IllegalArgumentException("lease"); } - CosmosItem itemForLease = this.createItemForLease(lease.getId()); + CosmosAsyncItem itemForLease = this.createItemForLease(lease.getId()); return this.leaseDocumentClient.readItem(itemForLease, this.requestOptionsFactory.createRequestOptions(lease)) .onErrorResume( ex -> { if (ex instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) ex; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { logger.info("Partition {} failed to renew lease. The lease is gone already.", lease.getLeaseToken()); throw new LeaseLostException(lease); } @@ -268,7 +268,7 @@ public Mono release(Lease lease) { return Mono.error(ex); }) - .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.properties())) + .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.getProperties())) .flatMap( refreshedLease -> this.leaseUpdater.updateLease( refreshedLease, this.createItemForLease(refreshedLease.getId()), @@ -297,13 +297,13 @@ public Mono renew(Lease lease) { // Get fresh lease. The assumption here is that check-pointing is done with higher frequency than lease renewal so almost // certainly the lease was updated in between. - CosmosItem itemForLease = this.createItemForLease(lease.getId()); + CosmosAsyncItem itemForLease = this.createItemForLease(lease.getId()); return this.leaseDocumentClient.readItem(itemForLease, this.requestOptionsFactory.createRequestOptions(lease)) .onErrorResume( ex -> { if (ex instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) ex; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { logger.info("Partition {} failed to renew lease. The lease is gone already.", lease.getLeaseToken()); throw new LeaseLostException(lease); } @@ -311,7 +311,7 @@ public Mono renew(Lease lease) { return Mono.error(ex); }) - .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.properties())) + .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.getProperties())) .flatMap( refreshedLease -> this.leaseUpdater.updateLease( refreshedLease, this.createItemForLease(refreshedLease.getId()), @@ -363,10 +363,10 @@ public Mono checkpoint(Lease lease, String continuationToken) { throw new IllegalArgumentException("continuationToken must be a non-empty string"); } - CosmosItem itemForLease = this.createItemForLease(lease.getId()); + CosmosAsyncItem itemForLease = this.createItemForLease(lease.getId()); return this.leaseDocumentClient.readItem(itemForLease, this.requestOptionsFactory.createRequestOptions(lease)) - .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.properties())) + .map( documentResourceResponse -> ServiceItemLease.fromDocument(documentResourceResponse.getProperties())) .flatMap( refreshedLease -> this.leaseUpdater.updateLease( refreshedLease, this.createItemForLease(lease.getId()), @@ -403,13 +403,13 @@ public Mono releaseInitializationLock() { } private Mono tryGetLease(Lease lease) { - CosmosItem itemForLease = this.createItemForLease(lease.getId()); + CosmosAsyncItem itemForLease = this.createItemForLease(lease.getId()); return this.leaseDocumentClient.readItem(itemForLease, this.requestOptionsFactory.createRequestOptions(lease)) .onErrorResume( ex -> { if (ex instanceof CosmosClientException) { CosmosClientException e = (CosmosClientException) ex; - if (e.statusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { + if (e.getStatusCode() == ChangeFeedHelper.HTTP_STATUS_CODE_NOT_FOUND) { return Mono.empty(); } } @@ -418,7 +418,7 @@ private Mono tryGetLease(Lease lease) { }) .map( documentResourceResponse -> { if (documentResourceResponse == null) return null; - return ServiceItemLease.fromDocument(documentResourceResponse.properties()); + return ServiceItemLease.fromDocument(documentResourceResponse.getProperties()); }); } @@ -428,8 +428,8 @@ private Flux listDocuments(String prefix) { } SqlParameter param = new SqlParameter(); - param.name("@PartitionLeasePrefix"); - param.value(prefix); + param.setName("@PartitionLeasePrefix"); + param.setValue(prefix); SqlQuerySpec querySpec = new SqlQuerySpec( "SELECT * FROM c WHERE STARTSWITH(c.id, @PartitionLeasePrefix)", new SqlParameterList(param)); @@ -439,7 +439,7 @@ private Flux listDocuments(String prefix) { querySpec, this.requestOptionsFactory.createFeedOptions()); - return query.flatMap( documentFeedResponse -> Flux.fromIterable(documentFeedResponse.results())) + return query.flatMap( documentFeedResponse -> Flux.fromIterable(documentFeedResponse.getResults())) .map(ServiceItemLease::fromDocument); } @@ -452,7 +452,7 @@ private String getPartitionLeasePrefix() { return this.settings.getContainerNamePrefix() + LEASE_STORE_MANAGER_LEASE_SUFFIX; } - private CosmosItem createItemForLease(String leaseId) { + private CosmosAsyncItem createItemForLease(String leaseId) { return this.leaseDocumentClient.getContainerClient().getItem(leaseId, "/id"); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ObserverExceptionWrappingChangeFeedObserverDecorator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ObserverExceptionWrappingChangeFeedObserverDecorator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ObserverExceptionWrappingChangeFeedObserverDecorator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/ObserverExceptionWrappingChangeFeedObserverDecorator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionCheckpointerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionCheckpointerImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionCheckpointerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionCheckpointerImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionControllerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionControllerImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionControllerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionControllerImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionLoadBalancerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionLoadBalancerImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionLoadBalancerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionLoadBalancerImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionManagerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionManagerImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionManagerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionManagerImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java index e508129d91f8..227dd127b905 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorFactoryImpl.java @@ -3,7 +3,7 @@ package com.azure.data.cosmos.internal.changefeed.implementation; import com.azure.data.cosmos.ChangeFeedProcessorOptions; -import com.azure.data.cosmos.CosmosContainer; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; import com.azure.data.cosmos.internal.changefeed.ChangeFeedObserver; import com.azure.data.cosmos.internal.changefeed.Lease; @@ -20,13 +20,13 @@ class PartitionProcessorFactoryImpl implements PartitionProcessorFactory { private final ChangeFeedContextClient documentClient; private final ChangeFeedProcessorOptions changeFeedProcessorOptions; private final LeaseCheckpointer leaseCheckpointer; - private final CosmosContainer collectionSelfLink; + private final CosmosAsyncContainer collectionSelfLink; public PartitionProcessorFactoryImpl( ChangeFeedContextClient documentClient, ChangeFeedProcessorOptions changeFeedProcessorOptions, LeaseCheckpointer leaseCheckpointer, - CosmosContainer collectionSelfLink) { + CosmosAsyncContainer collectionSelfLink) { if (documentClient == null) { throw new IllegalArgumentException("documentClient"); @@ -63,17 +63,17 @@ public PartitionProcessor create(Lease lease, ChangeFeedObserver observer) { String startContinuation = lease.getContinuationToken(); if (startContinuation == null || startContinuation.isEmpty()) { - startContinuation = this.changeFeedProcessorOptions.startContinuation(); + startContinuation = this.changeFeedProcessorOptions.getStartContinuation(); } ProcessorSettings settings = new ProcessorSettings() .withCollectionLink(this.collectionSelfLink) .withStartContinuation(startContinuation) .withPartitionKeyRangeId(lease.getLeaseToken()) - .withFeedPollDelay(this.changeFeedProcessorOptions.feedPollDelay()) - .withMaxItemCount(this.changeFeedProcessorOptions.maxItemCount()) - .withStartFromBeginning(this.changeFeedProcessorOptions.startFromBeginning()) - .withStartTime(this.changeFeedProcessorOptions.startTime()); // .sessionToken(this.changeFeedProcessorOptions.sessionToken()); + .withFeedPollDelay(this.changeFeedProcessorOptions.getFeedPollDelay()) + .withMaxItemCount(this.changeFeedProcessorOptions.getMaxItemCount()) + .withStartFromBeginning(this.changeFeedProcessorOptions.getStartFromBeginning()) + .withStartTime(this.changeFeedProcessorOptions.getStartTime()); // .getSessionToken(this.changeFeedProcessorOptions.getSessionToken()); PartitionCheckpointer checkpointer = new PartitionCheckpointerImpl(this.leaseCheckpointer, lease); return new PartitionProcessorImpl(observer, this.documentClient, settings, checkpointer); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java index 6a2960a59e7e..257810f64215 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionProcessorImpl.java @@ -51,12 +51,12 @@ public PartitionProcessorImpl(ChangeFeedObserver observer, ChangeFeedContextClie this.checkpointer = checkpointer; this.options = new ChangeFeedOptions(); - this.options.maxItemCount(settings.getMaxItemCount()); + this.options.setMaxItemCount(settings.getMaxItemCount()); partitionKeyRangeIdInternal(this.options, settings.getPartitionKeyRangeId()); - // this.options.sessionToken(properties.sessionToken()); - this.options.startFromBeginning(settings.isStartFromBeginning()); - this.options.requestContinuation(settings.getStartContinuation()); - this.options.startDateTime(settings.getStartTime()); + // this.setOptions.getSessionToken(getProperties.getSessionToken()); + this.options.setStartFromBeginning(settings.isStartFromBeginning()); + this.options.setRequestContinuation(settings.getStartContinuation()); + this.options.setStartDateTime(settings.getStartTime()); } @Override @@ -64,7 +64,7 @@ public Mono run(CancellationToken cancellationToken) { this.lastContinuation = this.settings.getStartContinuation(); this.isFirstQueryForChangeFeeds = true; - this.options.requestContinuation(this.lastContinuation); + this.options.setRequestContinuation(this.lastContinuation); return Flux.just(this) .flatMap( value -> { @@ -92,16 +92,16 @@ public Mono run(CancellationToken cancellationToken) { .flatMap(documentFeedResponse -> { if (cancellationToken.isCancellationRequested()) return Flux.error(new TaskCancelledException()); - this.lastContinuation = documentFeedResponse.continuationToken(); - if (documentFeedResponse.results() != null && documentFeedResponse.results().size() > 0) { + this.lastContinuation = documentFeedResponse.getContinuationToken(); + if (documentFeedResponse.getResults() != null && documentFeedResponse.getResults().size() > 0) { return this.dispatchChanges(documentFeedResponse) .doFinally( (Void) -> { - this.options.requestContinuation(this.lastContinuation); + this.options.setRequestContinuation(this.lastContinuation); if (cancellationToken.isCancellationRequested()) throw new TaskCancelledException(); }).flux(); } - this.options.requestContinuation(this.lastContinuation); + this.options.setRequestContinuation(this.lastContinuation); if (cancellationToken.isCancellationRequested()) { return Flux.error(new TaskCancelledException()); @@ -110,15 +110,15 @@ public Mono run(CancellationToken cancellationToken) { return Flux.empty(); }) .doOnComplete(() -> { - if (this.options.maxItemCount().compareTo(this.settings.getMaxItemCount()) != 0) { - this.options.maxItemCount(this.settings.getMaxItemCount()); // Reset after successful execution. + if (this.options.getMaxItemCount().compareTo(this.settings.getMaxItemCount()) != 0) { + this.options.setMaxItemCount(this.settings.getMaxItemCount()); // Reset after successful execution. } }) .onErrorResume(throwable -> { if (throwable instanceof CosmosClientException) { CosmosClientException clientException = (CosmosClientException) throwable; - this.logger.warn("Exception: partition {}", this.options.partitionKey().getInternalPartitionKey(), clientException); + this.logger.warn("Exception: partition {}", this.options.getPartitionKey().getInternalPartitionKey(), clientException); StatusCodeErrorType docDbError = ExceptionClassifier.classifyClientException(clientException); switch (docDbError) { @@ -132,19 +132,19 @@ public Mono run(CancellationToken cancellationToken) { this.resultException = new RuntimeException(clientException); } case MAX_ITEM_COUNT_TOO_LARGE: { - if (this.options.maxItemCount() == null) { - this.options.maxItemCount(DefaultMaxItemCount); - } else if (this.options.maxItemCount() <= 1) { - this.logger.error("Cannot reduce maxItemCount further as it's already at {}", this.options.maxItemCount(), clientException); + if (this.options.getMaxItemCount() == null) { + this.options.setMaxItemCount(DefaultMaxItemCount); + } else if (this.options.getMaxItemCount() <= 1) { + this.logger.error("Cannot reduce getMaxItemCount further as it's already at {}", this.options.getMaxItemCount(), clientException); this.resultException = new RuntimeException(clientException); } - this.options.maxItemCount(this.options.maxItemCount() / 2); - this.logger.warn("Reducing maxItemCount, new value: {}", this.options.maxItemCount()); + this.options.setMaxItemCount(this.options.getMaxItemCount() / 2); + this.logger.warn("Reducing getMaxItemCount, new getValue: {}", this.options.getMaxItemCount()); return Flux.empty(); } default: { - this.logger.error("Unrecognized DocDbError enum value {}", docDbError, clientException); + this.logger.error("Unrecognized DocDbError enum getValue {}", docDbError, clientException); this.resultException = new RuntimeException(clientException); } } @@ -174,6 +174,6 @@ public RuntimeException getResultException() { private Mono dispatchChanges(FeedResponse response) { ChangeFeedObserverContext context = new ChangeFeedObserverContextImpl(this.settings.getPartitionKeyRangeId(), response, this.checkpointer); - return this.observer.processChanges(context, response.results()); + return this.observer.processChanges(context, response.getResults()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java index e6101e43b80d..3dc70e536361 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorFactoryImpl.java @@ -14,8 +14,6 @@ import com.azure.data.cosmos.internal.changefeed.PartitionSupervisorFactory; import reactor.core.scheduler.Scheduler; -import java.util.concurrent.ExecutorService; - /** * Implementation for the partition supervisor factory. */ @@ -65,7 +63,7 @@ public PartitionSupervisor create(Lease lease) { ChangeFeedObserver changeFeedObserver = this.observerFactory.createObserver(); PartitionProcessor processor = this.partitionProcessorFactory.create(lease, changeFeedObserver); - LeaseRenewer renewer = new LeaseRenewerImpl(lease, this.leaseManager, this.changeFeedProcessorOptions.leaseRenewInterval()); + LeaseRenewer renewer = new LeaseRenewerImpl(lease, this.leaseManager, this.changeFeedProcessorOptions.getLeaseRenewInterval()); return new PartitionSupervisorImpl(lease, changeFeedObserver, processor, renewer, this.scheduler); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSupervisorImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java index 8811f075c514..da3f9aea967e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionSynchronizerImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.changefeed.implementation; -import com.azure.data.cosmos.CosmosContainer; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.FeedOptions; import com.azure.data.cosmos.internal.PartitionKeyRange; import com.azure.data.cosmos.internal.changefeed.ChangeFeedContextClient; @@ -26,7 +26,7 @@ class PartitionSynchronizerImpl implements PartitionSynchronizer { private final Logger logger = LoggerFactory.getLogger(PartitionSynchronizerImpl.class); private final ChangeFeedContextClient documentClient; - private final CosmosContainer collectionSelfLink; + private final CosmosAsyncContainer collectionSelfLink; private final LeaseContainer leaseContainer; private final LeaseManager leaseManager; private final int degreeOfParallelism; @@ -34,7 +34,7 @@ class PartitionSynchronizerImpl implements PartitionSynchronizer { public PartitionSynchronizerImpl( ChangeFeedContextClient documentClient, - CosmosContainer collectionSelfLink, + CosmosAsyncContainer collectionSelfLink, LeaseContainer leaseContainer, LeaseManager leaseManager, int degreeOfParallelism, @@ -52,8 +52,8 @@ public PartitionSynchronizerImpl( public Mono createMissingLeases() { return this.enumPartitionKeyRanges() .map(partitionKeyRange -> { - // TODO: log the partition key ID found. - return partitionKeyRange.id(); + // TODO: log the partition getKey ID found. + return partitionKeyRange.getId(); }) .collectList() .flatMap( partitionKeyRangeIds -> { @@ -80,7 +80,7 @@ public Flux splitPartition(Lease lease) { // After a split, the children are either all or none available return this.enumPartitionKeyRanges() .filter(range -> range != null && range.getParents() != null && range.getParents().contains(leaseToken)) - .map(PartitionKeyRange::id) + .map(PartitionKeyRange::getId) .collectList() .flatMapMany(addedLeaseTokens -> { if (addedLeaseTokens.size() == 0) { @@ -106,7 +106,7 @@ private Flux enumPartitionKeyRanges() { feedOptions.requestContinuation(null); return this.documentClient.readPartitionKeyRangeFeed(partitionKeyRangesPath, feedOptions) - .map(partitionKeyRangeFeedResponse -> partitionKeyRangeFeedResponse.results()) + .map(partitionKeyRangeFeedResponse -> partitionKeyRangeFeedResponse.getResults()) .flatMap(partitionKeyRangeList -> Flux.fromIterable(partitionKeyRangeList)) .onErrorResume(throwable -> { // TODO: Log the exception. diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java similarity index 78% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java index 423747a66f47..b1f749913d8b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/PartitionedByIdCollectionRequestOptionsFactory.java @@ -9,13 +9,13 @@ import com.azure.data.cosmos.internal.changefeed.RequestOptionsFactory; /** - * Used to create request options for partitioned lease collections, when partition key is defined as /id. + * Used to create request setOptions for partitioned lease collections, when partition getKey is defined as /getId. */ class PartitionedByIdCollectionRequestOptionsFactory implements RequestOptionsFactory { @Override public CosmosItemRequestOptions createRequestOptions(Lease lease) { CosmosItemRequestOptions requestOptions = new CosmosItemRequestOptions(); - requestOptions.partitionKey(new PartitionKey(lease.getId())); + requestOptions.setPartitionKey(new PartitionKey(lease.getId())); return requestOptions; } @@ -23,7 +23,7 @@ public CosmosItemRequestOptions createRequestOptions(Lease lease) { @Override public FeedOptions createFeedOptions() { FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); return feedOptions; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingPartitionWorkImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingPartitionWorkImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingPartitionWorkImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingPartitionWorkImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingWorkEstimatorImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingWorkEstimatorImpl.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingWorkEstimatorImpl.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/RemainingWorkEstimatorImpl.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/StatusCodeErrorType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/StatusCodeErrorType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/StatusCodeErrorType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/StatusCodeErrorType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/TraceHealthMonitor.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/TraceHealthMonitor.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/TraceHealthMonitor.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/TraceHealthMonitor.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/WorkerTask.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/WorkerTask.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/WorkerTask.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/changefeed/implementation/WorkerTask.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Address.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Address.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Address.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Address.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressInformation.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressInformation.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressInformation.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressInformation.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java index d5af634a825a..bf7724f9d91b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolver.java @@ -89,13 +89,13 @@ private static boolean isSameCollection(PartitionKeyRange initiallyResolved, Par return false; } - if (Strings.areEqual(initiallyResolved.id(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID) && - Strings.areEqual(newlyResolved.id(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID)) { + if (Strings.areEqual(initiallyResolved.getId(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID) && + Strings.areEqual(newlyResolved.getId(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID)) { return true; } - if (Strings.areEqual(initiallyResolved.id(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID) - || Strings.areEqual(newlyResolved.id(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID)) { + if (Strings.areEqual(initiallyResolved.getId(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID) + || Strings.areEqual(newlyResolved.getId(), PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID)) { String message = "Request was resolved to master partition and then to server partition."; assert false : message; @@ -103,14 +103,14 @@ private static boolean isSameCollection(PartitionKeyRange initiallyResolved, Par return false; } - if (ResourceId.parse(initiallyResolved.resourceId()).getDocumentCollection() - != ResourceId.parse(newlyResolved.resourceId()).getDocumentCollection()) { + if (ResourceId.parse(initiallyResolved.getResourceId()).getDocumentCollection() + != ResourceId.parse(newlyResolved.getResourceId()).getDocumentCollection()) { return false; } - if (!Strings.areEqual(initiallyResolved.id(), newlyResolved.id()) && - !(newlyResolved.getParents() != null && newlyResolved.getParents().contains(initiallyResolved.id()))) { - // the above condition should be always false in current codebase. + if (!Strings.areEqual(initiallyResolved.getId(), newlyResolved.getId()) && + !(newlyResolved.getParents() != null && newlyResolved.getParents().contains(initiallyResolved.getId()))) { + // the above getCondition should be always false in current codebase. // We don't need to refresh any caches if we resolved to a range which is child of previously resolved range. // Quorum reads should be handled transparently as child partitions share LSNs with parent partitions which are gone. String message = @@ -172,7 +172,7 @@ private static void ensureRoutingMapPresent( if (routingMap == null) { logger.debug( "Routing map was not found although collection cache is upto date for collection {}", - collection.resourceId()); + collection.getResourceId()); // Routing map not found although collection was resolved correctly. NotFoundException e = new NotFoundException(); BridgeInternal.setResourceAddress(e, request.getResourceAddress()); @@ -235,13 +235,13 @@ private Mono tryResolveServerPartitionAsync( Mono addressesObs = this.addressCache.tryGetAddresses( request, - new PartitionKeyRangeIdentity(collection.resourceId(), range.id()), + new PartitionKeyRangeIdentity(collection.getResourceId(), range.getId()), forceRefreshPartitionAddresses); return addressesObs.flatMap(addresses -> Mono.just(new ResolutionResult(range, addresses))).switchIfEmpty(Mono.defer(() -> { logger.info( "Could not resolve addresses for identity {}/{}. Potentially collection cache or routing map cache is outdated. Return empty - upper logic will refresh and retry. ", - new PartitionKeyRangeIdentity(collection.resourceId(), range.id())); + new PartitionKeyRangeIdentity(collection.getResourceId(), range.getId())); return Mono.empty(); })); @@ -289,12 +289,12 @@ private Mono resolveMasterResourceAddress(RxDocumentServiceReq return addressesObs.flatMap(addresses -> { PartitionKeyRange partitionKeyRange = new PartitionKeyRange(); - partitionKeyRange.id(PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID); + partitionKeyRange.setId(PartitionKeyRange.MASTER_PARTITION_KEY_RANGE_ID); return Mono.just(new ResolutionResult(partitionKeyRange, addresses)); }).switchIfEmpty(Mono.defer(() -> { logger.warn("Could not get addresses for master partition"); - // return Observable.error() + // return Observable.getError() NotFoundException e = new NotFoundException(); BridgeInternal.setResourceAddress(e, request.getResourceAddress()); return Mono.error(e); @@ -323,7 +323,7 @@ private Mono getOrRefreshRoutingMap(RxDocumentServiceRequest reque Mono stateObs = collectionObs.flatMap(collection -> { state.collection = collection; Mono routingMapObs = - this.collectionRoutingMapCache.tryLookupAsync(collection.resourceId(), null, request.forceCollectionRoutingMapRefresh, request.properties); + this.collectionRoutingMapCache.tryLookupAsync(collection.getResourceId(), null, request.forceCollectionRoutingMapRefresh, request.properties); final DocumentCollection underlyingCollection = collection; return routingMapObs.flatMap(routingMap -> { state.routingMap = routingMap; @@ -332,7 +332,7 @@ private Mono getOrRefreshRoutingMap(RxDocumentServiceRequest reque state.collectionRoutingMapCacheIsUptoDate = true; request.forcePartitionKeyRangeRefresh = false; if (routingMap != null) { - return this.collectionRoutingMapCache.tryLookupAsync(underlyingCollection.resourceId(), routingMap, request.properties) + return this.collectionRoutingMapCache.tryLookupAsync(underlyingCollection.getResourceId(), routingMap, request.properties) .map(newRoutingMap -> { state.routingMap = newRoutingMap; return state; @@ -364,7 +364,7 @@ private Mono getOrRefreshRoutingMap(RxDocumentServiceRequest reque return newCollectionObs.flatMap(collection -> { newState.collection = collection; Mono newRoutingMapObs = this.collectionRoutingMapCache.tryLookupAsync( - collection.resourceId(), + collection.getResourceId(), null, request.properties); @@ -437,7 +437,7 @@ private Mono resolveAddressesAndIdentityAsync( // InvalidPartitionException if we reach wrong collection. // Also this header will be used by backend to inject collection rid into metrics for // throttled requests. - request.getHeaders().put(WFConstants.BackendHeaders.COLLECTION_RID, state.collection.resourceId()); + request.getHeaders().put(WFConstants.BackendHeaders.COLLECTION_RID, state.collection.getResourceId()); } return Mono.just(funcResolutionResult); @@ -450,7 +450,7 @@ private Mono resolveAddressesAndIdentityAsync( if (!funcState.collectionRoutingMapCacheIsUptoDate) { funcState.collectionRoutingMapCacheIsUptoDate = true; Mono newRoutingMapObs = this.collectionRoutingMapCache.tryLookupAsync( - funcState.collection.resourceId(), + funcState.collection.getResourceId(), funcState.routingMap, request.properties); @@ -501,12 +501,12 @@ private Mono resolveAddressesAndIdentityAsync( Mono newRefreshStateObs = newCollectionObs.flatMap(collection -> { state.collection = collection; - if (collection.resourceId() != state.routingMap.getCollectionUniqueId()) { + if (collection.getResourceId() != state.routingMap.getCollectionUniqueId()) { // Collection cache was stale. We resolved to new Rid. routing map cache is potentially stale // for this new collection rid. Mark it as such. state.collectionRoutingMapCacheIsUptoDate = false; Mono newRoutingMap = this.collectionRoutingMapCache.tryLookupAsync( - collection.resourceId(), + collection.getResourceId(), null, request.properties); @@ -575,7 +575,7 @@ private Mono tryResolveServerPartitionByPartitionKeyRangeIdAsy Mono addressesObs = this.addressCache.tryGetAddresses( request, - new PartitionKeyRangeIdentity(collection.resourceId(), request.getPartitionKeyRangeIdentity().getPartitionKeyRangeId()), + new PartitionKeyRangeIdentity(collection.getResourceId(), request.getPartitionKeyRangeIdentity().getPartitionKeyRangeId()), forceRefreshPartitionAddresses); return addressesObs.flatMap(addresses -> Mono.just(new ResolutionResult(partitionKeyRange, addresses))).switchIfEmpty(Mono.defer(() -> { @@ -625,9 +625,9 @@ private PartitionKeyRange tryResolveServerPartitionByPartitionKey( throw new InternalServerErrorException(String.format("partition key is null '%s'", partitionKeyString)); } - if (partitionKey.equals(PartitionKeyInternal.Empty) || partitionKey.getComponents().size() == collection.getPartitionKey().paths().size()) { - // Although we can compute effective partition key here, in general case this GATEWAY can have outdated - // partition key definition cached - like if collection with same name but with RANGE partitioning is created. + if (partitionKey.equals(PartitionKeyInternal.Empty) || partitionKey.getComponents().size() == collection.getPartitionKey().getPaths().size()) { + // Although we can compute effective partition getKey here, in general case this GATEWAY can have outdated + // partition getKey definition cached - like if collection with same getName but with RANGE partitioning is created. // In this case server will not pass x-ms-documentdb-collection-rid check and will return back InvalidPartitionException. // GATEWAY will refresh its cache and retry. String effectivePartitionKey = PartitionKeyInternalHelper.getEffectivePartitionKeyString(partitionKey, collection.getPartitionKey()); @@ -638,7 +638,7 @@ private PartitionKeyRange tryResolveServerPartitionByPartitionKey( if (collectionCacheUptoDate) { BadRequestException badRequestException = BridgeInternal.setResourceAddress(new BadRequestException(RMResources.PartitionKeyMismatch), request.getResourceAddress()); - badRequestException.responseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.PARTITION_KEY_MISMATCH)); + badRequestException.getResponseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.PARTITION_KEY_MISMATCH)); throw badRequestException; } @@ -656,8 +656,8 @@ private PartitionKeyRange tryResolveServerPartitionByPartitionKey( // refresh name routing cache - this will refresh partition key definition as well, and retry. logger.debug( - "Cannot compute effective partition key. Definition has '{}' paths, values supplied has '{}' paths. Will refresh cache and retry.", - collection.getPartitionKey().paths().size(), + "Cannot compute effective partition getKey. Definition has '{}' getPaths, values supplied has '{}' getPaths. Will refresh cache and retry.", + collection.getPartitionKey().getPaths().size(), partitionKey.getComponents().size()); return null; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelector.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelector.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelector.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelector.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java index 842a463ab336..818f42e6c168 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReader.java @@ -310,7 +310,7 @@ private Mono readSessionAsync(RxDocumentServiceRequest entity, && responses.get(0).sessionToken != null && !entity.requestContext.sessionToken.isValid(responses.get(0).sessionToken)) { logger.warn("Convert to session read exception, request {} SESSION Lsn {}, responseLSN {}", entity.getResourceAddress(), entity.requestContext.sessionToken.convertToString(), responses.get(0).lsn); - notFoundException.responseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE)); + notFoundException.getResponseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE)); } return Mono.error(notFoundException); } catch (CosmosClientException e) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java index c4a38cf2abde..e788c72cd337 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriter.java @@ -171,7 +171,7 @@ Mono writePrivateAsync( } catch (CosmosClientException e) { logger.error("Error occurred while recording response", e); } - String value = ex.responseHeaders().get(HttpConstants.HttpHeaders.WRITE_REQUEST_TRIGGER_ADDRESS_REFRESH); + String value = ex.getResponseHeaders().get(HttpConstants.HttpHeaders.WRITE_REQUEST_TRIGGER_ADDRESS_REFRESH); if (!Strings.isNullOrWhiteSpace(value)) { Integer result = Integers.tryParse(value); if (result != null && result == 1) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/CustomHeaders.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/CustomHeaders.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/CustomHeaders.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/CustomHeaders.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ErrorUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ErrorUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ErrorUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ErrorUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java index e9427767cf87..9d46648d18a9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCache.java @@ -463,7 +463,7 @@ public Mono openAsync( RxDocumentServiceRequest request = RxDocumentServiceRequest.create( OperationType.Read, // collection.AltLink, - collection.resourceId(), + collection.getResourceId(), ResourceType.DocumentCollection, // AuthorizationTokenType.PrimaryMasterKey Collections.emptyMap()); @@ -475,7 +475,7 @@ public Mono openAsync( tasks.add(this.getServerAddressesViaGatewayAsync( request, - collection.resourceId(), + collection.getResourceId(), partitionKeyRangeIdentities.subList(i, endIndex). stream().map(PartitionKeyRangeIdentity::getPartitionKeyRangeId).collect(Collectors.toList()), @@ -487,12 +487,12 @@ public Mono openAsync( List> addressInfos = list.stream() .filter(addressInfo -> this.protocolScheme.equals(addressInfo.getProtocolScheme())) .collect(Collectors.groupingBy(Address::getParitionKeyRangeId)) - .values().stream().map(addresses -> toPartitionAddressAndRange(collection.resourceId(), addresses)) + .values().stream().map(addresses -> toPartitionAddressAndRange(collection.getResourceId(), addresses)) .collect(Collectors.toList()); for (Pair addressInfo : addressInfos) { this.serverPartitionAddressCache.set( - new PartitionKeyRangeIdentity(collection.resourceId(), addressInfo.getLeft().getPartitionKeyRangeId()), + new PartitionKeyRangeIdentity(collection.getResourceId(), addressInfo.getLeft().getPartitionKeyRangeId()), addressInfo.getRight()); } }).then(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java index 33397da58c6d..656f58a9f302 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReader.java @@ -101,7 +101,7 @@ private Mono getDatabaseAccountAsync(URI serviceEndpoint) { httpHeaders.set(HttpConstants.HttpHeaders.VERSION, HttpConstants.Versions.CURRENT_VERSION); UserAgentContainer userAgentContainer = new UserAgentContainer(); - String userAgentSuffix = this.connectionPolicy.userAgentSuffix(); + String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix(); if (userAgentSuffix != null && userAgentSuffix.length() > 0) { userAgentContainer.setSuffix(userAgentSuffix); } @@ -133,7 +133,7 @@ public Mono initializeReaderAsync() { try { return GlobalEndpointManager.getDatabaseAccountFromAnyLocationsAsync(this.serviceEndpoint.toURL(), - new ArrayList<>(this.connectionPolicy.preferredLocations()), url -> { + new ArrayList<>(this.connectionPolicy.getPreferredLocations()), url -> { try { return getDatabaseAccountAsync(url.toURI()); } catch (URISyntaxException e) { @@ -143,7 +143,7 @@ public Mono initializeReaderAsync() { userReplicationPolicy = BridgeInternal.getReplicationPolicy(databaseAccount); systemReplicationPolicy = BridgeInternal.getSystemReplicationPolicy(databaseAccount); queryEngineConfiguration = BridgeInternal.getQueryEngineConfiuration(databaseAccount); - consistencyLevel = BridgeInternal.getConsistencyPolicy(databaseAccount).defaultConsistencyLevel(); + consistencyLevel = BridgeInternal.getConsistencyPolicy(databaseAccount).getDefaultConsistencyLevel(); initialized = true; }); } catch (MalformedURLException e) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java index 082df288f118..4c8d1e33e823 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolver.java @@ -65,8 +65,8 @@ public GlobalAddressResolver( this.routingMapProvider = routingMapProvider; this.serviceConfigReader = serviceConfigReader; - int maxBackupReadEndpoints = (connectionPolicy.enableReadRequestsFallback() == null || connectionPolicy.enableReadRequestsFallback()) ? GlobalAddressResolver.MaxBackupReadRegions : 0; - this.maxEndpoints = maxBackupReadEndpoints + 2; // for write and alternate write endpoint (during failover) + int maxBackupReadEndpoints = (connectionPolicy.getEnableReadRequestsFallback() == null || connectionPolicy.getEnableReadRequestsFallback()) ? GlobalAddressResolver.MaxBackupReadRegions : 0; + this.maxEndpoints = maxBackupReadEndpoints + 2; // for write and alternate write getEndpoint (during failover) this.addressCacheByEndpoint = new ConcurrentHashMap<>(); for (URL endpoint : endpointManager.getWriteEndpoints()) { @@ -78,11 +78,11 @@ public GlobalAddressResolver( } Mono openAsync(DocumentCollection collection) { - Mono routingMap = this.routingMapProvider.tryLookupAsync(collection.id(), null, null); + Mono routingMap = this.routingMapProvider.tryLookupAsync(collection.getId(), null, null); return routingMap.flatMap(collectionRoutingMap -> { List ranges = ((List)collectionRoutingMap.getOrderedPartitionKeyRanges()).stream().map(range -> - new PartitionKeyRangeIdentity(collection.resourceId(), range.id())).collect(Collectors.toList()); + new PartitionKeyRangeIdentity(collection.getResourceId(), range.getId())).collect(Collectors.toList()); List> tasks = new ArrayList<>(); for (EndpointCache endpointCache : this.addressCacheByEndpoint.values()) { tasks.add(endpointCache.addressCache.openAsync(collection, ranges)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicy.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicy.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicy.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java index d33d6792e55a..7b157c0bc886 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClient.java @@ -187,8 +187,8 @@ public Mono invokeStoreAsync( exception, null, physicalAddress.toString()); - serviceUnavailableException.responseHeaders().put(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE, "1"); - serviceUnavailableException.responseHeaders().put(HttpConstants.HttpHeaders.WRITE_REQUEST_TRIGGER_ADDRESS_REFRESH, "1"); + serviceUnavailableException.getResponseHeaders().put(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE, "1"); + serviceUnavailableException.getResponseHeaders().put(HttpConstants.HttpHeaders.WRITE_REQUEST_TRIGGER_ADDRESS_REFRESH, "1"); return Mono.error(serviceUnavailableException); }}) .doOnSuccess(httpClientResponse -> { @@ -669,9 +669,9 @@ private Mono processHttpResponse(String resourceAddress, HttpRequ RMResources.InvalidBackendResponse), null, physicalAddress); - exception.responseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, + exception.getResponseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, activityId); - exception.responseHeaders().put(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE, "1"); + exception.getResponseHeaders().put(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE, "1"); return Mono.error(exception); } @@ -755,7 +755,7 @@ private Mono createErrorResponseFromHttpResponse(String resourceA RMResources.ExceptionMessage, RMResources.Gone), request.uri().toString()); - exception.responseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, + exception.getResponseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, activityId); break; @@ -849,7 +849,7 @@ private Mono createErrorResponseFromHttpResponse(String resourceA response.headers(), request.uri()); - exception.responseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, + exception.getResponseHeaders().put(HttpConstants.HttpHeaders.ACTIVITY_ID, activityId); break; } @@ -937,7 +937,7 @@ private Mono createErrorResponseFromHttpResponse(String resourceA if (values == null || values.isEmpty()) { logger.warn("RequestRateTooLargeException being thrown without RetryAfter."); } else { - exception.responseHeaders().put(HttpConstants.HttpHeaders.RETRY_AFTER_IN_MILLISECONDS, values.get(0)); + exception.getResponseHeaders().put(HttpConstants.HttpHeaders.RETRY_AFTER_IN_MILLISECONDS, values.get(0)); } break; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressCache.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressCache.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressResolver.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressResolver.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressResolver.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IAddressResolver.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IStoreClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IStoreClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IStoreClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/IStoreClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Protocol.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Protocol.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Protocol.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/Protocol.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QueryRequestPerformanceActivity.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QueryRequestPerformanceActivity.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QueryRequestPerformanceActivity.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QueryRequestPerformanceActivity.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java index 8f182a850053..f1eb73556d0f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReader.java @@ -787,4 +787,4 @@ private enum PrimaryReadOutcome { QuorumInconclusive, // Secondary replicas are available. Must read R secondary's to deduce current quorum. QuorumMet, } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReadMode.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReadMode.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReadMode.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReadMode.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RequestHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RequestHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RequestHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RequestHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResourceOperation.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResourceOperation.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResourceOperation.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResourceOperation.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResponseUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResponseUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResponseUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ResponseUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerProperties.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerProperties.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerProperties.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerStoreModel.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerStoreModel.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerStoreModel.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServerStoreModel.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServiceConfig.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServiceConfig.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServiceConfig.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/ServiceConfig.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java index e41245c011c1..76f6a1938f33 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClient.java @@ -114,12 +114,12 @@ public Mono processMessageAsync(RxDocumentServiceRequ } private void handleUnsuccessfulStoreResponse(RxDocumentServiceRequest request, CosmosClientException exception) { - this.updateResponseHeader(request, exception.responseHeaders()); + this.updateResponseHeader(request, exception.getResponseHeaders()); if ((!ReplicatedResourceClient.isMasterResource(request.getResourceType())) && (Exceptions.isStatusCode(exception, HttpConstants.StatusCodes.PRECONDITION_FAILED) || Exceptions.isStatusCode(exception, HttpConstants.StatusCodes.CONFLICT) || (Exceptions.isStatusCode(exception, HttpConstants.StatusCodes.NOTFOUND) && !Exceptions.isSubStatusCode(exception, HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE)))) { - this.captureSessionToken(request, exception.responseHeaders()); + this.captureSessionToken(request, exception.getResponseHeaders()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClientFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClientFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClientFactory.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreClientFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java index 35f97b27fea2..d395d45653bb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreReader.java @@ -74,7 +74,7 @@ public Mono> readMultipleReplicaAsync( * @param replicaCountToRead number of replicas to read from * @param requiresValidLsn flag to indicate whether a valid lsn is required to consider a response as valid * @param useSessionToken flag to indicate whether to use session token - * @param readMode READ mode + * @param readMode READ getMode * @param checkMinLSN set minimum required session lsn * @param forceReadAll reads from all available replicas to gather result from readsToRead number of replicas * @return ReadReplicaResult which indicates the LSN and whether Quorum was Met / Not Met etc @@ -319,7 +319,7 @@ private ReadReplicaResult createReadReplicaResult(List responseResu * @param replicaCountToRead number of replicas to read from * @param requiresValidLsn flag to indicate whether a valid lsn is required to consider a response as valid * @param useSessionToken flag to indicate whether to use session token - * @param readMode READ mode + * @param readMode READ getMode * @param checkMinLSN set minimum required session lsn * @param forceReadAll will read from all available replicas to put together result from readsToRead number of replicas * @return ReadReplicaResult which indicates the LSN and whether Quorum was Met / Not Met etc @@ -633,7 +633,7 @@ private Pair, URI> readFromStoreAsync( } default: - throw new IllegalStateException(String.format("Unexpected operation type {%s}", request.getOperationType())); + throw new IllegalStateException(String.format("Unexpected operation setType {%s}", request.getOperationType())); } } @@ -699,7 +699,7 @@ StoreResult createStoreResult(StoreResponse storeResponse, } ISessionToken sessionToken = null; - // SESSION token response header is introduced from version HttpConstants.Versions.v2018_06_18 onwards. + // SESSION token response header is introduced from getVersion HttpConstants.Versions.v2018_06_18 onwards. // Previously it was only a request header if ((headerValue = storeResponse.getHeaderValue(HttpConstants.HttpHeaders.SESSION_TOKEN)) != null) { sessionToken = SessionTokenHelper.parse(headerValue); @@ -711,7 +711,7 @@ StoreResult createStoreResult(StoreResponse storeResponse, /* partitionKeyRangeId: */ storeResponse.getPartitionKeyRangeId(), /* lsn: */ lsn, /* quorumAckedLsn: */ quorumAckedLSN, - /* requestCharge: */ requestCharge, + /* getRequestCharge: */ requestCharge, /* currentReplicaSetSize: */ currentReplicaSetSize, /* currentWriteQuorum: */ currentWriteQuorum, /* isValid: */true, @@ -719,7 +719,7 @@ StoreResult createStoreResult(StoreResponse storeResponse, /* globalCommittedLSN: */ globalCommittedLSN, /* numberOfReadRegions: */ numberOfReadRegions, /* itemLSN: */ itemLSN, - /* sessionToken: */ sessionToken); + /* getSessionToken: */ sessionToken); } else { CosmosClientException cosmosClientException = Utils.as(responseException, CosmosClientException.class); if (cosmosClientException != null) { @@ -729,40 +729,40 @@ StoreResult createStoreResult(StoreResponse storeResponse, int currentWriteQuorum = -1; long globalCommittedLSN = -1; int numberOfReadRegions = -1; - String headerValue = cosmosClientException.responseHeaders().get(useLocalLSNBasedHeaders ? WFConstants.BackendHeaders.QUORUM_ACKED_LOCAL_LSN : WFConstants.BackendHeaders.QUORUM_ACKED_LSN); + String headerValue = cosmosClientException.getResponseHeaders().get(useLocalLSNBasedHeaders ? WFConstants.BackendHeaders.QUORUM_ACKED_LOCAL_LSN : WFConstants.BackendHeaders.QUORUM_ACKED_LSN); if (!Strings.isNullOrEmpty(headerValue)) { quorumAckedLSN = Long.parseLong(headerValue); } - headerValue = cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.CURRENT_REPLICA_SET_SIZE); + headerValue = cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.CURRENT_REPLICA_SET_SIZE); if (!Strings.isNullOrEmpty(headerValue)) { currentReplicaSetSize = Integer.parseInt(headerValue); } - headerValue = cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.CURRENT_WRITE_QUORUM); + headerValue = cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.CURRENT_WRITE_QUORUM); if (!Strings.isNullOrEmpty(headerValue)) { currentReplicaSetSize = Integer.parseInt(headerValue); } double requestCharge = 0; - headerValue = cosmosClientException.responseHeaders().get(HttpConstants.HttpHeaders.REQUEST_CHARGE); + headerValue = cosmosClientException.getResponseHeaders().get(HttpConstants.HttpHeaders.REQUEST_CHARGE); if (!Strings.isNullOrEmpty(headerValue)) { requestCharge = Double.parseDouble(headerValue); } - headerValue = cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.NUMBER_OF_READ_REGIONS); + headerValue = cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.NUMBER_OF_READ_REGIONS); if (!Strings.isNullOrEmpty(headerValue)) { numberOfReadRegions = Integer.parseInt(headerValue); } - headerValue = cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN); + headerValue = cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN); if (!Strings.isNullOrEmpty(headerValue)) { globalCommittedLSN = Integer.parseInt(headerValue); } long lsn = -1; if (useLocalLSNBasedHeaders) { - headerValue = cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.LOCAL_LSN); + headerValue = cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.LOCAL_LSN); if (!Strings.isNullOrEmpty(headerValue)) { lsn = Long.parseLong(headerValue); } @@ -772,9 +772,9 @@ StoreResult createStoreResult(StoreResponse storeResponse, ISessionToken sessionToken = null; - // SESSION token response header is introduced from version HttpConstants.Versions.v2018_06_18 onwards. + // SESSION token response header is introduced from getVersion HttpConstants.Versions.v2018_06_18 onwards. // Previously it was only a request header - headerValue = cosmosClientException.responseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); + headerValue = cosmosClientException.getResponseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); if (!Strings.isNullOrEmpty(headerValue)) { sessionToken = SessionTokenHelper.parse(headerValue); } @@ -785,11 +785,11 @@ StoreResult createStoreResult(StoreResponse storeResponse, /* partitionKeyRangeId: */BridgeInternal.getPartitionKeyRangeId(cosmosClientException), /* lsn: */ lsn, /* quorumAckedLsn: */ quorumAckedLSN, - /* requestCharge: */ requestCharge, + /* getRequestCharge: */ requestCharge, /* currentReplicaSetSize: */ currentReplicaSetSize, /* currentWriteQuorum: */ currentWriteQuorum, /* isValid: */!requiresValidLsn - || ((cosmosClientException.statusCode() != HttpConstants.StatusCodes.GONE || isSubStatusCode(cosmosClientException, HttpConstants.SubStatusCodes.NAME_CACHE_IS_STALE)) + || ((cosmosClientException.getStatusCode() != HttpConstants.StatusCodes.GONE || isSubStatusCode(cosmosClientException, HttpConstants.SubStatusCodes.NAME_CACHE_IS_STALE)) && lsn >= 0), // TODO: verify where exception.RequestURI is supposed to be set in .Net /* storePhysicalAddress: */ storePhysicalAddress == null ? BridgeInternal.getRequestUri(cosmosClientException) : storePhysicalAddress, @@ -805,7 +805,7 @@ StoreResult createStoreResult(StoreResponse storeResponse, /* partitionKeyRangeId: */ (String) null, /* lsn: */ -1, /* quorumAckedLsn: */ -1, - /* requestCharge: */ 0, + /* getRequestCharge: */ 0, /* currentReplicaSetSize: */ 0, /* currentWriteQuorum: */ 0, /* isValid: */ false, @@ -813,7 +813,7 @@ StoreResult createStoreResult(StoreResponse storeResponse, /* globalCommittedLSN: */-1, /* numberOfReadRegions: */ 0, /* itemLSN: */ -1, - /* sessionToken: */ null); + /* getSessionToken: */ null); } } } @@ -848,7 +848,7 @@ static void verifyCanContinueOnException(CosmosClientException ex) throws Cosmos throw ex; } - String value = ex.responseHeaders().get(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE); + String value = ex.getResponseHeaders().get(HttpConstants.HttpHeaders.REQUEST_VALIDATION_FAILURE); if (Strings.isNullOrWhiteSpace(value)) { return; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponse.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponse.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java index c478df189252..deda87bee668 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/StoreResult.java @@ -63,8 +63,8 @@ public StoreResult( this.currentReplicaSetSize = currentReplicaSetSize; this.currentWriteQuorum = currentWriteQuorum; this.isValid = isValid; - this.isGoneException = this.exception != null && this.exception.statusCode() == HttpConstants.StatusCodes.GONE; - this.isNotFoundException = this.exception != null && this.exception.statusCode() == HttpConstants.StatusCodes.NOTFOUND; + this.isGoneException = this.exception != null && this.exception.getStatusCode() == HttpConstants.StatusCodes.GONE; + this.isNotFoundException = this.exception != null && this.exception.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND; this.isInvalidPartitionException = this.exception != null && Exceptions.isNameCacheStale(this.exception); this.storePhysicalAddress = storePhysicalAddress; @@ -112,7 +112,7 @@ public StoreResponse toResponse(RequestChargeTracker requestChargeTracker) throw private static void setRequestCharge(StoreResponse response, CosmosClientException cosmosClientException, double totalRequestCharge) { if (cosmosClientException != null) { - cosmosClientException.responseHeaders().put(HttpConstants.HttpHeaders.REQUEST_CHARGE, + cosmosClientException.getResponseHeaders().put(HttpConstants.HttpHeaders.REQUEST_CHARGE, Double.toString(totalRequestCharge)); } // Set total charge as final charge for the response. @@ -137,8 +137,8 @@ public String toString() { statusCode = this.storeResponse.getStatus(); subStatusCode = this.storeResponse.getSubStatusCode(); } else if (this.exception != null) { - statusCode = this.exception.statusCode(); - subStatusCode = this.exception.subStatusCode(); + statusCode = this.exception.getStatusCode(); + subStatusCode = this.exception.getSubStatusCode(); } return "storePhysicalAddress: " + this.storePhysicalAddress + diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/TransportException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WFConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WFConstants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WFConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WFConstants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtility.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtility.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtility.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtility.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHandler.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHandler.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHandler.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHandler.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHealthChecker.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHealthChecker.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHealthChecker.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelHealthChecker.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelPool.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelPool.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelPool.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdClientChannelPool.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdConstants.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdConstants.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdConstants.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContext.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContext.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextDecoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextDecoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextDecoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextDecoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextException.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextNegotiator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextNegotiator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextNegotiator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextNegotiator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestDecoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestDecoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestDecoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestDecoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestEncoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestEncoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestEncoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdContextRequestEncoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdEndpoint.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdEndpoint.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdEndpoint.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdEndpoint.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdFramer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdFramer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdFramer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdFramer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdHealthCheckRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdHealthCheckRequest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdHealthCheckRequest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdHealthCheckRequest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdMetrics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdMetrics.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdMetrics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdMetrics.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdObjectMapper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdObjectMapper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdObjectMapper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdObjectMapper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdReporter.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdReporter.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdReporter.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdReporter.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestArgs.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestArgs.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestArgs.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestArgs.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestDecoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestDecoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestDecoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestDecoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestEncoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestEncoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestEncoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestEncoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFrame.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFrame.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFrame.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFrame.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFramer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFramer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFramer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestFramer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestHeaders.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestHeaders.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestHeaders.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestHeaders.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestManager.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestManager.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestManager.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestManager.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestRecord.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestRecord.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestRecord.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestRecord.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestTimer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestTimer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestTimer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdRequestTimer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponse.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponse.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseDecoder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseDecoder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseDecoder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseDecoder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseHeaders.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseHeaders.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseHeaders.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseHeaders.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseStatus.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseStatus.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseStatus.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdResponseStatus.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdServiceEndpoint.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdServiceEndpoint.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdServiceEndpoint.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdServiceEndpoint.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenStream.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenStream.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenStream.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenStream.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdTokenType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdUUID.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdUUID.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdUUID.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/directconnectivity/rntbd/RntbdUUID.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/BufferedHttpResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/BufferedHttpResponse.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/BufferedHttpResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/BufferedHttpResponse.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClientConfig.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClientConfig.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClientConfig.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpClientConfig.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeader.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeader.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeader.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeaders.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeaders.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeaders.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpHeaders.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpRequest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpRequest.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpRequest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpResponse.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpResponse.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/HttpResponse.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/ReactorNettyClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/ReactorNettyClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/ReactorNettyClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/http/ReactorNettyClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java index 52458c3a3e83..244693f44302 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/AggregateDocumentQueryExecutionContext.java @@ -76,14 +76,14 @@ public Flux> drainAsync(int maxPageSize) { for(FeedResponse page : superList) { - if (page.results().size() == 0) { + if (page.getResults().size() == 0) { headers.put(HttpConstants.HttpHeaders.REQUEST_CHARGE, Double.toString(requestCharge)); FeedResponse frp = BridgeInternal.createFeedResponse(aggregateResults, headers); return (FeedResponse) frp; } - Document doc = ((Document)page.results().get(0)); - requestCharge += page.requestCharge(); + Document doc = ((Document)page.getResults().get(0)); + requestCharge += page.getRequestCharge(); QueryItem values = new QueryItem(doc.toJson()); this.aggregator.aggregate(values.getItem()); for(String key : BridgeInternal.queryMetricsFromFeedResponse(page).keySet()) { @@ -127,4 +127,4 @@ public IDocumentQueryExecutionComponent getComponent() { return this.component; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/CompositeContinuationToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/CompositeContinuationToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/CompositeContinuationToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/CompositeContinuationToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java index 2d24f4915e1a..b4257dc2f98f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DefaultDocumentQueryExecutionContext.java @@ -98,7 +98,7 @@ public Flux> executeAsync() { if (isClientSideContinuationToken(originalContinuation)) { // At this point we know we want back a query plan newFeedOptions.requestContinuation(null); - newFeedOptions.maxDegreeOfParallelism(Integer.MAX_VALUE); + newFeedOptions.setMaxDegreeOfParallelism(Integer.MAX_VALUE); } int maxPageSize = newFeedOptions.maxItemCount() != null ? newFeedOptions.maxItemCount() : Constants.Properties.DEFAULT_MAX_PAGE_SIZE; @@ -146,20 +146,20 @@ protected Function>> executeInter }, finalRetryPolicyInstance).flux() .map(tFeedResponse -> { this.fetchSchedulingMetrics.stop(); - this.fetchExecutionRangeAccumulator.endFetchRange(tFeedResponse.activityId(), - tFeedResponse.results().size(), + this.fetchExecutionRangeAccumulator.endFetchRange(tFeedResponse.getActivityId(), + tFeedResponse.getResults().size(), this.retries); ImmutablePair schedulingTimeSpanMap = new ImmutablePair<>(DEFAULT_PARTITION_KEY_RANGE_ID, this.fetchSchedulingMetrics.getElapsedTime()); - if (!StringUtils.isEmpty(tFeedResponse.responseHeaders().get(HttpConstants.HttpHeaders.QUERY_METRICS))) { + if (!StringUtils.isEmpty(tFeedResponse.getResponseHeaders().get(HttpConstants.HttpHeaders.QUERY_METRICS))) { QueryMetrics qm = - BridgeInternal.createQueryMetricsFromDelimitedStringAndClientSideMetrics(tFeedResponse.responseHeaders() + BridgeInternal.createQueryMetricsFromDelimitedStringAndClientSideMetrics(tFeedResponse.getResponseHeaders() .get(HttpConstants.HttpHeaders.QUERY_METRICS), new ClientSideMetrics(this.retries, - tFeedResponse.requestCharge(), + tFeedResponse.getRequestCharge(), this.fetchExecutionRangeAccumulator.getExecutionRanges(), Arrays.asList(schedulingTimeSpanMap)), - tFeedResponse.activityId()); + tFeedResponse.getActivityId()); BridgeInternal.putQueryMetricsIntoMap(tFeedResponse, DEFAULT_PARTITION_KEY_RANGE_ID, qm); } return tFeedResponse; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java index 8a43928e6b71..58d756d4f4db 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentProducer.java @@ -63,19 +63,19 @@ class DocumentProducerFeedResponse { } void populatePartitionedQueryMetrics() { - String queryMetricsDelimitedString = pageResult.responseHeaders().get(HttpConstants.HttpHeaders.QUERY_METRICS); + String queryMetricsDelimitedString = pageResult.getResponseHeaders().get(HttpConstants.HttpHeaders.QUERY_METRICS); if (!StringUtils.isEmpty(queryMetricsDelimitedString)) { - queryMetricsDelimitedString += String.format(";%s=%.2f", QueryMetricsConstants.RequestCharge, pageResult.requestCharge()); + queryMetricsDelimitedString += String.format(";%s=%.2f", QueryMetricsConstants.RequestCharge, pageResult.getRequestCharge()); ImmutablePair schedulingTimeSpanMap = - new ImmutablePair<>(targetRange.id(), fetchSchedulingMetrics.getElapsedTime()); + new ImmutablePair<>(targetRange.getId(), fetchSchedulingMetrics.getElapsedTime()); QueryMetrics qm =BridgeInternal.createQueryMetricsFromDelimitedStringAndClientSideMetrics(queryMetricsDelimitedString, new ClientSideMetrics(retries, - pageResult.requestCharge(), + pageResult.getRequestCharge(), fetchExecutionRangeAccumulator.getExecutionRanges(), Arrays.asList(schedulingTimeSpanMap) - ), pageResult.activityId()); - BridgeInternal.putQueryMetricsIntoMap(pageResult, targetRange.id(), qm); + ), pageResult.getActivityId()); + BridgeInternal.putQueryMetricsIntoMap(pageResult, targetRange.getId(), qm); } } } @@ -119,7 +119,7 @@ public DocumentProducer( this.fetchSchedulingMetrics = new SchedulingStopwatch(); this.fetchSchedulingMetrics.ready(); - this.fetchExecutionRangeAccumulator = new FetchExecutionRangeAccumulator(targetRange.id()); + this.fetchExecutionRangeAccumulator = new FetchExecutionRangeAccumulator(targetRange.getId()); this.executeRequestFuncWithRetries = request -> { retries = -1; @@ -166,9 +166,9 @@ public Flux produceAsync() { top, pageSize) .map(rsp -> { - lastResponseContinuationToken = rsp.continuationToken(); - this.fetchExecutionRangeAccumulator.endFetchRange(rsp.activityId(), - rsp.results().size(), + lastResponseContinuationToken = rsp.getContinuationToken(); + this.fetchExecutionRangeAccumulator.endFetchRange(rsp.getActivityId(), + rsp.getResults().size(), this.retries); this.fetchSchedulingMetrics.stop(); return rsp;}); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java index 982b81e2d9e0..9f8de788cc1f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/DocumentQueryExecutionContextBase.java @@ -123,7 +123,7 @@ public Map createCommonHeadersAsync(FeedOptions feedOptions) { ConsistencyLevel defaultConsistencyLevel = this.client.getDefaultConsistencyLevelAsync(); ConsistencyLevel desiredConsistencyLevel = this.client.getDesiredConsistencyLevelAsync(); - if (!Strings.isNullOrEmpty(feedOptions.sessionToken()) + if (!Strings.isNullOrEmpty(feedOptions.getSessionToken()) && !ReplicatedResourceClientUtils.isReadingFromMaster(this.resourceTypeEnum, OperationType.ReadFeed)) { if (defaultConsistencyLevel == ConsistencyLevel.SESSION || (desiredConsistencyLevel == ConsistencyLevel.SESSION)) { @@ -141,7 +141,7 @@ public Map createCommonHeadersAsync(FeedOptions feedOptions) { // irrespective of the chosen replica. // For server resources, which don't span partitions, specify the session token // for correct replica to be chosen for servicing the query result. - requestHeaders.put(HttpConstants.HttpHeaders.SESSION_TOKEN, feedOptions.sessionToken()); + requestHeaders.put(HttpConstants.HttpHeaders.SESSION_TOKEN, feedOptions.getSessionToken()); } } @@ -153,24 +153,24 @@ public Map createCommonHeadersAsync(FeedOptions feedOptions) { requestHeaders.put(HttpConstants.HttpHeaders.PAGE_SIZE, Strings.toString(feedOptions.maxItemCount())); } - if (feedOptions.enableCrossPartitionQuery() != null) { + if (feedOptions.getEnableCrossPartitionQuery() != null) { requestHeaders.put(HttpConstants.HttpHeaders.ENABLE_CROSS_PARTITION_QUERY, - Strings.toString(feedOptions.enableCrossPartitionQuery())); + Strings.toString(feedOptions.getEnableCrossPartitionQuery())); } - if (feedOptions.maxDegreeOfParallelism() != 0) { + if (feedOptions.getMaxDegreeOfParallelism() != 0) { requestHeaders.put(HttpConstants.HttpHeaders.PARALLELIZE_CROSS_PARTITION_QUERY, Strings.toString(true)); } - if (this.feedOptions.enableCrossPartitionQuery() != null) { + if (this.feedOptions.getEnableCrossPartitionQuery() != null) { requestHeaders.put(HttpConstants.HttpHeaders.ENABLE_SCAN_IN_QUERY, - Strings.toString(this.feedOptions.enableCrossPartitionQuery())); + Strings.toString(this.feedOptions.getEnableCrossPartitionQuery())); } - if (this.feedOptions.responseContinuationTokenLimitInKb() > 0) { + if (this.feedOptions.setResponseContinuationTokenLimitInKb() > 0) { requestHeaders.put(HttpConstants.HttpHeaders.RESPONSE_CONTINUATION_TOKEN_LIMIT_IN_KB, - Strings.toString(feedOptions.responseContinuationTokenLimitInKb())); + Strings.toString(feedOptions.setResponseContinuationTokenLimitInKb())); } if (desiredConsistencyLevel != null) { @@ -207,7 +207,7 @@ public void populatePartitionKeyRangeInfo(RxDocumentServiceRequest request, Part } if (this.resourceTypeEnum.isPartitioned()) { - request.routeTo(new PartitionKeyRangeIdentity(collectionRid, range.id())); + request.routeTo(new PartitionKeyRangeIdentity(collectionRid, range.getId())); } } @@ -218,7 +218,7 @@ private RxDocumentServiceRequest createQueryDocumentServiceRequest(Map 0, "query.parameters", "Unsupported argument in query compatibility mode '%s'", this.client.getQueryCompatibilityMode().toString()); @@ -229,7 +229,7 @@ private RxDocumentServiceRequest createQueryDocumentServiceRequest(Map> nextPage() { } private void updateState(FeedResponse response) { - continuationToken = response.continuationToken(); + continuationToken = response.getContinuationToken(); if (top != -1) { - top -= response.results().size(); + top -= response.getResults().size(); if (top < 0) { // this shouldn't happen // this means backend retrieved more items than requested diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryClient.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryClient.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryClient.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionContext.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/IDocumentQueryExecutionContext.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemComparator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemComparator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemComparator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemComparator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java index feb77f937a9b..2ad0fff7c348 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ItemTypeHelper.java @@ -29,4 +29,4 @@ public static ItemType getOrderByItemType(Object obj) { throw new IllegalArgumentException(String.format("Unexpected type: %s", obj.getClass().toString())); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByContinuationToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByContinuationToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByContinuationToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByContinuationToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentProducer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentProducer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentProducer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentProducer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java index a6ac400083c5..3af333069f1f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByDocumentQueryExecutionContext.java @@ -132,9 +132,9 @@ private void initialize( super.initialize(collectionRid, partitionKeyRangeToContinuationToken, initialPageSize, - new SqlQuerySpec(querySpec.queryText().replace(FormatPlaceHolder, + new SqlQuerySpec(querySpec.getQueryText().replace(FormatPlaceHolder, True), - querySpec.parameters())); + querySpec.getParameters())); } else { // Check to see if order by continuation token is a valid JSON. OrderByContinuationToken orderByContinuationToken; @@ -223,9 +223,9 @@ private void initializeRangeWithContinuationTokenAndFilter( super.initialize(collectionRid, partitionKeyRangeToContinuationToken, initialPageSize, - new SqlQuerySpec(querySpec.queryText().replace(FormatPlaceHolder, + new SqlQuerySpec(querySpec.getQueryText().replace(FormatPlaceHolder, filter), - querySpec.parameters())); + querySpec.getParameters())); } private ImmutablePair GetFiltersForPartitions( @@ -412,10 +412,10 @@ private static Map headerResponse( private FeedResponse> addOrderByContinuationToken( FeedResponse> page, String orderByContinuationToken) { - Map headers = new HashMap<>(page.responseHeaders()); + Map headers = new HashMap<>(page.getResponseHeaders()); headers.put(HttpConstants.HttpHeaders.CONTINUATION, orderByContinuationToken); - return BridgeInternal.createFeedResponseWithQueryMetrics(page.results(), + return BridgeInternal.createFeedResponseWithQueryMetrics(page.getResults(), headers, BridgeInternal.queryMetricsFromFeedResponse(page)); } @@ -469,7 +469,7 @@ public Flux> apply(Flux> source) { FeedResponse> next = currentNext.right; FeedResponse> page; - if (next.results().size() == 0) { + if (next.getResults().size() == 0) { // No more pages no send current page with null continuation token page = current; page = this.addOrderByContinuationToken(page, @@ -478,7 +478,7 @@ public Flux> apply(Flux> source) { // Give the first page but use the first value in the next page to generate the // continuation token page = current; - List> results = next.results(); + List> results = next.getResults(); OrderByRowResult firstElementInNextPage = results.get(0); String orderByContinuationToken = this.orderByContinuationTokenCallback .apply(firstElementInNextPage); @@ -490,12 +490,12 @@ public Flux> apply(Flux> source) { }).map(feedOfOrderByRowResults -> { // FeedResponse> to FeedResponse List unwrappedResults = new ArrayList(); - for (OrderByRowResult orderByRowResult : feedOfOrderByRowResults.results()) { + for (OrderByRowResult orderByRowResult : feedOfOrderByRowResults.getResults()) { unwrappedResults.add(orderByRowResult.getPayload()); } return BridgeInternal.createFeedResponseWithQueryMetrics(unwrappedResults, - feedOfOrderByRowResults.responseHeaders(), + feedOfOrderByRowResults.getResponseHeaders(), BridgeInternal.queryMetricsFromFeedResponse(feedOfOrderByRowResults)); }).switchIfEmpty(Flux.defer(() -> { // create an empty page if there is no result @@ -552,7 +552,7 @@ public Flux> executeAsync() { private String getContinuationToken( OrderByRowResult orderByRowResult) { // rid - String rid = orderByRowResult.resourceId(); + String rid = orderByRowResult.getResourceId(); // CompositeContinuationToken String backendContinuationToken = orderByRowResult.getSourceBackendContinuationToken(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java index e708c7399d5c..f2f1a181951d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/OrderByUtils.java @@ -76,8 +76,8 @@ public Flux> apply(Flux.DocumentProducer queryMetricsMap.put(key, BridgeInternal.queryMetricsFromFeedResponse(documentProducerFeedResponse.pageResult).get(key)); } } - List results = documentProducerFeedResponse.pageResult.results(); - OrderByContinuationToken orderByContinuationToken = targetRangeToOrderByContinuationTokenMap.get(documentProducerFeedResponse.sourcePartitionKeyRange.id()); + List results = documentProducerFeedResponse.pageResult.getResults(); + OrderByContinuationToken orderByContinuationToken = targetRangeToOrderByContinuationTokenMap.get(documentProducerFeedResponse.sourcePartitionKeyRange.getId()); if (orderByContinuationToken != null) { Pair booleanResourceIdPair = ResourceId.tryParse(orderByContinuationToken.getRid()); if (!booleanResourceIdPair.getLeft()) { @@ -117,7 +117,7 @@ public Flux> apply(Flux.DocumentProducer // If there is a tie in the sort order the documents should be in _rid order in the same direction as the first order by field. // So if it's ORDER BY c.age ASC, c.name DESC the _rids are ASC // If ti's ORDER BY c.age DESC, c.name DESC the _rids are DESC - cmp = (continuationTokenRid.getDocument() - ResourceId.tryParse(tOrderByRowResult.resourceId()).getRight().getDocument()); + cmp = (continuationTokenRid.getDocument() - ResourceId.tryParse(tOrderByRowResult.getResourceId()).getRight().getDocument()); if (sortOrders.iterator().next().equals(SortOrder.Descending)) { cmp = -cmp; @@ -131,14 +131,14 @@ public Flux> apply(Flux.DocumentProducer } - tracker.addCharge(documentProducerFeedResponse.pageResult.requestCharge()); + tracker.addCharge(documentProducerFeedResponse.pageResult.getRequestCharge()); Flux x = Flux.fromIterable(results); return x.map(r -> new OrderByRowResult( klass, r.toJson(), documentProducerFeedResponse.sourcePartitionKeyRange, - documentProducerFeedResponse.pageResult.continuationToken())); + documentProducerFeedResponse.pageResult.getContinuationToken())); }, 1); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java index 5a35e07e15a0..35162baa466b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/Paginator.java @@ -26,7 +26,7 @@ public static Flux> getPaginatedChangeFeedQ ChangeFeedOptions feedOptions, BiFunction createRequestFunc, Function>> executeFunc, Class resourceType, int maxPageSize) { - return getPaginatedQueryResultAsObservable(feedOptions.requestContinuation(), createRequestFunc, executeFunc, resourceType, + return getPaginatedQueryResultAsObservable(feedOptions.getRequestContinuation(), createRequestFunc, executeFunc, resourceType, -1, maxPageSize, true); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java index cd84e15bca88..d0340df73b65 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContext.java @@ -185,12 +185,12 @@ private DocumentProducer.DocumentProducerFeedResponse plusCharge( DocumentProducer.DocumentProducerFeedResponse documentProducerFeedResponse, double charge) { FeedResponse page = documentProducerFeedResponse.pageResult; - Map headers = new HashMap<>(page.responseHeaders()); - double pageCharge = page.requestCharge(); + Map headers = new HashMap<>(page.getResponseHeaders()); + double pageCharge = page.getRequestCharge(); pageCharge += charge; headers.put(HttpConstants.HttpHeaders.REQUEST_CHARGE, String.valueOf(pageCharge)); - FeedResponse newPage = BridgeInternal.createFeedResponseWithQueryMetrics(page.results(), + FeedResponse newPage = BridgeInternal.createFeedResponseWithQueryMetrics(page.getResults(), headers, BridgeInternal.queryMetricsFromFeedResponse(page)); documentProducerFeedResponse.pageResult = newPage; @@ -201,10 +201,10 @@ private DocumentProducer.DocumentProducerFeedResponse addCompositeContinuatio DocumentProducer.DocumentProducerFeedResponse documentProducerFeedResponse, String compositeContinuationToken) { FeedResponse page = documentProducerFeedResponse.pageResult; - Map headers = new HashMap<>(page.responseHeaders()); + Map headers = new HashMap<>(page.getResponseHeaders()); headers.put(HttpConstants.HttpHeaders.CONTINUATION, compositeContinuationToken); - FeedResponse newPage = BridgeInternal.createFeedResponseWithQueryMetrics(page.results(), + FeedResponse newPage = BridgeInternal.createFeedResponseWithQueryMetrics(page.getResults(), headers, BridgeInternal.queryMetricsFromFeedResponse(page)); documentProducerFeedResponse.pageResult = newPage; @@ -222,9 +222,9 @@ public Flux> apply(Flux.DocumentProducerFeed // Emit an empty page so the downstream observables know when there are no more // results. return source.filter(documentProducerFeedResponse -> { - if (documentProducerFeedResponse.pageResult.results().isEmpty()) { + if (documentProducerFeedResponse.pageResult.getResults().isEmpty()) { // filter empty pages and accumulate charge - tracker.addCharge(documentProducerFeedResponse.pageResult.requestCharge()); + tracker.addCharge(documentProducerFeedResponse.pageResult.getRequestCharge()); return false; } return true; @@ -253,7 +253,7 @@ public Flux> apply(Flux.DocumentProducerFeed DocumentProducer.DocumentProducerFeedResponse next = currentNext.right; String compositeContinuationToken; - String backendContinuationToken = current.pageResult.continuationToken(); + String backendContinuationToken = current.pageResult.getContinuationToken(); if (backendContinuationToken == null) { // We just finished reading the last document from a partition if (next == null) { diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java index e63832fb0f3b..d342f09ade96 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelDocumentQueryExecutionContextBase.java @@ -50,7 +50,7 @@ protected ParallelDocumentQueryExecutionContextBase(IDocumentQueryClient client, this.partitionKeyRanges = partitionKeyRanges; if (!Strings.isNullOrEmpty(rewrittenQuery)) { - this.querySpec = new SqlQuerySpec(rewrittenQuery, super.query.parameters()); + this.querySpec = new SqlQuerySpec(rewrittenQuery, super.query.getParameters()); } else { this.querySpec = super.query; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelQueryConfig.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelQueryConfig.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelQueryConfig.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ParallelQueryConfig.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfo.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfo.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfo.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfo.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfoInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfoInternal.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfoInternal.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PartitionedQueryExecutionInfoInternal.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PipelinedDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PipelinedDocumentQueryExecutionContext.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PipelinedDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/PipelinedDocumentQueryExecutionContext.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java index 9f9310935921..06b33b5d011a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/ProxyDocumentQueryExecutionContext.java @@ -95,14 +95,14 @@ public Flux> executeAsync() { CosmosClientException dce = (CosmosClientException) t; PartitionedQueryExecutionInfo partitionedQueryExecutionInfo = new - PartitionedQueryExecutionInfo(dce.error().getPartitionedQueryExecutionInfo()); + PartitionedQueryExecutionInfo(dce.getError().getPartitionedQueryExecutionInfo()); logger.debug("Query Plan from gateway {}", partitionedQueryExecutionInfo); DefaultDocumentQueryExecutionContext queryExecutionContext = (DefaultDocumentQueryExecutionContext) this.innerExecutionContext; - Mono> partitionKeyRanges = queryExecutionContext.getTargetPartitionKeyRanges(collection.resourceId(), + Mono> partitionKeyRanges = queryExecutionContext.getTargetPartitionKeyRanges(collection.getResourceId(), partitionedQueryExecutionInfo.getQueryRanges()); Flux> exContext = partitionKeyRanges.flux() @@ -116,7 +116,7 @@ public Flux> executeAsync() { isContinuationExpected, partitionedQueryExecutionInfo, pkranges, - this.collection.resourceId(), + this.collection.getResourceId(), this.correlatedActivityId)); return exContext.flatMap(IDocumentQueryExecutionContext::executeAsync); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java index b610cf6630c4..5c641f6044ce 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryInfo.java @@ -68,4 +68,4 @@ public Collection getOrderByExpressions() { ? this.orderByExpressions : (this.orderByExpressions = super.getCollection("orderByExpressions", String.class)); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryItem.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryItem.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryItem.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/QueryItem.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java index 8f53f4bb0ae5..de628dda0d04 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/SortOrder.java @@ -8,4 +8,4 @@ */ public enum SortOrder { Ascending, Descending, -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TakeContinuationToken.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TakeContinuationToken.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TakeContinuationToken.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TakeContinuationToken.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java index 72e708d7641f..f9b9541ab6a4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TopDocumentQueryExecutionContext.java @@ -79,7 +79,7 @@ public Flux> drainAsync(int maxPageSize) { @Override public boolean test(FeedResponse frp) { - fetchedItems += frp.results().size(); + fetchedItems += frp.getResults().size(); // take until we have at least top many elements fetched return fetchedItems >= top; @@ -92,13 +92,13 @@ public boolean test(FeedResponse frp) { @Override public FeedResponse apply(FeedResponse t) { - if (collectedItems + t.results().size() <= top) { - collectedItems += t.results().size(); + if (collectedItems + t.getResults().size() <= top) { + collectedItems += t.getResults().size(); - Map headers = new HashMap<>(t.responseHeaders()); + Map headers = new HashMap<>(t.getResponseHeaders()); if (top != collectedItems) { // Add Take Continuation Token - String sourceContinuationToken = t.continuationToken(); + String sourceContinuationToken = t.getContinuationToken(); TakeContinuationToken takeContinuationToken = new TakeContinuationToken(top - collectedItems, sourceContinuationToken); headers.put(HttpConstants.HttpHeaders.CONTINUATION, takeContinuationToken.toJson()); @@ -107,7 +107,7 @@ public FeedResponse apply(FeedResponse t) { headers.put(HttpConstants.HttpHeaders.CONTINUATION, null); } - return BridgeInternal.createFeedResponseWithQueryMetrics(t.results(), headers, + return BridgeInternal.createFeedResponseWithQueryMetrics(t.getResults(), headers, BridgeInternal.queryMetricsFromFeedResponse(t)); } else { assert lastPage == false; @@ -116,10 +116,10 @@ public FeedResponse apply(FeedResponse t) { collectedItems += lastPageSize; // Null out the continuation token - Map headers = new HashMap<>(t.responseHeaders()); + Map headers = new HashMap<>(t.getResponseHeaders()); headers.put(HttpConstants.HttpHeaders.CONTINUATION, null); - return BridgeInternal.createFeedResponseWithQueryMetrics(t.results().subList(0, lastPageSize), + return BridgeInternal.createFeedResponseWithQueryMetrics(t.getResults().subList(0, lastPageSize), headers, BridgeInternal.queryMetricsFromFeedResponse(t)); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java index fc4772ad8e94..ea7d4b59e7ca 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/TriFunction.java @@ -20,4 +20,4 @@ public interface TriFunction { * @return the function result */ R apply(T t, U u, V v); -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AggregateOperator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AggregateOperator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AggregateOperator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AggregateOperator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/Aggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/Aggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/Aggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/Aggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AverageAggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AverageAggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AverageAggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/AverageAggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/CountAggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/CountAggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/CountAggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/CountAggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MaxAggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MaxAggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MaxAggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MaxAggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MinAggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MinAggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MinAggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/MinAggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/SumAggregator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/SumAggregator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/SumAggregator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/aggregation/SumAggregator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/ClientSideMetrics.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/ClientSideMetrics.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/ClientSideMetrics.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/ClientSideMetrics.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRange.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRange.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRange.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRange.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRangeAccumulator.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRangeAccumulator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRangeAccumulator.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/FetchExecutionRangeAccumulator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsTextWriter.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsTextWriter.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsTextWriter.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsTextWriter.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsWriter.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsWriter.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsWriter.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/QueryMetricsWriter.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingStopwatch.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingStopwatch.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingStopwatch.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingStopwatch.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingTimeSpan.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingTimeSpan.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingTimeSpan.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/SchedulingTimeSpan.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/TextTable.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/TextTable.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/TextTable.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/metrics/TextTable.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java index 20b232162b41..4f3c0df07ce4 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderByRowResult.java @@ -46,4 +46,4 @@ public PartitionKeyRange getSourcePartitionKeyRange() { public String getSourceBackendContinuationToken() { return this.backendContinuationToken; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderbyRowComparer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderbyRowComparer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderbyRowComparer.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/query/orderbyquery/OrderbyRowComparer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/BoolPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/BoolPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/BoolPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/BoolPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CaseInsensitiveHashMap.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CaseInsensitiveHashMap.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CaseInsensitiveHashMap.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CaseInsensitiveHashMap.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CollectionRoutingMap.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CollectionRoutingMap.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CollectionRoutingMap.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/CollectionRoutingMap.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IServerIdentity.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IServerIdentity.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IServerIdentity.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/IServerIdentity.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java index 05a1516a95c3..f8e1137f407e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMap.java @@ -57,7 +57,7 @@ public static InMemoryCollectionRoutingMap tryCreateCompleteRoutingMap( new HashMap<>(); for (ImmutablePair range: ranges) { - rangeById.put(range.left.id(), range); + rangeById.put(range.left.getId(), range); } List> sortedRanges = new ArrayList<>(rangeById.values()); @@ -215,11 +215,11 @@ public CollectionRoutingMap tryCombine( newGoneRanges.addAll(this.goneRanges); Map> newRangeById = - this.rangeById.values().stream().filter(tuple -> !newGoneRanges.contains(tuple.left.id())).collect(Collectors. - toMap(tuple -> tuple.left.id(), tuple -> tuple)); + this.rangeById.values().stream().filter(tuple -> !newGoneRanges.contains(tuple.left.getId())).collect(Collectors. + toMap(tuple -> tuple.left.getId(), tuple -> tuple)); - for (ImmutablePair tuple : ranges.stream().filter(tuple -> !newGoneRanges.contains(tuple.getLeft().id())).collect(Collectors.toList())) { - newRangeById.put(tuple.getLeft().id(), tuple); + for (ImmutablePair tuple : ranges.stream().filter(tuple -> !newGoneRanges.contains(tuple.getLeft().getId())).collect(Collectors.toList())) { + newRangeById.put(tuple.getLeft().getId(), tuple); } List> sortedRanges = newRangeById.values().stream().collect(Collectors.toList()); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InfinityPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InfinityPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InfinityPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/InfinityPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Int128.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Int128.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Int128.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Int128.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java index ba0596c8e5f5..bcaac3877ba7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationCache.java @@ -119,8 +119,8 @@ public void markEndpointUnavailableForWrite(URL endpoint) { */ public void onDatabaseAccountRead(DatabaseAccount databaseAccount) { this.updateLocationCache( - databaseAccount.writableLocations(), - databaseAccount.readableLocations(), + databaseAccount.getWritableLocations(), + databaseAccount.getReadableLocations(), null, BridgeInternal.isEnableMultipleWriteLocations(databaseAccount)); } @@ -138,15 +138,15 @@ void onLocationPreferenceChanged(UnmodifiableList preferredLocations) { * Once the endpoint is marked unavailable, it is moved to the end of available write endpoint. Current request will * be retried on next preferred available write endpoint. * (ii) For all other resources, always resolve to first/second (regardless of preferred locations) - * write endpoint in {@link DatabaseAccount#writableLocations()}. - * Endpoint of first write location in {@link DatabaseAccount#writableLocations()} is the only endpoint that supports + * write getEndpoint in {@link DatabaseAccount#getWritableLocations()}. + * Endpoint of first write location in {@link DatabaseAccount#getWritableLocations()} is the only getEndpoint that supports * write operation on all resource types (except during that region's failover). - * Only during manual failover, client would retry write on second write location in {@link DatabaseAccount#writableLocations()}. - * (b) Else resolve the request to first write endpoint in {@link DatabaseAccount#writableLocations()} OR - * second write endpoint in {@link DatabaseAccount#writableLocations()} in case of manual failover of that location. - * 2. Else resolve the request to most preferred available read endpoint (automatic failover for read requests) - * @param request Request for which endpoint is to be resolved - * @return Resolved endpoint + * Only during manual failover, client would retry write on second write location in {@link DatabaseAccount#getWritableLocations()}. + * (b) Else resolve the request to first write getEndpoint in {@link DatabaseAccount#getWritableLocations()} OR + * second write getEndpoint in {@link DatabaseAccount#getWritableLocations()} in case of manual failover of that location. + * 2. Else resolve the request to most preferred available read getEndpoint (getAutomatic failover for read requests) + * @param request Request for which getEndpoint is to be resolved + * @return Resolved getEndpoint */ public URL resolveServiceEndpoint(RxDocumentServiceRequest request) { if(request.requestContext != null && request.requestContext.locationEndpointToRoute != null) { @@ -440,16 +440,16 @@ private UnmodifiableMap getEndpointByLocation(Iterable parsedLocations = new ArrayList<>(); for (DatabaseAccountLocation location: locations) { - if (!Strings.isNullOrEmpty(location.name())) { + if (!Strings.isNullOrEmpty(location.getName())) { try { - URL endpoint = new URL(location.endpoint().toLowerCase()); - endpointsByLocation.put(location.name().toLowerCase(), endpoint); - parsedLocations.add(location.name()); + URL endpoint = new URL(location.getEndpoint().toLowerCase()); + endpointsByLocation.put(location.getName().toLowerCase(), endpoint); + parsedLocations.add(location.getName()); } catch (Exception e) { logger.warn("GetAvailableEndpointsByLocation() - skipping add for location = [{}] as it is location name is either empty or endpoint is malformed [{}]", - location.name(), - location.endpoint()); + location.getName(), + location.getEndpoint()); } } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/LocationHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxNumberPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxNumberPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxNumberPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxNumberPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxStringPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxStringPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxStringPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MaxStringPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinNumberPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinNumberPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinNumberPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinNumberPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinStringPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinStringPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinStringPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MinStringPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_128.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_128.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_128.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_128.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_32.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_32.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_32.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/MurmurHash3_32.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NullPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NullPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NullPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NullPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NumberPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NumberPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NumberPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/NumberPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyAndResourceTokenPair.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyAndResourceTokenPair.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyAndResourceTokenPair.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyAndResourceTokenPair.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyComponentType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyComponentType.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyComponentType.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyComponentType.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternal.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternal.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternal.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java index 3ba39702b54c..a879d5980cfb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalHelper.java @@ -132,15 +132,15 @@ public static String getEffectivePartitionKeyString(PartitionKeyInternal partiti return MaximumExclusiveEffectivePartitionKey; } - if (partitionKeyInternal.components.size() < partitionKeyDefinition.paths().size()) { + if (partitionKeyInternal.components.size() < partitionKeyDefinition.getPaths().size()) { throw new IllegalArgumentException(RMResources.TooFewPartitionKeyComponents); } - if (partitionKeyInternal.components.size() > partitionKeyDefinition.paths().size() && strict) { + if (partitionKeyInternal.components.size() > partitionKeyDefinition.getPaths().size() && strict) { throw new IllegalArgumentException(RMResources.TooManyPartitionKeyComponents); } - PartitionKind kind = partitionKeyDefinition.kind(); + PartitionKind kind = partitionKeyDefinition.getKind(); if (kind == null) { kind = PartitionKind.HASH; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyRangeIdentity.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyRangeIdentity.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyRangeIdentity.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/PartitionKeyRangeIdentity.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Range.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Range.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Range.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/Range.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProvider.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProvider.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProvider.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProvider.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelper.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelper.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UInt128.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UInt128.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UInt128.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UInt128.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UndefinedPartitionKeyComponent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UndefinedPartitionKeyComponent.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UndefinedPartitionKeyComponent.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/internal/routing/UndefinedPartitionKeyComponent.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/package-info.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/package-info.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/package-info.java rename to sdk/cosmos/azure-cosmos/src/main/java/com/azure/data/cosmos/package-info.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java index 6dde420a393d..343baff8e539 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/BridgeUtils.java @@ -35,17 +35,17 @@ public static ConflictResolutionPolicy createConflictResolutionPolicy() { } public static ConflictResolutionPolicy setMode(ConflictResolutionPolicy policy, ConflictResolutionMode mode) { - policy.mode(mode); + policy.setMode(mode); return policy; } public static ConflictResolutionPolicy setPath(ConflictResolutionPolicy policy, String path) { - policy.conflictResolutionPath(path); + policy.setConflictResolutionPath(path); return policy; } public static ConflictResolutionPolicy setStoredProc(ConflictResolutionPolicy policy, String storedProcLink) { - policy.conflictResolutionProcedure(storedProcLink); + policy.setConflictResolutionProcedure(storedProcLink); return policy; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java similarity index 51% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java index ae651447b7ef..2058135de74f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ClientUnderTestBuilder.java @@ -12,29 +12,29 @@ public class ClientUnderTestBuilder extends CosmosClientBuilder { public ClientUnderTestBuilder(CosmosClientBuilder builder) { this.configs(builder.configs()); - this.connectionPolicy(builder.connectionPolicy()); - this.consistencyLevel(builder.consistencyLevel()); - this.key(builder.key()); - this.endpoint(builder.endpoint()); - this.cosmosKeyCredential(builder.cosmosKeyCredential()); + this.setConnectionPolicy(builder.getConnectionPolicy()); + this.setConsistencyLevel(builder.getConsistencyLevel()); + this.setKey(builder.getKey()); + this.setEndpoint(builder.getEndpoint()); + this.setCosmosKeyCredential(builder.getCosmosKeyCredential()); } @Override - public CosmosClient build() { + public CosmosAsyncClient buildAsyncClient() { RxDocumentClientUnderTest rxClient; try { rxClient = new RxDocumentClientUnderTest( - new URI(this.endpoint()), - this.key(), - this.connectionPolicy(), - this.consistencyLevel(), + new URI(this.getEndpoint()), + this.getKey(), + this.getConnectionPolicy(), + this.getConsistencyLevel(), this.configs(), - this.cosmosKeyCredential()); + this.getCosmosKeyCredential()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } - CosmosClient cosmosClient = super.build(); - ReflectionUtils.setAsyncDocumentClient(cosmosClient, rxClient); - return cosmosClient; + CosmosAsyncClient cosmosAsyncClient = super.buildAsyncClient(); + ReflectionUtils.setAsyncDocumentClient(cosmosAsyncClient, rxClient); + return cosmosAsyncClient; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java index 56cb39d2da3a..3c8099ff3921 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConflictTests.java @@ -44,9 +44,9 @@ public void getResourceType() { public void getResource() { Conflict conf = new Conflict(conflictAsString); Document doc = conf.getResource(Document.class); - assertThat(doc.id()).isEqualTo("0007312a-a1c5-4b54-9e39-35de2367fa33"); + assertThat(doc.getId()).isEqualTo("0007312a-a1c5-4b54-9e39-35de2367fa33"); assertThat(doc.getInt("regionId")).isEqualTo(2); - assertThat(doc.resourceId()).isEqualTo("k6d9ALgBmD+ChB4AAAAAAA=="); - assertThat(doc.etag()).isEqualTo("\"00000200-0000-0000-0000-5b6e214b0000\""); + assertThat(doc.getResourceId()).isEqualTo("k6d9ALgBmD+ChB4AAAAAAA=="); + assertThat(doc.getETag()).isEqualTo("\"00000200-0000-0000-0000-5b6e214b0000\""); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java index cb45aedccc22..aa4b682f46b7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ConnectionPolicyTest.java @@ -22,9 +22,9 @@ public Object[][] connectionModeArgProvider() { @Test(groups = { "unit" }, dataProvider = "connectionModeArgProvider") public void connectionMode(ConnectionMode connectionMode) { ConnectionPolicy policy = new ConnectionPolicy(); - policy.connectionMode(connectionMode); + policy.setConnectionMode(connectionMode); - assertThat(policy.connectionMode()).isEqualTo(connectionMode); + assertThat(policy.getConnectionMode()).isEqualTo(connectionMode); } @DataProvider(name = "connectionProtocolModeArgProvider") diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosAsyncClientTest.java similarity index 75% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosAsyncClientTest.java index e85587ff8e22..a812433b251c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosAsyncClientTest.java @@ -10,16 +10,16 @@ import java.lang.reflect.Method; -public abstract class CosmosClientTest implements ITest { +public abstract class CosmosAsyncClientTest implements ITest { private final CosmosClientBuilder clientBuilder; private String testName; - public CosmosClientTest() { + public CosmosAsyncClientTest() { this(new CosmosClientBuilder()); } - public CosmosClientTest(CosmosClientBuilder clientBuilder) { + public CosmosAsyncClientTest(CosmosClientBuilder clientBuilder) { this.clientBuilder = clientBuilder; } @@ -38,15 +38,15 @@ public final void setTestName(Method method) { method.getDeclaringClass().getSimpleName(), method.getName()); - if (this.clientBuilder.connectionPolicy() != null && this.clientBuilder.configs() != null) { - String connectionMode = this.clientBuilder.connectionPolicy().connectionMode() == ConnectionMode.DIRECT + if (this.clientBuilder.getConnectionPolicy() != null && this.clientBuilder.configs() != null) { + String connectionMode = this.clientBuilder.getConnectionPolicy().getConnectionMode() == ConnectionMode.DIRECT ? "Direct " + this.clientBuilder.configs().getProtocol() : "Gateway"; this.testName = Strings.lenientFormat("%s[%s with %s consistency]", testClassAndMethodName, connectionMode, - clientBuilder.consistencyLevel()); + clientBuilder.getConsistencyLevel()); } else { this.testName = testClassAndMethodName; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java index 1f3fa5e09c88..e4a327b0edcb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosClientExceptionTest.java @@ -15,50 +15,50 @@ public class CosmosClientExceptionTest { @Test(groups = { "unit" }) public void headerNotNull1() { CosmosClientException dce = BridgeInternal.createCosmosClientException(0); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull2() { CosmosClientException dce = BridgeInternal.createCosmosClientException(0, "dummy"); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull3() { CosmosClientException dce = BridgeInternal.createCosmosClientException(0, new RuntimeException()); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull4() { CosmosClientException dce = BridgeInternal.createCosmosClientException(0, (CosmosError) null, (Map) null); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull5() { CosmosClientException dce = BridgeInternal.createCosmosClientException((String) null, 0, (CosmosError) null, (Map) null); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull6() { CosmosClientException dce = BridgeInternal.createCosmosClientException((String) null, (Exception) null, (Map) null, 0, (String) null); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).isEmpty(); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).isEmpty(); } @Test(groups = { "unit" }) public void headerNotNull7() { - ImmutableMap respHeaders = ImmutableMap.of("key", "value"); + ImmutableMap respHeaders = ImmutableMap.of("key", "getValue"); CosmosClientException dce = BridgeInternal.createCosmosClientException((String) null, (Exception) null, respHeaders, 0, (String) null); - assertThat(dce.responseHeaders()).isNotNull(); - assertThat(dce.responseHeaders()).contains(respHeaders.entrySet().iterator().next()); + assertThat(dce.getResponseHeaders()).isNotNull(); + assertThat(dce.getResponseHeaders()).contains(respHeaders.entrySet().iterator().next()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncContainerTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosContainerTest.java similarity index 70% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncContainerTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosContainerTest.java index 99db89263599..67d128cd6248 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncContainerTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosContainerTest.java @@ -4,19 +4,8 @@ * */ -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.IndexingMode; -import com.azure.data.cosmos.IndexingPolicy; -import com.azure.data.cosmos.PartitionKeyDefinition; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.internal.HttpConstants; import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; @@ -31,21 +20,21 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosSyncContainerTest extends TestSuiteBase { +public class CosmosContainerTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List databases = new ArrayList<>(); - private CosmosSyncClient client; - private CosmosSyncDatabase createdDatabase; + private CosmosClient client; + private CosmosDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") - public CosmosSyncContainerTest(CosmosClientBuilder clientBuilder) { + public CosmosContainerTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().buildSyncClient(); + client = clientBuilder().buildClient(); createdDatabase = createSyncDatabase(client, preExistingDatabaseId); } @@ -62,7 +51,7 @@ private CosmosContainerProperties getCollectionDefinition(String collectionName) PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties( collectionName, @@ -76,7 +65,7 @@ public void createContainer_withProperties() throws Exception { String collectionName = UUID.randomUUID().toString(); CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); validateContainerResponse(containerProperties, containerResponse); } @@ -85,14 +74,14 @@ public void createContainer_alreadyExists() throws Exception { String collectionName = UUID.randomUUID().toString(); CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); validateContainerResponse(containerProperties, containerResponse); try { createdDatabase.createContainer(containerProperties); } catch (Exception e) { assertThat(e).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) e).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(((CosmosClientException) e).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } } @@ -102,7 +91,7 @@ public void createContainer_withThroughput() throws Exception { CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); int throughput = 1000; - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, throughput); validateContainerResponse(containerProperties, containerResponse); } @@ -113,7 +102,7 @@ public void createContainer_withOptions() throws Exception { CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, options); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, options); validateContainerResponse(containerProperties, containerResponse); } @@ -124,7 +113,7 @@ public void createContainer_withThroughputAndOptions() throws Exception { CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); int throughput = 1000; - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties, throughput, options); validateContainerResponse(containerProperties, containerResponse); } @@ -134,7 +123,7 @@ public void createContainer_withNameAndPartitoinKeyPath() throws Exception { String collectionName = UUID.randomUUID().toString(); String partitionKeyPath = "/mypk"; - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(collectionName, partitionKeyPath); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(collectionName, partitionKeyPath); validateContainerResponse(new CosmosContainerProperties(collectionName, partitionKeyPath), containerResponse); } @@ -144,7 +133,7 @@ public void createContainer_withNamePartitionPathAndThroughput() throws Exceptio String partitionKeyPath = "/mypk"; int throughput = 1000; - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(collectionName, + CosmosContainerResponse containerResponse = createdDatabase.createContainer(collectionName, partitionKeyPath, throughput); validateContainerResponse(new CosmosContainerProperties(collectionName, partitionKeyPath), containerResponse); } @@ -155,14 +144,14 @@ public void readContainer() throws Exception { CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); - CosmosSyncContainer syncContainer = createdDatabase.getContainer(collectionName); + CosmosContainer syncContainer = createdDatabase.getContainer(collectionName); - CosmosSyncContainerResponse read = syncContainer.read(); + CosmosContainerResponse read = syncContainer.read(); validateContainerResponse(containerProperties, read); - CosmosSyncContainerResponse read1 = syncContainer.read(options); + CosmosContainerResponse read1 = syncContainer.read(options); validateContainerResponse(containerProperties, read1); } @@ -171,10 +160,10 @@ public void deleteContainer() throws Exception { String collectionName = UUID.randomUUID().toString(); CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); - CosmosSyncContainer syncContainer = createdDatabase.getContainer(collectionName); - CosmosSyncContainerResponse deleteResponse = syncContainer.delete(); + CosmosContainer syncContainer = createdDatabase.getContainer(collectionName); + CosmosContainerResponse deleteResponse = syncContainer.delete(); } @@ -183,10 +172,10 @@ public void deleteContainer_withOptions() throws Exception { String collectionName = UUID.randomUUID().toString(); CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); - CosmosSyncContainer syncContainer = createdDatabase.getContainer(collectionName); - CosmosSyncContainerResponse deleteResponse = syncContainer.delete(options); + CosmosContainer syncContainer = createdDatabase.getContainer(collectionName); + CosmosContainerResponse deleteResponse = syncContainer.delete(options); } @@ -197,22 +186,22 @@ public void replace() throws Exception { CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); validateContainerResponse(containerProperties, containerResponse); - assertThat(containerResponse.properties().indexingPolicy().indexingMode()).isEqualTo(IndexingMode.CONSISTENT); + assertThat(containerResponse.getProperties().getIndexingPolicy().getIndexingMode()).isEqualTo(IndexingMode.CONSISTENT); - CosmosSyncContainerResponse replaceResponse = containerResponse.container() - .replace(containerResponse.properties().indexingPolicy( - new IndexingPolicy().indexingMode(IndexingMode.LAZY))); - assertThat(replaceResponse.properties().indexingPolicy().indexingMode()) + CosmosContainerResponse replaceResponse = containerResponse.getContainer() + .replace(containerResponse.getProperties().setIndexingPolicy( + new IndexingPolicy().setIndexingMode(IndexingMode.LAZY))); + assertThat(replaceResponse.getProperties().getIndexingPolicy().getIndexingMode()) .isEqualTo(IndexingMode.LAZY); - CosmosSyncContainerResponse replaceResponse1 = containerResponse.container() - .replace(containerResponse.properties().indexingPolicy( - new IndexingPolicy().indexingMode(IndexingMode.CONSISTENT)), + CosmosContainerResponse replaceResponse1 = containerResponse.getContainer() + .replace(containerResponse.getProperties().setIndexingPolicy( + new IndexingPolicy().setIndexingMode(IndexingMode.CONSISTENT)), options); - assertThat(replaceResponse1.properties().indexingPolicy().indexingMode()) + assertThat(replaceResponse1.getProperties().getIndexingPolicy().getIndexingMode()) .isEqualTo(IndexingMode.CONSISTENT); } @@ -223,7 +212,7 @@ public void readAllContainers() throws Exception{ CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); Iterator> feedResponseIterator = createdDatabase.readAllContainers(); // Very basic validation assertThat(feedResponseIterator.hasNext()).isTrue(); @@ -240,7 +229,7 @@ public void queryContainer() throws Exception{ CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - CosmosSyncContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); String query = String.format("SELECT * from c where c.id = '%s'", collectionName); FeedOptions feedOptions = new FeedOptions(); @@ -264,12 +253,12 @@ public void queryContainer() throws Exception{ } private void validateContainerResponse(CosmosContainerProperties containerProperties, - CosmosSyncContainerResponse createResponse) { + CosmosContainerResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(containerProperties.id()); + .isEqualTo(containerProperties.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java index 75672b63dd4d..36997bfbd51b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseForTest.java @@ -25,9 +25,9 @@ public class CosmosDatabaseForTest { private static DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss"); public LocalDateTime createdTime; - public CosmosDatabase createdDatabase; + public CosmosAsyncDatabase createdDatabase; - private CosmosDatabaseForTest(CosmosDatabase db, LocalDateTime createdTime) { + private CosmosDatabaseForTest(CosmosAsyncDatabase db, LocalDateTime createdTime) { this.createdDatabase = db; this.createdTime = createdTime; } @@ -44,12 +44,12 @@ public static String generateId() { return SHARED_DB_ID_PREFIX + DELIMITER + TIME_FORMATTER.format(LocalDateTime.now()) + DELIMITER + RandomStringUtils.randomAlphabetic(3); } - private static CosmosDatabaseForTest from(CosmosDatabase db) { - if (db == null || db.id() == null || db.getLink() == null) { + private static CosmosDatabaseForTest from(CosmosAsyncDatabase db) { + if (db == null || db.getId() == null || db.getLink() == null) { return null; } - String id = db.id(); + String id = db.getId(); if (id == null) { return null; } @@ -73,7 +73,7 @@ private static CosmosDatabaseForTest from(CosmosDatabase db) { public static CosmosDatabaseForTest create(DatabaseManager client) { CosmosDatabaseProperties dbDef = new CosmosDatabaseProperties(generateId()); - CosmosDatabase db = client.createDatabase(dbDef).block().database(); + CosmosAsyncDatabase db = client.createDatabase(dbDef).block().getDatabase(); CosmosDatabaseForTest dbForTest = CosmosDatabaseForTest.from(db); assertThat(dbForTest).isNotNull(); return dbForTest; @@ -84,16 +84,16 @@ public static void cleanupStaleTestDatabases(DatabaseManager client) { List dbs = client.queryDatabases( new SqlQuerySpec("SELECT * FROM c WHERE STARTSWITH(c.id, @PREFIX)", new SqlParameterList(new SqlParameter("@PREFIX", CosmosDatabaseForTest.SHARED_DB_ID_PREFIX)))) - .flatMap(page -> Flux.fromIterable(page.results())).collectList().block(); + .flatMap(page -> Flux.fromIterable(page.getResults())).collectList().block(); for (CosmosDatabaseProperties db : dbs) { - assertThat(db.id()).startsWith(CosmosDatabaseForTest.SHARED_DB_ID_PREFIX); + assertThat(db.getId()).startsWith(CosmosDatabaseForTest.SHARED_DB_ID_PREFIX); - CosmosDatabaseForTest dbForTest = CosmosDatabaseForTest.from(client.getDatabase(db.id())); + CosmosDatabaseForTest dbForTest = CosmosDatabaseForTest.from(client.getDatabase(db.getId())); if (db != null && dbForTest.isStale()) { - logger.info("Deleting database {}", db.id()); - dbForTest.deleteDatabase(db.id()); + logger.info("Deleting database {}", db.getId()); + dbForTest.deleteDatabase(db.getId()); } } } @@ -104,7 +104,7 @@ private void deleteDatabase(String id) { public interface DatabaseManager { Flux> queryDatabases(SqlQuerySpec query); - Mono createDatabase(CosmosDatabaseProperties databaseDefinition); - CosmosDatabase getDatabase(String id); + Mono createDatabase(CosmosDatabaseProperties databaseDefinition); + CosmosAsyncDatabase getDatabase(String id); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseTest.java similarity index 68% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseTest.java index 3dcbc2e0a7ee..9e335a0671ff 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosDatabaseTest.java @@ -4,16 +4,8 @@ * */ -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.internal.HttpConstants; import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; @@ -27,20 +19,20 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosSyncDatabaseTest extends TestSuiteBase { +public class CosmosDatabaseTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List databases = new ArrayList<>(); - private CosmosSyncClient client; - private CosmosSyncDatabase createdDatabase; + private CosmosClient client; + private CosmosDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") - public CosmosSyncDatabaseTest(CosmosClientBuilder clientBuilder) { + public CosmosDatabaseTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().buildSyncClient(); + client = clientBuilder().buildClient(); createdDatabase = createSyncDatabase(client, preExistingDatabaseId); } @@ -57,9 +49,9 @@ public void afterClass() { @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void createDatabase_withPropertiesAndOptions() throws CosmosClientException { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseDefinition, + CosmosDatabaseResponse createResponse = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); validateDatabaseResponse(databaseDefinition, createResponse); @@ -68,26 +60,26 @@ public void createDatabase_withPropertiesAndOptions() throws CosmosClientExcepti @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void createDatabase_withProperties() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties); validateDatabaseResponse(databaseDefinition, createResponse); } @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void createDatabase_alreadyExists() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties); validateDatabaseResponse(databaseDefinition, createResponse); try { client.createDatabase(databaseProperties); } catch (Exception e) { assertThat(e).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) e).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(((CosmosClientException) e).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } } @@ -95,35 +87,35 @@ public void createDatabase_alreadyExists() throws Exception { public void createDatabase_withId() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseDefinition.id()); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseDefinition.getId()); validateDatabaseResponse(databaseDefinition, createResponse); } @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void createDatabase_withPropertiesThroughputAndOptions() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); CosmosDatabaseRequestOptions requestOptions = new CosmosDatabaseRequestOptions(); int throughput = 400; try { - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties, throughput, requestOptions); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties, throughput, requestOptions); validateDatabaseResponse(databaseDefinition, createResponse); } catch (CosmosClientException ex) { - assertThat(ex.statusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); + assertThat(ex.getStatusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); } } @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void createDatabase_withPropertiesAndThroughput() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); int throughput = 1000; try { - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties, throughput); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties, throughput); validateDatabaseResponse(databaseDefinition, createResponse); } catch (Exception ex) { if (ex instanceof CosmosClientException) { - assertThat(((CosmosClientException) ex).statusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); + assertThat(((CosmosClientException) ex).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); } else { throw ex; } @@ -135,11 +127,11 @@ public void createDatabase_withIdAndThroughput() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); int throughput = 1000; try { - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseDefinition.id(), throughput); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseDefinition.getId(), throughput); validateDatabaseResponse(databaseDefinition, createResponse); } catch (Exception ex) { if (ex instanceof CosmosClientException) { - assertThat(((CosmosClientException) ex).statusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); + assertThat(((CosmosClientException) ex).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.FORBIDDEN); } else { throw ex; } @@ -148,14 +140,14 @@ public void createDatabase_withIdAndThroughput() throws Exception { @Test public void readDatabase() throws Exception { - CosmosSyncDatabase database = client.getDatabase(createdDatabase.id()); - CosmosDatabaseProperties properties = new CosmosDatabaseProperties(createdDatabase.id()); + CosmosDatabase database = client.getDatabase(createdDatabase.getId()); + CosmosDatabaseProperties properties = new CosmosDatabaseProperties(createdDatabase.getId()); CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions(); - CosmosSyncDatabaseResponse read = database.read(); + CosmosDatabaseResponse read = database.read(); validateDatabaseResponse(properties, read); - CosmosSyncDatabaseResponse read1 = database.read(options); + CosmosDatabaseResponse read1 = database.read(options); validateDatabaseResponse(properties, read1); } @@ -177,7 +169,7 @@ public void readAllDatabases() throws Exception { public void queryAllDatabases() throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(2); - String query = String.format("SELECT * from c where c.id = '%s'", createdDatabase.id()); + String query = String.format("SELECT * from c where c.getId = '%s'", createdDatabase.getId()); FeedOptions feedOptions = new FeedOptions(); Iterator> queryIterator = client.queryDatabases(query, options); @@ -194,28 +186,28 @@ public void queryAllDatabases() throws Exception { @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void deleteDatabase() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties); - client.getDatabase(databaseDefinition.id()).delete(); + client.getDatabase(databaseDefinition.getId()).delete(); } @Test(groups = {"emulator"}, timeOut = TIMEOUT) public void deleteDatabase_withOptions() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.id()); - CosmosSyncDatabaseResponse createResponse = client.createDatabase(databaseProperties); + CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId()); + CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties); CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions(); - client.getDatabase(databaseDefinition.id()).delete(options); + client.getDatabase(databaseDefinition.getId()).delete(options); } - private void validateDatabaseResponse(CosmosDatabaseProperties databaseDefinition, CosmosSyncDatabaseResponse createResponse) { + private void validateDatabaseResponse(CosmosDatabaseProperties databaseDefinition, CosmosDatabaseResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(databaseDefinition.id()); + .isEqualTo(databaseDefinition.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncItemTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosItemTest.java similarity index 65% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncItemTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosItemTest.java index 095c8bad2e5e..58adf4b568f2 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncItemTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosItemTest.java @@ -4,19 +4,8 @@ * */ -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.internal.HttpConstants; import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; @@ -31,15 +20,15 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosSyncItemTest extends TestSuiteBase { +public class CosmosItemTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List databases = new ArrayList<>(); - private CosmosSyncClient client; - private CosmosSyncContainer container; + private CosmosClient client; + private CosmosContainer container; @Factory(dataProvider = "clientBuilders") - public CosmosSyncItemTest(CosmosClientBuilder clientBuilder) { + public CosmosItemTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @@ -47,9 +36,9 @@ public CosmosSyncItemTest(CosmosClientBuilder clientBuilder) { @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = clientBuilder().buildSyncClient(); - CosmosContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); - container = client.getDatabase(asyncContainer.getDatabase().id()).getContainer(asyncContainer.id()); + this.client = clientBuilder().buildClient(); + CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); + container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); } @AfterClass(groups = {"simple"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) @@ -61,11 +50,11 @@ public void afterClass() { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createItem() throws Exception { CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); validateItemResponse(properties, itemResponse); properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse1 = container.createItem(properties, new CosmosItemRequestOptions()); + CosmosItemResponse itemResponse1 = container.createItem(properties, new CosmosItemRequestOptions()); validateItemResponse(properties, itemResponse1); } @@ -73,11 +62,11 @@ public void createItem() throws Exception { @Test(groups = {"simple"}, timeOut = TIMEOUT) public void createItem_alreadyExists() throws Exception { CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); validateItemResponse(properties, itemResponse); properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse1 = container.createItem(properties, new CosmosItemRequestOptions()); + CosmosItemResponse itemResponse1 = container.createItem(properties, new CosmosItemRequestOptions()); validateItemResponse(properties, itemResponse1); // Test for conflict @@ -85,18 +74,18 @@ public void createItem_alreadyExists() throws Exception { container.createItem(properties, new CosmosItemRequestOptions()); } catch (Exception e) { assertThat(e).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) e).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(((CosmosClientException) e).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void readItem() throws Exception { CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); - CosmosSyncItemResponse readResponse1 = itemResponse.item() + CosmosItemResponse readResponse1 = itemResponse.getItem() .read(new CosmosItemRequestOptions() - .partitionKey(new PartitionKey(properties.get("mypk")))); + .setPartitionKey(new PartitionKey(properties.get("mypk")))); validateItemResponse(properties, readResponse1); } @@ -104,27 +93,27 @@ public void readItem() throws Exception { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void replaceItem() throws Exception{ CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); validateItemResponse(properties, itemResponse); String newPropValue = UUID.randomUUID().toString(); BridgeInternal.setProperty(properties, "newProp", newPropValue); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(properties.get("mypk"))); + options.setPartitionKey(new PartitionKey(properties.get("mypk"))); // replace document - CosmosSyncItemResponse replace = itemResponse.item().replace(properties, options); - assertThat(replace.properties().get("newProp")).isEqualTo(newPropValue); + CosmosItemResponse replace = itemResponse.getItem().replace(properties, options); + assertThat(replace.getProperties().get("newProp")).isEqualTo(newPropValue); } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void deleteItem() throws Exception { CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(properties.get("mypk"))); + options.setPartitionKey(new PartitionKey(properties.get("mypk"))); - CosmosSyncItemResponse deleteResponse = itemResponse.item().delete(options); - assertThat(deleteResponse.item()).isNull(); + CosmosItemResponse deleteResponse = itemResponse.getItem().delete(options); + assertThat(deleteResponse.getItem()).isNull(); } @@ -132,10 +121,10 @@ public void deleteItem() throws Exception { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void readAllItems() throws Exception{ CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator3 = container.readAllItems(feedOptions); assertThat(feedResponseIterator3.hasNext()).isTrue(); @@ -145,10 +134,10 @@ public void readAllItems() throws Exception{ @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryItems() throws Exception{ CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); - CosmosSyncItemResponse itemResponse = container.createItem(properties); + CosmosItemResponse itemResponse = container.createItem(properties); - String query = String.format("SELECT * from c where c.id = '%s'", properties.id()); - FeedOptions feedOptions = new FeedOptions().enableCrossPartitionQuery(true); + String query = String.format("SELECT * from c where c.id = '%s'", properties.getId()); + FeedOptions feedOptions = new FeedOptions().setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator1 = container.queryItems(query, feedOptions); @@ -175,12 +164,12 @@ private CosmosItemProperties getDocumentDefinition(String documentId) { } private void validateItemResponse(CosmosItemProperties containerProperties, - CosmosSyncItemResponse createResponse) { + CosmosItemResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(containerProperties.id()); + .isEqualTo(containerProperties.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java similarity index 52% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java index ab9d4957f5a6..d8d34dc83799 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosKeyCredentialTest.java @@ -26,9 +26,9 @@ public class CosmosKeyCredentialTest extends TestSuiteBase { private final List databases = new ArrayList<>(); private final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosClient client; - private CosmosDatabase database; - private CosmosContainer container; + private CosmosAsyncClient client; + private CosmosAsyncDatabase database; + private CosmosAsyncContainer container; @Factory(dataProvider = "clientBuildersWithDirect") public CosmosKeyCredentialTest(CosmosClientBuilder clientBuilder) { @@ -51,7 +51,7 @@ private CosmosContainerProperties getCollectionDefinition(String collectionName) PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); return new CosmosContainerProperties( collectionName, @@ -73,19 +73,19 @@ public void createCollectionWithSecondaryKey(String collectionName) throws Inter CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); - Mono createObservable = database + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); + Mono createObservable = database .createContainer(collectionDefinition); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(collectionDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(collectionDefinition.getId()).build(); validateSuccess(createObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); safeDeleteAllCollections(database); } @@ -94,21 +94,21 @@ public void readCollectionWithSecondaryKey(String collectionName) throws Interru CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); - Mono readObservable = collection.read(); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); + Mono readObservable = collection.read(); - CosmosResponseValidator validator = - new CosmosResponseValidator.Builder() - .withId(collection.id()).build(); + CosmosResponseValidator validator = + new CosmosResponseValidator.Builder() + .withId(collection.getId()).build(); validateSuccess(readObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); safeDeleteAllCollections(database); } @@ -117,51 +117,51 @@ public void deleteCollectionWithSecondaryKey(String collectionName) throws Inter CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); - Mono deleteObservable = collection.delete(); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); + Mono deleteObservable = collection.delete(); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "crudArgProvider") public void replaceCollectionWithSecondaryKey(String collectionName) throws InterruptedException { // create a collection CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - CosmosContainerProperties collectionSettings = collection.read().block().properties(); + CosmosContainerProperties collectionSettings = collection.read().block().getProperties(); // sanity check - assertThat(collectionSettings.indexingPolicy().indexingMode()).isEqualTo(IndexingMode.CONSISTENT); + assertThat(collectionSettings.getIndexingPolicy().getIndexingMode()).isEqualTo(IndexingMode.CONSISTENT); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); // replace indexing mode IndexingPolicy indexingMode = new IndexingPolicy(); - indexingMode.indexingMode(IndexingMode.LAZY); - collectionSettings.indexingPolicy(indexingMode); - Mono readObservable = collection.replace(collectionSettings, new CosmosContainerRequestOptions()); + indexingMode.setIndexingMode(IndexingMode.LAZY); + collectionSettings.setIndexingPolicy(indexingMode); + Mono readObservable = collection.replace(collectionSettings, new CosmosContainerRequestOptions()); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .indexingMode(IndexingMode.LAZY).build(); validateSuccess(readObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); safeDeleteAllCollections(database); } @@ -169,141 +169,141 @@ public void replaceCollectionWithSecondaryKey(String collectionName) throws Inte public void createDocumentWithSecondaryKey(String documentId) throws InterruptedException { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); CosmosItemProperties properties = getDocumentDefinition(documentId); - Mono createObservable = container.createItem(properties, new CosmosItemRequestOptions()); + Mono createObservable = container.createItem(properties, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(properties.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(properties.getId()) .build(); validateSuccess(createObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "crudArgProvider") public void readDocumentWithSecondaryKey(String documentId) throws InterruptedException { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); waitIfNeededForReplicasToCatchUp(clientBuilder()); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); - Mono readObservable = document.read(options); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); + Mono readObservable = document.read(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(document.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(document.getId()) .build(); validateSuccess(readObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "crudArgProvider") public void deleteDocumentWithSecondaryKey(String documentId) throws InterruptedException { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); - Mono deleteObservable = document.delete(options); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); + Mono deleteObservable = document.delete(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); // attempt to read document which was deleted waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = document.read(options); + Mono readObservable = document.read(options); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(readObservable, notFoundValidator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createDatabaseWithSecondaryKey() throws Exception { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); - // create the database - Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); + databases.add(databaseDefinition.getId()); + // create the getDatabase + Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(databaseDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(databaseDefinition.getId()).build(); validateSuccess(createObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void readDatabaseWithSecondaryKey() throws Exception { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); // read database - Mono readObservable = client.getDatabase(databaseId).read(); + Mono readObservable = client.getDatabase(databaseId).read(); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withId(databaseId).build(); validateSuccess(readObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void deleteDatabaseWithSecondaryKey() throws Exception { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key(TestConfigurations.SECONDARY_MASTER_KEY); + cosmosKeyCredential.setKey(TestConfigurations.SECONDARY_MASTER_KEY); // create the database CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); - CosmosDatabase database = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().database(); - // delete the database - Mono deleteObservable = database.delete(); + CosmosAsyncDatabase database = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().getDatabase(); + // delete the getDatabase + Mono deleteObservable = database.delete(); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.SECONDARY_MASTER_KEY); } @Test(groups = { "simple" }, timeOut = TIMEOUT, @@ -311,24 +311,24 @@ public void deleteDatabaseWithSecondaryKey() throws Exception { expectedExceptionsMessageRegExp = "Illegal base64 character .*") public void invalidSecondaryKey() throws Exception { // sanity check - assertThat(client.cosmosKeyCredential().key()).isEqualTo(TestConfigurations.MASTER_KEY); + assertThat(client.cosmosKeyCredential().getKey()).isEqualTo(TestConfigurations.MASTER_KEY); - cosmosKeyCredential.key("Invalid Secondary Key"); + cosmosKeyCredential.setKey("Invalid Secondary Key"); // create the database, and this should throw Illegal Argument Exception for secondary key CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().database(); + client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().getDatabase(); } @AfterMethod(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void afterMethod() { - // Set back master key before every test - cosmosKeyCredential.key(TestConfigurations.MASTER_KEY); + // Set back master getKey before every test + cosmosKeyCredential.setKey(TestConfigurations.MASTER_KEY); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); database = createDatabase(client, databaseId); container = getSharedMultiPartitionCosmosContainer(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java similarity index 74% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java index 137816d3096b..57a0fad73eaf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosPartitionKeyTests.java @@ -32,8 +32,8 @@ public final class CosmosPartitionKeyTests extends TestSuiteBase { private final static String NON_PARTITIONED_CONTAINER_ID = "NonPartitionContainer" + UUID.randomUUID().toString(); private final static String NON_PARTITIONED_CONTAINER_DOCUEMNT_ID = "NonPartitionContainer_Document" + UUID.randomUUID().toString(); - private CosmosClient client; - private CosmosDatabase createdDatabase; + private CosmosAsyncClient client; + private CosmosAsyncDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") public CosmosPartitionKeyTests(CosmosClientBuilder clientBuilder) { @@ -43,7 +43,7 @@ public CosmosPartitionKeyTests(CosmosClientBuilder clientBuilder) { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws URISyntaxException, IOException { assertThat(this.client).isNull(); - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); } @@ -56,18 +56,18 @@ public void afterClass() { private void createContainerWithoutPk() throws URISyntaxException, IOException { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); HttpClientConfig httpClientConfig = new HttpClientConfig(new Configs()) - .withMaxIdleConnectionTimeoutInMillis(connectionPolicy.idleConnectionTimeoutInMillis()) - .withPoolSize(connectionPolicy.maxPoolSize()) - .withHttpProxy(connectionPolicy.proxy()) - .withRequestTimeoutInMillis(connectionPolicy.requestTimeoutInMillis()); + .withMaxIdleConnectionTimeoutInMillis(connectionPolicy.getIdleConnectionTimeoutInMillis()) + .withPoolSize(connectionPolicy.getMaxPoolSize()) + .withHttpProxy(connectionPolicy.getProxy()) + .withRequestTimeoutInMillis(connectionPolicy.getRequestTimeoutInMillis()); HttpClient httpClient = HttpClient.createFixed(httpClientConfig); - // CREATE a non partitioned collection using the rest API and older version - String resourceId = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.id(); - String path = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.id() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/"; + // CREATE a non partitioned collection using the rest API and older getVersion + String resourceId = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.getId(); + String path = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.getId() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/"; DocumentCollection collection = new DocumentCollection(); - collection.id(NON_PARTITIONED_CONTAINER_ID); + collection.setId(NON_PARTITIONED_CONTAINER_ID); HashMap headers = new HashMap(); headers.put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); @@ -80,20 +80,20 @@ private void createContainerWithoutPk() throws URISyntaxException, IOException { String[] baseUrlSplit = TestConfigurations.HOST.split(":"); String resourceUri = baseUrlSplit[0] + ":" + baseUrlSplit[1] + ":" + baseUrlSplit[2].split("/")[ - 0] + "//" + Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.id() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/"; + 0] + "//" + Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.getId() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/"; URI uri = new URI(resourceUri); HttpRequest httpRequest = new HttpRequest(HttpMethod.POST, uri, uri.getPort(), new HttpHeaders(headers)); httpRequest.withBody(request.getContent()); String body = httpClient.send(httpRequest).block().bodyAsString().block(); - assertThat(body).contains("\"id\":\"" + NON_PARTITIONED_CONTAINER_ID + "\""); + assertThat(body).contains("\"getId\":\"" + NON_PARTITIONED_CONTAINER_ID + "\""); - // CREATE a document in the non partitioned collection using the rest API and older version - resourceId = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.id() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/" + collection.id(); - path = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.id() + "/" + Paths.COLLECTIONS_PATH_SEGMENT - + "/" + collection.id() + "/" + Paths.DOCUMENTS_PATH_SEGMENT + "/"; + // CREATE a document in the non partitioned collection using the rest API and older getVersion + resourceId = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.getId() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/" + collection.getId(); + path = Paths.DATABASES_PATH_SEGMENT + "/" + createdDatabase.getId() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + + "/" + collection.getId() + "/" + Paths.DOCUMENTS_PATH_SEGMENT + "/"; Document document = new Document(); - document.id(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID); + document.setId(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID); authorization = base.generateKeyAuthorizationSignature(HttpConstants.HttpMethods.POST, resourceId, Paths.DOCUMENTS_PATH_SEGMENT, headers); headers.put(HttpConstants.HttpHeaders.AUTHORIZATION, URLEncoder.encode(authorization, "UTF-8")); @@ -101,7 +101,7 @@ private void createContainerWithoutPk() throws URISyntaxException, IOException { document, headers, new RequestOptions()); resourceUri = baseUrlSplit[0] + ":" + baseUrlSplit[1] + ":" + baseUrlSplit[2].split("/")[0] + "//" + Paths.DATABASES_PATH_SEGMENT + "/" - + createdDatabase.id() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/" + collection.id() + "/" + Paths.DOCUMENTS_PATH_SEGMENT + "/"; + + createdDatabase.getId() + "/" + Paths.COLLECTIONS_PATH_SEGMENT + "/" + collection.getId() + "/" + Paths.DOCUMENTS_PATH_SEGMENT + "/"; uri = new URI(resourceUri); httpRequest = new HttpRequest(HttpMethod.POST, uri, uri.getPort(), new HttpHeaders(headers)); @@ -116,37 +116,37 @@ private void createContainerWithoutPk() throws URISyntaxException, IOException { @Test(groups = { "simple" }) public void testNonPartitionedCollectionOperations() throws Exception { createContainerWithoutPk(); - CosmosContainer createdContainer = createdDatabase.getContainer(NON_PARTITIONED_CONTAINER_ID); + CosmosAsyncContainer createdContainer = createdDatabase.getContainer(NON_PARTITIONED_CONTAINER_ID); - Mono readMono = createdContainer.getItem(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID, PartitionKey.None).read(); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + Mono readMono = createdContainer.getItem(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID, PartitionKey.None).read(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withId(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID).build(); validateSuccess(readMono, validator); String createdItemId = UUID.randomUUID().toString(); - Mono createMono = createdContainer.createItem(new CosmosItemProperties("{'id':'" + createdItemId + "'}")); - validator = new CosmosResponseValidator.Builder() + Mono createMono = createdContainer.createItem(new CosmosItemProperties("{'id':'" + createdItemId + "'}")); + validator = new CosmosResponseValidator.Builder() .withId(createdItemId).build(); validateSuccess(createMono, validator); readMono = createdContainer.getItem(createdItemId, PartitionKey.None).read(); - validator = new CosmosResponseValidator.Builder() + validator = new CosmosResponseValidator.Builder() .withId(createdItemId).build(); validateSuccess(readMono, validator); - CosmosItem itemToReplace = createdContainer.getItem(createdItemId, PartitionKey.None).read().block().item(); - CosmosItemProperties itemSettingsToReplace = itemToReplace.read().block().properties(); + CosmosAsyncItem itemToReplace = createdContainer.getItem(createdItemId, PartitionKey.None).read().block().getItem(); + CosmosItemProperties itemSettingsToReplace = itemToReplace.read().block().getProperties(); String replacedItemId = UUID.randomUUID().toString(); - itemSettingsToReplace.id(replacedItemId); - Mono replaceMono = itemToReplace.replace(itemSettingsToReplace); - validator = new CosmosResponseValidator.Builder() + itemSettingsToReplace.setId(replacedItemId); + Mono replaceMono = itemToReplace.replace(itemSettingsToReplace); + validator = new CosmosResponseValidator.Builder() .withId(replacedItemId).build(); validateSuccess(replaceMono, validator); String upsertedItemId = UUID.randomUUID().toString(); - Mono upsertMono = createdContainer.upsertItem(new CosmosItemProperties("{'id':'" + upsertedItemId + "'}")); - validator = new CosmosResponseValidator.Builder() + Mono upsertMono = createdContainer.upsertItem(new CosmosItemProperties("{'id':'" + upsertedItemId + "'}")); + validator = new CosmosResponseValidator.Builder() .withId(upsertedItemId).build(); validateSuccess(upsertMono, validator); @@ -188,12 +188,12 @@ public void testNonPartitionedCollectionOperations() throws Exception { " });" + "}'" + "}"); - CosmosStoredProcedure createdSproc = createdContainer.getScripts().createStoredProcedure(sproc).block().storedProcedure(); + CosmosAsyncStoredProcedure createdSproc = createdContainer.getScripts().createStoredProcedure(sproc).block().getStoredProcedure(); // Partiton Key value same as what is specified in the stored procedure body RequestOptions options = new RequestOptions(); options.setPartitionKey(PartitionKey.None); - int result = Integer.parseInt(createdSproc.execute(null, new CosmosStoredProcedureRequestOptions()).block().responseAsString()); + int result = Integer.parseInt(createdSproc.execute(null, new CosmosStoredProcedureRequestOptions()).block().getResponseAsString()); assertThat(result).isEqualTo(1); // 3 previous items + 1 created from the sproc @@ -206,23 +206,23 @@ public void testNonPartitionedCollectionOperations() throws Exception { .build(); validateQuerySuccess(queryFlux, queryValidator); - Mono deleteMono = createdContainer.getItem(upsertedItemId, PartitionKey.None).delete(); - validator = new CosmosResponseValidator.Builder() + Mono deleteMono = createdContainer.getItem(upsertedItemId, PartitionKey.None).delete(); + validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteMono, validator); deleteMono = createdContainer.getItem(replacedItemId, PartitionKey.None).delete(); - validator = new CosmosResponseValidator.Builder() + validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteMono, validator); deleteMono = createdContainer.getItem(NON_PARTITIONED_CONTAINER_DOCUEMNT_ID, PartitionKey.None).delete(); - validator = new CosmosResponseValidator.Builder() + validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteMono, validator); deleteMono = createdContainer.getItem(documentCreatedBySprocId, PartitionKey.None).delete(); - validator = new CosmosResponseValidator.Builder() + validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteMono, validator); @@ -239,14 +239,14 @@ public void testMultiPartitionCollectionReadDocumentWithNoPk() throws Interrupte String partitionedCollectionId = "PartitionedCollection" + UUID.randomUUID().toString(); String IdOfDocumentWithNoPk = UUID.randomUUID().toString(); CosmosContainerProperties containerSettings = new CosmosContainerProperties(partitionedCollectionId, "/mypk"); - CosmosContainer createdContainer = createdDatabase.createContainer(containerSettings).block().container(); + CosmosAsyncContainer createdContainer = createdDatabase.createContainer(containerSettings).block().getContainer(); CosmosItemProperties cosmosItemProperties = new CosmosItemProperties(); - cosmosItemProperties.id(IdOfDocumentWithNoPk); - CosmosItem createdItem = createdContainer.createItem(cosmosItemProperties).block().item(); + cosmosItemProperties.setId(IdOfDocumentWithNoPk); + CosmosAsyncItem createdItem = createdContainer.createItem(cosmosItemProperties).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(PartitionKey.None); - Mono readMono = createdItem.read(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + options.setPartitionKey(PartitionKey.None); + Mono readMono = createdItem.read(options); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withId(IdOfDocumentWithNoPk).build(); validateSuccess(readMono, validator); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java similarity index 62% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java index e0e0afe4d42b..d64fa544c66e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java @@ -35,29 +35,29 @@ public Builder withId(final String resourceId) { @Override public void validate(T resourceResponse) { assertThat(getResource(resourceResponse)).isNotNull(); - assertThat(getResource(resourceResponse).id()).as("check Resource Id").isEqualTo(resourceId); + assertThat(getResource(resourceResponse).getId()).as("check Resource Id").isEqualTo(resourceId); } }); return this; } private Resource getResource(T resourceResponse) { - if (resourceResponse instanceof CosmosDatabaseResponse) { - return ((CosmosDatabaseResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosContainerResponse) { - return ((CosmosContainerResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosItemResponse) { - return ((CosmosItemResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosStoredProcedureResponse) { - return ((CosmosStoredProcedureResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosTriggerResponse) { - return ((CosmosTriggerResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosUserDefinedFunctionResponse) { - return ((CosmosUserDefinedFunctionResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosUserResponse) { - return ((CosmosUserResponse)resourceResponse).properties(); - } else if (resourceResponse instanceof CosmosPermissionResponse) { - return ((CosmosPermissionResponse) resourceResponse).properties(); + if (resourceResponse instanceof CosmosAsyncDatabaseResponse) { + return ((CosmosAsyncDatabaseResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncContainerResponse) { + return ((CosmosAsyncContainerResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncItemResponse) { + return ((CosmosAsyncItemResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncStoredProcedureResponse) { + return ((CosmosAsyncStoredProcedureResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncTriggerResponse) { + return ((CosmosAsyncTriggerResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncUserDefinedFunctionResponse) { + return ((CosmosAsyncUserDefinedFunctionResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncUserResponse) { + return ((CosmosAsyncUserResponse)resourceResponse).getProperties(); + } else if (resourceResponse instanceof CosmosAsyncPermissionResponse) { + return ((CosmosAsyncPermissionResponse) resourceResponse).getProperties(); } return null; } @@ -74,13 +74,13 @@ public void validate(T resourceResponse) { } public Builder indexingMode(IndexingMode mode) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosContainerResponse resourceResponse) { - assertThat(resourceResponse.properties()).isNotNull(); - assertThat(resourceResponse.properties().indexingPolicy()).isNotNull(); - assertThat(resourceResponse.properties().indexingPolicy().indexingMode()).isEqualTo(mode); + public void validate(CosmosAsyncContainerResponse resourceResponse) { + assertThat(resourceResponse.getProperties()).isNotNull(); + assertThat(resourceResponse.getProperties().getIndexingPolicy()).isNotNull(); + assertThat(resourceResponse.getProperties().getIndexingPolicy().getIndexingMode()).isEqualTo(mode); } }); return this; @@ -98,12 +98,12 @@ public void validate(T cosmosResponse) { } public Builder withCompositeIndexes(List> compositeIndexesWritten) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosContainerResponse resourceResponse) { - Iterator> compositeIndexesReadIterator = resourceResponse.properties() - .indexingPolicy().compositeIndexes().iterator(); + public void validate(CosmosAsyncContainerResponse resourceResponse) { + Iterator> compositeIndexesReadIterator = resourceResponse.getProperties() + .getIndexingPolicy().getCompositeIndexes().iterator(); Iterator> compositeIndexesWrittenIterator = compositeIndexesWritten.iterator(); ArrayList readIndexesStrings = new ArrayList(); @@ -120,8 +120,8 @@ public void validate(CosmosContainerResponse resourceResponse) { CompositePath compositePathRead = compositeIndexReadIterator.next(); CompositePath compositePathWritten = compositeIndexWrittenIterator.next(); - readIndexesString.append(compositePathRead.path() + ":" + compositePathRead.order() + ";"); - writtenIndexesString.append(compositePathWritten.path() + ":" + compositePathRead.order() + ";"); + readIndexesString.append(compositePathRead.getPath() + ":" + compositePathRead.getOrder() + ";"); + writtenIndexesString.append(compositePathWritten.getPath() + ":" + compositePathRead.getOrder() + ";"); } readIndexesStrings.add(readIndexesString.toString()); @@ -136,12 +136,12 @@ public void validate(CosmosContainerResponse resourceResponse) { } public Builder withSpatialIndexes(Collection spatialIndexes) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosContainerResponse resourceResponse) { - Iterator spatialIndexesReadIterator = resourceResponse.properties() - .indexingPolicy().spatialIndexes().iterator(); + public void validate(CosmosAsyncContainerResponse resourceResponse) { + Iterator spatialIndexesReadIterator = resourceResponse.getProperties() + .getIndexingPolicy().getSpatialIndexes().iterator(); Iterator spatialIndexesWrittenIterator = spatialIndexes.iterator(); HashMap> readIndexMap = new HashMap>(); @@ -151,14 +151,14 @@ public void validate(CosmosContainerResponse resourceResponse) { SpatialSpec spatialSpecRead = spatialIndexesReadIterator.next(); SpatialSpec spatialSpecWritten = spatialIndexesWrittenIterator.next(); - String readPath = spatialSpecRead.path() + ":"; - String writtenPath = spatialSpecWritten.path() + ":"; + String readPath = spatialSpecRead.getPath() + ":"; + String writtenPath = spatialSpecWritten.getPath() + ":"; ArrayList readSpatialTypes = new ArrayList(); ArrayList writtenSpatialTypes = new ArrayList(); - Iterator spatialTypesReadIterator = spatialSpecRead.spatialTypes().iterator(); - Iterator spatialTypesWrittenIterator = spatialSpecWritten.spatialTypes().iterator(); + Iterator spatialTypesReadIterator = spatialSpecRead.getSpatialTypes().iterator(); + Iterator spatialTypesWrittenIterator = spatialSpecWritten.getSpatialTypes().iterator(); while (spatialTypesReadIterator.hasNext() && spatialTypesWrittenIterator.hasNext()) { readSpatialTypes.add(spatialTypesReadIterator.next()); @@ -179,11 +179,11 @@ public void validate(CosmosContainerResponse resourceResponse) { } public Builder withStoredProcedureBody(String storedProcedureBody) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosStoredProcedureResponse resourceResponse) { - assertThat(resourceResponse.properties().body()).isEqualTo(storedProcedureBody); + public void validate(CosmosAsyncStoredProcedureResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getBody()).isEqualTo(storedProcedureBody); } }); return this; @@ -194,53 +194,53 @@ public Builder notNullEtag() { @Override public void validate(T resourceResponse) { - assertThat(resourceResponse.resourceSettings()).isNotNull(); - assertThat(resourceResponse.resourceSettings().etag()).isNotNull(); + assertThat(resourceResponse.getProperties()).isNotNull(); + assertThat(resourceResponse.getProperties().getETag()).isNotNull(); } }); return this; } public Builder withTriggerBody(String functionBody) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosTriggerResponse resourceResponse) { - assertThat(resourceResponse.properties().body()).isEqualTo(functionBody); + public void validate(CosmosAsyncTriggerResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getBody()).isEqualTo(functionBody); } }); return this; } public Builder withTriggerInternals(TriggerType type, TriggerOperation op) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosTriggerResponse resourceResponse) { - assertThat(resourceResponse.properties().triggerType()).isEqualTo(type); - assertThat(resourceResponse.properties().triggerOperation()).isEqualTo(op); + public void validate(CosmosAsyncTriggerResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getTriggerType()).isEqualTo(type); + assertThat(resourceResponse.getProperties().getTriggerOperation()).isEqualTo(op); } }); return this; } public Builder withUserDefinedFunctionBody(String functionBody) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosUserDefinedFunctionResponse resourceResponse) { - assertThat(resourceResponse.properties().body()).isEqualTo(functionBody); + public void validate(CosmosAsyncUserDefinedFunctionResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getBody()).isEqualTo(functionBody); } }); return this; } public Builder withPermissionMode(PermissionMode mode) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosPermissionResponse resourceResponse) { - assertThat(resourceResponse.properties().permissionMode()).isEqualTo(mode); + public void validate(CosmosAsyncPermissionResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getPermissionMode()).isEqualTo(mode); } }); return this; @@ -248,11 +248,11 @@ public void validate(CosmosPermissionResponse resourceResponse) { } public Builder withPermissionResourceLink(String resourceLink) { - validators.add(new CosmosResponseValidator() { + validators.add(new CosmosResponseValidator() { @Override - public void validate(CosmosPermissionResponse resourceResponse) { - assertThat(resourceResponse.properties().resourceLink()).isEqualTo(resourceLink); + public void validate(CosmosAsyncPermissionResponse resourceResponse) { + assertThat(resourceResponse.getProperties().getResourceLink()).isEqualTo(resourceLink); } }); return this; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncStoredProcTest.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncStoredProcTest.java index 7836f9ba17f3..e07413e97d18 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncStoredProcTest.java @@ -1,17 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.internal.HttpConstants; import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; @@ -29,8 +20,8 @@ public class CosmosSyncStoredProcTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List databases = new ArrayList<>(); - private CosmosSyncClient client; - private CosmosSyncContainer container; + private CosmosClient client; + private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncStoredProcTest(CosmosClientBuilder clientBuilder) { @@ -41,9 +32,9 @@ public CosmosSyncStoredProcTest(CosmosClientBuilder clientBuilder) { @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = clientBuilder().buildSyncClient(); - CosmosContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); - container = client.getDatabase(asyncContainer.getDatabase().id()).getContainer(asyncContainer.id()); + this.client = clientBuilder().buildClient(); + CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); + container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); } @AfterClass(groups = {"simple"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) @@ -57,12 +48,12 @@ public void createStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = getCosmosStoredProcedureProperties(); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); validateResponse(storedProcedureDef, response); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 11;}"); - CosmosSyncStoredProcedureResponse response1 = container.getScripts() + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 11;}"); + CosmosStoredProcedureResponse response1 = container.getScripts() .createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()); validateResponse(storedProcedureDef, response1); @@ -73,7 +64,7 @@ public void createStoredProcedure() throws Exception { public void createSproc_alreadyExists() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = getCosmosStoredProcedureProperties(); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); validateResponse(storedProcedureDef, response); // Test for conflict @@ -81,7 +72,7 @@ public void createSproc_alreadyExists() throws Exception { container.getScripts().createStoredProcedure(storedProcedureDef); } catch (Exception e) { assertThat(e).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) e).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(((CosmosClientException) e).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } } @@ -89,14 +80,14 @@ public void createSproc_alreadyExists() throws Exception { public void readStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = getCosmosStoredProcedureProperties(); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); validateResponse(storedProcedureDef, response); - CosmosSyncStoredProcedure storedProcedure = container.getScripts().getStoredProcedure(storedProcedureDef.id()); - CosmosSyncStoredProcedureResponse readResponse = storedProcedure.read(); + CosmosStoredProcedure storedProcedure = container.getScripts().getStoredProcedure(storedProcedureDef.getId()); + CosmosStoredProcedureResponse readResponse = storedProcedure.read(); validateResponse(storedProcedureDef, readResponse); - CosmosSyncStoredProcedureResponse readResponse2 = + CosmosStoredProcedureResponse readResponse2 = storedProcedure.read(new CosmosStoredProcedureRequestOptions()); validateResponse(storedProcedureDef, readResponse2); } @@ -105,24 +96,24 @@ public void readStoredProcedure() throws Exception { public void replaceStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = getCosmosStoredProcedureProperties(); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); validateResponse(storedProcedureDef, response); - CosmosSyncStoredProcedureResponse readResponse = container.getScripts() - .getStoredProcedure(storedProcedureDef.id()) + CosmosStoredProcedureResponse readResponse = container.getScripts() + .getStoredProcedure(storedProcedureDef.getId()) .read(); validateResponse(storedProcedureDef, readResponse); //replace - storedProcedureDef = readResponse.properties(); - storedProcedureDef.body("function(){ var y = 20;}"); - CosmosSyncStoredProcedureResponse replaceResponse = container.getScripts() - .getStoredProcedure(storedProcedureDef.id()) + storedProcedureDef = readResponse.getProperties(); + storedProcedureDef.setBody("function(){ var y = 20;}"); + CosmosStoredProcedureResponse replaceResponse = container.getScripts() + .getStoredProcedure(storedProcedureDef.getId()) .replace(storedProcedureDef); validateResponse(storedProcedureDef, replaceResponse); - storedProcedureDef.body("function(){ var z = 2;}"); - CosmosSyncStoredProcedureResponse replaceResponse2 = container.getScripts() - .getStoredProcedure(storedProcedureDef.id()) + storedProcedureDef.setBody("function(){ var z = 2;}"); + CosmosStoredProcedureResponse replaceResponse2 = container.getScripts() + .getStoredProcedure(storedProcedureDef.getId()) .replace(storedProcedureDef, new CosmosStoredProcedureRequestOptions()); validateResponse(storedProcedureDef, replaceResponse2); @@ -131,8 +122,8 @@ public void replaceStoredProcedure() throws Exception { private CosmosStoredProcedureProperties getCosmosStoredProcedureProperties() { CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); return storedProcedureDef; } @@ -140,11 +131,11 @@ private CosmosStoredProcedureProperties getCosmosStoredProcedureProperties() { public void deleteStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = getCosmosStoredProcedureProperties(); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(storedProcedureDef); validateResponse(storedProcedureDef, response); - CosmosSyncResponse deleteResponse = container.getScripts() - .getStoredProcedure(storedProcedureDef.id()) - .delete(); + container.getScripts() + .getStoredProcedure(storedProcedureDef.getId()) + .delete(); } @@ -156,7 +147,7 @@ public void executeStoredProcedure() throws Exception { .id(UUID.randomUUID().toString()); sproc.body("function() {var x = 10;}"); - CosmosSyncStoredProcedureResponse response = container.getScripts().createStoredProcedure(sproc); + CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(sproc); CosmosStoredProcedureRequestOptions options = new CosmosStoredProcedureRequestOptions(); options.partitionKey(PartitionKey.None); container.getScripts() @@ -171,7 +162,7 @@ private void readAllSprocs() throws Exception { container.getScripts().createStoredProcedure(storedProcedureDef); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator3 = container.getScripts().readAllStoredProcedures(feedOptions); assertThat(feedResponseIterator3.hasNext()).isTrue(); @@ -183,8 +174,8 @@ private void querySprocs() throws Exception { CosmosStoredProcedureProperties properties = getCosmosStoredProcedureProperties(); container.getScripts().createStoredProcedure(properties); - String query = String.format("SELECT * from c where c.id = '%s'", properties.id()); - FeedOptions feedOptions = new FeedOptions().enableCrossPartitionQuery(true); + String query = String.format("SELECT * from c where c.id = '%s'", properties.getId()); + FeedOptions feedOptions = new FeedOptions().setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator1 = container.getScripts().queryStoredProcedures(query, feedOptions); @@ -197,12 +188,12 @@ private void querySprocs() throws Exception { } private void validateResponse(CosmosStoredProcedureProperties properties, - CosmosSyncStoredProcedureResponse createResponse) { + CosmosStoredProcedureResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(properties.id()); + .isEqualTo(properties.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUDFTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncUDFTest.java similarity index 65% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUDFTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncUDFTest.java index 9593f0f46793..f8f1f9857bbc 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUDFTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosSyncUDFTest.java @@ -1,14 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -22,8 +16,8 @@ public class CosmosSyncUDFTest extends TestSuiteBase { - private CosmosSyncClient client; - private CosmosSyncContainer container; + private CosmosClient client; + private CosmosContainer container; @Factory(dataProvider = "clientBuilders") public CosmosSyncUDFTest(CosmosClientBuilder clientBuilder) { @@ -33,9 +27,9 @@ public CosmosSyncUDFTest(CosmosClientBuilder clientBuilder) { @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = clientBuilder().buildSyncClient(); - CosmosContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); - container = client.getDatabase(asyncContainer.getDatabase().id()).getContainer(asyncContainer.id()); + this.client = clientBuilder().buildClient(); + CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); + container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); } @AfterClass(groups = {"simple"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) @@ -48,7 +42,7 @@ public void afterClass() { public void createUDF() throws Exception { CosmosUserDefinedFunctionProperties udf = getCosmosUserDefinedFunctionProperties(); - CosmosSyncUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); + CosmosUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); validateResponse(udf, createResponse); } @@ -57,9 +51,9 @@ public void createUDF() throws Exception { public void readUDF() throws Exception { CosmosUserDefinedFunctionProperties udf = getCosmosUserDefinedFunctionProperties(); - CosmosSyncUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); + CosmosUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); - CosmosSyncUserDefinedFunctionResponse read = container.getScripts().getUserDefinedFunction(udf.id()).read(); + CosmosUserDefinedFunctionResponse read = container.getScripts().getUserDefinedFunction(udf.getId()).read(); validateResponse(udf, read); } @@ -68,16 +62,16 @@ public void replaceUDF() throws Exception { CosmosUserDefinedFunctionProperties udf = getCosmosUserDefinedFunctionProperties(); - CosmosSyncUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); + CosmosUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); CosmosUserDefinedFunctionProperties readUdf = container.getScripts() - .getUserDefinedFunction(udf.id()) + .getUserDefinedFunction(udf.getId()) .read() - .properties(); + .getProperties(); - readUdf.body("function() {var x = 11;}"); - CosmosSyncUserDefinedFunctionResponse replace = container.getScripts() - .getUserDefinedFunction(udf.id()) + readUdf.setBody("function() {var x = 11;}"); + CosmosUserDefinedFunctionResponse replace = container.getScripts() + .getUserDefinedFunction(udf.getId()) .replace(readUdf); validateResponse(udf, replace); @@ -87,18 +81,18 @@ public void replaceUDF() throws Exception { public void deleteUDF() throws Exception { CosmosUserDefinedFunctionProperties udf = getCosmosUserDefinedFunctionProperties(); - CosmosSyncUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); + CosmosUserDefinedFunctionResponse createResponse = container.getScripts().createUserDefinedFunction(udf); - CosmosSyncResponse delete = container.getScripts() - .getUserDefinedFunction(udf.id()) - .delete(); + container.getScripts() + .getUserDefinedFunction(udf.getId()) + .delete(); } private CosmosUserDefinedFunctionProperties getCosmosUserDefinedFunctionProperties() { CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); return udf; } @@ -109,7 +103,7 @@ public void readAllUDFs() throws Exception { container.getScripts().createUserDefinedFunction(udf); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator3 = container.getScripts().readAllUserDefinedFunctions(feedOptions); assertThat(feedResponseIterator3.hasNext()).isTrue(); @@ -120,9 +114,9 @@ public void queryUDFs() throws Exception { CosmosUserDefinedFunctionProperties properties = getCosmosUserDefinedFunctionProperties(); container.getScripts().createUserDefinedFunction(properties); - String query = String.format("SELECT * from c where c.id = '%s'", properties.id()); + String query = String.format("SELECT * from c where c.id = '%s'", properties.getId()); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator1 = container.getScripts().queryUserDefinedFunctions(query, feedOptions); @@ -135,12 +129,12 @@ public void queryUDFs() throws Exception { } private void validateResponse(CosmosUserDefinedFunctionProperties properties, - CosmosSyncUserDefinedFunctionResponse createResponse) { + CosmosUserDefinedFunctionResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(properties.id()); + .isEqualTo(properties.getId()); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncTriggerTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosTriggerTest.java similarity index 65% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncTriggerTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosTriggerTest.java index 5f505d99b272..97f0b6db9256 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncTriggerTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosTriggerTest.java @@ -1,16 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; -import com.azure.data.cosmos.TriggerOperation; -import com.azure.data.cosmos.TriggerType; +package com.azure.data.cosmos; + import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -22,21 +14,21 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosSyncTriggerTest extends TestSuiteBase { - private CosmosSyncClient client; - private CosmosSyncContainer container; +public class CosmosTriggerTest extends TestSuiteBase { + private CosmosClient client; + private CosmosContainer container; @Factory(dataProvider = "clientBuilders") - public CosmosSyncTriggerTest(CosmosClientBuilder clientBuilder) { + public CosmosTriggerTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = clientBuilder().buildSyncClient(); - CosmosContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); - container = client.getDatabase(asyncContainer.getDatabase().id()).getContainer(asyncContainer.id()); + this.client = clientBuilder().buildClient(); + CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); + container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); } @AfterClass(groups = {"simple"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) @@ -49,7 +41,7 @@ public void afterClass() { public void createTrigger() throws Exception { CosmosTriggerProperties trigger = getCosmosTriggerProperties(); - CosmosSyncTriggerResponse triggerResponse = container.getScripts().createTrigger(trigger); + CosmosTriggerResponse triggerResponse = container.getScripts().createTrigger(trigger); validateResponse(trigger, triggerResponse); } @@ -60,7 +52,7 @@ public void readTrigger() throws Exception { container.getScripts().createTrigger(trigger); - CosmosSyncTriggerResponse readResponse = container.getScripts().getTrigger(trigger.id()).read(); + CosmosTriggerResponse readResponse = container.getScripts().getTrigger(trigger.getId()).read(); validateResponse(trigger, readResponse); } @@ -71,10 +63,10 @@ public void replaceTrigger() throws Exception { container.getScripts().createTrigger(trigger); - CosmosTriggerProperties readTrigger = container.getScripts().getTrigger(trigger.id()).read().properties(); - readTrigger.body("function() {var x = 11;}"); + CosmosTriggerProperties readTrigger = container.getScripts().getTrigger(trigger.getId()).read().getProperties(); + readTrigger.setBody("function() {var x = 11;}"); - CosmosSyncTriggerResponse replace = container.getScripts().getTrigger(trigger.id()).replace(readTrigger); + CosmosTriggerResponse replace = container.getScripts().getTrigger(trigger.getId()).replace(readTrigger); validateResponse(trigger, replace); } @@ -84,7 +76,7 @@ public void deleteTrigger() throws Exception { container.getScripts().createTrigger(trigger); - CosmosSyncResponse delete = container.getScripts().getTrigger(trigger.id()).delete(); + container.getScripts().getTrigger(trigger.getId()).delete(); } @@ -95,7 +87,7 @@ public void readAllTriggers() throws Exception { container.getScripts().createTrigger(trigger); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator3 = container.getScripts().readAllTriggers(feedOptions); assertThat(feedResponseIterator3.hasNext()).isTrue(); @@ -103,10 +95,10 @@ public void readAllTriggers() throws Exception { private CosmosTriggerProperties getCosmosTriggerProperties() { CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); return trigger; } @@ -114,8 +106,8 @@ private CosmosTriggerProperties getCosmosTriggerProperties() { public void queryTriggers() throws Exception { CosmosTriggerProperties properties = getCosmosTriggerProperties(); container.getScripts().createTrigger(properties); - String query = String.format("SELECT * from c where c.id = '%s'", properties.id()); - FeedOptions feedOptions = new FeedOptions().enableCrossPartitionQuery(true); + String query = String.format("SELECT * from c where c.id = '%s'", properties.getId()); + FeedOptions feedOptions = new FeedOptions().setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator1 = container.getScripts().queryTriggers(query, feedOptions); @@ -128,12 +120,12 @@ public void queryTriggers() throws Exception { } private void validateResponse(CosmosTriggerProperties properties, - CosmosSyncTriggerResponse createResponse) { + CosmosTriggerResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(properties.id()); + .isEqualTo(properties.getId()); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUserTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosUserTest.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUserTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosUserTest.java index e56a90202605..a72550240a7d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/sync/CosmosSyncUserTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosUserTest.java @@ -1,14 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlQuerySpec; +package com.azure.data.cosmos; + import com.azure.data.cosmos.rx.TestSuiteBase; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -22,21 +16,21 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosSyncUserTest extends TestSuiteBase { +public class CosmosUserTest extends TestSuiteBase { private String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private List databases = new ArrayList<>(); - private CosmosSyncClient client; - private CosmosSyncDatabase createdDatabase; + private CosmosClient client; + private CosmosDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") - public CosmosSyncUserTest(CosmosClientBuilder clientBuilder) { + public CosmosUserTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().buildSyncClient(); + client = clientBuilder().buildClient(); createdDatabase = createSyncDatabase(client, preExistingDatabaseId); } @@ -53,14 +47,14 @@ public void afterClass() { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createUser() throws Exception { CosmosUserProperties user = getUserProperties(); - CosmosSyncUserResponse response = createdDatabase.createUser(user); + CosmosUserResponse response = createdDatabase.createUser(user); validateResponse(user, response); } private CosmosUserProperties getUserProperties() { CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); return user; } @@ -68,20 +62,20 @@ private CosmosUserProperties getUserProperties() { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void readUser() throws Exception { CosmosUserProperties userProperties = getUserProperties(); - CosmosSyncUserResponse response = createdDatabase.createUser(userProperties); + CosmosUserResponse response = createdDatabase.createUser(userProperties); - CosmosSyncUser user = createdDatabase.getUser(userProperties.id()); - CosmosSyncUserResponse readResponse = user.read(); + CosmosUser user = createdDatabase.getUser(userProperties.getId()); + CosmosUserResponse readResponse = user.read(); validateResponse(userProperties, readResponse); } @Test(groups = { "simple" }, timeOut = TIMEOUT) public void deleteUser() throws Exception { CosmosUserProperties userProperties = getUserProperties(); - CosmosSyncUserResponse response = createdDatabase.createUser(userProperties); + CosmosUserResponse response = createdDatabase.createUser(userProperties); - CosmosSyncUser user = createdDatabase.getUser(userProperties.id()); - CosmosSyncUserResponse delete = user.delete(); + CosmosUser user = createdDatabase.getUser(userProperties.getId()); + CosmosUserResponse delete = user.delete(); } @@ -90,7 +84,7 @@ public void deleteUser() throws Exception { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void readAllUsers() throws Exception{ CosmosUserProperties userProperties = getUserProperties(); - CosmosSyncUserResponse response = createdDatabase.createUser(userProperties); + CosmosUserResponse response = createdDatabase.createUser(userProperties); Iterator> feedResponseIterator = createdDatabase.readAllUsers(); assertThat(feedResponseIterator.hasNext()).isTrue(); @@ -104,10 +98,10 @@ public void readAllUsers() throws Exception{ @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryUsers() throws Exception{ CosmosUserProperties userProperties = getUserProperties(); - CosmosSyncUserResponse response = createdDatabase.createUser(userProperties); + CosmosUserResponse response = createdDatabase.createUser(userProperties); - String query = String.format("SELECT * from c where c.id = '%s'", userProperties.id()); - FeedOptions feedOptions = new FeedOptions().enableCrossPartitionQuery(true); + String query = String.format("SELECT * from c where c.id = '%s'", userProperties.getId()); + FeedOptions feedOptions = new FeedOptions().setEnableCrossPartitionQuery(true); Iterator> feedResponseIterator1 = createdDatabase.queryUsers(query, feedOptions); @@ -121,12 +115,12 @@ public void queryUsers() throws Exception{ } private void validateResponse(CosmosUserProperties properties, - CosmosSyncUserResponse createResponse) { + CosmosUserResponse createResponse) { // Basic validation - assertThat(createResponse.properties().id()).isNotNull(); - assertThat(createResponse.properties().id()) + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) .as("check Resource Id") - .isEqualTo(properties.id()); + .isEqualTo(properties.getId()); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java index 54e696730676..fc41a3ac6333 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentClientTest.java @@ -40,7 +40,7 @@ public final void setTestName(Method method) { method.getName()); if (this.clientBuilder.getConnectionPolicy() != null && this.clientBuilder.getConfigs() != null) { - String connectionMode = this.clientBuilder.getConnectionPolicy().connectionMode() == ConnectionMode.DIRECT + String connectionMode = this.clientBuilder.getConnectionPolicy().getConnectionMode() == ConnectionMode.DIRECT ? "Direct " + this.clientBuilder.getConfigs().getProtocol() : "Gateway"; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java similarity index 75% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java index c2780f77e6d8..faa43012590b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentCollectionTests.java @@ -18,7 +18,7 @@ public class DocumentCollectionTests { public void getPartitionKey() { DocumentCollection collection = new DocumentCollection(); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); - partitionKeyDefinition.paths(ImmutableList.of("/mypk")); + partitionKeyDefinition.setPaths(ImmutableList.of("/mypk")); collection.setPartitionKey(partitionKeyDefinition); assertThat(collection.getPartitionKey()).isEqualTo(partitionKeyDefinition); } @@ -27,14 +27,14 @@ public void getPartitionKey() { public void getPartitionKey_serializeAndDeserialize() { DocumentCollection collection = new DocumentCollection(); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); - partitionKeyDefinition.paths(ImmutableList.of("/mypk")); - partitionKeyDefinition.version(PartitionKeyDefinitionVersion.V2); + partitionKeyDefinition.setPaths(ImmutableList.of("/mypk")); + partitionKeyDefinition.setVersion(PartitionKeyDefinitionVersion.V2); collection.setPartitionKey(partitionKeyDefinition); DocumentCollection parsedColl = new DocumentCollection(collection.toJson()); - assertThat(parsedColl.getPartitionKey().kind().toString()).isEqualTo(partitionKeyDefinition.kind().toString()); - assertThat(parsedColl.getPartitionKey().paths()).isEqualTo(partitionKeyDefinition.paths()); - assertThat(parsedColl.getPartitionKey().version()).isEqualTo(partitionKeyDefinition.version()); + assertThat(parsedColl.getPartitionKey().getKind().toString()).isEqualTo(partitionKeyDefinition.getKind().toString()); + assertThat(parsedColl.getPartitionKey().getPaths()).isEqualTo(partitionKeyDefinition.getPaths()); + assertThat(parsedColl.getPartitionKey().getVersion()).isEqualTo(partitionKeyDefinition.getVersion()); } @Test(groups = { "unit"}) @@ -43,7 +43,7 @@ public void indexingPolicy_serializeAndDeserialize() { List spatialSpecList = new ArrayList<>(); spatialSpecList.add(spatialSpec); IndexingPolicy indexingPolicy = new IndexingPolicy(); - indexingPolicy.spatialIndexes(spatialSpecList); + indexingPolicy.setSpatialIndexes(spatialSpecList); DocumentCollection documentCollection = new DocumentCollection(); documentCollection.setIndexingPolicy(indexingPolicy); String json = documentCollection.toJson(); @@ -51,7 +51,7 @@ public void indexingPolicy_serializeAndDeserialize() { DocumentCollection documentCollectionPostSerialization = new DocumentCollection(json); IndexingPolicy indexingPolicyPostSerialization = documentCollectionPostSerialization.getIndexingPolicy(); assertThat(indexingPolicyPostSerialization).isNotNull(); - List spatialSpecListPostSerialization = indexingPolicyPostSerialization.spatialIndexes(); + List spatialSpecListPostSerialization = indexingPolicyPostSerialization.getSpatialIndexes(); assertThat(spatialSpecListPostSerialization).isNotNull(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java index 41941bfa8ed6..81a7508222cc 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/DocumentTests.java @@ -19,6 +19,6 @@ public void timestamp() { Document d = new Document(); OffsetDateTime time = OffsetDateTime.of(2019, 8, 6, 12, 53, 29, 0, ZoneOffset.UTC); setTimestamp(d, time); - assertThat(d.timestamp()).isEqualTo(time); + assertThat(d.getTimestamp()).isEqualTo(time); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/GatewayTestUtils.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/GatewayTestUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/GatewayTestUtils.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/GatewayTestUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java index bcfc0fe73466..685f86cc3f07 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/IncludedPathTest.java @@ -28,9 +28,9 @@ public void deserialize() { " ]" + "}"; IncludedPath path = new IncludedPath(json); - Collection indexes = path.indexes(); + Collection indexes = path.getIndexes(); assertThat(indexes).hasSize(2); assertThat(indexes).usingFieldByFieldElementComparator().contains(Index.Range(DataType.STRING, -1)); assertThat(indexes).usingFieldByFieldElementComparator().contains(Index.Range(DataType.NUMBER, -1)); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java index 07cc35d98a96..265a190b9d25 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/JsonSerializableTests.java @@ -87,10 +87,10 @@ public void getObjectAndCastToClass() { // JsonSerializable Document innerDocument = new Document(); - innerDocument.id("innerDocument"); + innerDocument.setId("innerDocument"); setProperty(document, "innerDocument", innerDocument); Document readInnerDocument = document.getObject("innerDocument", Document.class); - assertThat(readInnerDocument.id()).isEqualTo(innerDocument.id()); + assertThat(readInnerDocument.getId()).isEqualTo(innerDocument.getId()); } @Test(groups = { "unit" }) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java index 059ddcbde846..7dd78a41a535 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PartitionKeyHashingTests.java @@ -39,8 +39,8 @@ public void effectivePartitionKeyHashV1() { for (Map.Entry entry : keyToEffectivePartitionKeyString.entrySet()) { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); - partitionKeyDef.kind(PartitionKind.HASH); - partitionKeyDef.paths(Arrays.asList(new String[]{"\\id"})); + partitionKeyDef.setKind(PartitionKind.HASH); + partitionKeyDef.setPaths(Arrays.asList(new String[]{"\\id"})); String actualEffectiveKeyString = PartitionKeyInternalHelper.getEffectivePartitionKeyString(new PartitionKey(entry.getKey()).getInternalPartitionKey(),partitionKeyDef, true); assertThat(entry.getValue()).isEqualTo(actualEffectiveKeyString); } @@ -69,9 +69,9 @@ public void effectivePartitionKeyHashV2() { for (Map.Entry entry : keyToEffectivePartitionKeyString.entrySet()) { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); - partitionKeyDef.kind(PartitionKind.HASH); - partitionKeyDef.version(PartitionKeyDefinitionVersion.V2); - partitionKeyDef.paths(Arrays.asList(new String[]{"\\id"})); + partitionKeyDef.setKind(PartitionKind.HASH); + partitionKeyDef.setVersion(PartitionKeyDefinitionVersion.V2); + partitionKeyDef.setPaths(Arrays.asList(new String[]{"\\id"})); String actualEffectiveKeyString = PartitionKeyInternalHelper.getEffectivePartitionKeyString(new PartitionKey(entry.getKey()).getInternalPartitionKey(),partitionKeyDef, true); assertThat(entry.getValue()).isEqualTo(actualEffectiveKeyString); } @@ -81,17 +81,17 @@ public void effectivePartitionKeyHashV2() { public void hashV2PartitionKeyDeserialization() { String partitionKeyDefinitionStr = "{\"paths\":[\"/pk\"],\"kind\":\"Hash\",\"version\":2}"; PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(partitionKeyDefinitionStr); - assertThat(partitionKeyDef.version()).isEqualTo(PartitionKeyDefinitionVersion.V2); - assertThat(partitionKeyDef.kind()).isEqualTo(PartitionKind.HASH); - assertThat(partitionKeyDef.paths().toArray()[0]).isEqualTo("/pk"); + assertThat(partitionKeyDef.getVersion()).isEqualTo(PartitionKeyDefinitionVersion.V2); + assertThat(partitionKeyDef.getKind()).isEqualTo(PartitionKind.HASH); + assertThat(partitionKeyDef.getPaths().toArray()[0]).isEqualTo("/pk"); } @Test(groups = "unit") public void hashV1PartitionKeyDeserialization() { String partitionKeyDefinitionStr = "{\"paths\":[\"/pk\"],\"kind\":\"Hash\"}"; PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(partitionKeyDefinitionStr); - assertThat(partitionKeyDef.version()).isNull(); - assertThat(partitionKeyDef.kind()).isEqualTo(PartitionKind.HASH); - assertThat(partitionKeyDef.paths().toArray()[0]).isEqualTo("/pk"); + assertThat(partitionKeyDef.getVersion()).isNull(); + assertThat(partitionKeyDef.getKind()).isEqualTo(PartitionKind.HASH); + assertThat(partitionKeyDef.getPaths().toArray()[0]).isEqualTo("/pk"); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java index 5e8e81dec555..ae5910273dc6 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/PermissionTest.java @@ -21,4 +21,4 @@ public void deserialize() { assertThat(p.getResourcePartitionKey()).isEqualToComparingFieldByField(new PartitionKey("/id")); assertThat(p.getPermissionMode()).isEqualTo(PermissionMode.READ); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ResourceIdTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ResourceIdTests.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/ResourceIdTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/ResourceIdTests.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ClientRetryPolicyTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ClientRetryPolicyTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ClientRetryPolicyTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ClientRetryPolicyTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsBuilder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsBuilder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsTests.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConfigsTests.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java index ff584cac21bb..7a93681571d9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests1.java @@ -30,7 +30,7 @@ public void validateStrongConsistencyOnSyncReplication() throws Exception { } ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -41,8 +41,8 @@ public void validateStrongConsistencyOnSyncReplication() throws Exception { .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.STRONG).build(); User userDefinition = getUserDefinition(); - userDefinition.id(userDefinition.id() + "validateStrongConsistencyOnSyncReplication"); - User user = safeCreateUser(this.initClient, createdDatabase.id(), userDefinition); + userDefinition.setId(userDefinition.getId() + "validateStrongConsistencyOnSyncReplication"); + User user = safeCreateUser(this.initClient, createdDatabase.getId(), userDefinition); validateStrongConsistency(user); } @@ -52,7 +52,7 @@ public void validateConsistentLSNForDirectTCPClient() { //TODO Need to test with TCP protocol // https://msdata.visualstudio.com/CosmosDB/_workitems/edit/355057 ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -68,7 +68,7 @@ public void validateConsistentLSNForDirectTCPClient() { @Test(groups = {"direct"}, timeOut = CONSISTENCY_TEST_TIMEOUT) public void validateConsistentLSNForDirectHttpsClient() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -86,7 +86,7 @@ public void validateConsistentLSNAndQuorumAckedLSNForDirectTCPClient() { //TODO Need to test with TCP protocol //https://msdata.visualstudio.com/CosmosDB/_workitems/edit/355057 ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -120,7 +120,7 @@ public void validateBoundedStalenessDynamicQuorumSyncReplication() { @Test(groups = {"direct"}, timeOut = CONSISTENCY_TEST_TIMEOUT) public void validateConsistentLSNAndQuorumAckedLSNForDirectHttpsClient() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -167,7 +167,7 @@ public void validateConsistentPrefixOnSyncReplication() throws InterruptedExcept } ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -177,7 +177,7 @@ public void validateConsistentPrefixOnSyncReplication() throws InterruptedExcept .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.BOUNDED_STALENESS).build(); - User user = safeCreateUser(this.initClient, createdDatabase.id(), getUserDefinition()); + User user = safeCreateUser(this.initClient, createdDatabase.getId(), getUserDefinition()); boolean readLagging = validateConsistentPrefix(user); assertThat(readLagging).isFalse(); } @@ -191,7 +191,7 @@ public void validateConsistentPrefixOnAsyncReplication() throws InterruptedExcep } ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -204,7 +204,7 @@ public void validateConsistentPrefixOnAsyncReplication() throws InterruptedExcep .withConsistencyLevel(ConsistencyLevel.BOUNDED_STALENESS) .build(); Document documentDefinition = getDocumentDefinition(); - Document document = createDocument(this.initClient, createdDatabase.id(), createdCollection.id(), documentDefinition); + Document document = createDocument(this.initClient, createdDatabase.getId(), createdCollection.getId(), documentDefinition); boolean readLagging = validateConsistentPrefix(document); //assertThat(readLagging).isTrue(); //Will fail if batch repl is turned off } @@ -240,9 +240,9 @@ private void validateSubstatusCodeOnNotFoundExceptionInSessionReadAsync(boolean ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } AsyncDocumentClient client = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -251,28 +251,28 @@ private void validateSubstatusCodeOnNotFoundExceptionInSessionReadAsync(boolean .build(); try { DocumentCollection documentCollection = new DocumentCollection(); - documentCollection.id(UUID.randomUUID().toString()); + documentCollection.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); - partitionKeyDefinition.kind(PartitionKind.HASH); + partitionKeyDefinition.setKind(PartitionKind.HASH); ArrayList paths = new ArrayList(); paths.add("/id"); - partitionKeyDefinition.paths(paths); + partitionKeyDefinition.setPaths(paths); documentCollection.setPartitionKey(partitionKeyDefinition); - DocumentCollection collection = client.createCollection(createdDatabase.selfLink(), documentCollection + DocumentCollection collection = client.createCollection(createdDatabase.getSelfLink(), documentCollection , null).blockFirst().getResource(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey("1")); Document documentDefinition = new Document(); - documentDefinition.id("1"); - Document document = client.createDocument(collection.selfLink(), documentDefinition, requestOptions, false).blockFirst().getResource(); + documentDefinition.setId("1"); + Document document = client.createDocument(collection.getSelfLink(), documentDefinition, requestOptions, false).blockFirst().getResource(); - Flux> deleteObservable = client.deleteDocument(document.selfLink(), requestOptions); + Flux> deleteObservable = client.deleteDocument(document.getSelfLink(), requestOptions); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); - Flux> readObservable = client.readDocument(document.selfLink(), requestOptions); + Flux> readObservable = client.readDocument(document.getSelfLink(), requestOptions); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().unknownSubStatusCode().build(); validateFailure(readObservable, notFoundValidator); @@ -283,7 +283,7 @@ private void validateSubstatusCodeOnNotFoundExceptionInSessionReadAsync(boolean private static User getUserDefinition() { User user = new User(); - user.id(USER_NAME); + user.setId(USER_NAME); return user; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java index 9a0959f6cd87..634a4b4c1acf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTests2.java @@ -29,7 +29,7 @@ public class ConsistencyTests2 extends ConsistencyTestsBase { @Test(groups = {"direct"}, timeOut = CONSISTENCY_TEST_TIMEOUT) public void validateReadSessionOnAsyncReplication() throws InterruptedException { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -40,7 +40,7 @@ public void validateReadSessionOnAsyncReplication() throws InterruptedException .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); - Document document = this.initClient.createDocument(createdCollection.selfLink(), getDocumentDefinition(), + Document document = this.initClient.createDocument(createdCollection.getSelfLink(), getDocumentDefinition(), null, false).blockFirst().getResource(); Thread.sleep(5000);//WaitForServerReplication boolean readLagging = this.validateReadSession(document); @@ -50,7 +50,7 @@ public void validateReadSessionOnAsyncReplication() throws InterruptedException @Test(groups = {"direct"}, timeOut = CONSISTENCY_TEST_TIMEOUT) public void validateWriteSessionOnAsyncReplication() throws InterruptedException { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -61,7 +61,7 @@ public void validateWriteSessionOnAsyncReplication() throws InterruptedException .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); - Document document = this.initClient.createDocument(createdCollection.selfLink(), getDocumentDefinition(), + Document document = this.initClient.createDocument(createdCollection.getSelfLink(), getDocumentDefinition(), null, false).blockFirst().getResource(); Thread.sleep(5000);//WaitForServerReplication boolean readLagging = this.validateWriteSession(document); @@ -157,7 +157,7 @@ public void validateSessionTokenFromCollectionReplaceIsServerToken() { public void validateNoChargeOnFailedSessionRead() throws Exception { // DIRECT clients for read and write operations ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -171,22 +171,22 @@ public void validateNoChargeOnFailedSessionRead() throws Exception { .build(); try { // CREATE collection - DocumentCollection parentResource = writeClient.createCollection(createdDatabase.selfLink(), + DocumentCollection parentResource = writeClient.createCollection(createdDatabase.getSelfLink(), getCollectionDefinition(), null).blockFirst().getResource(); // Document to lock pause/resume clients Document documentDefinition = getDocumentDefinition(); - documentDefinition.id("test" + documentDefinition.id()); - ResourceResponse childResource = writeClient.createDocument(parentResource.selfLink(), documentDefinition, null, true).blockFirst(); - logger.info("Created {} child resource", childResource.getResource().resourceId()); + documentDefinition.setId("test" + documentDefinition.getId()); + ResourceResponse childResource = writeClient.createDocument(parentResource.getSelfLink(), documentDefinition, null, true).blockFirst(); + logger.info("Created {} child resource", childResource.getResource().getResourceId()); String token = childResource.getSessionToken().split(":")[0] + ":" + this.createSessionToken(SessionTokenHelper.parse(childResource.getSessionToken()), 100000000).convertToString(); FeedOptions feedOptions = new FeedOptions(); feedOptions.partitionKey(new PartitionKey(PartitionKeyInternal.Empty.toJson())); - feedOptions.sessionToken(token); + feedOptions.setSessionToken(token); FailureValidator validator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.NOTFOUND).subStatusCode(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE).build(); - Flux> feedObservable = readSecondaryClient.readDocuments(parentResource.selfLink(), feedOptions); + Flux> feedObservable = readSecondaryClient.readDocuments(parentResource.getSelfLink(), feedOptions); validateQueryFailure(feedObservable, validator); } finally { safeClose(writeClient); @@ -217,7 +217,7 @@ public void validateSessionTokenAsync() { } ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); RxDocumentClientImpl client = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -225,38 +225,38 @@ public void validateSessionTokenAsync() { .build(); try { - Document lastDocument = client.createDocument(createdCollection.selfLink(), getDocumentDefinition(), + Document lastDocument = client.createDocument(createdCollection.getSelfLink(), getDocumentDefinition(), null, true) .blockFirst() .getResource(); - Mono task1 = ParallelAsync.forEachAsync(Range.between(0, 1000), 5, index -> client.createDocument(createdCollection.selfLink(), documents.get(index % documents.size()), + Mono task1 = ParallelAsync.forEachAsync(Range.between(0, 1000), 5, index -> client.createDocument(createdCollection.getSelfLink(), documents.get(index % documents.size()), null, true) .blockFirst()); Mono task2 = ParallelAsync.forEachAsync(Range.between(0, 1000), 5, index -> { try { FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); - FeedResponse queryResponse = client.queryDocuments(createdCollection.selfLink(), + feedOptions.setEnableCrossPartitionQuery(true); + FeedResponse queryResponse = client.queryDocuments(createdCollection.getSelfLink(), "SELECT * FROM c WHERE c.Id = " + "'foo'", feedOptions) .blockFirst(); - String lsnHeaderValue = queryResponse.responseHeaders().get(WFConstants.BackendHeaders.LSN); + String lsnHeaderValue = queryResponse.getResponseHeaders().get(WFConstants.BackendHeaders.LSN); long lsn = Long.valueOf(lsnHeaderValue); - String sessionTokenHeaderValue = queryResponse.responseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); + String sessionTokenHeaderValue = queryResponse.getResponseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); ISessionToken sessionToken = SessionTokenHelper.parse(sessionTokenHeaderValue); logger.info("SESSION Token = {}, LSN = {}", sessionToken.convertToString(), lsn); assertThat(lsn).isEqualTo(sessionToken.getLSN()); } catch (Exception ex) { CosmosClientException clientException = (CosmosClientException) ex.getCause(); - if (clientException.statusCode() != 0) { - if (clientException.statusCode() == HttpConstants.StatusCodes.REQUEST_TIMEOUT) { + if (clientException.getStatusCode() != 0) { + if (clientException.getStatusCode() == HttpConstants.StatusCodes.REQUEST_TIMEOUT) { // ignore - } else if (clientException.statusCode() == HttpConstants.StatusCodes.NOTFOUND) { - String lsnHeaderValue = clientException.responseHeaders().get(WFConstants.BackendHeaders.LSN); + } else if (clientException.getStatusCode() == HttpConstants.StatusCodes.NOTFOUND) { + String lsnHeaderValue = clientException.getResponseHeaders().get(WFConstants.BackendHeaders.LSN); long lsn = Long.valueOf(lsnHeaderValue); - String sessionTokenHeaderValue = clientException.responseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); + String sessionTokenHeaderValue = clientException.getResponseHeaders().get(HttpConstants.HttpHeaders.SESSION_TOKEN); ISessionToken sessionToken = SessionTokenHelper.parse(sessionTokenHeaderValue); logger.info("SESSION Token = {}, LSN = {}", sessionToken.convertToString(), lsn); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java similarity index 84% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java index 5b13cf8c0470..d2d1ddc76a69 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ConsistencyTestsBase.java @@ -54,20 +54,20 @@ void validateStrongConsistency(Resource resourceToWorkWith) throws Exception { Resource writeResource = resourceToWorkWith; while (numberOfTestIteration-- > 0) //Write from a client and do point read through second client and ensure TS matches. { - OffsetDateTime sourceTimestamp = writeResource.timestamp(); + OffsetDateTime sourceTimestamp = writeResource.getTimestamp(); Thread.sleep(1000); //Timestamp is in granularity of seconds. Resource updatedResource = null; if (resourceToWorkWith instanceof User) { - updatedResource = this.writeClient.upsertUser(createdDatabase.selfLink(), (User) writeResource, null).blockFirst().getResource(); + updatedResource = this.writeClient.upsertUser(createdDatabase.getSelfLink(), (User) writeResource, null).blockFirst().getResource(); } else if (resourceToWorkWith instanceof Document) { RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(resourceToWorkWith.get("mypk"))); - updatedResource = this.writeClient.upsertDocument(createdCollection.selfLink(), (Document) writeResource, options, false).blockFirst().getResource(); + updatedResource = this.writeClient.upsertDocument(createdCollection.getSelfLink(), (Document) writeResource, options, false).blockFirst().getResource(); } - assertThat(updatedResource.timestamp().isAfter(sourceTimestamp)).isTrue(); + assertThat(updatedResource.getTimestamp().isAfter(sourceTimestamp)).isTrue(); - User readResource = this.readClient.readUser(resourceToWorkWith.selfLink(), null).blockFirst().getResource(); - assertThat(updatedResource.timestamp().equals(readResource.timestamp())); + User readResource = this.readClient.readUser(resourceToWorkWith.getSelfLink(), null).blockFirst().getResource(); + assertThat(updatedResource.getTimestamp().equals(readResource.getTimestamp())); } } @@ -75,14 +75,14 @@ void validateConsistentLSN() { Document documentDefinition = getDocumentDefinition(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(documentDefinition.get("mypk"))); - Document document = createDocument(this.writeClient, createdDatabase.id(), createdCollection.id(), documentDefinition); - ResourceResponse response = this.writeClient.deleteDocument(document.selfLink(), options).single().block(); + Document document = createDocument(this.writeClient, createdDatabase.getId(), createdCollection.getId(), documentDefinition); + ResourceResponse response = this.writeClient.deleteDocument(document.getSelfLink(), options).single().block(); assertThat(response.getStatusCode()).isEqualTo(204); long quorumAckedLSN = Long.parseLong((String) response.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN)); assertThat(quorumAckedLSN > 0).isTrue(); FailureValidator validator = new FailureValidator.Builder().statusCode(404).lsnGreaterThan(quorumAckedLSN).build(); - Flux> readObservable = this.readClient.readDocument(document.selfLink(), options); + Flux> readObservable = this.readClient.readDocument(document.getSelfLink(), options); validateFailure(readObservable, validator); } @@ -90,15 +90,15 @@ void validateConsistentLSNAndQuorumAckedLSN() { Document documentDefinition = getDocumentDefinition(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(documentDefinition.get("mypk"))); - Document document = createDocument(this.writeClient, createdDatabase.id(), createdCollection.id(), documentDefinition); - ResourceResponse response = this.writeClient.deleteDocument(document.selfLink(), options).single().block(); + Document document = createDocument(this.writeClient, createdDatabase.getId(), createdCollection.getId(), documentDefinition); + ResourceResponse response = this.writeClient.deleteDocument(document.getSelfLink(), options).single().block(); assertThat(response.getStatusCode()).isEqualTo(204); long quorumAckedLSN = Long.parseLong((String) response.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN)); assertThat(quorumAckedLSN > 0).isTrue(); FailureValidator validator = new FailureValidator.Builder().statusCode(404).lsnGreaterThanEqualsTo(quorumAckedLSN).exceptionQuorumAckedLSNInNotNull().build(); - Flux> readObservable = this.readClient.deleteDocument(document.selfLink(), options); + Flux> readObservable = this.readClient.deleteDocument(document.getSelfLink(), options); validateFailure(readObservable, validator); } @@ -116,7 +116,7 @@ void validateStrongConsistencyOnAsyncReplication(boolean useGateway) throws Inte ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } this.writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) @@ -130,7 +130,7 @@ void validateStrongConsistencyOnAsyncReplication(boolean useGateway) throws Inte .withConsistencyLevel(ConsistencyLevel.STRONG).build(); Document documentDefinition = getDocumentDefinition(); - Document document = createDocument(this.writeClient, createdDatabase.id(), createdCollection.id(), documentDefinition); + Document document = createDocument(this.writeClient, createdDatabase.getId(), createdCollection.getId(), documentDefinition); validateStrongConsistency(document); } @@ -138,15 +138,15 @@ void validateStrongConsistency(Document documentToWorkWith) throws InterruptedEx int numberOfTestIteration = 5; Document writeDocument = documentToWorkWith; while (numberOfTestIteration-- > 0) { - OffsetDateTime sourceTimestamp = writeDocument.timestamp(); + OffsetDateTime sourceTimestamp = writeDocument.getTimestamp(); Thread.sleep(1000);//Timestamp is in granularity of seconds. RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(documentToWorkWith.get("mypk"))); Document updatedDocument = this.writeClient.replaceDocument(writeDocument, options).blockFirst().getResource(); - assertThat(updatedDocument.timestamp().isAfter(sourceTimestamp)).isTrue(); + assertThat(updatedDocument.getTimestamp().isAfter(sourceTimestamp)).isTrue(); - Document readDocument = this.readClient.readDocument(documentToWorkWith.selfLink(), options).blockFirst().getResource(); - assertThat(updatedDocument.timestamp().equals(readDocument.timestamp())); + Document readDocument = this.readClient.readDocument(documentToWorkWith.getSelfLink(), options).blockFirst().getResource(); + assertThat(updatedDocument.getTimestamp().equals(readDocument.getTimestamp())); } } @@ -154,9 +154,9 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) { // DIRECT clients for read and write operations ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) @@ -166,31 +166,31 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) { try { PartitionKeyDefinition partitionKey = new PartitionKeyDefinition(); - partitionKey.paths(Arrays.asList("/customerid")); - partitionKey.kind(PartitionKind.HASH); + partitionKey.setPaths(Arrays.asList("/customerid")); + partitionKey.setKind(PartitionKind.HASH); DocumentCollection coll = null; { // self link - ResourceResponse collection = writeClient.createCollection(createdDatabase.selfLink(), getCollectionDefinition(), null).blockFirst(); - String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(collection.getResource().selfLink()); + ResourceResponse collection = writeClient.createCollection(createdDatabase.getSelfLink(), getCollectionDefinition(), null).blockFirst(); + String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(collection.getResource().getSelfLink()); String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(BridgeInternal.getAltLink(collection.getResource())); System.out.println("BridgeInternal.getAltLink(collection.getResource()) " + BridgeInternal.getAltLink(collection.getResource())); assertThat(collection.getSessionToken()).isEqualTo(globalSessionToken1); assertThat(collection.getSessionToken()).isEqualTo(globalSessionToken2); coll = collection.getResource(); - ResourceResponse collectionRead = writeClient.readCollection(coll.selfLink(), null).blockFirst(); - // timesync might bump the version, comment out the check - //assertThat(collection.sessionToken()).isEqualTo(collectionRead.sessionToken()); + ResourceResponse collectionRead = writeClient.readCollection(coll.getSelfLink(), null).blockFirst(); + // timesync might bump the getVersion, comment out the check + //assertThat(collection.getSessionToken()).isEqualTo(collectionRead.getSessionToken()); } { // name link ResourceResponse collection = writeClient.createCollection(BridgeInternal.getAltLink(createdDatabase), getCollectionDefinition(), null).blockFirst(); - String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(collection.getResource().selfLink()); + String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(collection.getResource().getSelfLink()); String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(BridgeInternal.getAltLink(collection.getResource())); assertThat(collection.getSessionToken()).isEqualTo(globalSessionToken1); - //assertThat(collection.sessionToken()).isEqualTo(globalSessionToken2); + //assertThat(collection.getSessionToken()).isEqualTo(globalSessionToken2); ResourceResponse collectionRead = writeClient.readCollection(BridgeInternal.getAltLink(collection.getResource()), null).blockFirst(); @@ -199,13 +199,13 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) { } { Document document2 = new Document(); - document2.id("test" + UUID.randomUUID().toString()); + document2.setId("test" + UUID.randomUUID().toString()); BridgeInternal.setProperty(document2, "customerid", 2); // name link ResourceResponse document = writeClient.createDocument(BridgeInternal.getAltLink(coll), document2, null, false) .blockFirst(); - String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(coll.selfLink()); + String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(coll.getSelfLink()); String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(BridgeInternal.getAltLink(coll)); assertThat(globalSessionToken1.indexOf(document.getSessionToken())).isNotNegative(); @@ -213,13 +213,13 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) { } { Document document2 = new Document(); - document2.id("test" + UUID.randomUUID().toString()); + document2.setId("test" + UUID.randomUUID().toString()); BridgeInternal.setProperty(document2, "customerid", 3); // name link ResourceResponse document = writeClient.createDocument(BridgeInternal.getAltLink(coll), document2, null, false) .blockFirst(); - String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(coll.selfLink()); + String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(coll.getSelfLink()); String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(BridgeInternal.getAltLink(coll)); assertThat(globalSessionToken1.indexOf(document.getSessionToken())).isNotNegative(); @@ -232,43 +232,43 @@ void validateSessionContainerAfterCollectionCreateReplace(boolean useGateway) { boolean validateConsistentPrefix(Resource resourceToWorkWith) throws InterruptedException { int numberOfTestIteration = 5; - OffsetDateTime lastReadDateTime = resourceToWorkWith.timestamp(); + OffsetDateTime lastReadDateTime = resourceToWorkWith.getTimestamp(); boolean readLagging = false; Resource writeResource = resourceToWorkWith; while (numberOfTestIteration-- > 0) { //Write from a client and do point read through second client and ensure TS monotonically increases. - OffsetDateTime sourceTimestamp = writeResource.timestamp(); + OffsetDateTime sourceTimestamp = writeResource.getTimestamp(); Thread.sleep(1000); //Timestamp is in granularity of seconds. Resource updatedResource = null; if (resourceToWorkWith instanceof User) { - updatedResource = this.writeClient.upsertUser(createdDatabase.selfLink(), (User) writeResource, + updatedResource = this.writeClient.upsertUser(createdDatabase.getSelfLink(), (User) writeResource, null) .blockFirst() .getResource(); } else if (resourceToWorkWith instanceof Document) { - updatedResource = this.writeClient.upsertDocument(createdCollection.selfLink(), + updatedResource = this.writeClient.upsertDocument(createdCollection.getSelfLink(), (Document) writeResource, null, false) .blockFirst() .getResource(); } - assertThat(updatedResource.timestamp().isAfter(sourceTimestamp)).isTrue(); + assertThat(updatedResource.getTimestamp().isAfter(sourceTimestamp)).isTrue(); writeResource = updatedResource; Resource readResource = null; if (resourceToWorkWith instanceof User) { - readResource = this.readClient.readUser(resourceToWorkWith.selfLink(), null) + readResource = this.readClient.readUser(resourceToWorkWith.getSelfLink(), null) .blockFirst() .getResource(); } else if (resourceToWorkWith instanceof Document) { RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(resourceToWorkWith.get("mypk"))); - readResource = this.readClient.readDocument(resourceToWorkWith.selfLink(), options) + readResource = this.readClient.readDocument(resourceToWorkWith.getSelfLink(), options) .blockFirst() .getResource(); } - assertThat(readResource.timestamp().compareTo(lastReadDateTime) >= 0).isTrue(); - lastReadDateTime = readResource.timestamp(); - if (readResource.timestamp().isBefore(updatedResource.timestamp())) { + assertThat(readResource.getTimestamp().compareTo(lastReadDateTime) >= 0).isTrue(); + lastReadDateTime = readResource.getTimestamp(); + if (readResource.getTimestamp().isBefore(updatedResource.getTimestamp())) { readLagging = true; } } @@ -282,29 +282,29 @@ boolean validateReadSession(Resource resourceToWorkWith) throws InterruptedExcep Resource writeResource = resourceToWorkWith; while (numberOfTestIteration-- > 0) { - OffsetDateTime sourceTimestamp = writeResource.timestamp(); + OffsetDateTime sourceTimestamp = writeResource.getTimestamp(); Thread.sleep(1000); Resource updatedResource = null; if (resourceToWorkWith instanceof Document) { - updatedResource = this.writeClient.upsertDocument(createdCollection.selfLink(), writeResource, + updatedResource = this.writeClient.upsertDocument(createdCollection.getSelfLink(), writeResource, null, false) .single() .block() .getResource(); } - assertThat(updatedResource.timestamp().isAfter(sourceTimestamp)).isTrue(); + assertThat(updatedResource.getTimestamp().isAfter(sourceTimestamp)).isTrue(); writeResource = updatedResource; Resource readResource = null; RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(resourceToWorkWith.get("mypk"))); if (resourceToWorkWith instanceof Document) { - readResource = this.readClient.readDocument(resourceToWorkWith.selfLink(), requestOptions).blockFirst().getResource(); + readResource = this.readClient.readDocument(resourceToWorkWith.getSelfLink(), requestOptions).blockFirst().getResource(); } - assertThat(readResource.timestamp().compareTo(lastReadDateTime) >= 0).isTrue(); - lastReadDateTime = readResource.timestamp(); + assertThat(readResource.getTimestamp().compareTo(lastReadDateTime) >= 0).isTrue(); + lastReadDateTime = readResource.getTimestamp(); - if (readResource.timestamp().isBefore(updatedResource.timestamp())) { + if (readResource.getTimestamp().isBefore(updatedResource.getTimestamp())) { readLagging = true; } } @@ -318,13 +318,13 @@ boolean validateWriteSession(Resource resourceToWorkWith) throws InterruptedExce Resource writeResource = resourceToWorkWith; while (numberOfTestIteration-- > 0) { - OffsetDateTime sourceTimestamp = writeResource.timestamp(); + OffsetDateTime sourceTimestamp = writeResource.getTimestamp(); Thread.sleep(1000); Resource updatedResource = null; if (resourceToWorkWith instanceof Document) { - updatedResource = this.writeClient.upsertDocument(createdCollection.selfLink(), writeResource, null, false).single().block().getResource(); + updatedResource = this.writeClient.upsertDocument(createdCollection.getSelfLink(), writeResource, null, false).single().block().getResource(); } - assertThat(updatedResource.timestamp().isAfter(sourceTimestamp)).isTrue(); + assertThat(updatedResource.getTimestamp().isAfter(sourceTimestamp)).isTrue(); writeResource = updatedResource; Resource readResource = null; @@ -332,27 +332,27 @@ boolean validateWriteSession(Resource resourceToWorkWith) throws InterruptedExce requestOptions.setPartitionKey(new PartitionKey(resourceToWorkWith.get("mypk"))); if (resourceToWorkWith instanceof Document) { readResource = - this.readClient.readDocument(resourceToWorkWith.selfLink(), requestOptions) + this.readClient.readDocument(resourceToWorkWith.getSelfLink(), requestOptions) .blockFirst() .getResource(); } - assertThat(readResource.timestamp().compareTo(lastReadDateTime) >= 0).isTrue(); - lastReadDateTime = readResource.timestamp(); + assertThat(readResource.getTimestamp().compareTo(lastReadDateTime) >= 0).isTrue(); + lastReadDateTime = readResource.getTimestamp(); - if (readResource.timestamp().isBefore(updatedResource.timestamp())) { + if (readResource.getTimestamp().isBefore(updatedResource.getTimestamp())) { readLagging = true; } //Now perform write on session and update our session token and lastReadTS Thread.sleep(1000); if (resourceToWorkWith instanceof Document) { - readResource = this.writeClient.upsertDocument(createdCollection.selfLink(), readResource, + readResource = this.writeClient.upsertDocument(createdCollection.getSelfLink(), readResource, requestOptions, false) .blockFirst() .getResource(); //Now perform write on session } - assertThat(readResource.timestamp().isAfter(lastReadDateTime)); + assertThat(readResource.getTimestamp().isAfter(lastReadDateTime)); this.readClient.setSession(this.writeClient.getSession()); } @@ -362,9 +362,9 @@ boolean validateWriteSession(Resource resourceToWorkWith) throws InterruptedExce void validateSessionContainerAfterCollectionDeletion(boolean useGateway) throws Exception { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl client1 = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -380,68 +380,68 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway) throws String collectionId = UUID.randomUUID().toString(); try { DocumentCollection collectionDefinition = getCollectionDefinition(); - collectionDefinition.id(collectionId); - DocumentCollection collection = createCollection(client2, createdDatabase.id(), collectionDefinition, null); + collectionDefinition.setId(collectionId); + DocumentCollection collection = createCollection(client2, createdDatabase.getId(), collectionDefinition, null); ResourceResponseValidator successValidatorCollection = new ResourceResponseValidator.Builder() - .withId(collection.id()) + .withId(collection.getId()) .build(); - Flux> readObservableCollection = client2.readCollection(collection.selfLink(), null); + Flux> readObservableCollection = client2.readCollection(collection.getSelfLink(), null); validateSuccess(readObservableCollection, successValidatorCollection); for (int i = 0; i < 5; i++) { String documentId = "Generation1-" + i; Document documentDefinition = getDocumentDefinition(); - documentDefinition.id(documentId); - Document documentCreated = client2.createDocument(collection.selfLink(), documentDefinition, null, true).blockFirst().getResource(); + documentDefinition.setId(documentId); + Document documentCreated = client2.createDocument(collection.getSelfLink(), documentDefinition, null, true).blockFirst().getResource(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(documentCreated.get("mypk"))); client2.readDocument(BridgeInternal.getAltLink(documentCreated), requestOptions).blockFirst(); - client2.readDocument(documentCreated.selfLink(), requestOptions).blockFirst(); + client2.readDocument(documentCreated.getSelfLink(), requestOptions).blockFirst(); } { // just create the second for fun - DocumentCollection collection2 = createCollection(client2, createdDatabase.id(), getCollectionDefinition(), null); + DocumentCollection collection2 = createCollection(client2, createdDatabase.getId(), getCollectionDefinition(), null); successValidatorCollection = new ResourceResponseValidator.Builder() - .withId(collection2.id()) + .withId(collection2.getId()) .build(); - readObservableCollection = client2.readCollection(collection2.selfLink(), null); + readObservableCollection = client2.readCollection(collection2.getSelfLink(), null); validateSuccess(readObservableCollection, successValidatorCollection); } // verify the client2 has the same token. { String token1 = ((SessionContainer) client2.getSession()).getSessionToken(BridgeInternal.getAltLink(collection)); - String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collection.selfLink()); + String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collection.getSelfLink()); assertThat(token1).isEqualTo(token2); } // now delete collection use different client - client1.deleteCollection(collection.selfLink(), null).blockFirst(); + client1.deleteCollection(collection.getSelfLink(), null).blockFirst(); - DocumentCollection collectionRandom1 = createCollection(client2, createdDatabase.id(), getCollectionDefinition()); + DocumentCollection collectionRandom1 = createCollection(client2, createdDatabase.getId(), getCollectionDefinition()); DocumentCollection documentCollection = getCollectionDefinition(); - collectionDefinition.id(collectionId); - DocumentCollection collectionSameName = createCollection(client2, createdDatabase.id(), collectionDefinition); + collectionDefinition.setId(collectionId); + DocumentCollection collectionSameName = createCollection(client2, createdDatabase.getId(), collectionDefinition); String documentId1 = "Generation2-" + 0; Document databaseDefinition2 = getDocumentDefinition(); - databaseDefinition2.id(documentId1); - Document createdDocument = client1.createDocument(collectionSameName.selfLink(), databaseDefinition2, null, true).blockFirst().getResource(); + databaseDefinition2.setId(documentId1); + Document createdDocument = client1.createDocument(collectionSameName.getSelfLink(), databaseDefinition2, null, true).blockFirst().getResource(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(createdDocument.get("mypk"))); ResourceResponseValidator successValidator = new ResourceResponseValidator.Builder() - .withId(createdDocument.id()) + .withId(createdDocument.getId()) .build(); - Flux> readObservable = client1.readDocument(createdDocument.selfLink(), requestOptions); + Flux> readObservable = client1.readDocument(createdDocument.getSelfLink(), requestOptions); validateSuccess(readObservable, successValidator); { String token1 = ((SessionContainer) client1.getSession()).getSessionToken(BridgeInternal.getAltLink(collectionSameName)); - String token2 = ((SessionContainer) client1.getSession()).getSessionToken(collectionSameName.selfLink()); + String token2 = ((SessionContainer) client1.getSession()).getSessionToken(collectionSameName.getSelfLink()); assertThat(token1).isEqualTo(token2); } { - // Client2 read using name link should fail with higher LSN. - String token = ((SessionContainer) client1.getSession()).getSessionToken(collectionSameName.selfLink()); + // Client2 read using getName link should fail with higher LSN. + String token = ((SessionContainer) client1.getSession()).getSessionToken(collectionSameName.getSelfLink()); // artificially bump to higher LSN String higherLsnToken = this.getDifferentLSNToken(token, 2000); RequestOptions requestOptions1 = new RequestOptions(); @@ -455,7 +455,7 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway) throws { // verify token by altlink is gone! String token1 = ((SessionContainer) client2.getSession()).getSessionToken(BridgeInternal.getAltLink(collectionSameName)); - String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collection.selfLink()); + String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collection.getSelfLink()); assertThat(token1).isEmpty(); //assertThat(token2).isNotEmpty(); In java both SelfLink and AltLink token remain in sync. } @@ -471,14 +471,14 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway) throws RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(documentTest.get("mypk"))); successValidator = new ResourceResponseValidator.Builder() - .withId(documentTest.id()) + .withId(documentTest.getId()) .build(); - readObservable = client1.readDocument(documentTest.selfLink(), options); + readObservable = client1.readDocument(documentTest.getSelfLink(), options); validateSuccess(readObservable, successValidator); - client1.deleteCollection(collectionSameName.selfLink(), null).blockFirst(); + client1.deleteCollection(collectionSameName.getSelfLink(), null).blockFirst(); String token1 = ((SessionContainer) client2.getSession()).getSessionToken(BridgeInternal.getAltLink(collectionSameName)); - String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collectionSameName.selfLink()); + String token2 = ((SessionContainer) client2.getSession()).getSessionToken(collectionSameName.getSelfLink()); // currently we can't delete the token from Altlink when deleting using selflink assertThat(token1).isNotEmpty(); //assertThat(token2).isEmpty(); In java both SelfLink and AltLink token remain in sync. @@ -493,9 +493,9 @@ void validateSessionContainerAfterCollectionDeletion(boolean useGateway) throws void validateSessionTokenWithPreConditionFailure(boolean useGateway) throws Exception { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -517,8 +517,8 @@ void validateSessionTokenWithPreConditionFailure(boolean useGateway) throws Exce // create a conditioned read request, with first write request's etag, so the read fails with PreconditionFailure AccessCondition ac = new AccessCondition(); - ac.condition(documentResponse.getResource().etag()); - ac.type(AccessConditionType.IF_MATCH); + ac.setCondition(documentResponse.getResource().getETag()); + ac.setType(AccessConditionType.IF_MATCH); RequestOptions requestOptions1 = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(documentResponse.getResource().get("mypk"))); requestOptions1.setAccessCondition(ac); @@ -537,9 +537,9 @@ void validateSessionTokenWithPreConditionFailure(boolean useGateway) throws Exce void validateSessionTokenWithDocumentNotFoundException(boolean useGateway) throws Exception { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -553,7 +553,7 @@ void validateSessionTokenWithDocumentNotFoundException(boolean useGateway) throw .build(); try { DocumentCollection collectionDefinition = getCollectionDefinition(); - collectionDefinition.id("TestCollection"); + collectionDefinition.setId("TestCollection"); ResourceResponse documentResponse = writeClient.createDocument(BridgeInternal.getAltLink(createdCollection), getDocumentDefinition(), null, true).blockFirst(); @@ -573,9 +573,9 @@ void validateSessionTokenWithDocumentNotFoundException(boolean useGateway) throw void validateSessionTokenWithExpectedException(boolean useGateway) throws Exception { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -606,9 +606,9 @@ void validateSessionTokenWithExpectedException(boolean useGateway) throws Except void validateSessionTokenWithConflictException(boolean useGateway) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -639,9 +639,9 @@ void validateSessionTokenWithConflictException(boolean useGateway) { void validateSessionTokenMultiPartitionCollection(boolean useGateway) throws Exception { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl writeClient = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -658,23 +658,23 @@ void validateSessionTokenMultiPartitionCollection(boolean useGateway) throws Exc // Document to lock pause/resume clients Document document1 = new Document(); - document1.id("test" + UUID.randomUUID().toString()); + document1.setId("test" + UUID.randomUUID().toString()); BridgeInternal.setProperty(document1, "mypk", 1); - ResourceResponse childResource1 = writeClient.createDocument(createdCollection.selfLink(), document1, null, true).blockFirst(); - logger.info("Created {} child resource", childResource1.getResource().resourceId()); + ResourceResponse childResource1 = writeClient.createDocument(createdCollection.getSelfLink(), document1, null, true).blockFirst(); + logger.info("Created {} child resource", childResource1.getResource().getResourceId()); assertThat(childResource1.getSessionToken()).isNotNull(); assertThat(childResource1.getSessionToken().contains(":")).isTrue(); - String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.selfLink()); + String globalSessionToken1 = ((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.getSelfLink()); assertThat(globalSessionToken1.contains(childResource1.getSessionToken())); // Document to lock pause/resume clients Document document2 = new Document(); - document2.id("test" + UUID.randomUUID().toString()); + document2.setId("test" + UUID.randomUUID().toString()); BridgeInternal.setProperty(document2, "mypk", 2); - ResourceResponse childResource2 = writeClient.createDocument(createdCollection.selfLink(), document2, null, true).blockFirst(); + ResourceResponse childResource2 = writeClient.createDocument(createdCollection.getSelfLink(), document2, null, true).blockFirst(); assertThat(childResource2.getSessionToken()).isNotNull(); assertThat(childResource2.getSessionToken().contains(":")).isTrue(); - String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.selfLink()); + String globalSessionToken2 = ((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.getSelfLink()); logger.info("globalsessiontoken2 {}, childtoken1 {}, childtoken2 {}", globalSessionToken2, childResource1.getSessionToken(), childResource2.getSessionToken()); assertThat(globalSessionToken2.contains(childResource2.getSessionToken())).isTrue(); @@ -685,31 +685,31 @@ void validateSessionTokenMultiPartitionCollection(boolean useGateway) throws Exc RequestOptions option = new RequestOptions(); option.setSessionToken(sessionToken); option.setPartitionKey(new PartitionKey(2)); - writeClient.readDocument(childResource2.getResource().selfLink(), option).blockFirst(); + writeClient.readDocument(childResource2.getResource().getSelfLink(), option).blockFirst(); option = new RequestOptions(); option.setSessionToken(StringUtils.EMPTY); option.setPartitionKey(new PartitionKey(1)); - writeClient.readDocument(childResource1.getResource().selfLink(), option).blockFirst(); + writeClient.readDocument(childResource1.getResource().getSelfLink(), option).blockFirst(); option = new RequestOptions(); option.setSessionToken(sessionToken); option.setPartitionKey(new PartitionKey(1)); - Flux> readObservable = writeClient.readDocument(childResource1.getResource().selfLink(), option); + Flux> readObservable = writeClient.readDocument(childResource1.getResource().getSelfLink(), option); FailureValidator failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.NOTFOUND).subStatusCode(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE).build(); validateFailure(readObservable, failureValidator); - readObservable = writeClient.readDocument(childResource2.getResource().selfLink(), option); + readObservable = writeClient.readDocument(childResource2.getResource().getSelfLink(), option); failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.NOTFOUND).subStatusCode(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE).build(); validateFailure(readObservable, failureValidator); - assertThat(((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.selfLink())).isEqualTo + assertThat(((SessionContainer) writeClient.getSession()).getSessionToken(createdCollection.getSelfLink())).isEqualTo (((SessionContainer) writeClient.getSession()).getSessionToken(BridgeInternal.getAltLink(createdCollection))); assertThat(((SessionContainer) writeClient.getSession()).getSessionToken("asdfasdf")).isEmpty(); - assertThat(((SessionContainer) writeClient.getSession()).getSessionToken(createdDatabase.selfLink())).isEmpty(); + assertThat(((SessionContainer) writeClient.getSession()).getSessionToken(createdDatabase.getSelfLink())).isEmpty(); } finally { safeClose(writeClient); } @@ -718,9 +718,9 @@ void validateSessionTokenMultiPartitionCollection(boolean useGateway) throws Exc void validateSessionTokenFromCollectionReplaceIsServerToken(boolean useGateway) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); if (useGateway) { - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); } else { - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); } RxDocumentClientImpl client1 = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) @@ -729,19 +729,19 @@ void validateSessionTokenFromCollectionReplaceIsServerToken(boolean useGateway) .build(); RxDocumentClientImpl client2 = null; try { - Document doc = client1.createDocument(createdCollection.selfLink(), getDocumentDefinition(), null, true).blockFirst().getResource(); + Document doc = client1.createDocument(createdCollection.getSelfLink(), getDocumentDefinition(), null, true).blockFirst().getResource(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(doc.get("mypk"))); Document doc1 = client1.readDocument(BridgeInternal.getAltLink(doc), requestOptions).blockFirst().getResource(); - String token1 = ((SessionContainer) client1.getSession()).getSessionToken(createdCollection.selfLink()); + String token1 = ((SessionContainer) client1.getSession()).getSessionToken(createdCollection.getSelfLink()); client2 = (RxDocumentClientImpl) new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION) .build(); client2.replaceCollection(createdCollection, null).blockFirst(); - String token2 = ((SessionContainer) client2.getSession()).getSessionToken(createdCollection.selfLink()); + String token2 = ((SessionContainer) client2.getSession()).getSessionToken(createdCollection.getSelfLink()); logger.info("Token after document and after collection replace {} = {}", token1, token2); } finally { @@ -846,4 +846,4 @@ private boolean isSessionEqual(SessionContainer sessionContainer1, SessionContai return true; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java index 4ed2b01753e3..404e5404ba1b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentQuerySpyWireContentTest.java @@ -34,11 +34,11 @@ public class DocumentQuerySpyWireContentTest extends TestSuiteBase { private SpyClientUnderTestFactory.ClientUnderTest client; public String getSinglePartitionCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdSinglePartitionCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdSinglePartitionCollection.getId()); } public String getMultiPartitionCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdMultiPartitionCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdMultiPartitionCollection.getId()); } @Factory(dataProvider = "clientBuilders") @@ -51,21 +51,21 @@ public static Object[][] responseContinuationTokenLimitParamProvider() { FeedOptions options1 = new FeedOptions(); options1.maxItemCount(1); - options1.responseContinuationTokenLimitInKb(5); + options1.getResponseContinuationTokenLimitInKb(5); options1.partitionKey(new PartitionKey("99")); String query1 = "Select * from r"; boolean multiPartitionCollection1 = true; FeedOptions options2 = new FeedOptions(); options2.maxItemCount(1); - options2.responseContinuationTokenLimitInKb(5); + options2.getResponseContinuationTokenLimitInKb(5); options2.partitionKey(new PartitionKey("99")); String query2 = "Select * from r order by r.prop"; boolean multiPartitionCollection2 = false; FeedOptions options3 = new FeedOptions(); options3.maxItemCount(1); - options3.responseContinuationTokenLimitInKb(5); + options3.getResponseContinuationTokenLimitInKb(5); options3.partitionKey(new PartitionKey("99")); String query3 = "Select * from r"; boolean multiPartitionCollection3 = false; @@ -97,7 +97,7 @@ public void queryWithContinuationTokenLimit(FeedOptions options, String query, b Flux> queryObservable = client .queryDocuments(collectionLink, query, options); - List results = queryObservable.flatMap(p -> Flux.fromIterable(p.results())) + List results = queryObservable.flatMap(p -> Flux.fromIterable(p.getResults())) .collectList().block(); assertThat(results.size()).describedAs("total results").isGreaterThanOrEqualTo(1); @@ -105,7 +105,7 @@ public void queryWithContinuationTokenLimit(FeedOptions options, String query, b List requests = client.getCapturedRequests(); for(HttpRequest req: requests) { - validateRequestHasContinuationTokenLimit(req, options.responseContinuationTokenLimitInKb()); + validateRequestHasContinuationTokenLimit(req, options.setResponseContinuationTokenLimitInKb()); } } @@ -158,7 +158,7 @@ public void beforeClass() throws Exception { TimeUnit.SECONDS.sleep(1); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); // do the query once to ensure the collection is cached. client.queryDocuments(getMultiPartitionCollectionLink(), "select * from root", options) @@ -185,4 +185,4 @@ private static Document getDocumentDefinition(int cnt) { , uuid, cnt, cnt)); return doc; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestContextValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestContextValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestContextValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestContextValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/DocumentServiceRequestValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java index cb4dffbe5a27..f3c809714d7a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FailureValidator.java @@ -40,7 +40,7 @@ public Builder statusCode(int statusCode) { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).statusCode()).isEqualTo(statusCode); + assertThat(((CosmosClientException) t).getStatusCode()).isEqualTo(statusCode); } }); return this; @@ -78,8 +78,8 @@ public void validate(Throwable t) { assertThat(t).isInstanceOf(CosmosClientException.class); CosmosClientException cosmosClientException = (CosmosClientException) t; long exceptionQuorumAckedLSN = -1; - if (cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN) != null) { - exceptionQuorumAckedLSN = Long.parseLong((String) cosmosClientException.responseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN)); + if (cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN) != null) { + exceptionQuorumAckedLSN = Long.parseLong((String) cosmosClientException.getResponseHeaders().get(WFConstants.BackendHeaders.QUORUM_ACKED_LSN)); } assertThat(exceptionQuorumAckedLSN).isNotEqualTo(-1); @@ -105,7 +105,7 @@ public Builder notNullActivityId() { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).message()).isNotNull(); + assertThat(((CosmosClientException) t).getActivityId()).isNotNull(); } }); return this; @@ -117,7 +117,7 @@ public Builder error(CosmosError cosmosError) { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).error().toJson()).isEqualTo(cosmosError.toJson()); + assertThat(((CosmosClientException) t).getError().toJson()).isEqualTo(cosmosError.toJson()); } }); return this; @@ -129,7 +129,7 @@ public Builder subStatusCode(Integer substatusCode) { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).subStatusCode()).isEqualTo(substatusCode); + assertThat(((CosmosClientException) t).getSubStatusCode()).isEqualTo(substatusCode); } }); return this; @@ -141,7 +141,7 @@ public Builder unknownSubStatusCode() { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).subStatusCode()).isEqualTo(HttpConstants.SubStatusCodes.UNKNOWN); + assertThat(((CosmosClientException) t).getSubStatusCode()).isEqualTo(HttpConstants.SubStatusCodes.UNKNOWN); } }); return this; @@ -153,7 +153,7 @@ public Builder responseHeader(String key, String value) { public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); - assertThat(((CosmosClientException) t).responseHeaders().get(key)).isEqualTo(value); + assertThat(((CosmosClientException) t).getResponseHeaders().get(key)).isEqualTo(value); } }); return this; @@ -227,7 +227,7 @@ public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); CosmosClientException ex = (CosmosClientException) t; - assertThat(ex.statusCode()).isEqualTo(404); + assertThat(ex.getStatusCode()).isEqualTo(404); } }); @@ -255,7 +255,7 @@ public void validate(Throwable t) { assertThat(t).isNotNull(); assertThat(t).isInstanceOf(CosmosClientException.class); CosmosClientException ex = (CosmosClientException) t; - assertThat(ex.statusCode()).isEqualTo(409); + assertThat(ex.getStatusCode()).isEqualTo(409); } }); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java index 616e36422665..43172b1016e0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseListValidator.java @@ -42,7 +42,7 @@ public Builder totalSize(final int expectedCount) { validators.add(new FeedResponseListValidator() { @Override public void validate(List> feedList) { - int resultCount = feedList.stream().mapToInt(f -> f.results().size()).sum(); + int resultCount = feedList.stream().mapToInt(f -> f.getResults().size()).sum(); assertThat(resultCount) .describedAs("total number of results").isEqualTo(expectedCount); } @@ -56,8 +56,8 @@ public Builder containsExactly(List expectedRids) { public void validate(List> feedList) { List actualIds = feedList .stream() - .flatMap(f -> f.results().stream()) - .map(r -> r.resourceId()) + .flatMap(f -> f.getResults().stream()) + .map(r -> r.getResourceId()) .collect(Collectors.toList()); assertThat(actualIds) .describedAs("Resource IDs of results") @@ -73,8 +73,8 @@ public Builder containsExactlyIds(List expectedIds) { public void validate(List> feedList) { List actualIds = feedList .stream() - .flatMap(f -> f.results().stream()) - .map(r -> r.id()) + .flatMap(f -> f.getResults().stream()) + .map(r -> r.getId()) .collect(Collectors.toList()); assertThat(actualIds) .describedAs("IDs of results") @@ -90,11 +90,11 @@ public Builder validateAllResources(Map> resourc public void validate(List> feedList) { List resources = feedList .stream() - .flatMap(f -> f.results().stream()) + .flatMap(f -> f.getResults().stream()) .collect(Collectors.toList()); for(T r: resources) { - ResourceValidator validator = resourceIDToValidator.get(r.resourceId()); + ResourceValidator validator = resourceIDToValidator.get(r.getResourceId()); assertThat(validator).isNotNull(); validator.validate(r); } @@ -109,8 +109,8 @@ public Builder exactlyContainsInAnyOrder(List expectedIds) { public void validate(List> feedList) { List actualIds = feedList .stream() - .flatMap(f -> f.results().stream()) - .map(Resource::resourceId) + .flatMap(f -> f.getResults().stream()) + .map(Resource::getResourceId) .collect(Collectors.toList()); assertThat(actualIds) .describedAs("Resource IDs of results") @@ -148,7 +148,7 @@ public Builder totalRequestChargeIsAtLeast(double minimumCharge) { validators.add(new FeedResponseListValidator() { @Override public void validate(List> feedList) { - assertThat(feedList.stream().mapToDouble(p -> p.requestCharge()).sum()) + assertThat(feedList.stream().mapToDouble(p -> p.getRequestCharge()).sum()) .describedAs("total request charge") .isGreaterThanOrEqualTo(minimumCharge); } @@ -184,7 +184,7 @@ public Builder withAggregateValue(Object value) { validators.add(new FeedResponseListValidator() { @Override public void validate(List> feedList) { - List list = feedList.get(0).results(); + List list = feedList.get(0).getResults(); CosmosItemProperties result = list.size() > 0 ? list.get(0) : null; if (result != null) { @@ -225,14 +225,14 @@ public Builder withOrderedResults(List expectedOrderedL public void validate(List> feedList) { List resultOrderedList = feedList.stream() - .flatMap(f -> f.results().stream()) + .flatMap(f -> f.getResults().stream()) .collect(Collectors.toList()); assertThat(expectedOrderedList.size()).isEqualTo(resultOrderedList.size()); ArrayList paths = new ArrayList(); Iterator compositeIndexIterator = compositeIndex.iterator(); while (compositeIndexIterator.hasNext()) { - paths.add(compositeIndexIterator.next().path().replace("/", "")); + paths.add(compositeIndexIterator.next().getPath().replace("/", "")); } for (int i = 0; i < resultOrderedList.size(); i ++) { ArrayNode resultValues = (ArrayNode) resultOrderedList.get(i).get("$1"); @@ -262,7 +262,7 @@ public Builder pageLengths(int[] pageLengths) { public void validate(List> feedList) { assertThat(feedList).hasSize(pageLengths.length); for (int i = 0; i < pageLengths.length; i++) - assertThat(feedList.get(i).results().size()).isEqualTo(pageLengths[i]); + assertThat(feedList.get(i).getResults().size()).isEqualTo(pageLengths[i]); } }); return this; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java index 9087dc771f5f..177be25c838a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/FeedResponseValidator.java @@ -36,7 +36,7 @@ public Builder pageSizeIsLessThanOrEqualTo(final int maxPageSize) { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.results().size()).isLessThanOrEqualTo(maxPageSize); + assertThat(feedPage.getResults().size()).isLessThanOrEqualTo(maxPageSize); } }); return this; @@ -47,7 +47,7 @@ public Builder pageSizeOf(final int expectedCount) { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.results()).hasSize(expectedCount); + assertThat(feedPage.getResults()).hasSize(expectedCount); } }); return this; @@ -58,7 +58,7 @@ public Builder positiveRequestCharge() { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.requestCharge()).isPositive(); + assertThat(feedPage.getRequestCharge()).isPositive(); } }); return this; @@ -69,7 +69,7 @@ public Builder requestChargeGreaterThanOrEqualTo(double minRequestCharge) { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.requestCharge()).isGreaterThanOrEqualTo(minRequestCharge); + assertThat(feedPage.getRequestCharge()).isGreaterThanOrEqualTo(minRequestCharge); } }); return this; @@ -80,7 +80,7 @@ public Builder requestChargeLessThanOrEqualTo(double maxRequestCharge) { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.requestCharge()).isLessThanOrEqualTo(maxRequestCharge); + assertThat(feedPage.getRequestCharge()).isLessThanOrEqualTo(maxRequestCharge); } }); return this; @@ -91,7 +91,7 @@ public Builder hasHeader(String headerKey) { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.responseHeaders()).containsKey(headerKey); + assertThat(feedPage.getResponseHeaders()).containsKey(headerKey); } }); return this; @@ -102,7 +102,7 @@ public Builder hasRequestChargeHeader() { validators.add(new FeedResponseValidator() { @Override public void validate(FeedResponse feedPage) { - assertThat(feedPage.responseHeaders()).containsKey(HttpConstants.HttpHeaders.REQUEST_CHARGE); + assertThat(feedPage.getResponseHeaders()).containsKey(HttpConstants.HttpHeaders.REQUEST_CHARGE); } }); return this; @@ -113,8 +113,8 @@ public Builder idsExactlyAre(final List expectedIds) { @Override public void validate(FeedResponse feedPage) { assertThat(feedPage - .results().stream() - .map(r -> r.resourceId()) + .getResults().stream() + .map(r -> r.getResourceId()) .collect(Collectors.toList())) .containsExactlyElementsOf(expectedIds); } @@ -122,4 +122,4 @@ public void validate(FeedResponse feedPage) { return this; } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/HttpClientUnderTestWrapper.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/HttpClientUnderTestWrapper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/HttpClientUnderTestWrapper.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/HttpClientUnderTestWrapper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/LocationHelperTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/LocationHelperTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/LocationHelperTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/LocationHelperTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java index 69269db7f221..ed01979a1f4d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/NetworkFailureTest.java @@ -34,7 +34,7 @@ public void createCollectionWithUnreachableHost() { Database database = SHARED_DATABASE; Flux> createObservable = client - .createCollection(database.selfLink(), collectionDefinition, null); + .createCollection(database.getSelfLink(), collectionDefinition, null); final RxGatewayStoreModel origGatewayStoreModel = client.getOrigGatewayStoreModel(); @@ -69,4 +69,4 @@ public void afterClass() { safeDeleteCollection(client, collectionDefinition); client.close(); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ParallelAsync.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ParallelAsync.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ParallelAsync.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ParallelAsync.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/PathsHelperTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/PathsHelperTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/PathsHelperTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/PathsHelperTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java index e5b551e2e401..7909e1625ed1 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RenameCollectionAwareClientRetryPolicyTest.java @@ -24,7 +24,7 @@ public void onBeforeSendRequestNotInvoked() { GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(Mockito.eq(null)); - IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.defaultPolicy()); + IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.getDefaultPolicy()); RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class); ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class); @@ -52,7 +52,7 @@ public void onBeforeSendRequestNotInvoked() { public void shouldRetryWithNotFoundStatusCode() { GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(Mockito.eq(null)); - IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.defaultPolicy()); + IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.getDefaultPolicy()); RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class); ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class); @@ -78,7 +78,7 @@ public void shouldRetryWithNotFoundStatusCode() { public void shouldRetryWithNotFoundStatusCodeAndReadSessionNotAvailableSubStatusCode() { GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(Mockito.eq(null)); - IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.defaultPolicy()); + IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.getDefaultPolicy()); RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class); ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class); @@ -92,11 +92,11 @@ public void shouldRetryWithNotFoundStatusCodeAndReadSessionNotAvailableSubStatus renameCollectionAwareClientRetryPolicy.onBeforeSendRequest(request); NotFoundException notFoundException = new NotFoundException(); - notFoundException.responseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, + notFoundException.getResponseHeaders().put(WFConstants.BackendHeaders.SUB_STATUS, Integer.toString(HttpConstants.SubStatusCodes.READ_SESSION_NOT_AVAILABLE)); DocumentCollection documentCollection = new DocumentCollection(); - documentCollection.resourceId("rid_1"); + documentCollection.setResourceId("rid_1"); Mockito.when(rxClientCollectionCache.resolveCollectionAsync(request)).thenReturn(Mono.just(documentCollection)); @@ -115,7 +115,7 @@ public void shouldRetryWithNotFoundStatusCodeAndReadSessionNotAvailableSubStatus public void shouldRetryWithGenericException() { GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(Mockito.eq(null)); - IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.defaultPolicy()); + IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(endpointManager, ConnectionPolicy.getDefaultPolicy()); RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class); ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java index 166030f0c3cf..a045b7ffd5d7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceResponseValidator.java @@ -53,7 +53,7 @@ public Builder withId(final String resourceId) { @Override public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); - assertThat(resourceResponse.getResource().id()).as("check Resource Id").isEqualTo(resourceId); + assertThat(resourceResponse.getResource().getId()).as("check Resource Id").isEqualTo(resourceId); } }); return this; @@ -103,8 +103,8 @@ public Builder withTimestampIsAfterOrEqualTo(Instant time) { @Override public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); - assertThat(resourceResponse.getResource().timestamp()).isNotNull(); - OffsetDateTime d = resourceResponse.getResource().timestamp(); + assertThat(resourceResponse.getResource().getTimestamp()).isNotNull(); + OffsetDateTime d = resourceResponse.getResource().getTimestamp(); System.out.println(d.toString()); assertThat(d.toInstant()).isAfterOrEqualTo(time); } @@ -118,8 +118,8 @@ public Builder withTimestampIsBeforeOrEqualTo(Instant time) { @Override public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); - assertThat(resourceResponse.getResource().timestamp()).isNotNull(); - OffsetDateTime d = resourceResponse.getResource().timestamp(); + assertThat(resourceResponse.getResource().getTimestamp()).isNotNull(); + OffsetDateTime d = resourceResponse.getResource().getTimestamp(); assertThat(d.toInstant()).isBeforeOrEqualTo(time); } }); @@ -155,7 +155,7 @@ public Builder indexingMode(IndexingMode mode) { public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); assertThat(resourceResponse.getResource().getIndexingPolicy()).isNotNull(); - assertThat(resourceResponse.getResource().getIndexingPolicy().indexingMode()).isEqualTo(mode); + assertThat(resourceResponse.getResource().getIndexingPolicy().getIndexingMode()).isEqualTo(mode); } }); return this; @@ -201,7 +201,7 @@ public Builder notNullEtag() { @Override public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); - assertThat(resourceResponse.getResource().etag()).isNotNull(); + assertThat(resourceResponse.getResource().getETag()).isNotNull(); } }); return this; @@ -213,7 +213,7 @@ public Builder notEmptySelfLink() { @Override public void validate(ResourceResponse resourceResponse) { assertThat(resourceResponse.getResource()).isNotNull(); - assertThat(resourceResponse.getResource().selfLink()).isNotEmpty(); + assertThat(resourceResponse.getResource().getSelfLink()).isNotEmpty(); } }); return this; @@ -262,7 +262,7 @@ public Builder withCompositeIndexes(Collection> comp @Override public void validate(ResourceResponse resourceResponse) { Iterator> compositeIndexesReadIterator = resourceResponse.getResource() - .getIndexingPolicy().compositeIndexes().iterator(); + .getIndexingPolicy().getCompositeIndexes().iterator(); Iterator> compositeIndexesWrittenIterator = compositeIndexesWritten.iterator(); ArrayList readIndexesStrings = new ArrayList(); @@ -279,8 +279,8 @@ public void validate(ResourceResponse resourceResponse) { CompositePath compositePathRead = compositeIndexReadIterator.next(); CompositePath compositePathWritten = compositeIndexWrittenIterator.next(); - readIndexesString.append(compositePathRead.path() + ":" + compositePathRead.order() + ";"); - writtenIndexesString.append(compositePathWritten.path() + ":" + compositePathRead.order() + ";"); + readIndexesString.append(compositePathRead.getPath() + ":" + compositePathRead.getOrder() + ";"); + writtenIndexesString.append(compositePathWritten.getPath() + ":" + compositePathRead.getOrder() + ";"); } readIndexesStrings.add(readIndexesString.toString()); @@ -299,7 +299,7 @@ public Builder withSpatialIndexes(Collection spatialIndexes) { @Override public void validate(ResourceResponse resourceResponse) { Iterator spatialIndexesReadIterator = resourceResponse.getResource() - .getIndexingPolicy().spatialIndexes().iterator(); + .getIndexingPolicy().getSpatialIndexes().iterator(); Iterator spatialIndexesWrittenIterator = spatialIndexes.iterator(); HashMap> readIndexMap = new HashMap>(); @@ -309,14 +309,14 @@ public void validate(ResourceResponse resourceResponse) { SpatialSpec spatialSpecRead = spatialIndexesReadIterator.next(); SpatialSpec spatialSpecWritten = spatialIndexesWrittenIterator.next(); - String readPath = spatialSpecRead.path() + ":"; - String writtenPath = spatialSpecWritten.path() + ":"; + String readPath = spatialSpecRead.getPath() + ":"; + String writtenPath = spatialSpecWritten.getPath() + ":"; ArrayList readSpatialTypes = new ArrayList(); ArrayList writtenSpatialTypes = new ArrayList(); - Iterator spatialTypesReadIterator = spatialSpecRead.spatialTypes().iterator(); - Iterator spatialTypesWrittenIterator = spatialSpecWritten.spatialTypes().iterator(); + Iterator spatialTypesReadIterator = spatialSpecRead.getSpatialTypes().iterator(); + Iterator spatialTypesWrittenIterator = spatialSpecWritten.getSpatialTypes().iterator(); while (spatialTypesReadIterator.hasNext() && spatialTypesWrittenIterator.hasNext()) { readSpatialTypes.add(spatialTypesReadIterator.next()); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java index e627f81aa38a..1b379986df83 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ResourceValidator.java @@ -49,4 +49,4 @@ public void validate(T v) { } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryAnalyzer.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryAnalyzer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryAnalyzer.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryAnalyzer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java index 27c8e2b78b69..a04794697803 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryCreateDocumentTest.java @@ -39,12 +39,12 @@ public RetryCreateDocumentTest(AsyncDocumentClient.Builder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void retryDocumentCreate() throws Exception { // create a document to ensure collection is cached - client.createDocument(collection.selfLink(), getDocumentDefinition(), null, false).single().block(); + client.createDocument(collection.getSelfLink(), getDocumentDefinition(), null, false).single().block(); Document docDefinition = getDocumentDefinition(); Flux> createObservable = client - .createDocument(collection.selfLink(), docDefinition, null, false); + .createDocument(collection.getSelfLink(), docDefinition, null, false); AtomicInteger count = new AtomicInteger(); doAnswer((Answer>) invocation -> { @@ -67,7 +67,7 @@ public void retryDocumentCreate() throws Exception { // validate ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(docDefinition.id()).build(); + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); } @@ -95,14 +95,14 @@ public void createDocument_noRetryOnNonRetriableFailure() throws Exception { }).when(client.getSpyGatewayStoreModel()).processMessage(anyObject()); // create a document to ensure collection is cached - client.createDocument(collection.selfLink(), getDocumentDefinition(), null, false) + client.createDocument(collection.getSelfLink(), getDocumentDefinition(), null, false) .single() .block(); Document docDefinition = getDocumentDefinition(); Flux> createObservable = client - .createDocument(collection.selfLink(), docDefinition, null, false); + .createDocument(collection.getSelfLink(), docDefinition, null, false); // validate FailureValidator validator = new FailureValidator.Builder().statusCode(1).subStatusCode(2).build(); @@ -112,7 +112,7 @@ public void createDocument_noRetryOnNonRetriableFailure() throws Exception { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createDocument_failImmediatelyOnNonRetriable() throws Exception { // create a document to ensure collection is cached - client.createDocument(collection.selfLink(), getDocumentDefinition(), null, false).single().block(); + client.createDocument(collection.getSelfLink(), getDocumentDefinition(), null, false).single().block(); AtomicInteger count = new AtomicInteger(); doAnswer((Answer>) invocation -> { @@ -135,7 +135,7 @@ public void createDocument_failImmediatelyOnNonRetriable() throws Exception { Document docDefinition = getDocumentDefinition(); Flux> createObservable = client - .createDocument(collection.selfLink(), docDefinition, null, false); + .createDocument(collection.getSelfLink(), docDefinition, null, false); // validate FailureValidator validator = new FailureValidator.Builder().statusCode(1).subStatusCode(2).build(); @@ -171,4 +171,4 @@ private Document getDocumentDefinition() { public void afterClass() { safeClose(client); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java similarity index 94% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java index 1a5e3b4d036e..d55669ef6757 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryThrottleTest.java @@ -36,9 +36,9 @@ public class RetryThrottleTest extends TestSuiteBase { public void retryCreateDocumentsOnSpike() throws Exception { ConnectionPolicy policy = new ConnectionPolicy(); RetryOptions retryOptions = new RetryOptions(); - retryOptions.maxRetryAttemptsOnThrottledRequests(Integer.MAX_VALUE); - retryOptions.maxRetryWaitTimeInSeconds(LARGE_TIMEOUT); - policy.retryOptions(retryOptions); + retryOptions.setMaxRetryAttemptsOnThrottledRequests(Integer.MAX_VALUE); + retryOptions.setMaxRetryWaitTimeInSeconds(LARGE_TIMEOUT); + policy.setRetryOptions(retryOptions); AsyncDocumentClient.Builder builder = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) @@ -87,7 +87,7 @@ public void retryDocumentCreate() throws Exception { Document docDefinition = getDocumentDefinition(); Flux> createObservable = client - .createDocument(collection.selfLink(), docDefinition, null, false); + .createDocument(collection.getSelfLink(), docDefinition, null, false); AtomicInteger count = new AtomicInteger(); doAnswer((Answer>) invocation -> { @@ -105,7 +105,7 @@ public void retryDocumentCreate() throws Exception { // validate ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(docDefinition.id()).build(); + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator, TIMEOUT); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryUtilsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryUtilsTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryUtilsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RetryUtilsTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentClientUnderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentClientUnderTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentClientUnderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentClientUnderTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentServiceRequestTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentServiceRequestTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentServiceRequestTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxDocumentServiceRequestTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxGatewayStoreModelTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxGatewayStoreModelTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxGatewayStoreModelTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/RxGatewayStoreModelTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java index b788c96f861e..9876c8ae593c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionContainerTest.java @@ -59,12 +59,12 @@ public void sessionContainer() throws Exception { DocumentServiceRequestContext dsrContext = new DocumentServiceRequestContext(); PartitionKeyRange resolvedPKRange = new PartitionKeyRange(); - resolvedPKRange.id("range_" + (numPartitionKeyRangeIds + 10)); + resolvedPKRange.setId("range_" + (numPartitionKeyRangeIds + 10)); GatewayTestUtils.setParent(resolvedPKRange, ImmutableList.of("range_2", "range_x")); dsrContext.resolvedPartitionKeyRange = resolvedPKRange; request.requestContext = dsrContext; - sessionToken = sessionContainer.resolvePartitionLocalSessionToken(request, resolvedPKRange.id()); + sessionToken = sessionContainer.resolvePartitionLocalSessionToken(request, resolvedPKRange.getId()); assertThat(sessionToken.getLSN()).isEqualTo(2); } @@ -307,7 +307,7 @@ public void clearTokenByCollectionFullNameRemovesToken() { sessionContainer.setSessionToken(documentCollectionId, collectionFullName, ImmutableMap.of(HttpConstants.HttpHeaders.SESSION_TOKEN, "range_0:1#100#1=20#2=5#3=30")); - // Test resourceId based + // Test getResourceId based RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, documentCollectionId, ResourceType.Document, new HashMap<>()); ISessionToken sessionToken = sessionContainer.resolvePartitionLocalSessionToken(request, "range_0"); @@ -617,4 +617,4 @@ private static int getRandomCollectionId() { private static int getRandomDbId() { return random.nextInt(Integer.MAX_VALUE / 2); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java index e3253f9f49c8..109c34b52295 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTest.java @@ -61,16 +61,16 @@ public void beforeClass() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); DocumentCollection collection = new DocumentCollection(); - collection.id(collectionId); + collection.setId(collectionId); collection.setPartitionKey(partitionKeyDef); - createdCollection = createCollection(createGatewayHouseKeepingDocumentClient().build(), createdDatabase.id(), + createdCollection = createCollection(createGatewayHouseKeepingDocumentClient().build(), createdDatabase.getId(), collection, null); houseKeepingClient = clientBuilder().build(); - connectionMode = houseKeepingClient.getConnectionPolicy().connectionMode(); + connectionMode = houseKeepingClient.getConnectionPolicy().getConnectionMode(); if (connectionMode == ConnectionMode.DIRECT) { spyClient = SpyClientUnderTestFactory.createDirectHttpsClientUnderTest(clientBuilder()); @@ -132,7 +132,7 @@ public void sessionConsistency_ReadYourWrites(boolean isNameBased) { @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "sessionTestArgProvider") public void sessionTokenInDocumentRead(boolean isNameBased) throws UnsupportedEncodingException { Document document = new Document(); - document.id(UUID.randomUUID().toString()); + document.setId(UUID.randomUUID().toString()); BridgeInternal.setProperty(document, "pk", "pk"); document = spyClient.createDocument(getCollectionLink(isNameBased), document, null, false) .blockFirst() @@ -183,12 +183,12 @@ public void sessionTokenRemovedForMasterResource(boolean isNameBased) throws Uns } private String getCollectionLink(boolean isNameBased) { - return isNameBased ? "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(): - createdCollection.selfLink(); + return isNameBased ? "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(): + createdCollection.getSelfLink(); } private String getDocumentLink(Document doc, boolean isNameBased) { - return isNameBased ? "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id() + "/docs/" + doc.id() : - "dbs/" + createdDatabase.resourceId() + "/colls/" + createdCollection.resourceId() + "/docs/" + doc.resourceId() + "/"; + return isNameBased ? "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId() + "/docs/" + doc.getId() : + "dbs/" + createdDatabase.getResourceId() + "/colls/" + createdCollection.getResourceId() + "/docs/" + doc.getResourceId() + "/"; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTokenTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTokenTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTokenTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SessionTokenTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ShouldRetryValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ShouldRetryValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ShouldRetryValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/ShouldRetryValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientBuilder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientBuilder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java index faeac5af3da2..e540aa073f98 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/SpyClientUnderTestFactory.java @@ -171,7 +171,7 @@ public static class DirectHttpsClientUnderTest extends SpyBaseClass DirectHttpsClientUnderTest(URI serviceEndpoint, String masterKey, ConnectionPolicy connectionPolicy, ConsistencyLevel consistencyLevel, CosmosKeyCredential cosmosKeyCredential) { super(serviceEndpoint, masterKey, connectionPolicy, consistencyLevel, createConfigsSpy(Protocol.HTTPS), cosmosKeyCredential); - assert connectionPolicy.connectionMode() == ConnectionMode.DIRECT; + assert connectionPolicy.getConnectionMode() == ConnectionMode.DIRECT; init(); this.origHttpClient = ReflectionUtils.getDirectHttpsHttpClient(this); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java index 0992ef18a8c0..f49ecd63c2a5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreHeaderTests.java @@ -25,15 +25,15 @@ public StoreHeaderTests(AsyncDocumentClient.Builder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void validateStoreHeader() { Document docDefinition1 = getDocumentDefinition(); - Document responseDoc1 = createDocument(client, createdDatabase.id(), createdCollection.id(), docDefinition1); - Assert.assertNotNull(responseDoc1.selfLink()); + Document responseDoc1 = createDocument(client, createdDatabase.getId(), createdCollection.getId(), docDefinition1); + Assert.assertNotNull(responseDoc1.getSelfLink()); Assert.assertNotNull(responseDoc1.get("_attachments")); Document docDefinition2 = getDocumentDefinition(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setHeader("x-ms-exclude-system-properties", "true"); - Document responseDoc2 = createDocument(client, createdDatabase.id(), createdCollection.id(), docDefinition2, requestOptions); - Assert.assertNull(responseDoc2.selfLink()); + Document responseDoc2 = createDocument(client, createdDatabase.getId(), createdCollection.getId(), docDefinition2, requestOptions); + Assert.assertNull(responseDoc2.getSelfLink()); Assert.assertNull(responseDoc2.get("_attachments")); } @@ -60,4 +60,4 @@ private Document getDocumentDefinition() { , uuid, uuid)); return doc; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreResponseBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreResponseBuilder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreResponseBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/StoreResponseBuilder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java index 36ee7b343595..ff0879605155 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestSuiteBase.java @@ -142,9 +142,9 @@ public static void beforeSuite() { SHARED_DATABASE = dbForTest.createdDatabase; RequestOptions options = new RequestOptions(); options.setOfferThroughput(10100); - SHARED_MULTI_PARTITION_COLLECTION = createCollection(houseKeepingClient, SHARED_DATABASE.id(), getCollectionDefinitionWithRangeRangeIndex(), options); - SHARED_SINGLE_PARTITION_COLLECTION = createCollection(houseKeepingClient, SHARED_DATABASE.id(), getCollectionDefinition(), null); - SHARED_MULTI_PARTITION_COLLECTION_WITH_COMPOSITE_AND_SPATIAL_INDEXES = createCollection(houseKeepingClient, SHARED_DATABASE.id(), getCollectionDefinitionMultiPartitionWithCompositeAndSpatialIndexes(), options); + SHARED_MULTI_PARTITION_COLLECTION = createCollection(houseKeepingClient, SHARED_DATABASE.getId(), getCollectionDefinitionWithRangeRangeIndex(), options); + SHARED_SINGLE_PARTITION_COLLECTION = createCollection(houseKeepingClient, SHARED_DATABASE.getId(), getCollectionDefinition(), null); + SHARED_MULTI_PARTITION_COLLECTION_WITH_COMPOSITE_AND_SPATIAL_INDEXES = createCollection(houseKeepingClient, SHARED_DATABASE.getId(), getCollectionDefinitionMultiPartitionWithCompositeAndSpatialIndexes(), options); } finally { houseKeepingClient.close(); } @@ -163,21 +163,21 @@ public static void afterSuite() { } protected static void truncateCollection(DocumentCollection collection) { - logger.info("Truncating collection {} ...", collection.id()); + logger.info("Truncating collection {} ...", collection.getId()); AsyncDocumentClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().build(); try { - List paths = collection.getPartitionKey().paths(); + List paths = collection.getPartitionKey().getPaths(); FeedOptions options = new FeedOptions(); - options.maxDegreeOfParallelism(-1); - options.enableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(-1); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(100); - logger.info("Truncating collection {} documents ...", collection.id()); + logger.info("Truncating collection {} documents ...", collection.getId()); - houseKeepingClient.queryDocuments(collection.selfLink(), "SELECT * FROM root", options) + houseKeepingClient.queryDocuments(collection.getSelfLink(), "SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(doc -> { RequestOptions requestOptions = new RequestOptions(); @@ -191,14 +191,14 @@ protected static void truncateCollection(DocumentCollection collection) { requestOptions.setPartitionKey(new PartitionKey(propertyValue)); } - return houseKeepingClient.deleteDocument(doc.selfLink(), requestOptions); + return houseKeepingClient.deleteDocument(doc.getSelfLink(), requestOptions); }).then().block(); - logger.info("Truncating collection {} triggers ...", collection.id()); + logger.info("Truncating collection {} triggers ...", collection.getId()); - houseKeepingClient.queryTriggers(collection.selfLink(), "SELECT * FROM root", options) + houseKeepingClient.queryTriggers(collection.getSelfLink(), "SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(trigger -> { RequestOptions requestOptions = new RequestOptions(); @@ -207,14 +207,14 @@ protected static void truncateCollection(DocumentCollection collection) { // requestOptions.partitionKey(new PartitionKey(propertyValue)); // } - return houseKeepingClient.deleteTrigger(trigger.selfLink(), requestOptions); + return houseKeepingClient.deleteTrigger(trigger.getSelfLink(), requestOptions); }).then().block(); - logger.info("Truncating collection {} storedProcedures ...", collection.id()); + logger.info("Truncating collection {} storedProcedures ...", collection.getId()); - houseKeepingClient.queryStoredProcedures(collection.selfLink(), "SELECT * FROM root", options) + houseKeepingClient.queryStoredProcedures(collection.getSelfLink(), "SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(storedProcedure -> { RequestOptions requestOptions = new RequestOptions(); @@ -223,14 +223,14 @@ protected static void truncateCollection(DocumentCollection collection) { // requestOptions.partitionKey(new PartitionKey(propertyValue)); // } - return houseKeepingClient.deleteStoredProcedure(storedProcedure.selfLink(), requestOptions); + return houseKeepingClient.deleteStoredProcedure(storedProcedure.getSelfLink(), requestOptions); }).then().block(); - logger.info("Truncating collection {} udfs ...", collection.id()); + logger.info("Truncating collection {} udfs ...", collection.getId()); - houseKeepingClient.queryUserDefinedFunctions(collection.selfLink(), "SELECT * FROM root", options) + houseKeepingClient.queryUserDefinedFunctions(collection.getSelfLink(), "SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(udf -> { RequestOptions requestOptions = new RequestOptions(); @@ -239,14 +239,14 @@ protected static void truncateCollection(DocumentCollection collection) { // requestOptions.partitionKey(new PartitionKey(propertyValue)); // } - return houseKeepingClient.deleteUserDefinedFunction(udf.selfLink(), requestOptions); + return houseKeepingClient.deleteUserDefinedFunction(udf.getSelfLink(), requestOptions); }).then().block(); } finally { houseKeepingClient.close(); } - logger.info("Finished truncating collection {}.", collection.id()); + logger.info("Finished truncating collection {}.", collection.getId()); } protected static void waitIfNeededForReplicasToCatchUp(Builder clientBuilder) { @@ -312,12 +312,12 @@ private static DocumentCollection getCollectionDefinitionMultiPartitionWithCompo //Simple ArrayList compositeIndexSimple = new ArrayList(); CompositePath compositePath1 = new CompositePath(); - compositePath1.path("/" + NUMBER_FIELD); - compositePath1.order(CompositePathSortOrder.ASCENDING); + compositePath1.setPath("/" + NUMBER_FIELD); + compositePath1.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath2 = new CompositePath(); - compositePath2.path("/" + STRING_FIELD); - compositePath2.order(CompositePathSortOrder.DESCENDING); + compositePath2.setPath("/" + STRING_FIELD); + compositePath2.setOrder(CompositePathSortOrder.DESCENDING); compositeIndexSimple.add(compositePath1); compositeIndexSimple.add(compositePath2); @@ -325,20 +325,20 @@ private static DocumentCollection getCollectionDefinitionMultiPartitionWithCompo //Max Columns ArrayList compositeIndexMaxColumns = new ArrayList(); CompositePath compositePath3 = new CompositePath(); - compositePath3.path("/" + NUMBER_FIELD); - compositePath3.order(CompositePathSortOrder.DESCENDING); + compositePath3.setPath("/" + NUMBER_FIELD); + compositePath3.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath4 = new CompositePath(); - compositePath4.path("/" + STRING_FIELD); - compositePath4.order(CompositePathSortOrder.ASCENDING); + compositePath4.setPath("/" + STRING_FIELD); + compositePath4.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath5 = new CompositePath(); - compositePath5.path("/" + NUMBER_FIELD_2); - compositePath5.order(CompositePathSortOrder.DESCENDING); + compositePath5.setPath("/" + NUMBER_FIELD_2); + compositePath5.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath6 = new CompositePath(); - compositePath6.path("/" + STRING_FIELD_2); - compositePath6.order(CompositePathSortOrder.ASCENDING); + compositePath6.setPath("/" + STRING_FIELD_2); + compositePath6.setOrder(CompositePathSortOrder.ASCENDING); compositeIndexMaxColumns.add(compositePath3); compositeIndexMaxColumns.add(compositePath4); @@ -348,20 +348,20 @@ private static DocumentCollection getCollectionDefinitionMultiPartitionWithCompo //Primitive Values ArrayList compositeIndexPrimitiveValues = new ArrayList(); CompositePath compositePath7 = new CompositePath(); - compositePath7.path("/" + NUMBER_FIELD); - compositePath7.order(CompositePathSortOrder.DESCENDING); + compositePath7.setPath("/" + NUMBER_FIELD); + compositePath7.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath8 = new CompositePath(); - compositePath8.path("/" + STRING_FIELD); - compositePath8.order(CompositePathSortOrder.ASCENDING); + compositePath8.setPath("/" + STRING_FIELD); + compositePath8.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath9 = new CompositePath(); - compositePath9.path("/" + BOOL_FIELD); - compositePath9.order(CompositePathSortOrder.DESCENDING); + compositePath9.setPath("/" + BOOL_FIELD); + compositePath9.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath10 = new CompositePath(); - compositePath10.path("/" + NULL_FIELD); - compositePath10.order(CompositePathSortOrder.ASCENDING); + compositePath10.setPath("/" + NULL_FIELD); + compositePath10.setOrder(CompositePathSortOrder.ASCENDING); compositeIndexPrimitiveValues.add(compositePath7); compositeIndexPrimitiveValues.add(compositePath8); @@ -371,16 +371,16 @@ private static DocumentCollection getCollectionDefinitionMultiPartitionWithCompo //Long Strings ArrayList compositeIndexLongStrings = new ArrayList(); CompositePath compositePath11 = new CompositePath(); - compositePath11.path("/" + STRING_FIELD); + compositePath11.setPath("/" + STRING_FIELD); CompositePath compositePath12 = new CompositePath(); - compositePath12.path("/" + SHORT_STRING_FIELD); + compositePath12.setPath("/" + SHORT_STRING_FIELD); CompositePath compositePath13 = new CompositePath(); - compositePath13.path("/" + MEDIUM_STRING_FIELD); + compositePath13.setPath("/" + MEDIUM_STRING_FIELD); CompositePath compositePath14 = new CompositePath(); - compositePath14.path("/" + LONG_STRING_FIELD); + compositePath14.setPath("/" + LONG_STRING_FIELD); compositeIndexLongStrings.add(compositePath11); compositeIndexLongStrings.add(compositePath12); @@ -392,16 +392,16 @@ private static DocumentCollection getCollectionDefinitionMultiPartitionWithCompo compositeIndexes.add(compositeIndexPrimitiveValues); compositeIndexes.add(compositeIndexLongStrings); - indexingPolicy.compositeIndexes(compositeIndexes); + indexingPolicy.setCompositeIndexes(compositeIndexes); documentCollection.setIndexingPolicy(indexingPolicy); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); ArrayList partitionKeyPaths = new ArrayList(); partitionKeyPaths.add("/" + PARTITION_KEY); - partitionKeyDefinition.paths(partitionKeyPaths); + partitionKeyDefinition.setPaths(partitionKeyPaths); documentCollection.setPartitionKey(partitionKeyDefinition); - documentCollection.id(UUID.randomUUID().toString()); + documentCollection.setId(UUID.randomUUID().toString()); return documentCollection; } @@ -433,7 +433,7 @@ public Flux> bulkInsert(AsyncDocumentClient client, } public static ConsistencyLevel getAccountDefaultConsistencyLevel(AsyncDocumentClient client) { - return BridgeInternal.getConsistencyPolicy(client.getDatabaseAccount().single().block()).defaultConsistencyLevel(); + return BridgeInternal.getConsistencyPolicy(client.getDatabaseAccount().single().block()).getDefaultConsistencyLevel(); } public static User createUser(AsyncDocumentClient client, String databaseId, User user) { @@ -441,27 +441,27 @@ public static User createUser(AsyncDocumentClient client, String databaseId, Use } public static User safeCreateUser(AsyncDocumentClient client, String databaseId, User user) { - deleteUserIfExists(client, databaseId, user.id()); + deleteUserIfExists(client, databaseId, user.getId()); return createUser(client, databaseId, user); } private static DocumentCollection safeCreateCollection(AsyncDocumentClient client, String databaseId, DocumentCollection collection, RequestOptions options) { - deleteCollectionIfExists(client, databaseId, collection.id()); + deleteCollectionIfExists(client, databaseId, collection.getId()); return createCollection(client, databaseId, collection, options); } public static String getCollectionLink(DocumentCollection collection) { - return collection.selfLink(); + return collection.getSelfLink(); } static protected DocumentCollection getCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; @@ -471,11 +471,11 @@ static protected DocumentCollection getCollectionDefinitionWithRangeRangeIndex() PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); BridgeInternal.setProperty(stringIndex, "precision", -1); @@ -484,13 +484,13 @@ static protected DocumentCollection getCollectionDefinitionWithRangeRangeIndex() Index numberIndex = Index.Range(DataType.NUMBER); BridgeInternal.setProperty(numberIndex, "precision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setIndexingPolicy(indexingPolicy); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; @@ -499,7 +499,7 @@ static protected DocumentCollection getCollectionDefinitionWithRangeRangeIndex() public static void deleteCollectionIfExists(AsyncDocumentClient client, String databaseId, String collectionId) { List res = client.queryCollections("dbs/" + databaseId, String.format("SELECT * FROM root r where r.id = '%s'", collectionId), null).single().block() - .results(); + .getResults(); if (!res.isEmpty()) { deleteCollection(client, TestUtils.getCollectionNameLink(databaseId, collectionId)); } @@ -514,7 +514,7 @@ public static void deleteDocumentIfExists(AsyncDocumentClient client, String dat options.partitionKey(new PartitionKey(docId)); List res = client .queryDocuments(TestUtils.getCollectionNameLink(databaseId, collectionId), String.format("SELECT * FROM root r where r.id = '%s'", docId), options) - .single().block().results(); + .single().block().getResults(); if (!res.isEmpty()) { deleteDocument(client, TestUtils.getDocumentNameLink(databaseId, collectionId, docId)); } @@ -526,7 +526,7 @@ public static void safeDeleteDocument(AsyncDocumentClient client, String documen client.deleteDocument(documentLink, options).single().block(); } catch (Exception e) { CosmosClientException dce = Utils.as(e, CosmosClientException.class); - if (dce == null || dce.statusCode() != 404) { + if (dce == null || dce.getStatusCode() != 404) { throw e; } } @@ -540,7 +540,7 @@ public static void deleteDocument(AsyncDocumentClient client, String documentLin public static void deleteUserIfExists(AsyncDocumentClient client, String databaseId, String userId) { List res = client .queryUsers("dbs/" + databaseId, String.format("SELECT * FROM root r where r.id = '%s'", userId), null) - .single().block().results(); + .single().block().getResults(); if (!res.isEmpty()) { deleteUser(client, TestUtils.getUserNameLink(databaseId, userId)); } @@ -551,11 +551,11 @@ public static void deleteUser(AsyncDocumentClient client, String userLink) { } public static String getDatabaseLink(Database database) { - return database.selfLink(); + return database.getSelfLink(); } static private Database safeCreateDatabase(AsyncDocumentClient client, Database database) { - safeDeleteDatabase(client, database.id()); + safeDeleteDatabase(client, database.getId()); return createDatabase(client, database); } @@ -566,16 +566,16 @@ static protected Database createDatabase(AsyncDocumentClient client, Database da static protected Database createDatabase(AsyncDocumentClient client, String databaseId) { Database databaseDefinition = new Database(); - databaseDefinition.id(databaseId); + databaseDefinition.setId(databaseId); return createDatabase(client, databaseDefinition); } static protected Database createDatabaseIfNotExists(AsyncDocumentClient client, String databaseId) { - return client.queryDatabases(String.format("SELECT * FROM r where r.id = '%s'", databaseId), null).flatMap(p -> Flux.fromIterable(p.results())).switchIfEmpty( + return client.queryDatabases(String.format("SELECT * FROM r where r.id = '%s'", databaseId), null).flatMap(p -> Flux.fromIterable(p.getResults())).switchIfEmpty( Flux.defer(() -> { Database databaseDefinition = new Database(); - databaseDefinition.id(databaseId); + databaseDefinition.setId(databaseId); return client.createDatabase(databaseDefinition, null).map(ResourceResponse::getResource); }) @@ -584,7 +584,7 @@ static protected Database createDatabaseIfNotExists(AsyncDocumentClient client, static protected void safeDeleteDatabase(AsyncDocumentClient client, Database database) { if (database != null) { - safeDeleteDatabase(client, database.id()); + safeDeleteDatabase(client, database.getId()); } } @@ -599,14 +599,14 @@ static protected void safeDeleteDatabase(AsyncDocumentClient client, String data static protected void safeDeleteAllCollections(AsyncDocumentClient client, Database database) { if (database != null) { - List collections = client.readCollections(database.selfLink(), null) - .flatMap(p -> Flux.fromIterable(p.results())) + List collections = client.readCollections(database.getSelfLink(), null) + .flatMap(p -> Flux.fromIterable(p.getResults())) .collectList() .single() .block(); for (DocumentCollection collection : collections) { - client.deleteCollection(collection.selfLink(), null).single().block().getResource(); + client.deleteCollection(collection.getSelfLink(), null).single().block().getResource(); } } } @@ -614,7 +614,7 @@ static protected void safeDeleteAllCollections(AsyncDocumentClient client, Datab static protected void safeDeleteCollection(AsyncDocumentClient client, DocumentCollection collection) { if (client != null && collection != null) { try { - client.deleteCollection(collection.selfLink(), null).single().block(); + client.deleteCollection(collection.getSelfLink(), null).single().block(); } catch (Exception e) { } } @@ -805,7 +805,7 @@ private static Object[][] simpleClientBuildersWithDirect(Protocol... protocols) } builders.forEach(b -> logger.info("Will Use ConnectionMode [{}], Consistency [{}], Protocol [{}]", - b.getConnectionPolicy().connectionMode(), + b.getConnectionPolicy().getConnectionMode(), b.getDesiredConsistencyLevel(), b.getConfigs().getProtocol() )); @@ -894,7 +894,7 @@ private static Object[][] clientBuildersWithDirect(List testCo } builders.forEach(b -> logger.info("Will Use ConnectionMode [{}], Consistency [{}], Protocol [{}]", - b.getConnectionPolicy().connectionMode(), + b.getConnectionPolicy().getConnectionMode(), b.getDesiredConsistencyLevel(), b.getConfigs().getProtocol() )); @@ -904,10 +904,10 @@ private static Object[][] clientBuildersWithDirect(List testCo static protected Builder createGatewayHouseKeepingDocumentClient() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); RetryOptions options = new RetryOptions(); - options.maxRetryWaitTimeInSeconds(SUITE_SETUP_TIMEOUT); - connectionPolicy.retryOptions(options); + options.setMaxRetryWaitTimeInSeconds(SUITE_SETUP_TIMEOUT); + connectionPolicy.setRetryOptions(options); return new Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -916,9 +916,9 @@ static protected Builder createGatewayHouseKeepingDocumentClient() { static protected Builder createGatewayRxDocumentClient(ConsistencyLevel consistencyLevel, boolean multiMasterEnabled, List preferredLocations) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); - connectionPolicy.usingMultipleWriteLocations(multiMasterEnabled); - connectionPolicy.preferredLocations(preferredLocations); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setUsingMultipleWriteLocations(multiMasterEnabled); + connectionPolicy.setPreferredLocations(preferredLocations); return new Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) @@ -934,14 +934,14 @@ static protected Builder createDirectRxDocumentClient(ConsistencyLevel consisten boolean multiMasterEnabled, List preferredLocations) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); if (preferredLocations != null) { - connectionPolicy.preferredLocations(preferredLocations); + connectionPolicy.setPreferredLocations(preferredLocations); } if (multiMasterEnabled && consistencyLevel == ConsistencyLevel.SESSION) { - connectionPolicy.usingMultipleWriteLocations(true); + connectionPolicy.setUsingMultipleWriteLocations(true); } Configs configs = spy(new Configs()); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java index fc8dbbe08001..b4f30a880eec 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TestUtils.java @@ -10,9 +10,9 @@ public class TestUtils { public static String getDatabaseLink(Database database, boolean isNameBased) { if (isNameBased) { - return getDatabaseNameLink(database.id()); + return getDatabaseNameLink(database.getId()); } else { - return database.selfLink(); + return database.getSelfLink(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TimeTokenTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TimeTokenTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TimeTokenTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/TimeTokenTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/caches/AsyncCacheTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/caches/AsyncCacheTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/caches/AsyncCacheTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/caches/AsyncCacheTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java index f63ccc9c7820..eee73d6fded8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressResolverTest.java @@ -74,21 +74,21 @@ public void setup() throws Exception { this.addressResolver.initializeCaches(this.collectionCache, this.collectionRoutingMapCache, this.fabricAddressCache); this.collection1 = new DocumentCollection(); - this.collection1.id("coll"); - this.collection1.resourceId("rid1"); + this.collection1.setId("coll"); + this.collection1.setResourceId("rid1"); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); - partitionKeyDef.paths(ImmutableList.of("/field1")); + partitionKeyDef.setPaths(ImmutableList.of("/field1")); this.collection1.setPartitionKey(partitionKeyDef); this.collection2 = new DocumentCollection(); - this.collection2.id("coll"); - this.collection2.resourceId("rid2"); + this.collection2.setId("coll"); + this.collection2.setResourceId("rid2"); new PartitionKeyDefinition(); - partitionKeyDef.paths(ImmutableList.of("/field1")); + partitionKeyDef.setPaths(ImmutableList.of("/field1")); this.collection2.setPartitionKey(partitionKeyDef); Function>, Void> addPartitionKeyRangeFunc = listArg -> { - listArg.forEach(tuple -> ((ServiceIdentity) tuple.right).partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collection1.resourceId(), tuple.left.id()))); + listArg.forEach(tuple -> ((ServiceIdentity) tuple.right).partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collection1.getResourceId(), tuple.left.getId()))); return null; }; @@ -106,7 +106,7 @@ public void setup() throws Exception { this.routingMapCollection1BeforeSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap( rangesBeforeSplit1, - collection1.resourceId()); + collection1.getResourceId()); List> rangesAfterSplit1 = new ArrayList<>(); @@ -125,7 +125,7 @@ public void setup() throws Exception { addPartitionKeyRangeFunc.apply(rangesAfterSplit1); - this.routingMapCollection1AfterSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesAfterSplit1, collection1.resourceId()); + this.routingMapCollection1AfterSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesAfterSplit1, collection1.getResourceId()); List> rangesBeforeSplit2 = new ArrayList<>(); @@ -139,7 +139,7 @@ public void setup() throws Exception { addPartitionKeyRangeFunc.apply(rangesBeforeSplit2); - this.routingMapCollection2BeforeSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesBeforeSplit2, collection2.resourceId()); + this.routingMapCollection2BeforeSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesBeforeSplit2, collection2.getResourceId()); List> rangesAfterSplit2 = new ArrayList<>(); @@ -160,7 +160,7 @@ public void setup() throws Exception { addPartitionKeyRangeFunc.apply(rangesAfterSplit2); - this.routingMapCollection2AfterSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesAfterSplit2, collection2.resourceId()); + this.routingMapCollection2AfterSplit = InMemoryCollectionRoutingMap.tryCreateCompleteRoutingMap(rangesAfterSplit2, collection2.getResourceId()); } private void TestCacheRefreshWhileRouteByPartitionKey( @@ -182,7 +182,7 @@ private void TestCacheRefreshWhileRouteByPartitionKey( boolean nameBased) throws Exception { if (targetServiceIdentity != null && targetPartitionKeyRange != null) { - targetServiceIdentity.partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collectionAfterRefresh != null ? collectionAfterRefresh.resourceId() : collectionBeforeRefresh.resourceId(), targetPartitionKeyRange.id())); + targetServiceIdentity.partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collectionAfterRefresh != null ? collectionAfterRefresh.getResourceId() : collectionBeforeRefresh.getResourceId(), targetPartitionKeyRange.getId())); } this.initializeMocks( @@ -227,7 +227,7 @@ private void TestCacheRefreshWhileRouteByPartitionKey( assertThat(targetAddresses[0].getPhysicalUri()).isEqualTo(resolvedAddresses[0].getPhysicalUri()); // Assert.AreEqual(targetServiceIdentity, request.requestContext.TargetIdentity); - assertThat(targetPartitionKeyRange.id()).isEqualTo(request.requestContext.resolvedPartitionKeyRange.id()); + assertThat(targetPartitionKeyRange.getId()).isEqualTo(request.requestContext.resolvedPartitionKeyRange.getId()); } private void TestCacheRefreshWhileRouteByPartitionKeyRangeId( @@ -250,7 +250,7 @@ private void TestCacheRefreshWhileRouteByPartitionKeyRangeId( boolean nameBased) throws Exception { if (targetServiceIdentity != null && targetPartitionKeyRange != null) { - targetServiceIdentity.partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collectionAfterRefresh != null ? collectionAfterRefresh.resourceId() : collectionBeforeRefresh.resourceId(), targetPartitionKeyRange.id())); + targetServiceIdentity.partitionKeyRangeIds.add(new PartitionKeyRangeIdentity(collectionAfterRefresh != null ? collectionAfterRefresh.getResourceId() : collectionBeforeRefresh.getResourceId(), targetPartitionKeyRange.getId())); } this.initializeMocks( @@ -296,7 +296,7 @@ private void TestCacheRefreshWhileRouteByPartitionKeyRangeId( assertThat(targetAddresses[0].getPhysicalUri()).isEqualTo(resolvedAddresses[0].getPhysicalUri()); // Assert.AreEqual(targetServiceIdentity, request.requestContext.TargetIdentity); - assertThat(targetPartitionKeyRange.id()).isEqualTo(request.requestContext.resolvedPartitionKeyRange.id()); + assertThat(targetPartitionKeyRange.getId()).isEqualTo(request.requestContext.resolvedPartitionKeyRange.getId()); } private void initializeMocks( @@ -459,7 +459,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), null, @@ -478,7 +478,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), null, @@ -497,7 +497,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses2), @@ -516,7 +516,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses2), @@ -535,8 +535,8 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), ImmutableMap.of( getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses2, @@ -557,8 +557,8 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), ImmutableMap.of( getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses2, @@ -579,7 +579,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection2, - ImmutableMap.of(this.collection2.resourceId(), this.routingMapCollection2BeforeSplit), + ImmutableMap.of(this.collection2.getResourceId(), this.routingMapCollection2BeforeSplit), null, ImmutableMap.of( getServiceIdentityAt(this.routingMapCollection2BeforeSplit, 0), this.addresses1), @@ -599,7 +599,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection2, - ImmutableMap.of(this.collection2.resourceId(), this.routingMapCollection2BeforeSplit), + ImmutableMap.of(this.collection2.getResourceId(), this.routingMapCollection2BeforeSplit), null, ImmutableMap.of( getServiceIdentityAt(this.routingMapCollection2BeforeSplit, 0), this.addresses1), @@ -619,8 +619,8 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, this.addresses1, @@ -639,9 +639,9 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, this.collection2, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit, - this.collection2.resourceId(), this.routingMapCollection2BeforeSplit), - ImmutableMap.of(this.collection2.resourceId(), this.routingMapCollection2AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit, + this.collection2.getResourceId(), this.routingMapCollection2BeforeSplit), + ImmutableMap.of(this.collection2.getResourceId(), this.routingMapCollection2AfterSplit), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection2AfterSplit, 0), this.addresses1), null, this.addresses1, @@ -660,7 +660,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKey() throws Exception { this.TestCacheRefreshWhileRouteByPartitionKey( this.collection1, null, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), ImmutableMap.of(), ImmutableMap.of(), null, @@ -709,7 +709,7 @@ private static PartitionKeyRange getRangeAt(CollectionRoutingMap routingMap, int } private static ServiceIdentity getServiceIdentityAt(CollectionRoutingMap routingMap, int index) { - return (ServiceIdentity) routingMap.tryGetInfoByPartitionKeyRangeId(routingMap.getOrderedPartitionKeyRanges().get(index).id()); + return (ServiceIdentity) routingMap.tryGetInfoByPartitionKeyRangeId(routingMap.getOrderedPartitionKeyRanges().get(index).getId()); } @Test(groups = "unit") @@ -718,11 +718,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(this.collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(this.collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), getRangeAt(this.routingMapCollection1BeforeSplit, 0), @@ -739,11 +739,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(this.collection1.resourceId(), "1"), + new PartitionKeyRangeIdentity(this.collection1.getResourceId(), "1"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), getRangeAt(this.routingMapCollection1BeforeSplit, 0), @@ -764,7 +764,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), this.addresses1), null, @@ -789,11 +789,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), null, ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1BeforeSplit, 0), getRangeAt(this.routingMapCollection1BeforeSplit, 0), @@ -814,11 +814,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), getRangeAt(this.routingMapCollection1AfterSplit, 0), @@ -838,11 +838,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection1, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1AfterSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1AfterSplit), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(collection1.resourceId(), "1"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "1"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), getRangeAt(this.routingMapCollection1AfterSplit, 0), @@ -863,7 +863,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti ImmutableMap.of(), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), getRangeAt(this.routingMapCollection1AfterSplit, 0), @@ -913,7 +913,7 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti ImmutableMap.of(), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), null, - new PartitionKeyRangeIdentity(collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), getRangeAt(this.routingMapCollection1AfterSplit, 0), @@ -934,11 +934,11 @@ public void testCacheRefreshesWhileRoutingByPartitionKeyRangeId() throws Excepti this.TestCacheRefreshWhileRouteByPartitionKeyRangeId( this.collection1, this.collection2, - ImmutableMap.of(this.collection1.resourceId(), this.routingMapCollection1BeforeSplit), - ImmutableMap.of(this.collection2.resourceId(), this.routingMapCollection2BeforeSplit), + ImmutableMap.of(this.collection1.getResourceId(), this.routingMapCollection1BeforeSplit), + ImmutableMap.of(this.collection2.getResourceId(), this.routingMapCollection2BeforeSplit), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), this.addresses1), ImmutableMap.of(getServiceIdentityAt(this.routingMapCollection2AfterSplit, 0), this.addresses2), - new PartitionKeyRangeIdentity(collection1.resourceId(), "0"), + new PartitionKeyRangeIdentity(collection1.getResourceId(), "0"), this.addresses1, getServiceIdentityAt(this.routingMapCollection1AfterSplit, 0), getRangeAt(this.routingMapCollection1AfterSplit, 0), diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java index cdaa9ec2c3cc..4a09932228c7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressSelectorWrapper.java @@ -194,7 +194,7 @@ public void verify(InvocationOnMock invocation) { VerifierBuilder resolveAllUriAsync_IncludePrimary(boolean primaryIncluded) { methodName(resolveAllUriAsync); - Condition alwaysTrue = new Condition(Predicates.alwaysTrue(), "no condition"); + Condition alwaysTrue = new Condition(Predicates.alwaysTrue(), "no getCondition"); Condition primaryIncludedCond = new Condition(Predicates.equalTo(primaryIncluded), String.format("%b (primaryIncluded)", primaryIncluded)); resolveAllUriAsync(alwaysTrue, primaryIncludedCond, alwaysTrue); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java index dc5275345b82..ad607a786785 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/AddressValidator.java @@ -2,10 +2,6 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.directconnectivity; -import com.azure.data.cosmos.internal.directconnectivity.Address; -import com.azure.data.cosmos.internal.directconnectivity.Protocol; -import com.azure.data.cosmos.internal.directconnectivity.Address; -import com.azure.data.cosmos.internal.directconnectivity.Protocol; import org.assertj.core.api.Condition; import java.util.ArrayList; @@ -40,7 +36,7 @@ public Builder withId(final String resourceId) { @Override public void validate(Address address) { - assertThat(address.id()).as("check Resource Id").isEqualTo(resourceId); + assertThat(address.getId()).as("check Resource Id").isEqualTo(resourceId); } }); return this; @@ -114,7 +110,7 @@ public Builder withRid(String rid) { @Override public void validate(Address address) { - assertThat(address.resourceId()).isEqualTo(rid); + assertThat(address.getResourceId()).isEqualTo(rid); } }); return this; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java index ded96c5657b7..709d4c6270b5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/BarrierRequestHelperTest.java @@ -31,7 +31,7 @@ public void barrierBasic() { for (OperationType operationType : OperationType.values()) { Document randomResource = new Document(); - randomResource.id(UUID.randomUUID().toString()); + randomResource.setId(UUID.randomUUID().toString()); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, resourceType, "/dbs/7mVFAA==/colls/7mVFAP1jpeU=", randomResource, (Map) null); @@ -59,7 +59,7 @@ public void barrierDBFeed() { OperationType operationType = OperationType.Query; Document randomResource = new Document(); - randomResource.id(UUID.randomUUID().toString()); + randomResource.setId(UUID.randomUUID().toString()); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, resourceType, "/dbs/7mVFAA==/colls/7mVFAP1jpeU=", randomResource, (Map) null); @@ -81,7 +81,7 @@ public void barrierDocumentQueryNameBasedRequest() { OperationType operationType = OperationType.Query; Document randomResource = new Document(); - randomResource.id(UUID.randomUUID().toString()); + randomResource.setId(UUID.randomUUID().toString()); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, resourceType, "/dbs/dbname/colls/collname", randomResource, (Map) null); @@ -103,7 +103,7 @@ public void barrierDocumentReadNameBasedRequest() { OperationType operationType = OperationType.Read; Document randomResource = new Document(); - randomResource.id(UUID.randomUUID().toString()); + randomResource.setId(UUID.randomUUID().toString()); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, resourceType, "/dbs/dbname/colls/collname", randomResource, (Map) null); @@ -127,7 +127,7 @@ public void barrierDocumentReadRidBasedRequest() { OperationType operationType = OperationType.Read; Document randomResource = new Document(); - randomResource.id(UUID.randomUUID().toString()); + randomResource.setId(UUID.randomUUID().toString()); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, "7mVFAA==", resourceType, (Map) null); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java index d4325b599e63..8e6a86f61960 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderTest.java @@ -340,10 +340,10 @@ public void sessionNotAvailableFromSomeReplicasThrowingNotFound_FindReplicaSatis String partitionKeyRangeId = "1"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + slowReplicaLSN); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(slowReplicaLSN)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(slowReplicaLSN)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + slowReplicaLSN); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(slowReplicaLSN)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(slowReplicaLSN)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); StoreResponse storeResponse = StoreResponseBuilder.create() .withSessionToken(partitionKeyRangeId + ":-1#" + fasterReplicaLSN) @@ -420,10 +420,10 @@ public void sessionRead_LegitimateNotFound() { String partitionKeyRangeId = "73"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -486,10 +486,10 @@ public void sessionRead_ReplicasDoNotHaveTheRequestedLSN() { long globalCommittedLsn = 651174; String partitionKeyRangeId = "73"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(651175)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(651175)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(651175)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(651175)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -550,10 +550,10 @@ public void requestRateTooLarge_BubbleUp() { String partitionKeyRangeId = "73"; RequestRateTooLargeException requestTooLargeException = new RequestRateTooLargeException(); - requestTooLargeException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); - requestTooLargeException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(651175)); - requestTooLargeException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(651175)); - requestTooLargeException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + requestTooLargeException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + requestTooLargeException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(651175)); + requestTooLargeException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(651175)); + requestTooLargeException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -745,7 +745,7 @@ public static void validateException(Mono single, private PartitionKeyRange partitionKeyRangeWithId(String id) { PartitionKeyRange partitionKeyRange = Mockito.mock(PartitionKeyRange.class); - Mockito.doReturn(id).when(partitionKeyRange).id(); + Mockito.doReturn(id).when(partitionKeyRange).getId(); return partitionKeyRange; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderUnderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderUnderTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderUnderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyReaderUnderTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriterTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriterTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriterTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ConsistencyWriterTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java index 689500477055..0b0fea9ff518 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/DCDocumentCrudTest.java @@ -69,7 +69,7 @@ public static Object[][] directClientBuilder() { static Builder createDCBuilder(Protocol protocol) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); Configs configs = spy(new Configs()); doAnswer((Answer) invocation -> protocol).when(configs).getProtocol(); @@ -90,14 +90,14 @@ public DCDocumentCrudTest(Builder clientBuilder) { @Test(groups = { "direct" }, timeOut = TIMEOUT) public void executeStoredProc() { StoredProcedure storedProcedure = new StoredProcedure(); - storedProcedure.id(UUID.randomUUID().toString()); + storedProcedure.setId(UUID.randomUUID().toString()); storedProcedure.setBody("function() {var x = 10;}"); Flux> createObservable = client .createStoredProcedure(getCollectionLink(), storedProcedure, null); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(storedProcedure.id()) + .withId(storedProcedure.getId()) .build(); validateSuccess(createObservable, validator, TIMEOUT); @@ -107,7 +107,7 @@ public void executeStoredProc() { client.getCapturedRequests().clear(); // execute the created storedProc and ensure it goes through direct connectivity stack - String storedProcLink = "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id() + "/sprocs/" + storedProcedure.id(); + String storedProcLink = "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId() + "/sprocs/" + storedProcedure.getId(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey("dummy")); @@ -131,7 +131,7 @@ public void create() { this.getCollectionLink(), docDefinition, null, false); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(docDefinition.id()) + .withId(docDefinition.getId()) .build(); validateSuccess(createObservable, validator, TIMEOUT); @@ -156,10 +156,10 @@ public void read() throws Exception { options.setPartitionKey(new PartitionKey(pkValue)); String docLink = - String.format("dbs/%s/colls/%s/docs/%s", createdDatabase.id(), createdCollection.id(), document.id()); + String.format("dbs/%s/colls/%s/docs/%s", createdDatabase.getId(), createdCollection.getId(), document.getId()); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(docDefinition.id()) + .withId(docDefinition.getId()) .build(); validateSuccess(client.readDocument(docLink, options), validator, TIMEOUT); @@ -222,14 +222,14 @@ public void crossPartitionQuery() { waitIfNeededForReplicasToCatchUp(clientBuilder()); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); - options.maxDegreeOfParallelism(-1); + options.setEnableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(-1); options.maxItemCount(100); Flux> results = client.queryDocuments(getCollectionLink(), "SELECT * FROM r", options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(documentList.size()) - .exactlyContainsInAnyOrder(documentList.stream().map(Document::resourceId).collect(Collectors.toList())).build(); + .exactlyContainsInAnyOrder(documentList.stream().map(Document::getResourceId).collect(Collectors.toList())).build(); validateQuerySuccess(results, validator, QUERY_TIMEOUT); validateNoDocumentQueryOperationThroughGateway(); @@ -292,7 +292,7 @@ public void beforeClass() { RequestOptions options = new RequestOptions(); options.setOfferThroughput(10100); createdDatabase = SHARED_DATABASE; - createdCollection = createCollection(createdDatabase.id(), getCollectionDefinition(), options); + createdCollection = createCollection(createdDatabase.getId(), getCollectionDefinition(), options); client = SpyClientUnderTestFactory.createClientWithGatewaySpy(clientBuilder()); assertThat(client.getCapturedRequests()).isNotEmpty(); @@ -309,12 +309,12 @@ public void beforeMethod(Method method) { } private String getCollectionLink() { - return String.format("/dbs/%s/colls/%s", createdDatabase.id(), createdCollection.id()); + return String.format("/dbs/%s/colls/%s", createdDatabase.getId(), createdCollection.getId()); } private Document getDocumentDefinition() { Document doc = new Document(); - doc.id(UUID.randomUUID().toString()); + doc.setId(UUID.randomUUID().toString()); BridgeInternal.setProperty(doc, PARTITION_KEY_FIELD_NAME, UUID.randomUUID().toString()); BridgeInternal.setProperty(doc, "name", "Hafez"); return doc; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/EndpointMock.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/EndpointMock.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/EndpointMock.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/EndpointMock.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java index 63f87f35cdff..09e7ffed0145 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ExceptionBuilder.java @@ -47,21 +47,21 @@ public ExceptionBuilder withMessage(String message) { public GoneException asGoneException() { assert status == null; GoneException dce = new GoneException(); - dce.responseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); + dce.getResponseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); return dce; } public InvalidPartitionException asInvalidPartitionException() { assert status == null; InvalidPartitionException dce = new InvalidPartitionException(); - dce.responseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); + dce.getResponseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); return dce; } public PartitionKeyRangeGoneException asPartitionKeyRangeGoneException() { assert status == null; PartitionKeyRangeGoneException dce = new PartitionKeyRangeGoneException(); - dce.responseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); + dce.getResponseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); return dce; } @@ -69,14 +69,14 @@ public PartitionKeyRangeGoneException asPartitionKeyRangeGoneException() { public PartitionKeyRangeIsSplittingException asPartitionKeyRangeIsSplittingException() { assert status == null; PartitionKeyRangeIsSplittingException dce = new PartitionKeyRangeIsSplittingException(); - dce.responseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); + dce.getResponseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); return dce; } public PartitionIsMigratingException asPartitionIsMigratingException() { assert status == null; PartitionIsMigratingException dce = new PartitionIsMigratingException(); - dce.responseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); + dce.getResponseHeaders().putAll(headerEntries.stream().collect(Collectors.toMap(i -> i.getKey(), i -> i.getValue()))); return dce; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function1WithCheckedException.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function1WithCheckedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function1WithCheckedException.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function1WithCheckedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function2WithCheckedException.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function2WithCheckedException.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function2WithCheckedException.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/Function2WithCheckedException.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java index 9f43c1c8f914..aedf5a4128e2 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayAddressCacheTest.java @@ -96,7 +96,7 @@ public void getServerAddressesViaGateway(List partitionKeyRangeIds, getDocumentDefinition(), new HashMap<>()); Mono> addresses = cache.getServerAddressesViaGatewayAsync( - req, createdCollection.resourceId(), partitionKeyRangeIds, false); + req, createdCollection.getResourceId(), partitionKeyRangeIds, false); PartitionReplicasAddressesValidator validator = new PartitionReplicasAddressesValidator.Builder() .withProtocol(protocol) @@ -165,7 +165,7 @@ public void tryGetAddresses_ForDataPartitions(String partitionKeyRangeId, String collectionLink, new Database(), new HashMap<>()); - String collectionRid = createdCollection.resourceId(); + String collectionRid = createdCollection.getResourceId(); PartitionKeyRangeIdentity partitionKeyRangeIdentity = new PartitionKeyRangeIdentity(collectionRid, partitionKeyRangeId); boolean forceRefreshPartitionAddresses = false; @@ -208,7 +208,7 @@ public void tryGetAddresses_ForDataPartitions_AddressCachedByOpenAsync_NoHttpReq null, httpClientWrapper.getSpyHttpClient()); - String collectionRid = createdCollection.resourceId(); + String collectionRid = createdCollection.getResourceId(); List pkriList = allPartitionKeyRangeIds.stream().map( pkri -> new PartitionKeyRangeIdentity(collectionRid, pkri)).collect(Collectors.toList()); @@ -263,7 +263,7 @@ public void tryGetAddresses_ForDataPartitions_ForceRefresh( null, httpClientWrapper.getSpyHttpClient()); - String collectionRid = createdCollection.resourceId(); + String collectionRid = createdCollection.getResourceId(); List pkriList = allPartitionKeyRangeIds.stream().map( pkri -> new PartitionKeyRangeIdentity(collectionRid, pkri)).collect(Collectors.toList()); @@ -320,7 +320,7 @@ public void tryGetAddresses_ForDataPartitions_Suboptimal_Refresh( httpClientWrapper.getSpyHttpClient(), suboptimalRefreshTime); - String collectionRid = createdCollection.resourceId(); + String collectionRid = createdCollection.getResourceId(); List pkriList = allPartitionKeyRangeIds.stream().map( pkri -> new PartitionKeyRangeIdentity(collectionRid, pkri)).collect(Collectors.toList()); @@ -799,7 +799,7 @@ public void beforeClass() { RequestOptions options = new RequestOptions(); options.setOfferThroughput(30000); - createdCollection = createCollection(client, createdDatabase.id(), getCollectionDefinition(), options); + createdCollection = createCollection(client, createdDatabase.getId(), getCollectionDefinition(), options); } @AfterClass(groups = { "direct" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) @@ -812,10 +812,10 @@ static protected DocumentCollection getCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id("mycol"); + collectionDefinition.setId("mycol"); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; @@ -831,11 +831,11 @@ private HttpClientUnderTestWrapper getHttpClientUnderTestWrapper(Configs configs } public String getNameBasedCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } public String getCollectionSelfLink() { - return createdCollection.selfLink(); + return createdCollection.getSelfLink(); } private Document getDocumentDefinition() { @@ -848,4 +848,4 @@ private Document getDocumentDefinition() { , uuid, uuid)); return doc; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java index b78b9e6cc4c1..c1b94deac09a 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfigurationReaderTest.java @@ -58,7 +58,7 @@ public void setup() throws Exception { SpyClientUnderTestFactory.ClientUnderTest clientUnderTest = SpyClientUnderTestFactory.createClientUnderTest(this.clientBuilder()); HttpClient httpClient = clientUnderTest.getSpyHttpClient(); baseAuthorizationTokenProvider = new BaseAuthorizationTokenProvider(new CosmosKeyCredential(TestConfigurations.MASTER_KEY)); - connectionPolicy = ConnectionPolicy.defaultPolicy(); + connectionPolicy = ConnectionPolicy.getDefaultPolicy(); mockHttpClient = Mockito.mock(HttpClient.class); mockGatewayServiceConfigurationReader = new GatewayServiceConfigurationReader(new URI(TestConfigurations.HOST), false, TestConfigurations.MASTER_KEY, connectionPolicy, baseAuthorizationTokenProvider, mockHttpClient); @@ -128,11 +128,11 @@ public static void validateSuccess(Mono observable, DatabaseAcc testSubscriber.assertComplete(); testSubscriber.assertValueCount(1); DatabaseAccount databaseAccount = testSubscriber.values().get(0); - assertThat(databaseAccount.id()).isEqualTo(expectedDatabaseAccount.id()); + assertThat(databaseAccount.getId()).isEqualTo(expectedDatabaseAccount.getId()); assertThat(BridgeInternal.getAddressesLink(databaseAccount)) .isEqualTo(BridgeInternal.getAddressesLink(expectedDatabaseAccount)); - assertThat(databaseAccount.writableLocations().iterator().next().endpoint()) - .isEqualTo(expectedDatabaseAccount.writableLocations().iterator().next().endpoint()); + assertThat(databaseAccount.getWritableLocations().iterator().next().getEndpoint()) + .isEqualTo(expectedDatabaseAccount.getWritableLocations().iterator().next().getEndpoint()); assertThat(BridgeInternal.getSystemReplicationPolicy(databaseAccount).getMaxReplicaSetSize()) .isEqualTo(BridgeInternal.getSystemReplicationPolicy(expectedDatabaseAccount).getMaxReplicaSetSize()); assertThat(BridgeInternal.getSystemReplicationPolicy(databaseAccount).getMaxReplicaSetSize()) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfiguratorReaderMock.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfiguratorReaderMock.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfiguratorReaderMock.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GatewayServiceConfiguratorReaderMock.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java index ba4e45108abd..d58ae9be1aea 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GlobalAddressResolverTest.java @@ -67,7 +67,7 @@ public void setup() throws Exception { urlforWrite3 = new URL("http://testWrite3.com/"); connectionPolicy = new ConnectionPolicy(); - connectionPolicy.enableReadRequestsFallback(true); + connectionPolicy.setEnableReadRequestsFallback(true); httpClient = Mockito.mock(HttpClient.class); endpointManager = Mockito.mock(GlobalEndpointManager.class); @@ -89,7 +89,7 @@ public void setup() throws Exception { authorizationTokenProvider = Mockito.mock(IAuthorizationTokenProvider.class); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionCache = Mockito.mock(RxCollectionCache.class); Mockito.when(collectionCache.resolveCollectionAsync(Matchers.any(RxDocumentServiceRequest.class))).thenReturn(Mono.just(collectionDefinition)); routingMapProvider = Mockito.mock(RxPartitionKeyRangeCache.class); @@ -140,8 +140,8 @@ public void openAsync() throws Exception { DocumentCollection documentCollection = new DocumentCollection(); - documentCollection.id("TestColl"); - documentCollection.resourceId("IXYFAOHEBPM="); + documentCollection.setId("TestColl"); + documentCollection.setResourceId("IXYFAOHEBPM="); CollectionRoutingMap collectionRoutingMap = Mockito.mock(CollectionRoutingMap.class); PartitionKeyRange range = new PartitionKeyRange("0", PartitionKeyInternalHelper.MinimumInclusiveEffectivePartitionKey, PartitionKeyInternalHelper.MaximumExclusiveEffectivePartitionKey); @@ -153,7 +153,7 @@ public void openAsync() throws Exception { List ranges = new ArrayList<>(); for (PartitionKeyRange partitionKeyRange : (List) collectionRoutingMap.getOrderedPartitionKeyRanges()) { - PartitionKeyRangeIdentity partitionKeyRangeIdentity = new PartitionKeyRangeIdentity(documentCollection.resourceId(), partitionKeyRange.id()); + PartitionKeyRangeIdentity partitionKeyRangeIdentity = new PartitionKeyRangeIdentity(documentCollection.getResourceId(), partitionKeyRange.getId()); ranges.add(partitionKeyRangeIdentity); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java similarity index 97% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java index 0432868ab61c..f65cd5cf9b73 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/GoneAndRetryWithRetryPolicyTest.java @@ -14,7 +14,6 @@ import com.azure.data.cosmos.PartitionKeyRangeIsSplittingException; import com.azure.data.cosmos.internal.ResourceType; import com.azure.data.cosmos.internal.RxDocumentServiceRequest; -import com.azure.data.cosmos.internal.directconnectivity.GoneAndRetryWithRetryPolicy; import org.testng.annotations.Test; import reactor.core.publisher.Mono; @@ -102,7 +101,7 @@ public void shouldRetryWithInvalidPartitionException() { shouldRetryResult = goneAndRetryWithRetryPolicy.shouldRetry(new InvalidPartitionException()).block(); assertThat(shouldRetryResult.shouldRetry).isFalse(); CosmosClientException clientException = (CosmosClientException) shouldRetryResult.exception; - assertThat(clientException.statusCode()).isEqualTo(HttpConstants.StatusCodes.SERVICE_UNAVAILABLE); + assertThat(clientException.getStatusCode()).isEqualTo(HttpConstants.StatusCodes.SERVICE_UNAVAILABLE); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientMockWrapper.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientMockWrapper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientMockWrapper.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpClientMockWrapper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClientTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClientTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClientTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpTransportClientTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtilsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtilsTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtilsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/HttpUtilsTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MultiStoreResultValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MultiStoreResultValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MultiStoreResultValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MultiStoreResultValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MurmurHash3_32Test.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MurmurHash3_32Test.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MurmurHash3_32Test.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/MurmurHash3_32Test.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java similarity index 98% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java index 95e0f71b63aa..5d170c91ca59 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyInternalTest.java @@ -291,7 +291,7 @@ public void hashEffectivePartitionKey() { .isEqualTo(PartitionKeyInternalHelper.MaximumExclusiveEffectivePartitionKey); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); - partitionKeyDefinition.paths(Lists.newArrayList("/A", "/B", "/C", "/E", "/F", "/G")); + partitionKeyDefinition.setPaths(Lists.newArrayList("/A", "/B", "/C", "/E", "/F", "/G")); PartitionKeyInternal partitionKey = PartitionKeyInternal.fromObjectArray( new Object[]{2, true, false, null, Undefined.Value(), "Привет!"}, true); @@ -334,7 +334,7 @@ public void managedNativeCompatibility() { PartitionKeyInternal.fromJsonString("[\"по-русски\",null,true,false,{},5.5]"); PartitionKeyDefinition pkDefinition = new PartitionKeyDefinition(); - pkDefinition.paths(ImmutableList.of("/field1", "/field2", "/field3", "/field4", "/field5", "/field6")); + pkDefinition.setPaths(ImmutableList.of("/field1", "/field2", "/field3", "/field4", "/field5", "/field6")); String effectivePartitionKey = PartitionKeyInternalHelper.getEffectivePartitionKeyString(partitionKey, pkDefinition); assertThat("05C1D39FA55F0408D1C0D1BF2ED281D284D282D282D1BBD1B9000103020005C016").isEqualTo(effectivePartitionKey); @@ -419,7 +419,7 @@ private static void validateEffectivePartitionKeyV2(String partitionKeyRangeJson PartitionKeyInternal partitionKey = PartitionKeyInternal.fromJsonString(partitionKeyRangeJson); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); - partitionKeyDefinition.kind(PartitionKind.HASH); + partitionKeyDefinition.setKind(PartitionKind.HASH); CommonsBridgeInternal.setV2(partitionKeyDefinition); ArrayList paths = new ArrayList(); for (int i = 0; i < partitionKey.getComponents().size(); i++) { @@ -427,7 +427,7 @@ private static void validateEffectivePartitionKeyV2(String partitionKeyRangeJson } if (paths.size() > 0) { - partitionKeyDefinition.paths(paths); + partitionKeyDefinition.setPaths(paths); } String hexEncodedEffectivePartitionKey = PartitionKeyInternalHelper.getEffectivePartitionKeyString(partitionKey, partitionKeyDefinition); @@ -441,7 +441,7 @@ private void verifyComparison(String leftKey, String rightKey, int result) { private static void verifyEffectivePartitionKeyEncoding(String buffer, int length, String expectedValue, boolean v2) { PartitionKeyDefinition pkDefinition = new PartitionKeyDefinition(); - pkDefinition.paths(ImmutableList.of("/field1")); + pkDefinition.setPaths(ImmutableList.of("/field1")); if (v2) { CommonsBridgeInternal.setV2(pkDefinition); } @@ -449,4 +449,4 @@ private static void verifyEffectivePartitionKeyEncoding(String buffer, int lengt PartitionKeyInternal pk = PartitionKeyInternalUtils.createPartitionKeyInternal(buffer.substring(0, length)); assertThat(PartitionKeyInternalHelper.getEffectivePartitionKeyString(pk, pkDefinition)).isEqualTo(expectedValue); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java similarity index 96% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java index e07fa9bca60b..38fa914e5dd5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionKeyTest.java @@ -52,7 +52,7 @@ public void partitionKeyCompare(Object partitionKey, String partitionKeyAsJson) @Test(groups = "unit") public void tooFewPartitionKeyComponents() { PartitionKeyDefinition pkd = new PartitionKeyDefinition(); - pkd.paths(ImmutableList.of("/pk1", "/pk2")); + pkd.setPaths(ImmutableList.of("/pk1", "/pk2")); PartitionKey pk = PartitionKey.fromJsonString("[\"PartitionKeyValue\"]"); try { @@ -69,7 +69,7 @@ public void tooFewPartitionKeyComponents() { @Test(groups = "unit") public void tooManyPartitionKeyComponents() { PartitionKeyDefinition pkd = new PartitionKeyDefinition(); - pkd.paths(ImmutableList.of("/pk1")); + pkd.setPaths(ImmutableList.of("/pk1")); PartitionKey pk = PartitionKey.fromJsonString("[true, false]"); try { @@ -79,4 +79,4 @@ public void tooManyPartitionKeyComponents() { assertThat(e.getMessage()).isEqualTo(RMResources.TooManyPartitionKeyComponents); } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java index 739321531d9c..7c40019ab645 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/PartitionReplicasAddressesValidator.java @@ -2,11 +2,6 @@ // Licensed under the MIT License. package com.azure.data.cosmos.internal.directconnectivity; -import com.azure.data.cosmos.internal.directconnectivity.Address; -import com.azure.data.cosmos.internal.directconnectivity.Protocol; -import com.azure.data.cosmos.internal.directconnectivity.Address; -import com.azure.data.cosmos.internal.directconnectivity.Protocol; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -86,7 +81,7 @@ public void validate(Collection
addresses) { AddressValidator validator = new AddressValidator.Builder() .withPartitionKeyRangeId(partitionKeyRangeId) - .withRid(a.resourceId()) + .withRid(a.getResourceId()) .build(); for (Address address : addresses) { @@ -110,7 +105,7 @@ public void validate(Collection
addresses) { AddressValidator validator = new AddressValidator.Builder() .withPartitionKeyRangeId(a.getParitionKeyRangeId()) - .withRid(a.resourceId()) + .withRid(a.getResourceId()) .build(); for (Address address : addresses) { @@ -139,4 +134,4 @@ public void validate(Collection
addresses) { return this; } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReaderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReaderTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReaderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/QuorumReaderTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java index a013e4a2b1d7..a6c9fee31d4f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReflectionUtils.java @@ -3,8 +3,8 @@ package com.azure.data.cosmos.internal.directconnectivity; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.AsyncDocumentClient; -import com.azure.data.cosmos.CosmosClient; import com.azure.data.cosmos.internal.RxDocumentClientImpl; import com.azure.data.cosmos.internal.http.HttpClient; import org.apache.commons.lang3.reflect.FieldUtils; @@ -62,11 +62,11 @@ public static void setDirectHttpsHttpClient(RxDocumentClientImpl client, HttpCli set(transportClient, newHttpClient, "httpClient"); } - public static AsyncDocumentClient getAsyncDocumentClient(CosmosClient client) { + public static AsyncDocumentClient getAsyncDocumentClient(CosmosAsyncClient client) { return get(AsyncDocumentClient.class, client, "asyncDocumentClient"); } - public static void setAsyncDocumentClient(CosmosClient client, RxDocumentClientImpl rxClient) { + public static void setAsyncDocumentClient(CosmosAsyncClient client, RxDocumentClientImpl rxClient) { set(client, rxClient, "asyncDocumentClient"); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicaAddressFactory.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicaAddressFactory.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicaAddressFactory.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicaAddressFactory.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java index 7fa9a01f2c74..1bf5839039aa 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientPartitionSplitTest.java @@ -187,7 +187,7 @@ public static void validateFailure(Mono single, FailureValidator private PartitionKeyRange partitionKeyRangeWithId(String id) { PartitionKeyRange partitionKeyRange = Mockito.mock(PartitionKeyRange.class); - Mockito.doReturn(id).when(partitionKeyRange).id(); + Mockito.doReturn(id).when(partitionKeyRange).getId(); return partitionKeyRange; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/ReplicatedResourceClientTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClientTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClientTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClientTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/RntbdTransportClientTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderDotNetTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderDotNetTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderDotNetTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderDotNetTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java index 99959406c852..25cbe0ad1541 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderTest.java @@ -169,10 +169,10 @@ public void sessionNotAvailableFromSomeReplicas_FindReplicaSatisfyingRequestedSe long globalCommittedLsn = 651174; String partitionKeyRangeId = "73"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + slowReplicaLSN); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(slowReplicaLSN)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(slowReplicaLSN)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + slowReplicaLSN); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(slowReplicaLSN)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(slowReplicaLSN)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); long fasterReplicaLSN = 651176; @@ -259,10 +259,10 @@ public void sessionRead_LegitimateNotFound() { String partitionKeyRangeId = "73"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -328,10 +328,10 @@ public void sessionRead_ReplicasDoNotHaveTheRequestedLSN_NoResult() { String partitionKeyRangeId = "73"; NotFoundException foundException = new NotFoundException(); - foundException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); - foundException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + foundException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); + foundException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -390,10 +390,10 @@ public void requestRateTooLarge_BubbleUp() { String partitionKeyRangeId = "257"; RequestRateTooLargeException requestRateTooLargeException = new RequestRateTooLargeException(); - requestRateTooLargeException.responseHeaders().put(HttpConstants.HttpHeaders.LSN, Long.toString(lsn)); - requestRateTooLargeException.responseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); - requestRateTooLargeException.responseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); - requestRateTooLargeException.responseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); + requestRateTooLargeException.getResponseHeaders().put(HttpConstants.HttpHeaders.LSN, Long.toString(lsn)); + requestRateTooLargeException.getResponseHeaders().put(WFConstants.BackendHeaders.GLOBAL_COMMITTED_LSN, Long.toString(globalCommittedLsn)); + requestRateTooLargeException.getResponseHeaders().put(WFConstants.BackendHeaders.LOCAL_LSN, Long.toString(lsn)); + requestRateTooLargeException.getResponseHeaders().put(HttpConstants.HttpHeaders.SESSION_TOKEN, partitionKeyRangeId + ":-1#" + lsn); TransportClientWrapper transportClientWrapper = new TransportClientWrapper.Builder.ReplicaResponseBuilder .SequentialBuilder() @@ -788,7 +788,7 @@ public static void validateException(Mono single, private PartitionKeyRange partitionKeyRangeWithId(String id) { PartitionKeyRange partitionKeyRange = Mockito.mock(PartitionKeyRange.class); - Mockito.doReturn(id).when(partitionKeyRange).id(); + Mockito.doReturn(id).when(partitionKeyRange).getId(); return partitionKeyRange; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderUnderTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderUnderTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderUnderTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreReaderUnderTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResponseValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResultValidator.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResultValidator.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResultValidator.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/StoreResultValidator.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelperTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelperTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelperTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TimeoutHelperTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TransportClientWrapper.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TransportClientWrapper.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TransportClientWrapper.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/TransportClientWrapper.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtilityTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtilityTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtilityTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/directconnectivity/WebExceptionUtilityTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java index 062847e91c85..625fa7fa2336 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/DocumentProducerTest.java @@ -95,7 +95,7 @@ private IRetryPolicyFactory mockDocumentClientIRetryPolicyFactory() { GlobalEndpointManager globalEndpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(url).when(globalEndpointManager).resolveServiceEndpoint(Mockito.any(RxDocumentServiceRequest.class)); doReturn(false).when(globalEndpointManager).isClosed(); - return new RetryPolicy(globalEndpointManager, ConnectionPolicy.defaultPolicy()); + return new RetryPolicy(globalEndpointManager, ConnectionPolicy.getDefaultPolicy()); } @Test(groups = {"unit"}, dataProvider = "splitParamProvider", timeOut = TIMEOUT) @@ -320,7 +320,7 @@ public void simple() { // continuation tokens assertThat(requestCreator.invocations.get(0).continuationToken).isEqualTo(initialContinuationToken); - assertThat(requestCreator.invocations.stream().skip(1).map(i -> i.continuationToken).collect(Collectors.toList())).containsExactlyElementsOf(responses.stream().limit(9).map(r -> r.continuationToken()).collect(Collectors.toList())); + assertThat(requestCreator.invocations.stream().skip(1).map(i -> i.continuationToken).collect(Collectors.toList())).containsExactlyElementsOf(responses.stream().limit(9).map(r -> r.getContinuationToken()).collect(Collectors.toList())); // source partition assertThat(requestCreator.invocations.stream().map(i -> i.sourcePartition).distinct().collect(Collectors.toList())).containsExactlyElementsOf(Collections.singletonList(targetRange)); @@ -380,11 +380,11 @@ public void retries() { assertThat(requestCreator.invocations.stream().map(i -> i.sourcePartition).distinct().collect(Collectors.toList())).containsExactlyElementsOf(Collections.singletonList(targetRange)); List resultContinuationToken = - subscriber.values().stream().map(r -> r.pageResult.continuationToken()).collect(Collectors.toList()); + subscriber.values().stream().map(r -> r.pageResult.getContinuationToken()).collect(Collectors.toList()); List beforeExceptionContinuationTokens = - responsesBeforeThrottle.stream().map(FeedResponse::continuationToken).collect(Collectors.toList()); + responsesBeforeThrottle.stream().map(FeedResponse::getContinuationToken).collect(Collectors.toList()); List afterExceptionContinuationTokens = - responsesAfterThrottle.stream().map(FeedResponse::continuationToken).collect(Collectors.toList()); + responsesAfterThrottle.stream().map(FeedResponse::getContinuationToken).collect(Collectors.toList()); assertThat(resultContinuationToken).containsExactlyElementsOf(Iterables.concat(beforeExceptionContinuationTokens, afterExceptionContinuationTokens)); @@ -436,8 +436,8 @@ public void retriesExhausted() { private CosmosClientException mockThrottlingException(long retriesAfter) { CosmosClientException throttleException = mock(CosmosClientException.class); - doReturn(429).when(throttleException).statusCode(); - doReturn(retriesAfter).when(throttleException).retryAfterInMilliseconds(); + doReturn(429).when(throttleException).getStatusCode(); + doReturn(retriesAfter).when(throttleException).getRetryAfterInMilliseconds(); return throttleException; } @@ -500,7 +500,7 @@ private List> mockFeedResponsesPartiallySorted(String par private int getLastValueInAsc(int initialValue, List> responsesList) { Integer value = null; for (FeedResponse page : responsesList) { - for (Document d : page.results()) { + for (Document d : page.getResults()) { Integer tmp = d.getInt(OrderByIntFieldName); if (tmp != null) { value = tmp; @@ -525,7 +525,7 @@ private IDocumentQueryClient mockQueryClient(List replacement private PartitionKeyRange mockPartitionKeyRange(String partitionKeyRangeId) { PartitionKeyRange pkr = Mockito.mock(PartitionKeyRange.class); - doReturn(partitionKeyRangeId).when(pkr).id(); + doReturn(partitionKeyRangeId).when(pkr).getId(); doReturn(partitionKeyRangeId + ":AA").when(pkr).getMinInclusive(); doReturn(partitionKeyRangeId + ":FF").when(pkr).getMaxExclusive(); return pkr; @@ -550,22 +550,22 @@ private static void validateSplitCaptureRequests(List i.sourcePartition.id().equals(parentPartitionId))).hasSize(numberOfResultPagesFromParentBeforeSplit + 1); + assertThat(capturedInvocationList.stream().limit(numberOfResultPagesFromParentBeforeSplit + 1).filter(i -> i.sourcePartition.getId().equals(parentPartitionId))).hasSize(numberOfResultPagesFromParentBeforeSplit + 1); - assertThat(capturedInvocationList.stream().skip(numberOfResultPagesFromParentBeforeSplit + 1).filter(i -> i.sourcePartition.id().equals(leftChildPartitionId))).hasSize(numberOfResultPagesFromLeftChildAfterSplit); + assertThat(capturedInvocationList.stream().skip(numberOfResultPagesFromParentBeforeSplit + 1).filter(i -> i.sourcePartition.getId().equals(leftChildPartitionId))).hasSize(numberOfResultPagesFromLeftChildAfterSplit); - assertThat(capturedInvocationList.stream().skip(numberOfResultPagesFromParentBeforeSplit + 1).filter(i -> i.sourcePartition.id().equals(rightChildPartitionId))).hasSize(numberOfResultPagesFromRightChildAfterSplit); + assertThat(capturedInvocationList.stream().skip(numberOfResultPagesFromParentBeforeSplit + 1).filter(i -> i.sourcePartition.getId().equals(rightChildPartitionId))).hasSize(numberOfResultPagesFromRightChildAfterSplit); - BiFunction, String, Stream> filterByPartition = (stream, partitionId) -> stream.filter(i -> i.sourcePartition.id().equals(partitionId)); + BiFunction, String, Stream> filterByPartition = (stream, partitionId) -> stream.filter(i -> i.sourcePartition.getId().equals(partitionId)); Function>, Stream> extractContinuationToken = - (list) -> list.stream().map(p -> p.continuationToken()); + (list) -> list.stream().map(p -> p.getContinuationToken()); assertThat(filterByPartition.apply(capturedInvocationList.stream(), parentPartitionId).map(r -> r.continuationToken)).containsExactlyElementsOf(toList(Stream.concat(Stream.of(initialContinuationToken), extractContinuationToken.apply(expectedResultPagesFromParentPartitionBeforeSplit)))); String expectedInitialChildContinuationTokenInheritedFromParent = expectedResultPagesFromParentPartitionBeforeSplit.size() > 0 ? - expectedResultPagesFromParentPartitionBeforeSplit.get(expectedResultPagesFromParentPartitionBeforeSplit.size() - 1).continuationToken() : initialContinuationToken; + expectedResultPagesFromParentPartitionBeforeSplit.get(expectedResultPagesFromParentPartitionBeforeSplit.size() - 1).getContinuationToken() : initialContinuationToken; assertThat(filterByPartition.andThen(s -> s.map(r -> r.continuationToken)).apply(capturedInvocationList.stream(), leftChildPartitionId)).containsExactlyElementsOf(toList(Stream.concat(Stream.of(expectedInitialChildContinuationTokenInheritedFromParent), extractContinuationToken.apply(expectedResultPagesFromLeftChildPartition) //drop last page with null cp which doesn't trigger any request @@ -587,15 +587,15 @@ private static void sanityCheckSplitValidation(String parentPartitionId, String assertThat(resultFromRightChild).hasSize(numberOfResultPagesFromRightChildAfterSplit); //validate expected result continuation token - assertThat(toList(resultFromParent.stream().map(p -> p.continuationToken()).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); + assertThat(toList(resultFromParent.stream().map(p -> p.getContinuationToken()).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); - assertThat(toList(resultFromLeftChild.stream().map(p -> p.continuationToken()).limit(resultFromLeftChild.size() - 1).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); + assertThat(toList(resultFromLeftChild.stream().map(p -> p.getContinuationToken()).limit(resultFromLeftChild.size() - 1).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); - assertThat(resultFromLeftChild.get(resultFromLeftChild.size() - 1).continuationToken()).isNullOrEmpty(); + assertThat(resultFromLeftChild.get(resultFromLeftChild.size() - 1).getContinuationToken()).isNullOrEmpty(); - assertThat(toList(resultFromRightChild.stream().map(p -> p.continuationToken()).limit(resultFromRightChild.size() - 1).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); + assertThat(toList(resultFromRightChild.stream().map(p -> p.getContinuationToken()).limit(resultFromRightChild.size() - 1).filter(cp -> Strings.isNullOrEmpty(cp)))).isEmpty(); - assertThat(resultFromRightChild.get(resultFromRightChild.size() - 1).continuationToken()).isNullOrEmpty(); + assertThat(resultFromRightChild.get(resultFromRightChild.size() - 1).getContinuationToken()).isNullOrEmpty(); } private void validateSplitResults(List.DocumentProducerFeedResponse> actualPages, @@ -605,7 +605,7 @@ private void validateSplitResults(List.DocumentProduc if (isOrderby) { Supplier> getStreamOfActualDocuments = - () -> actualPages.stream().flatMap(p -> p.pageResult.results().stream()); + () -> actualPages.stream().flatMap(p -> p.pageResult.getResults().stream()); Comparator comparator = new Comparator() { @Override @@ -624,11 +624,11 @@ public int compare(Document o1, Document o2) { List expectedDocuments = Stream.concat(Stream.concat(resultFromParent.stream(), resultFromLeftChild.stream()), - resultFromRightChild.stream()).flatMap(p -> p.results().stream()).sorted(comparator).collect(Collectors.toList()); + resultFromRightChild.stream()).flatMap(p -> p.getResults().stream()).sorted(comparator).collect(Collectors.toList()); List actualDocuments = - getStreamOfActualDocuments.get().map(d -> d.id()).collect(Collectors.toList()); - assertThat(actualDocuments).containsExactlyElementsOf(expectedDocuments.stream().map(d -> d.id()).collect(Collectors.toList())); + getStreamOfActualDocuments.get().map(d -> d.getId()).collect(Collectors.toList()); + assertThat(actualDocuments).containsExactlyElementsOf(expectedDocuments.stream().map(d -> d.getId()).collect(Collectors.toList())); } else { assertThat(actualPages).hasSize(resultFromParent.size() + resultFromLeftChild.size() + resultFromRightChild.size()); @@ -663,7 +663,7 @@ private static List toList(Stream stream) { } private static List partitionKeyRangeIds(List.DocumentProducerFeedResponse> responses) { - return responses.stream().map(dpFR -> dpFR.sourcePartitionKeyRange.id()).collect(Collectors.toList()); + return responses.stream().map(dpFR -> dpFR.sourcePartitionKeyRange.getId()).collect(Collectors.toList()); } private static void validateResults(List> captured, @@ -679,13 +679,13 @@ private static void validateResults(List> captured, } private static void assertEqual(FeedResponse actualPage, FeedResponse expectedPage) { - assertThat(actualPage.results()).hasSameSizeAs(actualPage.results()); - assertThat(actualPage.continuationToken()).isEqualTo(expectedPage.continuationToken()); + assertThat(actualPage.getResults()).hasSameSizeAs(actualPage.getResults()); + assertThat(actualPage.getContinuationToken()).isEqualTo(expectedPage.getContinuationToken()); - for (int i = 0; i < actualPage.results().size(); i++) { - Document actualDoc = actualPage.results().get(i); - Document expectedDoc = expectedPage.results().get(i); - assertThat(actualDoc.id()).isEqualTo(expectedDoc.id()); + for (int i = 0; i < actualPage.getResults().size(); i++) { + Document actualDoc = actualPage.getResults().get(i); + Document expectedDoc = expectedPage.getResults().get(i); + assertThat(actualDoc.getId()).isEqualTo(expectedDoc.getId()); assertThat(actualDoc.getString("prop")).isEqualTo(expectedDoc.getString("prop")); } } @@ -881,7 +881,7 @@ public static RequestCreator simpleMock() { public RxDocumentServiceRequest apply(PartitionKeyRange pkr, String cp, Integer ps) { synchronized (this) { RxDocumentServiceRequest req = Mockito.mock(RxDocumentServiceRequest.class); - PartitionKeyRangeIdentity pkri = new PartitionKeyRangeIdentity(pkr.id()); + PartitionKeyRangeIdentity pkri = new PartitionKeyRangeIdentity(pkr.getId()); doReturn(pkri).when(req).getPartitionKeyRangeIdentity(); doReturn(cp).when(req).getContinuation(); invocations.add(new CapturedInvocation(pkr, cp, ps, req)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FeedResponseBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FeedResponseBuilder.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FeedResponseBuilder.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FeedResponseBuilder.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java index ead0be5f708c..16de0c407dbf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/query/FetcherTest.java @@ -87,7 +87,7 @@ public void query(FeedOptions options, int top) { Function>> executeFunc = request -> { FeedResponse rsp = feedResponseList.get(executeIndex.getAndIncrement()); - totalResultsReceived.addAndGet(rsp.results().size()); + totalResultsReceived.addAndGet(rsp.getResults().size()); return Flux.just(rsp); }; @@ -108,7 +108,7 @@ private void validateFetcher(Fetcher fetcher, int index = 0; while(index < feedResponseList.size()) { assertThat(fetcher.shouldFetchMore()).describedAs("should fetch more pages").isTrue(); - totalNumberOfDocs += validate(fetcher.nextPage()).results().size(); + totalNumberOfDocs += validate(fetcher.nextPage()).getResults().size(); if ((top != -1) && (totalNumberOfDocs >= top)) { break; @@ -122,7 +122,7 @@ private void validateFetcher(Fetcher fetcher, public void changeFeed() { ChangeFeedOptions options = new ChangeFeedOptions(); - options.maxItemCount(100); + options.setMaxItemCount(100); boolean isChangeFeed = true; int top = -1; @@ -142,9 +142,9 @@ public void changeFeed() { AtomicInteger requestIndex = new AtomicInteger(0); BiFunction createRequestFunc = (token, maxItemCount) -> { - assertThat(maxItemCount).describedAs("max item count").isEqualTo(options.maxItemCount()); + assertThat(maxItemCount).describedAs("max getItem count").isEqualTo(options.getMaxItemCount()); assertThat(token).describedAs("continuation token").isEqualTo( - getExpectedContinuationTokenInRequest(options.requestContinuation(), feedResponseList, requestIndex.getAndIncrement())); + getExpectedContinuationTokenInRequest(options.getRequestContinuation(), feedResponseList, requestIndex.getAndIncrement())); return mock(RxDocumentServiceRequest.class); }; @@ -156,8 +156,8 @@ public void changeFeed() { }; Fetcher fetcher = - new Fetcher<>(createRequestFunc, executeFunc, options.requestContinuation(), isChangeFeed, top, - options.maxItemCount()); + new Fetcher<>(createRequestFunc, executeFunc, options.getRequestContinuation(), isChangeFeed, top, + options.getMaxItemCount()); validateFetcher(fetcher, options, feedResponseList); } @@ -192,7 +192,7 @@ private String getExpectedContinuationTokenInRequest(String continuationToken, return continuationToken; } - return feedResponseList.get(requestIndex - 1).continuationToken(); + return feedResponseList.get(requestIndex - 1).getContinuationToken(); } private int getExpectedMaxItemCountInRequest(FeedOptions options, @@ -204,7 +204,7 @@ private int getExpectedMaxItemCountInRequest(FeedOptions options, } int numberOfReceivedItemsSoFar = - feedResponseList.subList(0, requestIndex).stream().mapToInt(rsp -> rsp.results().size()).sum(); + feedResponseList.subList(0, requestIndex).stream().mapToInt(rsp -> rsp.getResults().size()).sum(); return Math.min(top - numberOfReceivedItemsSoFar, options.maxItemCount()); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java similarity index 95% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java index e2a79621c203..5d0471a438da 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/InMemoryCollectionRoutingMapTest.java @@ -43,20 +43,20 @@ public void collectionRoutingMap() { ServerIdentityImp.of(3))), StringUtils.EMPTY); - assertThat("0").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(0).id()); - assertThat("1").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(1).id()); - assertThat("2").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(2).id()); - assertThat("3").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(3).id()); + assertThat("0").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(0).getId()); + assertThat("1").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(1).getId()); + assertThat("2").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(2).getId()); + assertThat("3").isEqualTo(routingMap.getOrderedPartitionKeyRanges().get(3).getId()); - assertThat("0").isEqualTo(routingMap.getRangeByEffectivePartitionKey("").id()); - assertThat("0").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000000").id()); - assertThat("1").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000030").id()); - assertThat("1").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000031").id()); - assertThat("3").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000071").id()); + assertThat("0").isEqualTo(routingMap.getRangeByEffectivePartitionKey("").getId()); + assertThat("0").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000000").getId()); + assertThat("1").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000030").getId()); + assertThat("1").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000031").getId()); + assertThat("3").isEqualTo(routingMap.getRangeByEffectivePartitionKey("0000000071").getId()); - assertThat("0").isEqualTo(routingMap.getRangeByPartitionKeyRangeId("0").id()); - assertThat("1").isEqualTo(routingMap.getRangeByPartitionKeyRangeId("1").id()); + assertThat("0").isEqualTo(routingMap.getRangeByPartitionKeyRangeId("0").getId()); + assertThat("1").isEqualTo(routingMap.getRangeByPartitionKeyRangeId("1").getId()); assertThat(4).isEqualTo( routingMap @@ -74,7 +74,7 @@ public void collectionRoutingMap() { assertThat(1).isEqualTo(partitionKeyRanges.size()); Iterator iterator = partitionKeyRanges.iterator(); - assertThat("1").isEqualTo(iterator.next().id()); + assertThat("1").isEqualTo(iterator.next().getId()); Collection partitionKeyRanges1 = routingMap .getOverlappingRanges(Arrays.asList(new Range("0000000040", "0000000045", true, true), @@ -83,8 +83,8 @@ public void collectionRoutingMap() { assertThat(2).isEqualTo(partitionKeyRanges1.size()); Iterator iterator1 = partitionKeyRanges1.iterator(); - assertThat("1").isEqualTo(iterator1.next().id()); - assertThat("2").isEqualTo(iterator1.next().id()); + assertThat("1").isEqualTo(iterator1.next().getId()); + assertThat("2").isEqualTo(iterator1.next().getId()); } @Test(groups = { "unit" }, expectedExceptions = IllegalStateException.class) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java index a6f2d7953f4d..77baf7fa10bd 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/LocationCacheTest.java @@ -142,9 +142,9 @@ private void initialize( this.cache.onDatabaseAccountRead(this.databaseAccount); ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.enableEndpointDiscovery(enableEndpointDiscovery); + connectionPolicy.setEnableEndpointDiscovery(enableEndpointDiscovery); BridgeInternal.setUseMultipleWriteLocations(connectionPolicy, useMultipleWriteLocations); - connectionPolicy.preferredLocations(this.preferredLocations); + connectionPolicy.setPreferredLocations(this.preferredLocations); this.endpointManager = new GlobalEndpointManager(mockedClient, connectionPolicy, configs); } @@ -198,19 +198,19 @@ private void validateLocationCacheAsync( UnmodifiableList currentWriteEndpoints = this.cache.getWriteEndpoints(); UnmodifiableList currentReadEndpoints = this.cache.getReadEndpoints(); for (int i = 0; i < readLocationIndex; i++) { - this.cache.markEndpointUnavailableForRead(createUrl(Iterables.get(this.databaseAccount.readableLocations(), i).endpoint())); - this.endpointManager.markEndpointUnavailableForRead(createUrl(Iterables.get(this.databaseAccount.readableLocations(), i).endpoint()));; + this.cache.markEndpointUnavailableForRead(createUrl(Iterables.get(this.databaseAccount.getReadableLocations(), i).getEndpoint())); + this.endpointManager.markEndpointUnavailableForRead(createUrl(Iterables.get(this.databaseAccount.getReadableLocations(), i).getEndpoint()));; } for (int i = 0; i < writeLocationIndex; i++) { - this.cache.markEndpointUnavailableForWrite(createUrl(Iterables.get(this.databaseAccount.writableLocations(), i).endpoint())); - this.endpointManager.markEndpointUnavailableForWrite(createUrl(Iterables.get(this.databaseAccount.writableLocations(), i).endpoint())); + this.cache.markEndpointUnavailableForWrite(createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), i).getEndpoint())); + this.endpointManager.markEndpointUnavailableForWrite(createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), i).getEndpoint())); } - Map writeEndpointByLocation = toStream(this.databaseAccount.writableLocations()) - .collect(Collectors.toMap(i -> i.name(), i -> createUrl(i.endpoint()))); + Map writeEndpointByLocation = toStream(this.databaseAccount.getWritableLocations()) + .collect(Collectors.toMap(i -> i.getName(), i -> createUrl(i.getEndpoint()))); - Map readEndpointByLocation = toStream(this.databaseAccount.readableLocations()) - .collect(Collectors.toMap(i -> i.name(), i -> createUrl(i.endpoint()))); + Map readEndpointByLocation = toStream(this.databaseAccount.getReadableLocations()) + .collect(Collectors.toMap(i -> i.getName(), i -> createUrl(i.getEndpoint()))); URL[] preferredAvailableWriteEndpoints = toStream(this.preferredLocations).skip(writeLocationIndex) .filter(location -> writeEndpointByLocation.containsKey(location)) @@ -264,8 +264,8 @@ private void validateEndpointRefresh( false : isFirstWriteEndpointUnavailable; if (this.preferredLocations.size() > 0) { String mostPreferredReadLocationName = this.preferredLocations.stream() - .filter(location -> toStream(databaseAccount.readableLocations()) - .anyMatch(readLocation -> readLocation.name().equals(location))) + .filter(location -> toStream(databaseAccount.getReadableLocations()) + .anyMatch(readLocation -> readLocation.getName().equals(location))) .findFirst().orElse(null); URL mostPreferredReadEndpoint = LocationCacheTest.EndpointByLocation.get(mostPreferredReadLocationName); @@ -273,8 +273,8 @@ private void validateEndpointRefresh( true : (!areEqual(preferredAvailableReadEndpoints[0], mostPreferredReadEndpoint)); String mostPreferredWriteLocationName = this.preferredLocations.stream() - .filter(location -> toStream(databaseAccount.writableLocations()) - .anyMatch(writeLocation -> writeLocation.name().equals(location))) + .filter(location -> toStream(databaseAccount.getWritableLocations()) + .anyMatch(writeLocation -> writeLocation.getName().equals(location))) .findFirst().orElse(null); URL mostPreferredWriteEndpoint = LocationCacheTest.EndpointByLocation.get(mostPreferredWriteLocationName); @@ -335,18 +335,18 @@ private void validateRequestEndpointResolution( firstAvailableWriteEndpoint = LocationCacheTest.DefaultEndpoint; secondAvailableWriteEndpoint = LocationCacheTest.DefaultEndpoint; } else if (!useMultipleWriteLocations) { - firstAvailableWriteEndpoint = createUrl(Iterables.get(this.databaseAccount.writableLocations(), 0).endpoint()); - secondAvailableWriteEndpoint = createUrl(Iterables.get(this.databaseAccount.writableLocations(), 1).endpoint()); + firstAvailableWriteEndpoint = createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), 0).getEndpoint()); + secondAvailableWriteEndpoint = createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), 1).getEndpoint()); } else if (availableWriteEndpoints.length > 1) { firstAvailableWriteEndpoint = availableWriteEndpoints[0]; secondAvailableWriteEndpoint = availableWriteEndpoints[1]; } else if (availableWriteEndpoints.length > 0) { firstAvailableWriteEndpoint = availableWriteEndpoints[0]; - Iterator writeLocationsIterator = databaseAccount.writableLocations().iterator(); - String writeEndpoint = writeLocationsIterator.next().endpoint(); + Iterator writeLocationsIterator = databaseAccount.getWritableLocations().iterator(); + String writeEndpoint = writeLocationsIterator.next().getEndpoint(); secondAvailableWriteEndpoint = writeEndpoint != firstAvailableWriteEndpoint.toString() ? new URL(writeEndpoint) - : new URL(writeLocationsIterator.next().endpoint()); + : new URL(writeLocationsIterator.next().getEndpoint()); } else { firstAvailableWriteEndpoint = LocationCacheTest.DefaultEndpoint; secondAvailableWriteEndpoint = LocationCacheTest.DefaultEndpoint; @@ -366,11 +366,11 @@ private void validateRequestEndpointResolution( URL firstWriteEnpoint = !endpointDiscoveryEnabled ? LocationCacheTest.DefaultEndpoint : - createUrl(Iterables.get(this.databaseAccount.writableLocations(), 0).endpoint()); + createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), 0).getEndpoint()); URL secondWriteEnpoint = !endpointDiscoveryEnabled ? LocationCacheTest.DefaultEndpoint : - createUrl(Iterables.get(this.databaseAccount.writableLocations(), 1).endpoint()); + createUrl(Iterables.get(this.databaseAccount.getWritableLocations(), 1).getEndpoint()); // If current write endpoint is unavailable, write endpoints order doesn't change // ALL write requests flip-flop between current write and alternate write endpoint @@ -380,7 +380,7 @@ private void validateRequestEndpointResolution( assertThat(secondAvailableWriteEndpoint).isEqualTo(this.resolveEndpointForWriteRequest(ResourceType.Document, true)); assertThat(firstAvailableWriteEndpoint).isEqualTo(this.resolveEndpointForWriteRequest(ResourceType.Document, false)); - // Writes to other resource types should be directed to first/second write endpoint + // Writes to other resource types should be directed to first/second write getEndpoint assertThat(firstWriteEnpoint).isEqualTo(this.resolveEndpointForWriteRequest(ResourceType.Database, false)); assertThat(secondWriteEnpoint).isEqualTo(this.resolveEndpointForWriteRequest(ResourceType.Database, true)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalUtils.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalUtils.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalUtils.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/PartitionKeyInternalUtils.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java similarity index 99% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java index 42201b08dbf8..a1feace139d1 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/RoutingMapProviderHelperTest.java @@ -84,7 +84,7 @@ public void getOverlappingRanges() { Function func = new Function() { @Override public String apply(PartitionKeyRange range) { - return range.id(); + return range.getId(); } }; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponentTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponentTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponentTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/internal/routing/StringPartitionKeyComponentTest.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java index 9e37686cf4f9..b6d9703af3d0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/AggregateQueryTests.java @@ -2,14 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.Document; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; import com.azure.data.cosmos.internal.FeedResponseListValidator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -46,7 +41,7 @@ public AggregateConfig(String operator, Object expected, String condition) { } } - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private ArrayList docs = new ArrayList(); private ArrayList queryConfigs = new ArrayList(); @@ -58,7 +53,7 @@ public AggregateConfig(String operator, Object expected, String condition) { private int numberOfDocumentsWithNumericId; private int numberOfDocsWithSamePartitionKey = 400; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public AggregateQueryTests(CosmosClientBuilder clientBuilder) { @@ -69,9 +64,9 @@ public AggregateQueryTests(CosmosClientBuilder clientBuilder) { public void queryDocumentsWithAggregates(boolean qmEnabled) throws Exception { FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(qmEnabled); - options.maxDegreeOfParallelism(2); + options.setMaxDegreeOfParallelism(2); for (QueryConfig queryConfig : queryConfigs) { @@ -97,7 +92,7 @@ public void generateTestData() { Object[] values = new Object[]{null, false, true, "abc", "cdfg", "opqrs", "ttttttt", "xyz", "oo", "ppp"}; for (int i = 0; i < values.length; i++) { CosmosItemProperties d = new CosmosItemProperties(); - d.id(UUID.randomUUID().toString()); + d.setId(UUID.randomUUID().toString()); BridgeInternal.setProperty(d, partitionKey, values[i]); docs.add(d); } @@ -105,9 +100,9 @@ public void generateTestData() { for (int i = 0; i < numberOfDocsWithSamePartitionKey; i++) { CosmosItemProperties d = new CosmosItemProperties(); BridgeInternal.setProperty(d, partitionKey, uniquePartitionKey); - BridgeInternal.setProperty(d, "resourceId", Integer.toString(i)); + BridgeInternal.setProperty(d, "getResourceId", Integer.toString(i)); BridgeInternal.setProperty(d, field, i + 1); - d.id(UUID.randomUUID().toString()); + d.setId(UUID.randomUUID().toString()); docs.add(d); } @@ -115,7 +110,7 @@ public void generateTestData() { for (int i = 0; i < numberOfDocumentsWithNumericId; i++) { CosmosItemProperties d = new CosmosItemProperties(); BridgeInternal.setProperty(d, partitionKey, i + 1); - d.id(UUID.randomUUID().toString()); + d.setId(UUID.randomUUID().toString()); docs.add(d); } @@ -182,7 +177,7 @@ public void afterClass() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT * 2) public void beforeClass() throws Exception { - client = this.clientBuilder().build(); + client = this.clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java index 60b31f0c8d93..1fcb7769caab 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureCrossPartitionTest.java @@ -2,23 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.ClientUnderTestBuilder; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.DataType; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.IncludedPath; -import com.azure.data.cosmos.Index; -import com.azure.data.cosmos.IndexingPolicy; -import com.azure.data.cosmos.PartitionKeyDefinition; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.RxDocumentClientUnderTest; import com.azure.data.cosmos.internal.TestUtils; import io.reactivex.subscribers.TestSubscriber; @@ -48,43 +33,43 @@ public class BackPressureCrossPartitionTest extends TestSuiteBase { private static final int SETUP_TIMEOUT = 60000; private int numberOfDocs = 4000; - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; private List createdDocuments; - private CosmosClient client; + private CosmosAsyncClient client; private int numberOfPartitions; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } static protected CosmosContainerProperties getCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); - BridgeInternal.setProperty(stringIndex, "precision", -1); + BridgeInternal.setProperty(stringIndex, "getPrecision", -1); indexes.add(stringIndex); Index numberIndex = Index.Range(DataType.NUMBER); - BridgeInternal.setProperty(numberIndex, "precision", -1); + BridgeInternal.setProperty(numberIndex, "getPrecision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties( UUID.randomUUID().toString(), partitionKeyDef); - collectionDefinition.indexingPolicy(indexingPolicy); + collectionDefinition.setIndexingPolicy(indexingPolicy); return collectionDefinition; } @@ -96,7 +81,7 @@ public BackPressureCrossPartitionTest(CosmosClientBuilder clientBuilder) { private void warmUp() { FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); // ensure collection is cached createdCollection.queryItems("SELECT * FROM r", options).blockFirst(); } @@ -120,9 +105,9 @@ public Object[][] queryProvider() { @Test(groups = { "long" }, dataProvider = "queryProvider", timeOut = 2 * TIMEOUT) public void query(String query, int maxItemCount, int maxExpectedBufferedCountForBackPressure, int expectedNumberOfResults) throws Exception { FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(maxItemCount); - options.maxDegreeOfParallelism(2); + options.setMaxDegreeOfParallelism(2); Flux> queryObservable = createdCollection.queryItems(query, options); RxDocumentClientUnderTest rxClient = (RxDocumentClientUnderTest)CosmosBridgeInternal.getAsyncDocumentClient(client); @@ -160,13 +145,13 @@ public void query(String query, int maxItemCount, int maxExpectedBufferedCountFo subscriber.assertNoErrors(); subscriber.assertComplete(); - assertThat(subscriber.values().stream().mapToInt(p -> p.results().size()).sum()).isEqualTo(expectedNumberOfResults); + assertThat(subscriber.values().stream().mapToInt(p -> p.getResults().size()).sum()).isEqualTo(expectedNumberOfResults); } @BeforeClass(groups = { "long" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - client = new ClientUnderTestBuilder(clientBuilder()).build(); + client = new ClientUnderTestBuilder(clientBuilder()).buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); createdCollection = createCollection(createdDatabase, getCollectionDefinition(), options, 20000); @@ -180,7 +165,7 @@ public void beforeClass() { docDefList); numberOfPartitions = CosmosBridgeInternal.getAsyncDocumentClient(client).readPartitionKeyRanges(getCollectionLink(), null) - .flatMap(p -> Flux.fromIterable(p.results())).collectList().single().block().size(); + .flatMap(p -> Flux.fromIterable(p.getResults())).collectList().single().block().size(); waitIfNeededForReplicasToCatchUp(clientBuilder()); warmUp(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java index 22ff4bad41f2..d9852b951f39 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/BackPressureTest.java @@ -2,19 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.ClientUnderTestBuilder; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.Offer; -import com.azure.data.cosmos.PartitionKeyDefinition; import com.azure.data.cosmos.internal.RxDocumentClientUnderTest; import com.azure.data.cosmos.internal.TestUtils; import io.reactivex.subscribers.TestSubscriber; @@ -41,21 +31,21 @@ public class BackPressureTest extends TestSuiteBase { private static final int TIMEOUT = 200000; private static final int SETUP_TIMEOUT = 60000; - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; private List createdDocuments; - private CosmosClient client; + private CosmosAsyncClient client; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } private static CosmosContainerProperties getSinglePartitionCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); return collectionDefinition; @@ -70,7 +60,7 @@ public BackPressureTest(CosmosClientBuilder clientBuilder) { public void readFeed() throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(1); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.readAllItems(options); RxDocumentClientUnderTest rxClient = (RxDocumentClientUnderTest)CosmosBridgeInternal.getAsyncDocumentClient(client); @@ -109,7 +99,7 @@ public void readFeed() throws Exception { public void query() throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(1); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems("SELECT * from r", options); RxDocumentClientUnderTest rxClient = (RxDocumentClientUnderTest)CosmosBridgeInternal.getAsyncDocumentClient(client); @@ -148,7 +138,7 @@ public void query() throws Exception { public void beforeClass() throws Exception { CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); - client = new ClientUnderTestBuilder(clientBuilder()).build(); + client = new ClientUnderTestBuilder(clientBuilder()).buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); createdCollection = createCollection(createdDatabase, getSinglePartitionCollectionDefinition(), options, 1000); @@ -159,8 +149,8 @@ public void beforeClass() throws Exception { // for bulk insert and later queries. Offer offer = rxClient.queryOffers( String.format("SELECT * FROM r WHERE r.offerResourceId = '%s'", - createdCollection.read().block().properties().resourceId()) - , null).take(1).map(FeedResponse::results).single().block().get(0); + createdCollection.read().block().getProperties().getResourceId()) + , null).take(1).map(FeedResponse::getResults).single().block().get(0); offer.setThroughput(6000); offer = rxClient.replaceOffer(offer).single().block().getResource(); assertThat(offer.getThroughput()).isEqualTo(6000); @@ -179,7 +169,7 @@ public void beforeClass() throws Exception { private void warmUp() { // ensure collection is cached FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); createdCollection.queryItems("SELECT * from r", options).blockFirst(); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java similarity index 77% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java index 18c700950de9..0fe490fffdc9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedProcessorTest.java @@ -2,24 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.ChangeFeedProcessor; -import com.azure.data.cosmos.ChangeFeedProcessorOptions; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.SerializationFormattingPolicy; -import com.azure.data.cosmos.SqlParameter; -import com.azure.data.cosmos.SqlParameterList; -import com.azure.data.cosmos.SqlQuerySpec; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.changefeed.ServiceItemLease; import org.apache.commons.lang3.RandomStringUtils; import org.slf4j.Logger; @@ -46,9 +30,9 @@ public class ChangeFeedProcessorTest extends TestSuiteBase { private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class); - private CosmosDatabase createdDatabase; - private CosmosContainer createdFeedCollection; - private CosmosContainer createdLeaseCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdFeedCollection; + private CosmosAsyncContainer createdLeaseCollection; private List createdDocuments; private static Map receivedDocuments; // private final String databaseId = "testdb1"; @@ -57,7 +41,7 @@ public class ChangeFeedProcessorTest extends TestSuiteBase { private final int FEED_COUNT = 10; private final int CHANGE_FEED_PROCESSOR_TIMEOUT = 5000; - private CosmosClient client; + private CosmosAsyncClient client; private ChangeFeedProcessor changeFeedProcessor; @@ -71,26 +55,26 @@ public void readFeedDocumentsStartFromBeginning() { setupReadFeedDocuments(); changeFeedProcessor = ChangeFeedProcessor.Builder() - .hostName(hostName) - .handleChanges(docs -> { + .setHostName(hostName) + .setHandleChanges(docs -> { ChangeFeedProcessorTest.log.info("START processing from thread {}", Thread.currentThread().getId()); for (CosmosItemProperties item : docs) { processItem(item); } ChangeFeedProcessorTest.log.info("END processing from thread {}", Thread.currentThread().getId()); }) - .feedContainer(createdFeedCollection) - .leaseContainer(createdLeaseCollection) - .options(new ChangeFeedProcessorOptions() - .leaseRenewInterval(Duration.ofSeconds(20)) - .leaseAcquireInterval(Duration.ofSeconds(10)) - .leaseExpirationInterval(Duration.ofSeconds(30)) - .feedPollDelay(Duration.ofSeconds(2)) - .leasePrefix("TEST") - .maxItemCount(10) - .startFromBeginning(true) - .maxScaleCount(0) // unlimited - .discardExistingLeases(true) + .setFeedContainer(createdFeedCollection) + .setLeaseContainer(createdLeaseCollection) + .setOptions(new ChangeFeedProcessorOptions() + .setLeaseRenewInterval(Duration.ofSeconds(20)) + .setLeaseAcquireInterval(Duration.ofSeconds(10)) + .setLeaseExpirationInterval(Duration.ofSeconds(30)) + .setFeedPollDelay(Duration.ofSeconds(2)) + .setLeasePrefix("TEST") + .setMaxItemCount(10) + .setStartFromBeginning(true) + .setMaxScaleCount(0) // unlimited + .setDiscardExistingLeases(true) ) .build(); @@ -112,7 +96,7 @@ public void readFeedDocumentsStartFromBeginning() { changeFeedProcessor.stop().subscribeOn(Schedulers.elastic()).timeout(Duration.ofMillis(CHANGE_FEED_PROCESSOR_TIMEOUT)).subscribe(); for (CosmosItemProperties item : createdDocuments) { - assertThat(receivedDocuments.containsKey(item.id())).as("Document with id: " + item.id()).isTrue(); + assertThat(receivedDocuments.containsKey(item.getId())).as("Document with getId: " + item.getId()).isTrue(); } // Wait for the feed processor to shutdown. @@ -127,27 +111,27 @@ public void readFeedDocumentsStartFromBeginning() { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void readFeedDocumentsStartFromCustomDate() { ChangeFeedProcessor changeFeedProcessor = ChangeFeedProcessor.Builder() - .hostName(hostName) - .handleChanges(docs -> { + .setHostName(hostName) + .setHandleChanges(docs -> { ChangeFeedProcessorTest.log.info("START processing from thread {}", Thread.currentThread().getId()); for (CosmosItemProperties item : docs) { processItem(item); } ChangeFeedProcessorTest.log.info("END processing from thread {}", Thread.currentThread().getId()); }) - .feedContainer(createdFeedCollection) - .leaseContainer(createdLeaseCollection) - .options(new ChangeFeedProcessorOptions() - .leaseRenewInterval(Duration.ofSeconds(20)) - .leaseAcquireInterval(Duration.ofSeconds(10)) - .leaseExpirationInterval(Duration.ofSeconds(30)) - .feedPollDelay(Duration.ofSeconds(1)) - .leasePrefix("TEST") - .maxItemCount(10) - .startTime(OffsetDateTime.now().minusDays(1)) - .minScaleCount(1) - .maxScaleCount(3) - .discardExistingLeases(true) + .setFeedContainer(createdFeedCollection) + .setLeaseContainer(createdLeaseCollection) + .setOptions(new ChangeFeedProcessorOptions() + .setLeaseRenewInterval(Duration.ofSeconds(20)) + .setLeaseAcquireInterval(Duration.ofSeconds(10)) + .setLeaseExpirationInterval(Duration.ofSeconds(30)) + .setFeedPollDelay(Duration.ofSeconds(1)) + .setLeasePrefix("TEST") + .setMaxItemCount(10) + .setStartTime(OffsetDateTime.now().minusDays(1)) + .setMinScaleCount(1) + .setMaxScaleCount(3) + .setDiscardExistingLeases(true) ) .build(); @@ -177,7 +161,7 @@ public void readFeedDocumentsStartFromCustomDate() { changeFeedProcessor.stop().subscribeOn(Schedulers.elastic()).timeout(Duration.ofMillis(2 * CHANGE_FEED_PROCESSOR_TIMEOUT)).subscribe(); for (CosmosItemProperties item : createdDocuments) { - assertThat(receivedDocuments.containsKey(item.id())).as("Document with id: " + item.id()).isTrue(); + assertThat(receivedDocuments.containsKey(item.getId())).as("Document with getId: " + item.getId()).isTrue(); } // Wait for the feed processor to shutdown. @@ -196,38 +180,38 @@ public void staledLeaseAcquiring() { final String leasePrefix = "TEST"; ChangeFeedProcessor changeFeedProcessorFirst = ChangeFeedProcessor.Builder() - .hostName(ownerFirst) - .handleChanges(docs -> { + .setHostName(ownerFirst) + .setHandleChanges(docs -> { ChangeFeedProcessorTest.log.info("START processing from thread {} using host {}", Thread.currentThread().getId(), ownerFirst); ChangeFeedProcessorTest.log.info("END processing from thread {} using host {}", Thread.currentThread().getId(), ownerFirst); }) - .feedContainer(createdFeedCollection) - .leaseContainer(createdLeaseCollection) - .options(new ChangeFeedProcessorOptions() - .leasePrefix(leasePrefix) + .setFeedContainer(createdFeedCollection) + .setLeaseContainer(createdLeaseCollection) + .setOptions(new ChangeFeedProcessorOptions() + .setLeasePrefix(leasePrefix) ) .build(); ChangeFeedProcessor changeFeedProcessorSecond = ChangeFeedProcessor.Builder() - .hostName(ownerSecond) - .handleChanges(docs -> { + .setHostName(ownerSecond) + .setHandleChanges(docs -> { ChangeFeedProcessorTest.log.info("START processing from thread {} using host {}", Thread.currentThread().getId(), ownerSecond); for (CosmosItemProperties item : docs) { processItem(item); } ChangeFeedProcessorTest.log.info("END processing from thread {} using host {}", Thread.currentThread().getId(), ownerSecond); }) - .feedContainer(createdFeedCollection) - .leaseContainer(createdLeaseCollection) - .options(new ChangeFeedProcessorOptions() - .leaseRenewInterval(Duration.ofSeconds(10)) - .leaseAcquireInterval(Duration.ofSeconds(5)) - .leaseExpirationInterval(Duration.ofSeconds(20)) - .feedPollDelay(Duration.ofSeconds(2)) - .leasePrefix(leasePrefix) - .maxItemCount(10) - .startFromBeginning(true) - .maxScaleCount(0) // unlimited + .setFeedContainer(createdFeedCollection) + .setLeaseContainer(createdLeaseCollection) + .setOptions(new ChangeFeedProcessorOptions() + .setLeaseRenewInterval(Duration.ofSeconds(10)) + .setLeaseAcquireInterval(Duration.ofSeconds(5)) + .setLeaseExpirationInterval(Duration.ofSeconds(20)) + .setFeedPollDelay(Duration.ofSeconds(2)) + .setLeasePrefix(leasePrefix) + .setMaxItemCount(10) + .setStartFromBeginning(true) + .setMaxScaleCount(0) // unlimited ) .build(); @@ -254,25 +238,25 @@ public void staledLeaseAcquiring() { ChangeFeedProcessorTest.log.info("Update leases for Change feed processor in thread {} using host {}", Thread.currentThread().getId(), "Owner_first"); SqlParameter param = new SqlParameter(); - param.name("@PartitionLeasePrefix"); - param.value(leasePrefix); + param.setName("@PartitionLeasePrefix"); + param.setValue(leasePrefix); SqlQuerySpec querySpec = new SqlQuerySpec( "SELECT * FROM c WHERE STARTSWITH(c.id, @PartitionLeasePrefix)", new SqlParameterList(param)); FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); createdLeaseCollection.queryItems(querySpec, feedOptions) .delayElements(Duration.ofMillis(CHANGE_FEED_PROCESSOR_TIMEOUT / 2)) - .flatMap(documentFeedResponse -> reactor.core.publisher.Flux.fromIterable(documentFeedResponse.results())) + .flatMap(documentFeedResponse -> reactor.core.publisher.Flux.fromIterable(documentFeedResponse.getResults())) .flatMap(doc -> { BridgeInternal.setProperty(doc, "Owner", "TEMP_OWNER"); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(doc.id())); - return createdLeaseCollection.getItem(doc.id(), "/id") + options.setPartitionKey(new PartitionKey(doc.getId())); + return createdLeaseCollection.getItem(doc.getId(), "/id") .replace(doc, options) - .map(CosmosItemResponse::properties); + .map(CosmosAsyncItemResponse::getProperties); }) .map(ServiceItemLease::fromDocument) .map(leaseDocument -> { @@ -337,7 +321,7 @@ public void beforeMethod() { @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); // try { // client.getDatabase(databaseId).read() @@ -377,7 +361,7 @@ public void afterClass() { // client.readAllDatabases() // .flatMap(cosmosDatabaseSettingsFeedResponse -> reactor.core.publisher.Flux.fromIterable(cosmosDatabaseSettingsFeedResponse.results())) // .flatMap(cosmosDatabaseSettings -> { -// CosmosDatabase cosmosDatabase = client.getDatabase(cosmosDatabaseSettings.id()); +// CosmosAsyncDatabase cosmosDatabase = client.getDatabase(cosmosDatabaseSettings.id()); // return cosmosDatabase.delete(); // }).blockLast(); // Thread.sleep(500); @@ -409,12 +393,12 @@ private CosmosItemProperties getDocumentDefinition() { return doc; } - private CosmosContainer createFeedCollection() { + private CosmosAsyncContainer createFeedCollection() { CosmosContainerRequestOptions optionsFeedCollection = new CosmosContainerRequestOptions(); return createCollection(createdDatabase, getCollectionDefinition(), optionsFeedCollection, 10100); } - private CosmosContainer createLeaseCollection() { + private CosmosAsyncContainer createLeaseCollection() { CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), "/id"); return createCollection(createdDatabase, collectionDefinition, options, 400); @@ -422,6 +406,6 @@ private CosmosContainer createLeaseCollection() { private static synchronized void processItem(CosmosItemProperties item) { ChangeFeedProcessorTest.log.info("RECEIVED {}", item.toJson(SerializationFormattingPolicy.INDENTED)); - receivedDocuments.put(item.id(), item); + receivedDocuments.put(item.getId(), item); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java similarity index 80% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java index 6d3810b011f5..4b8d7f97098d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ChangeFeedTest.java @@ -47,17 +47,17 @@ public class ChangeFeedTest extends TestSuiteBase { private AsyncDocumentClient client; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } static protected DocumentCollection getCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/" + PartitionKeyFieldName); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; @@ -74,9 +74,9 @@ public void changeFeed_fromBeginning() throws Exception { Collection expectedDocuments = partitionKeyToDocuments.get(partitionKey); ChangeFeedOptions changeFeedOption = new ChangeFeedOptions(); - changeFeedOption.maxItemCount(3); - changeFeedOption.partitionKey(new PartitionKey(partitionKey)); - changeFeedOption.startFromBeginning(true); + changeFeedOption.setMaxItemCount(3); + changeFeedOption.setPartitionKey(new PartitionKey(partitionKey)); + changeFeedOption.setStartFromBeginning(true); List> changeFeedResultList = client.queryDocumentChangeFeed(getCollectionLink(), changeFeedOption) .collectList().block(); @@ -84,12 +84,12 @@ public void changeFeed_fromBeginning() throws Exception { int count = 0; for (int i = 0; i < changeFeedResultList.size(); i++) { FeedResponse changeFeedPage = changeFeedResultList.get(i); - assertThat(changeFeedPage.continuationToken()).as("Response continuation should not be null").isNotNull(); + assertThat(changeFeedPage.getContinuationToken()).as("Response continuation should not be null").isNotNull(); - count += changeFeedPage.results().size(); - assertThat(changeFeedPage.results().size()) + count += changeFeedPage.getResults().size(); + assertThat(changeFeedPage.getResults().size()) .as("change feed should contain all the previously created documents") - .isLessThanOrEqualTo(changeFeedOption.maxItemCount()); + .isLessThanOrEqualTo(changeFeedOption.getMaxItemCount()); } assertThat(count).as("the number of changes").isEqualTo(expectedDocuments.size()); } @@ -97,8 +97,8 @@ public void changeFeed_fromBeginning() throws Exception { @Test(groups = { "simple" }, timeOut = 5 * TIMEOUT) public void changesFromPartitionKeyRangeId_FromBeginning() throws Exception { List partitionKeyRangeIds = client.readPartitionKeyRanges(getCollectionLink(), null) - .flatMap(p -> Flux.fromIterable(p.results()), 1) - .map(Resource::id) + .flatMap(p -> Flux.fromIterable(p.getResults()), 1) + .map(Resource::getId) .collectList() .block(); @@ -107,24 +107,24 @@ public void changesFromPartitionKeyRangeId_FromBeginning() throws Exception { String pkRangeId = partitionKeyRangeIds.get(0); ChangeFeedOptions changeFeedOption = new ChangeFeedOptions(); - changeFeedOption.maxItemCount(3); + changeFeedOption.setMaxItemCount(3); partitionKeyRangeIdInternal(changeFeedOption, pkRangeId); - changeFeedOption.startFromBeginning(true); + changeFeedOption.setStartFromBeginning(true); List> changeFeedResultList = client.queryDocumentChangeFeed(getCollectionLink(), changeFeedOption) .collectList().block(); int count = 0; for(int i = 0; i < changeFeedResultList.size(); i++) { FeedResponse changeFeedPage = changeFeedResultList.get(i); - assertThat(changeFeedPage.continuationToken()).as("Response continuation should not be null").isNotNull(); + assertThat(changeFeedPage.getContinuationToken()).as("Response continuation should not be null").isNotNull(); - count += changeFeedPage.results().size(); - assertThat(changeFeedPage.results().size()) + count += changeFeedPage.getResults().size(); + assertThat(changeFeedPage.getResults().size()) .as("change feed should contain all the previously created documents") - .isLessThanOrEqualTo(changeFeedOption.maxItemCount()); + .isLessThanOrEqualTo(changeFeedOption.getMaxItemCount()); - assertThat(changeFeedPage.continuationToken()).as("Response continuation should not be null").isNotNull(); - assertThat(changeFeedPage.continuationToken()).as("Response continuation should not be empty").isNotEmpty(); + assertThat(changeFeedPage.getContinuationToken()).as("Response continuation should not be null").isNotNull(); + assertThat(changeFeedPage.getContinuationToken()).as("Response continuation should not be empty").isNotEmpty(); } assertThat(changeFeedResultList.size()).as("has at least one page").isGreaterThanOrEqualTo(1); assertThat(count).as("the number of changes").isGreaterThan(0); @@ -136,7 +136,7 @@ public void changeFeed_fromNow() throws Exception { // READ change feed from current. ChangeFeedOptions changeFeedOption = new ChangeFeedOptions(); String partitionKey = partitionKeyToDocuments.keySet().iterator().next(); - changeFeedOption.partitionKey(new PartitionKey(partitionKey)); + changeFeedOption.setPartitionKey(new PartitionKey(partitionKey)); List> changeFeedResultsList = client.queryDocumentChangeFeed(getCollectionLink(), changeFeedOption) .collectList() @@ -145,7 +145,7 @@ public void changeFeed_fromNow() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder().totalSize(0).build(); validator.validate(changeFeedResultsList); assertThat(changeFeedResultsList.get(changeFeedResultsList.size() -1 ). - continuationToken()).as("Response continuation should not be null").isNotNull(); + getContinuationToken()).as("Response continuation should not be null").isNotNull(); } @Test(groups = { "simple" }, timeOut = TIMEOUT) @@ -160,13 +160,13 @@ public void changeFeed_fromStartDate() throws Exception { ChangeFeedOptions changeFeedOption = new ChangeFeedOptions(); String partitionKey = partitionKeyToDocuments.keySet().iterator().next(); - changeFeedOption.partitionKey(new PartitionKey(partitionKey)); + changeFeedOption.setPartitionKey(new PartitionKey(partitionKey)); OffsetDateTime befTime = OffsetDateTime.now(); // Waiting for at-least a second to ensure that new document is created after we took the time stamp waitAtleastASecond(befTime); OffsetDateTime dateTimeBeforeCreatingDoc = OffsetDateTime.now(); - changeFeedOption.startDateTime(dateTimeBeforeCreatingDoc); + changeFeedOption.setStartDateTime(dateTimeBeforeCreatingDoc); // Waiting for at-least a second to ensure that new document is created after we took the time stamp waitAtleastASecond(dateTimeBeforeCreatingDoc); @@ -178,8 +178,8 @@ public void changeFeed_fromStartDate() throws Exception { int count = 0; for(int i = 0; i < changeFeedResultList.size(); i++) { FeedResponse changeFeedPage = changeFeedResultList.get(i); - count += changeFeedPage.results().size(); - assertThat(changeFeedPage.continuationToken()).as("Response continuation should not be null").isNotNull(); + count += changeFeedPage.getResults().size(); + assertThat(changeFeedPage.getContinuationToken()).as("Response continuation should not be null").isNotNull(); } assertThat(count).as("Change feed should have one newly created document").isEqualTo(1); } @@ -187,17 +187,17 @@ public void changeFeed_fromStartDate() throws Exception { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void changesFromPartitionKey_AfterInsertingNewDocuments() throws Exception { ChangeFeedOptions changeFeedOption = new ChangeFeedOptions(); - changeFeedOption.maxItemCount(3); + changeFeedOption.setMaxItemCount(3); String partitionKey = partitionKeyToDocuments.keySet().iterator().next(); - changeFeedOption.partitionKey(new PartitionKey(partitionKey)); + changeFeedOption.setPartitionKey(new PartitionKey(partitionKey)); List> changeFeedResultsList = client.queryDocumentChangeFeed(getCollectionLink(), changeFeedOption) .collectList().block(); assertThat(changeFeedResultsList).as("only one page").hasSize(1); - assertThat(changeFeedResultsList.get(0).results()).as("no recent changes").isEmpty(); + assertThat(changeFeedResultsList.get(0).getResults()).as("no recent changes").isEmpty(); - String changeFeedContinuation = changeFeedResultsList.get(changeFeedResultsList.size()-1).continuationToken(); + String changeFeedContinuation = changeFeedResultsList.get(changeFeedResultsList.size()-1).getContinuationToken(); assertThat(changeFeedContinuation).as("continuation token is not null").isNotNull(); assertThat(changeFeedContinuation).as("continuation token is not empty").isNotEmpty(); @@ -206,14 +206,14 @@ public void changesFromPartitionKey_AfterInsertingNewDocuments() throws Exceptio client.createDocument(getCollectionLink(), getDocumentDefinition(partitionKey), null, true).single().block(); // READ change feed from continuation - changeFeedOption.requestContinuation(changeFeedContinuation); + changeFeedOption.setRequestContinuation(changeFeedContinuation); FeedResponse changeFeedResults2 = client.queryDocumentChangeFeed(getCollectionLink(), changeFeedOption) .blockFirst(); - assertThat(changeFeedResults2.results()).as("change feed should contain newly inserted docs.").hasSize(2); - assertThat(changeFeedResults2.continuationToken()).as("Response continuation should not be null").isNotNull(); + assertThat(changeFeedResults2.getResults()).as("change feed should contain newly inserted docs.").hasSize(2); + assertThat(changeFeedResults2.getContinuationToken()).as("Response continuation should not be null").isNotNull(); } public void createDocument(AsyncDocumentClient client, String partitionKey) { @@ -227,7 +227,7 @@ public void createDocument(AsyncDocumentClient client, String partitionKey) { public List bulkInsert(AsyncDocumentClient client, List docs) { ArrayList>> result = new ArrayList>>(); for (int i = 0; i < docs.size(); i++) { - result.add(client.createDocument("dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(), docs.get(i), null, false)); + result.add(client.createDocument("dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(), docs.get(i), null, false)); } return Flux.merge(Flux.fromIterable(result), 100).map(ResourceResponse::getResource).collectList().block(); @@ -247,7 +247,7 @@ public void populateDocuments(Method method) { RequestOptions options = new RequestOptions(); options.setOfferThroughput(10100); - createdCollection = createCollection(client, createdDatabase.id(), getCollectionDefinition(), options); + createdCollection = createCollection(client, createdDatabase.getId(), getCollectionDefinition(), options); List docs = new ArrayList<>(); @@ -279,7 +279,7 @@ public void afterClass() { private static Document getDocumentDefinition(String partitionKey) { String uuid = UUID.randomUUID().toString(); Document doc = new Document(); - doc.id(uuid); + doc.setId(uuid); BridgeInternal.setProperty(doc, "mypk", partitionKey); BridgeInternal.setProperty(doc, "prop", uuid); return doc; @@ -290,4 +290,4 @@ private static void waitAtleastASecond(OffsetDateTime befTime) throws Interrupte Thread.sleep(100); } } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java similarity index 63% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java index ddd5157eb6fb..477eeec573bf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionCrudTest.java @@ -2,31 +2,11 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CompositePath; -import com.azure.data.cosmos.CompositePathSortOrder; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.CosmosResponseValidator; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.Database; -import com.azure.data.cosmos.IndexingMode; -import com.azure.data.cosmos.IndexingPolicy; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.PartitionKeyDefinition; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.RetryAnalyzer; -import com.azure.data.cosmos.SpatialSpec; -import com.azure.data.cosmos.SpatialType; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -47,8 +27,8 @@ public class CollectionCrudTest extends TestSuiteBase { private static final int SHUTDOWN_TIMEOUT = 20000; private final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosClient client; - private CosmosDatabase database; + private CosmosAsyncClient client; + private CosmosAsyncDatabase database; @Factory(dataProvider = "clientBuildersWithDirect") public CollectionCrudTest(CosmosClientBuilder clientBuilder) { @@ -71,7 +51,7 @@ private CosmosContainerProperties getCollectionDefinition(String collectionName) PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties( collectionName, @@ -84,11 +64,11 @@ private CosmosContainerProperties getCollectionDefinition(String collectionName) public void createCollection(String collectionName) throws InterruptedException { CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); - Mono createObservable = database + Mono createObservable = database .createContainer(collectionDefinition); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(collectionDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(collectionDefinition.getId()).build(); validateSuccess(createObservable, validator); safeDeleteAllCollections(database); @@ -99,7 +79,7 @@ public void createCollectionWithCompositeIndexAndSpatialSpec() throws Interrupte PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collection = new CosmosContainerProperties( UUID.randomUUID().toString(), @@ -107,21 +87,21 @@ public void createCollectionWithCompositeIndexAndSpatialSpec() throws Interrupte IndexingPolicy indexingPolicy = new IndexingPolicy(); CompositePath compositePath1 = new CompositePath(); - compositePath1.path("/path1"); - compositePath1.order(CompositePathSortOrder.ASCENDING); + compositePath1.setPath("/path1"); + compositePath1.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath2 = new CompositePath(); - compositePath2.path("/path2"); - compositePath2.order(CompositePathSortOrder.DESCENDING); + compositePath2.setPath("/path2"); + compositePath2.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath3 = new CompositePath(); - compositePath3.path("/path3"); + compositePath3.setPath("/path3"); CompositePath compositePath4 = new CompositePath(); - compositePath4.path("/path4"); - compositePath4.order(CompositePathSortOrder.ASCENDING); + compositePath4.setPath("/path4"); + compositePath4.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath5 = new CompositePath(); - compositePath5.path("/path5"); - compositePath5.order(CompositePathSortOrder.DESCENDING); + compositePath5.setPath("/path5"); + compositePath5.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath6 = new CompositePath(); - compositePath6.path("/path6"); + compositePath6.setPath("/path6"); ArrayList compositeIndex1 = new ArrayList(); compositeIndex1.add(compositePath1); @@ -136,7 +116,7 @@ public void createCollectionWithCompositeIndexAndSpatialSpec() throws Interrupte List> compositeIndexes = new ArrayList<>(); compositeIndexes.add(compositeIndex1); compositeIndexes.add(compositeIndex2); - indexingPolicy.compositeIndexes(compositeIndexes); + indexingPolicy.setCompositeIndexes(compositeIndexes); SpatialType[] spatialTypes = new SpatialType[] { SpatialType.POINT, @@ -149,24 +129,24 @@ public void createCollectionWithCompositeIndexAndSpatialSpec() throws Interrupte List collectionOfSpatialTypes = new ArrayList(); SpatialSpec spec = new SpatialSpec(); - spec.path("/path" + index + "/*"); + spec.setPath("/path" + index + "/*"); for (int i = index; i < index + 3; i++) { collectionOfSpatialTypes.add(spatialTypes[i]); } - spec.spatialTypes(collectionOfSpatialTypes); + spec.setSpatialTypes(collectionOfSpatialTypes); spatialIndexes.add(spec); } - indexingPolicy.spatialIndexes(spatialIndexes); + indexingPolicy.setSpatialIndexes(spatialIndexes); - collection.indexingPolicy(indexingPolicy); + collection.setIndexingPolicy(indexingPolicy); - Mono createObservable = database + Mono createObservable = database .createContainer(collection, new CosmosContainerRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(collection.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(collection.getId()) .withCompositeIndexes(compositeIndexes) .withSpatialIndexes(spatialIndexes) .build(); @@ -179,13 +159,13 @@ public void createCollectionWithCompositeIndexAndSpatialSpec() throws Interrupte public void readCollection(String collectionName) throws InterruptedException { CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); - Mono readObservable = collection.read(); + Mono readObservable = collection.read(); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(collection.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(collection.getId()).build(); validateSuccess(readObservable, validator); safeDeleteAllCollections(database); } @@ -193,7 +173,7 @@ public void readCollection(String collectionName) throws InterruptedException { @Test(groups = { "emulator" }, timeOut = TIMEOUT, dataProvider = "collectionCrudArgProvider") public void readCollection_DoesntExist(String collectionName) throws Exception { - Mono readObservable = database + Mono readObservable = database .getContainer("I don't exist").read(); FailureValidator validator = new FailureValidator.Builder().resourceNotFound().build(); @@ -204,12 +184,12 @@ public void readCollection_DoesntExist(String collectionName) throws Exception { public void deleteCollection(String collectionName) throws InterruptedException { CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); - Mono deleteObservable = collection.delete(); + Mono deleteObservable = collection.delete(); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); } @@ -218,20 +198,20 @@ public void deleteCollection(String collectionName) throws InterruptedException public void replaceCollection(String collectionName) throws InterruptedException { // create a collection CosmosContainerProperties collectionDefinition = getCollectionDefinition(collectionName); - Mono createObservable = database.createContainer(collectionDefinition); - CosmosContainer collection = createObservable.block().container(); - CosmosContainerProperties collectionSettings = collection.read().block().properties(); + Mono createObservable = database.createContainer(collectionDefinition); + CosmosAsyncContainer collection = createObservable.block().getContainer(); + CosmosContainerProperties collectionSettings = collection.read().block().getProperties(); // sanity check - assertThat(collectionSettings.indexingPolicy().indexingMode()).isEqualTo(IndexingMode.CONSISTENT); + assertThat(collectionSettings.getIndexingPolicy().getIndexingMode()).isEqualTo(IndexingMode.CONSISTENT); - // replace indexing mode + // replace indexing getMode IndexingPolicy indexingMode = new IndexingPolicy(); - indexingMode.indexingMode(IndexingMode.LAZY); - collectionSettings.indexingPolicy(indexingMode); - Mono readObservable = collection.replace(collectionSettings, new CosmosContainerRequestOptions()); + indexingMode.setIndexingMode(IndexingMode.LAZY); + collectionSettings.setIndexingPolicy(indexingMode); + Mono readObservable = collection.replace(collectionSettings, new CosmosContainerRequestOptions()); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .indexingMode(IndexingMode.LAZY).build(); validateSuccess(readObservable, validator); safeDeleteAllCollections(database); @@ -239,59 +219,59 @@ public void replaceCollection(String collectionName) throws InterruptedException @Test(groups = { "emulator" }, timeOut = 10 * TIMEOUT, retryAnalyzer = RetryAnalyzer.class) public void sessionTokenConsistencyCollectionDeleteCreateSameName() { - CosmosClient client1 = clientBuilder().build(); - CosmosClient client2 = clientBuilder().build(); + CosmosAsyncClient client1 = clientBuilder().buildAsyncClient(); + CosmosAsyncClient client2 = clientBuilder().buildAsyncClient(); String dbId = CosmosDatabaseForTest.generateId(); String collectionId = "coll"; - CosmosDatabase db = null; + CosmosAsyncDatabase db = null; try { Database databaseDefinition = new Database(); - databaseDefinition.id(dbId); + databaseDefinition.setId(dbId); db = createDatabase(client1, dbId); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(collectionId, partitionKeyDef); - CosmosContainer collection = createCollection(db, collectionDefinition, new CosmosContainerRequestOptions()); + CosmosAsyncContainer collection = createCollection(db, collectionDefinition, new CosmosContainerRequestOptions()); CosmosItemProperties document = new CosmosItemProperties(); - document.id("doc"); + document.setId("doc"); BridgeInternal.setProperty(document, "name", "New Document"); BridgeInternal.setProperty(document, "mypk", "mypkValue"); - CosmosItem item = createDocument(collection, document); + CosmosAsyncItem item = createDocument(collection, document); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey("mypkValue")); - CosmosItemResponse readDocumentResponse = item.read(options).block(); - logger.info("Client 1 READ Document Client Side Request Statistics {}", readDocumentResponse.cosmosResponseDiagnosticsString()); - logger.info("Client 1 READ Document Latency {}", readDocumentResponse.requestLatency()); + options.setPartitionKey(new PartitionKey("mypkValue")); + CosmosAsyncItemResponse readDocumentResponse = item.read(options).block(); + logger.info("Client 1 READ Document Client Side Request Statistics {}", readDocumentResponse.getCosmosResponseDiagnosticsString()); + logger.info("Client 1 READ Document Latency {}", readDocumentResponse.getRequestLatency()); BridgeInternal.setProperty(document, "name", "New Updated Document"); - CosmosItemResponse upsertDocumentResponse = collection.upsertItem(document).block(); - logger.info("Client 1 Upsert Document Client Side Request Statistics {}", upsertDocumentResponse.cosmosResponseDiagnosticsString()); - logger.info("Client 1 Upsert Document Latency {}", upsertDocumentResponse.requestLatency()); + CosmosAsyncItemResponse upsertDocumentResponse = collection.upsertItem(document).block(); + logger.info("Client 1 Upsert Document Client Side Request Statistics {}", upsertDocumentResponse.getCosmosResponseDiagnosticsString()); + logger.info("Client 1 Upsert Document Latency {}", upsertDocumentResponse.getRequestLatency()); // DELETE the existing collection deleteCollection(client2, dbId, collectionId); // Recreate the collection with the same name but with different client - CosmosContainer collection2 = createCollection(client2, dbId, collectionDefinition); + CosmosAsyncContainer collection2 = createCollection(client2, dbId, collectionDefinition); CosmosItemProperties newDocument = new CosmosItemProperties(); - newDocument.id("doc"); + newDocument.setId("doc"); BridgeInternal.setProperty(newDocument, "name", "New Created Document"); BridgeInternal.setProperty(newDocument, "mypk", "mypk"); createDocument(collection2, newDocument); - readDocumentResponse = client1.getDatabase(dbId).getContainer(collectionId).getItem(newDocument.id(), newDocument.get("mypk")).read().block(); - logger.info("Client 2 READ Document Client Side Request Statistics {}", readDocumentResponse.cosmosResponseDiagnosticsString()); - logger.info("Client 2 READ Document Latency {}", readDocumentResponse.requestLatency()); + readDocumentResponse = client1.getDatabase(dbId).getContainer(collectionId).getItem(newDocument.getId(), newDocument.get("mypk")).read().block(); + logger.info("Client 2 READ Document Client Side Request Statistics {}", readDocumentResponse.getCosmosResponseDiagnosticsString()); + logger.info("Client 2 READ Document Latency {}", readDocumentResponse.getRequestLatency()); - CosmosItemProperties readDocument = readDocumentResponse.properties(); + CosmosItemProperties readDocument = readDocumentResponse.getProperties(); - assertThat(readDocument.id().equals(newDocument.id())).isTrue(); + assertThat(readDocument.getId().equals(newDocument.getId())).isTrue(); assertThat(readDocument.get("name").equals(newDocument.get("name"))).isTrue(); } finally { safeDeleteDatabase(db); @@ -302,7 +282,7 @@ public void sessionTokenConsistencyCollectionDeleteCreateSameName() { @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); database = createDatabase(client, databaseId); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java similarity index 81% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java index 87e38698d81f..399824438b16 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CollectionQueryTest.java @@ -2,15 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.PartitionKeyDefinition; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.apache.commons.lang3.StringUtils; @@ -30,9 +23,9 @@ public class CollectionQueryTest extends TestSuiteBase { private final static int TIMEOUT = 30000; private final String databaseId = CosmosDatabaseForTest.generateId(); - private List createdCollections = new ArrayList<>(); - private CosmosClient client; - private CosmosDatabase createdDatabase; + private List createdCollections = new ArrayList<>(); + private CosmosAsyncClient client; + private CosmosAsyncDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") public CollectionQueryTest(CosmosClientBuilder clientBuilder) { @@ -43,15 +36,15 @@ public CollectionQueryTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryCollectionsWithFilter() throws Exception { - String filterCollectionId = createdCollections.get(0).id(); + String filterCollectionId = createdCollections.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterCollectionId); FeedOptions options = new FeedOptions(); options.maxItemCount(2); Flux> queryObservable = createdDatabase.queryContainers(query, options); - List expectedCollections = createdCollections.stream() - .filter(c -> StringUtils.equals(filterCollectionId, c.id()) ).collect(Collectors.toList()); + List expectedCollections = createdCollections.stream() + .filter(c -> StringUtils.equals(filterCollectionId, c.getId()) ).collect(Collectors.toList()); assertThat(expectedCollections).isNotEmpty(); @@ -59,7 +52,7 @@ public void queryCollectionsWithFilter() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedCollections.size()) - .exactlyContainsInAnyOrder(expectedCollections.stream().map(d -> d.read().block().properties().resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedCollections.stream().map(d -> d.read().block().getProperties().getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -77,7 +70,7 @@ public void queryAllCollections() throws Exception { options.maxItemCount(2); Flux> queryObservable = createdDatabase.queryContainers(query, options); - List expectedCollections = createdCollections; + List expectedCollections = createdCollections; assertThat(expectedCollections).isNotEmpty(); @@ -85,7 +78,7 @@ public void queryAllCollections() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedCollections.size()) - .exactlyContainsInAnyOrder(expectedCollections.stream().map(d -> d.read().block().properties().resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedCollections.stream().map(d -> d.read().block().getProperties().getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -99,7 +92,7 @@ public void queryCollections_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdDatabase.queryContainers(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -113,13 +106,13 @@ public void queryCollections_NoResults() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, databaseId); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collection = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); createdCollections.add(createCollection(client, databaseId, collection)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosConflictTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosAsyncConflictTest.java similarity index 71% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosConflictTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosAsyncConflictTest.java index 0e8f9ce7e34d..3c47ec2b4c1e 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosConflictTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/CosmosAsyncConflictTest.java @@ -2,12 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosConflictProperties; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.HttpConstants; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -20,14 +16,14 @@ import static org.assertj.core.api.Assertions.assertThat; -public class CosmosConflictTest extends TestSuiteBase { +public class CosmosAsyncConflictTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") - public CosmosConflictTest(CosmosClientBuilder clientBuilder) { + public CosmosAsyncConflictTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } @@ -47,12 +43,12 @@ public void readConflicts_toBlocking_toIterator() { int numberOfResults = 0; while (it.hasNext()) { FeedResponse page = it.next(); - String pageSizeAsString = page.responseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); + String pageSizeAsString = page.getResponseHeaders().get(HttpConstants.HttpHeaders.ITEM_COUNT); assertThat(pageSizeAsString).isNotNull(); // assertThat("header item count must be present", pageSizeAsString, notNullValue()); int pageSize = Integer.valueOf(pageSizeAsString); - // Assert that Result size must match header item count - assertThat(page.results().size()).isEqualTo(pageSize); + // Assert that Result size must match header getItem count + assertThat(page.getResults().size()).isEqualTo(pageSize); numberOfResults += pageSize; } assertThat(numberOfResults).isEqualTo(expectedNumberOfConflicts); @@ -61,7 +57,7 @@ public void readConflicts_toBlocking_toIterator() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } @@ -73,6 +69,6 @@ public void afterClass() { @BeforeMethod(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeMethod() { safeClose(client); - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java similarity index 64% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java index 685cc11c8082..2d2ee1e26740 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseCrudTest.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.CosmosDatabaseResponse; -import com.azure.data.cosmos.CosmosResponseValidator; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.FailureValidator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -23,8 +17,8 @@ public class DatabaseCrudTest extends TestSuiteBase { private final String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); private final List databases = new ArrayList<>(); - private CosmosClient client; - private CosmosDatabase createdDatabase; + private CosmosAsyncClient client; + private CosmosAsyncDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") public DatabaseCrudTest(CosmosClientBuilder clientBuilder) { @@ -34,26 +28,26 @@ public DatabaseCrudTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void createDatabase() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); // create the database - Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); + Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(databaseDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(databaseDefinition.getId()).build(); validateSuccess(createObservable, validator); } @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void createDatabase_AlreadyExists() throws Exception { CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); + databases.add(databaseDefinition.getId()); client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block(); // attempt to create the database - Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); + Mono createObservable = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); // validate FailureValidator validator = new FailureValidator.Builder().resourceAlreadyExists().build(); @@ -63,10 +57,10 @@ public void createDatabase_AlreadyExists() throws Exception { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void readDatabase() throws Exception { // read database - Mono readObservable = client.getDatabase(preExistingDatabaseId).read(); + Mono readObservable = client.getDatabase(preExistingDatabaseId).read(); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withId(preExistingDatabaseId).build(); validateSuccess(readObservable, validator); } @@ -74,7 +68,7 @@ public void readDatabase() throws Exception { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void readDatabase_DoesntExist() throws Exception { // read database - Mono readObservable = client.getDatabase("I don't exist").read(); + Mono readObservable = client.getDatabase("I don't exist").read(); // validate FailureValidator validator = new FailureValidator.Builder().resourceNotFound().build(); @@ -86,14 +80,14 @@ public void readDatabase_DoesntExist() throws Exception { public void deleteDatabase() throws Exception { // create the database CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); - databases.add(databaseDefinition.id()); - CosmosDatabase database = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().database(); + databases.add(databaseDefinition.getId()); + CosmosAsyncDatabase database = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()).block().getDatabase(); // delete the database - Mono deleteObservable = database.delete(); + Mono deleteObservable = database.delete(); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); } @@ -101,7 +95,7 @@ public void deleteDatabase() throws Exception { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void deleteDatabase_DoesntExist() throws Exception { // delete the database - Mono deleteObservable = client.getDatabase("I don't exist").delete(); + Mono deleteObservable = client.getDatabase("I don't exist").delete(); // validate FailureValidator validator = new FailureValidator.Builder().resourceNotFound().build(); @@ -110,7 +104,7 @@ public void deleteDatabase_DoesntExist() throws Exception { @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, preExistingDatabaseId); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java similarity index 84% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java index 95fb7f6ecc70..9f4d814f15ed 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DatabaseQueryTest.java @@ -2,13 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.apache.commons.lang3.StringUtils; @@ -29,9 +24,9 @@ public class DatabaseQueryTest extends TestSuiteBase { public final String databaseId1 = CosmosDatabaseForTest.generateId(); public final String databaseId2 = CosmosDatabaseForTest.generateId(); - private List createdDatabases = new ArrayList<>(); + private List createdDatabases = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public DatabaseQueryTest(CosmosClientBuilder clientBuilder) { @@ -47,7 +42,7 @@ public void queryDatabaseWithFilter() throws Exception { Flux> queryObservable = client.queryDatabases(query, options); List expectedDatabases = createdDatabases.stream() - .filter(d -> StringUtils.equals(databaseId1, d.id()) ).map(d -> d.read().block().properties()).collect(Collectors.toList()); + .filter(d -> StringUtils.equals(databaseId1, d.getId()) ).map(d -> d.read().block().getProperties()).collect(Collectors.toList()); assertThat(expectedDatabases).isNotEmpty(); @@ -55,7 +50,7 @@ public void queryDatabaseWithFilter() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDatabases.size()) - .exactlyContainsInAnyOrder(expectedDatabases.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -75,7 +70,7 @@ public void queryAllDatabase() throws Exception { options.maxItemCount(2); Flux> queryObservable = client.queryDatabases(query, options); - List expectedDatabases = createdDatabases.stream().map(d -> d.read().block().properties()).collect(Collectors.toList()); + List expectedDatabases = createdDatabases.stream().map(d -> d.read().block().getProperties()).collect(Collectors.toList()); assertThat(expectedDatabases).isNotEmpty(); @@ -83,7 +78,7 @@ public void queryAllDatabase() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDatabases.size()) - .exactlyContainsInAnyOrder(expectedDatabases.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -97,7 +92,7 @@ public void queryDatabases_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = client.queryDatabases(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -111,7 +106,7 @@ public void queryDatabases_NoResults() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabases.add(createDatabase(client, databaseId1)); createdDatabases.add(createDatabase(client, databaseId2)); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java similarity index 84% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java index fca51e0e65bb..51ab8c2858f7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentClientResourceLeakTest.java @@ -2,11 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.google.common.base.Strings; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; @@ -23,8 +20,8 @@ public class DocumentClientResourceLeakTest extends TestSuiteBase { private static final int TIMEOUT = 2400000; private static final int MAX_NUMBER = 1000; - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; @Factory(dataProvider = "simpleClientBuildersWithDirect") public DocumentClientResourceLeakTest(CosmosClientBuilder clientBuilder) { @@ -40,10 +37,10 @@ public void resourceLeak() throws Exception { for (int i = 0; i < MAX_NUMBER; i++) { logger.info("CLIENT {}", i); - CosmosClient client = this.clientBuilder().build(); + CosmosAsyncClient client = this.clientBuilder().buildAsyncClient(); try { logger.info("creating document"); - createDocument(client.getDatabase(createdDatabase.id()).getContainer(createdCollection.id()), + createDocument(client.getDatabase(createdDatabase.getId()).getContainer(createdCollection.getId()), getDocumentDefinition()); } finally { logger.info("closing client"); @@ -66,7 +63,7 @@ public void resourceLeak() throws Exception { @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { - CosmosClient client = this.clientBuilder().build(); + CosmosAsyncClient client = this.clientBuilder().buildAsyncClient(); try { createdDatabase = getSharedCosmosDatabase(client); createdCollection = getSharedMultiPartitionCosmosContainer(client); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java index b56ff5bd257c..9b04b04800cf 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/DocumentCrudTest.java @@ -2,17 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.PartitionKey; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncItem; import com.azure.data.cosmos.internal.FailureValidator; import org.apache.commons.lang3.StringUtils; import org.testng.annotations.DataProvider; @@ -33,8 +24,8 @@ public class DocumentCrudTest extends TestSuiteBase { - private CosmosClient client; - private CosmosContainer container; + private CosmosAsyncClient client; + private CosmosAsyncContainer container; @Factory(dataProvider = "clientBuildersWithDirect") public DocumentCrudTest(CosmosClientBuilder clientBuilder) { @@ -55,10 +46,10 @@ public Object[][] documentCrudArgProvider() { public void createDocument(String documentId) throws InterruptedException { CosmosItemProperties properties = getDocumentDefinition(documentId); - Mono createObservable = container.createItem(properties, new CosmosItemRequestOptions()); + Mono createObservable = container.createItem(properties, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(properties.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(properties.getId()) .build(); validateSuccess(createObservable, validator); @@ -72,10 +63,10 @@ public void createLargeDocument(String documentId) throws InterruptedException { int size = (int) (ONE_MB * 1.5); BridgeInternal.setProperty(docDefinition, "largeString", StringUtils.repeat("x", size)); - Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); + Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()) .build(); validateSuccess(createObservable, validator); @@ -90,10 +81,10 @@ public void createDocumentWithVeryLargePartitionKey(String documentId) throws In } BridgeInternal.setProperty(docDefinition, "mypk", sb.toString()); - Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); + Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()) .withProperty("mypk", sb.toString()) .build(); validateSuccess(createObservable, validator); @@ -108,16 +99,16 @@ public void readDocumentWithVeryLargePartitionKey(String documentId) throws Inte } BridgeInternal.setProperty(docDefinition, "mypk", sb.toString()); - CosmosItem createdDocument = TestSuiteBase.createDocument(container, docDefinition); + CosmosAsyncItem createdDocument = TestSuiteBase.createDocument(container, docDefinition); waitIfNeededForReplicasToCatchUp(clientBuilder()); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(sb.toString())); - Mono readObservable = createdDocument.read(options); + options.setPartitionKey(new PartitionKey(sb.toString())); + Mono readObservable = createdDocument.read(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()) .withProperty("mypk", sb.toString()) .build(); validateSuccess(readObservable, validator); @@ -127,7 +118,7 @@ public void readDocumentWithVeryLargePartitionKey(String documentId) throws Inte public void createDocument_AlreadyExists(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); container.createItem(docDefinition, new CosmosItemRequestOptions()).block(); - Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); + Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()); FailureValidator validator = new FailureValidator.Builder().resourceAlreadyExists().build(); validateFailure(createObservable, validator); } @@ -135,7 +126,7 @@ public void createDocument_AlreadyExists(String documentId) throws InterruptedEx @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "documentCrudArgProvider") public void createDocumentTimeout(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()).timeout(Duration.ofMillis(1)); + Mono createObservable = container.createItem(docDefinition, new CosmosItemRequestOptions()).timeout(Duration.ofMillis(1)); FailureValidator validator = new FailureValidator.Builder().instanceOf(TimeoutException.class).build(); validateFailure(createObservable, validator); } @@ -144,16 +135,16 @@ public void createDocumentTimeout(String documentId) throws InterruptedException public void readDocument(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); waitIfNeededForReplicasToCatchUp(clientBuilder()); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); - Mono readObservable = document.read(options); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); + Mono readObservable = document.read(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(document.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(document.getId()) .build(); validateSuccess(readObservable, validator); @@ -166,34 +157,34 @@ public void timestamp(String documentId) throws Exception { OffsetDateTime before = OffsetDateTime.now(); CosmosItemProperties docDefinition = getDocumentDefinition(documentId); Thread.sleep(1000); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); waitIfNeededForReplicasToCatchUp(clientBuilder()); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); - CosmosItemProperties readDocument = document.read(options).block().properties(); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); + CosmosItemProperties readDocument = document.read(options).block().getProperties(); Thread.sleep(1000); OffsetDateTime after = OffsetDateTime.now(); - assertThat(readDocument.timestamp()).isAfterOrEqualTo(before); - assertThat(readDocument.timestamp()).isBeforeOrEqualTo(after); + assertThat(readDocument.getTimestamp()).isAfterOrEqualTo(before); + assertThat(readDocument.getTimestamp()).isBeforeOrEqualTo(after); } @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "documentCrudArgProvider") public void readDocument_DoesntExist(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); document.delete(options).block(); waitIfNeededForReplicasToCatchUp(clientBuilder()); - options.partitionKey(new PartitionKey("looloo")); - Mono readObservable = document.read(options); + options.setPartitionKey(new PartitionKey("looloo")); + Mono readObservable = document.read(options); FailureValidator validator = new FailureValidator.Builder().instanceOf(CosmosClientException.class) .statusCode(404).build(); @@ -204,21 +195,21 @@ public void readDocument_DoesntExist(String documentId) throws InterruptedExcept public void deleteDocument(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); - Mono deleteObservable = document.delete(options); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); + Mono deleteObservable = document.delete(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); // attempt to read document which was deleted waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = document.read(options); + Mono readObservable = document.read(options); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(readObservable, notFoundValidator); } @@ -226,22 +217,22 @@ public void deleteDocument(String documentId) throws InterruptedException { @Test(groups = { "simple" }, timeOut = TIMEOUT, dataProvider = "documentCrudArgProvider") public void deleteDocument_undefinedPK(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = new CosmosItemProperties(); - docDefinition.id(documentId); + docDefinition.setId(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(PartitionKey.None); - Mono deleteObservable = document.delete(options); + options.setPartitionKey(PartitionKey.None); + Mono deleteObservable = document.delete(options); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource().build(); validateSuccess(deleteObservable, validator); // attempt to read document which was deleted waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = document.read(options); + Mono readObservable = document.read(options); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(readObservable, notFoundValidator); } @@ -250,14 +241,14 @@ public void deleteDocument_undefinedPK(String documentId) throws InterruptedExce public void deleteDocument_DoesntExist(String documentId) throws InterruptedException { CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); document.delete(options).block(); // delete again - Mono deleteObservable = document.delete(options); + Mono deleteObservable = document.delete(options); FailureValidator validator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(deleteObservable, validator); @@ -268,18 +259,18 @@ public void replaceDocument(String documentId) throws InterruptedException { // create a document CosmosItemProperties docDefinition = getDocumentDefinition(documentId); - CosmosItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().item(); + CosmosAsyncItem document = container.createItem(docDefinition, new CosmosItemRequestOptions()).block().getItem(); String newPropValue = UUID.randomUUID().toString(); BridgeInternal.setProperty(docDefinition, "newProp", newPropValue); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(docDefinition.get("mypk"))); + options.setPartitionKey(new PartitionKey(docDefinition.get("mypk"))); // replace document - Mono replaceObservable = document.replace(docDefinition, options); + Mono replaceObservable = document.replace(docDefinition, options); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withProperty("newProp", newPropValue).build(); validateSuccess(replaceObservable, validator); } @@ -291,11 +282,11 @@ public void upsertDocument_CreateDocument(String documentId) throws Throwable { // replace document - Mono upsertObservable = container.upsertItem(docDefinition, new CosmosItemRequestOptions()); + Mono upsertObservable = container.upsertItem(docDefinition, new CosmosItemRequestOptions()); // validate - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(upsertObservable, validator); } @@ -304,19 +295,19 @@ public void upsertDocument_CreateDocument(String documentId) throws Throwable { public void upsertDocument_ReplaceDocument(String documentId) throws Throwable { CosmosItemProperties properties = getDocumentDefinition(documentId); - properties = container.createItem(properties, new CosmosItemRequestOptions()).block().properties(); + properties = container.createItem(properties, new CosmosItemRequestOptions()).block().getProperties(); String newPropValue = UUID.randomUUID().toString(); BridgeInternal.setProperty(properties, "newProp", newPropValue); // Replace document - Mono readObservable = container.upsertItem(properties, new CosmosItemRequestOptions()); + Mono readObservable = container.upsertItem(properties, new CosmosItemRequestOptions()); System.out.println(properties); // Validate result - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .withProperty("newProp", newPropValue).build(); validateSuccess(readObservable, validator); @@ -325,7 +316,7 @@ public void upsertDocument_ReplaceDocument(String documentId) throws Throwable { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = this.clientBuilder().build(); + this.client = this.clientBuilder().buildAsyncClient(); this.container = getSharedMultiPartitionCosmosContainer(this.client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java similarity index 77% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java index 15bfbd217e9c..d72e7d28ea08 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/LogLevelTest.java @@ -3,12 +3,8 @@ package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.CosmosResponseValidator; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -37,8 +33,8 @@ public class LogLevelTest extends TestSuiteBase { public final static String LOG_PATTERN_3 = "USER_EVENT: SslHandshakeCompletionEvent(SUCCESS)"; public final static String LOG_PATTERN_4 = "CONNECT: "; - private static CosmosContainer createdCollection; - private static CosmosClient client; + private static CosmosAsyncContainer createdCollection; + private static CosmosAsyncClient client; public LogLevelTest() { super(createGatewayRxDocumentClient()); @@ -46,7 +42,7 @@ public LogLevelTest() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } @@ -63,13 +59,13 @@ public void createDocumentWithDebugLevel() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); LogManager.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).isEmpty(); @@ -93,13 +89,13 @@ public void createDocumentWithWarningLevel() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).isEmpty(); @@ -124,13 +120,13 @@ public void createDocumentWithTraceLevel() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).contains(LOG_PATTERN_1); @@ -153,13 +149,13 @@ public void createDocumentWithTraceLevelAtRoot() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).contains(LOG_PATTERN_1); @@ -179,13 +175,13 @@ public void createDocumentWithDebugLevelAtRoot() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).isEmpty(); @@ -208,13 +204,13 @@ public void createDocumentWithErrorClient() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).isEmpty(); @@ -237,13 +233,13 @@ public void createDocumentWithInfoLevel() throws Exception { WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(NETWORK_LOGGING_CATEGORY).addAppender(appender); - CosmosClient client = clientBuilder().build(); + CosmosAsyncClient client = clientBuilder().buildAsyncClient(); try { CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = createdCollection.createItem(docDefinition, + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()).build(); + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()).build(); validateSuccess(createObservable, validator); assertThat(consoleWriter.toString()).isEmpty(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java similarity index 66% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java index 0f8996e31132..8555cbf267ca 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiMasterConflictResolutionTest.java @@ -2,21 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeUtils; -import com.azure.data.cosmos.ConflictResolutionMode; -import com.azure.data.cosmos.ConflictResolutionPolicy; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.PartitionKeyDefinition; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; -import com.azure.data.cosmos.internal.TestUtils; import com.azure.data.cosmos.internal.Utils; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -37,8 +25,8 @@ public class MultiMasterConflictResolutionTest extends TestSuiteBase { private final String databaseId = CosmosDatabaseForTest.generateId(); private PartitionKeyDefinition partitionKeyDef; - private CosmosClient client; - private CosmosDatabase database; + private CosmosAsyncClient client; + private CosmosAsyncDatabase database; @Factory(dataProvider = "clientBuilders") public MultiMasterConflictResolutionTest(CosmosClientBuilder clientBuilder) { @@ -50,17 +38,17 @@ public void conflictResolutionPolicyCRUD() { // default last writer wins, path _ts CosmosContainerProperties collectionSettings = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); - CosmosContainer collection = database.createContainer(collectionSettings, new CosmosContainerRequestOptions()).block().container(); - collectionSettings = collection.read().block().properties(); + CosmosAsyncContainer collection = database.createContainer(collectionSettings, new CosmosContainerRequestOptions()).block().getContainer(); + collectionSettings = collection.read().block().getProperties(); - assertThat(collectionSettings.conflictResolutionPolicy().mode()).isEqualTo(ConflictResolutionMode.LAST_WRITER_WINS); + assertThat(collectionSettings.getConflictResolutionPolicy().getMode()).isEqualTo(ConflictResolutionMode.LAST_WRITER_WINS); - // LWW without path specified, should default to _ts - collectionSettings.conflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy()); - collectionSettings = collection.replace(collectionSettings, null).block().properties(); + // LWW without getPath specified, should default to _ts + collectionSettings.setConflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy()); + collectionSettings = collection.replace(collectionSettings, null).block().getProperties(); - assertThat(collectionSettings.conflictResolutionPolicy().mode()).isEqualTo(ConflictResolutionMode.LAST_WRITER_WINS); - assertThat(collectionSettings.conflictResolutionPolicy().conflictResolutionPath()).isEqualTo("/_ts"); + assertThat(collectionSettings.getConflictResolutionPolicy().getMode()).isEqualTo(ConflictResolutionMode.LAST_WRITER_WINS); + assertThat(collectionSettings.getConflictResolutionPolicy().getConflictResolutionPath()).isEqualTo("/_ts"); // Tests the following scenarios // 1. LWW with valid path @@ -69,34 +57,34 @@ public void conflictResolutionPolicyCRUD() { testConflictResolutionPolicyRequiringPath(ConflictResolutionMode.LAST_WRITER_WINS, new String[] { "/a", null, "" }, new String[] { "/a", "/_ts", "/_ts" }); - // LWW invalid path - collectionSettings.conflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy("/a/b")); + // LWW invalid getPath + collectionSettings.setConflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy("/a/b")); try { - collectionSettings = collection.replace(collectionSettings, null).block().properties(); - fail("Expected exception on invalid path."); + collectionSettings = collection.replace(collectionSettings, null).block().getProperties(); + fail("Expected exception on invalid getPath."); } catch (Exception e) { // when (e.StatusCode == HttpStatusCode.BadRequest) CosmosClientException dce = Utils.as(e.getCause(), CosmosClientException.class); - if (dce != null && dce.statusCode() == 400) { + if (dce != null && dce.getStatusCode() == 400) { assertThat(dce.getMessage()).contains("Invalid path '\\/a\\/b' for last writer wins conflict resolution"); } else { throw e; } } - // LWW invalid path + // LWW invalid getPath - collectionSettings.conflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy("someText")); + collectionSettings.setConflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy("someText")); try { - collectionSettings = collection.replace(collectionSettings, null).block().properties(); + collectionSettings = collection.replace(collectionSettings, null).block().getProperties(); fail("Expected exception on invalid path."); } catch (Exception e) { // when (e.StatusCode == HttpStatusCode.BadRequest) CosmosClientException dce = Utils.as(e.getCause(), CosmosClientException.class); - if (dce != null && dce.statusCode() == 400) { + if (dce != null && dce.getStatusCode() == 400) { assertThat(dce.getMessage()).contains("Invalid path 'someText' for last writer wins conflict resolution"); } else { throw e; @@ -117,17 +105,17 @@ private void testConflictResolutionPolicyRequiringPath(ConflictResolutionMode co CosmosContainerProperties collectionSettings = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); if (conflictResolutionMode == ConflictResolutionMode.LAST_WRITER_WINS) { - collectionSettings.conflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy(paths[i])); + collectionSettings.setConflictResolutionPolicy(ConflictResolutionPolicy.createLastWriterWinsPolicy(paths[i])); } else { - collectionSettings.conflictResolutionPolicy(ConflictResolutionPolicy.createCustomPolicy(paths[i])); + collectionSettings.setConflictResolutionPolicy(ConflictResolutionPolicy.createCustomPolicy(paths[i])); } - collectionSettings = database.createContainer(collectionSettings, new CosmosContainerRequestOptions()).block().properties(); - assertThat(collectionSettings.conflictResolutionPolicy().mode()).isEqualTo(conflictResolutionMode); + collectionSettings = database.createContainer(collectionSettings, new CosmosContainerRequestOptions()).block().getProperties(); + assertThat(collectionSettings.getConflictResolutionPolicy().getMode()).isEqualTo(conflictResolutionMode); if (conflictResolutionMode == ConflictResolutionMode.LAST_WRITER_WINS) { - assertThat(collectionSettings.conflictResolutionPolicy().conflictResolutionPath()).isEqualTo(expectedPaths[i]); + assertThat(collectionSettings.getConflictResolutionPolicy().getConflictResolutionPath()).isEqualTo(expectedPaths[i]); } else { - assertThat(collectionSettings.conflictResolutionPolicy().conflictResolutionProcedure()).isEqualTo(expectedPaths[i]); + assertThat(collectionSettings.getConflictResolutionPolicy().getConflictResolutionProcedure()).isEqualTo(expectedPaths[i]); } } } @@ -140,9 +128,9 @@ public void invalidConflictResolutionPolicy_LastWriterWinsWithStoredProc() throw ConflictResolutionPolicy policy = BridgeUtils.createConflictResolutionPolicy(); BridgeUtils.setMode(policy, ConflictResolutionMode.LAST_WRITER_WINS); BridgeUtils.setStoredProc(policy,"randomSprocName"); - collection.conflictResolutionPolicy(policy); + collection.setConflictResolutionPolicy(policy); - Mono createObservable = database.createContainer( + Mono createObservable = database.createContainer( collection, new CosmosContainerRequestOptions()); @@ -158,13 +146,13 @@ public void invalidConflictResolutionPolicy_LastWriterWinsWithStoredProc() throw public void invalidConflictResolutionPolicy_CustomWithPath() throws Exception { CosmosContainerProperties collection = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); - // LWW without path specified, should default to _ts + // LWW without getPath specified, should default to _ts ConflictResolutionPolicy policy = BridgeUtils.createConflictResolutionPolicy(); BridgeUtils.setMode(policy, ConflictResolutionMode.CUSTOM); BridgeUtils.setPath(policy,"/mypath"); - collection.conflictResolutionPolicy(policy); + collection.setConflictResolutionPolicy(policy); - Mono createObservable = database.createContainer( + Mono createObservable = database.createContainer( collection, new CosmosContainerRequestOptions()); @@ -180,12 +168,12 @@ public void invalidConflictResolutionPolicy_CustomWithPath() throws Exception { public void beforeClass() { // set up the client - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); database = createDatabase(client, databaseId); partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); } @AfterClass(groups = {"multi-master"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java index 6f9474351745..9c6f9fec4807 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/MultiOrderByQueryTests.java @@ -3,18 +3,8 @@ package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CompositePath; -import com.azure.data.cosmos.CompositePathSortOrder; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.fasterxml.jackson.databind.ObjectMapper; @@ -50,8 +40,8 @@ public class MultiOrderByQueryTests extends TestSuiteBase { private static final String LONG_STRING_FIELD = "longStringField"; private static final String PARTITION_KEY = "pk"; private List documents = new ArrayList(); - private CosmosContainer documentCollection; - private CosmosClient client; + private CosmosAsyncContainer documentCollection; + private CosmosAsyncClient client; class CustomComparator implements Comparator { String path; @@ -120,7 +110,7 @@ public void afterClass() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); documentCollection = getSharedMultiPartitionCosmosContainerWithCompositeAndSpatialIndexes(client); truncateCollection(documentCollection); @@ -135,29 +125,29 @@ public void beforeClass() throws Exception { for (int j = 0; j < numberOfDuplicates; j++) { // Add the document itself for exact duplicates CosmosItemProperties initialDocument = new CosmosItemProperties(multiOrderByDocumentString); - initialDocument.id(UUID.randomUUID().toString()); + initialDocument.setId(UUID.randomUUID().toString()); this.documents.add(initialDocument); // Permute all the fields so that there are duplicates with tie breaks CosmosItemProperties numberClone = new CosmosItemProperties(multiOrderByDocumentString); BridgeInternal.setProperty(numberClone, NUMBER_FIELD, random.nextInt(5)); - numberClone.id(UUID.randomUUID().toString()); + numberClone.setId(UUID.randomUUID().toString()); this.documents.add(numberClone); CosmosItemProperties stringClone = new CosmosItemProperties(multiOrderByDocumentString); BridgeInternal.setProperty(stringClone, STRING_FIELD, Integer.toString(random.nextInt(5))); - stringClone.id(UUID.randomUUID().toString()); + stringClone.setId(UUID.randomUUID().toString()); this.documents.add(stringClone); CosmosItemProperties boolClone = new CosmosItemProperties(multiOrderByDocumentString); BridgeInternal.setProperty(boolClone, BOOL_FIELD, random.nextInt(2) % 2 == 0); - boolClone.id(UUID.randomUUID().toString()); + boolClone.setId(UUID.randomUUID().toString()); this.documents.add(boolClone); // Also fuzz what partition it goes to CosmosItemProperties partitionClone = new CosmosItemProperties(multiOrderByDocumentString); BridgeInternal.setProperty(partitionClone, PARTITION_KEY, random.nextInt(5)); - partitionClone.id(UUID.randomUUID().toString()); + partitionClone.setId(UUID.randomUUID().toString()); this.documents.add(partitionClone); } } @@ -170,7 +160,7 @@ public void beforeClass() throws Exception { private CosmosItemProperties generateMultiOrderByDocument() { Random random = new Random(); CosmosItemProperties document = new CosmosItemProperties(); - document.id(UUID.randomUUID().toString()); + document.setId(UUID.randomUUID().toString()); BridgeInternal.setProperty(document, NUMBER_FIELD, random.nextInt(5)); BridgeInternal.setProperty(document, NUMBER_FIELD_2, random.nextInt(5)); BridgeInternal.setProperty(document, BOOL_FIELD, (random.nextInt() % 2) == 0); @@ -189,11 +179,11 @@ private CosmosItemProperties generateMultiOrderByDocument() { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryDocumentsWithMultiOrder() throws CosmosClientException, InterruptedException { FeedOptions feedOptions = new FeedOptions(); - feedOptions.enableCrossPartitionQuery(true); + feedOptions.setEnableCrossPartitionQuery(true); boolean[] booleanValues = new boolean[] {true, false}; - CosmosContainerProperties containerSettings = documentCollection.read().block().properties(); - Iterator> compositeIndexesIterator = containerSettings.indexingPolicy().compositeIndexes().iterator(); + CosmosContainerProperties containerSettings = documentCollection.read().block().getProperties(); + Iterator> compositeIndexesIterator = containerSettings.getIndexingPolicy().getCompositeIndexes().iterator(); while (compositeIndexesIterator.hasNext()) { List compositeIndex = compositeIndexesIterator.next(); // for every order @@ -210,13 +200,13 @@ public void queryDocumentsWithMultiOrder() throws CosmosClientException, Interru Iterator compositeIndexiterator = compositeIndex.iterator(); while (compositeIndexiterator.hasNext()) { CompositePath compositePath = compositeIndexiterator.next(); - isDesc = compositePath.order() == CompositePathSortOrder.DESCENDING ? true : false; + isDesc = compositePath.getOrder() == CompositePathSortOrder.DESCENDING ? true : false; if (invert) { isDesc = !isDesc; } String isDescString = isDesc ? "DESC" : "ASC"; - String compositePathName = compositePath.path().replaceAll("/", ""); + String compositePathName = compositePath.getPath().replaceAll("/", ""); String orderByItemsString = "root." + compositePathName + " " + isDescString; String selectItemsString = "root." + compositePathName; orderByItems.add(orderByItemsString); @@ -293,7 +283,7 @@ private List sort(List arrayList, Li Iterator compositeIndexIterator = compositeIndex.iterator(); while (compositeIndexIterator.hasNext()) { CompositePath compositePath = compositeIndexIterator.next(); - CompositePathSortOrder order = compositePath.order(); + CompositePathSortOrder order = compositePath.getOrder(); if (invert) { if (order == CompositePathSortOrder.DESCENDING) { order = CompositePathSortOrder.ASCENDING; @@ -301,7 +291,7 @@ private List sort(List arrayList, Li order = CompositePathSortOrder.DESCENDING; } } - String path = compositePath.path().replace("/", ""); + String path = compositePath.getPath().replace("/", ""); comparators.add(new CustomComparator(path, order)); } Collections.sort(arrayList, ComparatorUtils.chainedComparator(comparators)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java index 700609e63162..8f70819be9ed 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferQueryTest.java @@ -46,14 +46,14 @@ public OfferQueryTest(Builder clientBuilder) { @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void queryOffersWithFilter() throws Exception { - String collectionResourceId = createdCollections.get(0).resourceId(); + String collectionResourceId = createdCollections.get(0).getResourceId(); String query = String.format("SELECT * from c where c.offerResourceId = '%s'", collectionResourceId); FeedOptions options = new FeedOptions(); options.maxItemCount(2); Flux> queryObservable = client.queryOffers(query, null); - List allOffers = client.readOffers(null).flatMap(f -> Flux.fromIterable(f.results())).collectList().single().block(); + List allOffers = client.readOffers(null).flatMap(f -> Flux.fromIterable(f.getResults())).collectList().single().block(); List expectedOffers = allOffers.stream().filter(o -> collectionResourceId.equals(o.getString("offerResourceId"))).collect(Collectors.toList()); assertThat(expectedOffers).isNotEmpty(); @@ -62,7 +62,7 @@ public void queryOffersWithFilter() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedOffers.size()) - .exactlyContainsInAnyOrder(expectedOffers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedOffers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -74,7 +74,7 @@ public void queryOffersWithFilter() throws Exception { @Test(groups = { "emulator" }, timeOut = TIMEOUT * 100) public void queryOffersFilterMorePages() throws Exception { - List collectionResourceIds = createdCollections.stream().map(c -> c.resourceId()).collect(Collectors.toList()); + List collectionResourceIds = createdCollections.stream().map(c -> c.getResourceId()).collect(Collectors.toList()); String query = String.format("SELECT * from c where c.offerResourceId in (%s)", Strings.join(collectionResourceIds.stream().map(s -> "'" + s + "'").collect(Collectors.toList())).with(",")); @@ -82,7 +82,7 @@ public void queryOffersFilterMorePages() throws Exception { options.maxItemCount(1); Flux> queryObservable = client.queryOffers(query, options); - List expectedOffers = client.readOffers(null).flatMap(f -> Flux.fromIterable(f.results())) + List expectedOffers = client.readOffers(null).flatMap(f -> Flux.fromIterable(f.getResults())) .collectList() .single().block() .stream().filter(o -> collectionResourceIds.contains(o.getOfferResourceId())) @@ -94,7 +94,7 @@ public void queryOffersFilterMorePages() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedOffers.size()) - .exactlyContainsInAnyOrder(expectedOffers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedOffers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -124,17 +124,17 @@ public void beforeClass() throws Exception { client = clientBuilder().build(); Database d1 = new Database(); - d1.id(databaseId); + d1.setId(databaseId); createDatabase(client, d1); for(int i = 0; i < 3; i++) { DocumentCollection collection = new DocumentCollection(); - collection.id(UUID.randomUUID().toString()); + collection.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collection.setPartitionKey(partitionKeyDef); createdCollections.add(createCollection(client, databaseId, collection)); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java similarity index 92% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java index 0256708d3d75..b0468c60e5b9 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OfferReadReplaceTest.java @@ -36,17 +36,17 @@ public void readAndReplaceOffer() { client.readOffers(null).subscribe((offersFeed) -> { try { int i; - List offers = offersFeed.results(); + List offers = offersFeed.getResults(); for (i = 0; i < offers.size(); i++) { - if (offers.get(i).getOfferResourceId().equals(createdCollection.resourceId())) { + if (offers.get(i).getOfferResourceId().equals(createdCollection.getResourceId())) { break; } } - Offer rOffer = client.readOffer(offers.get(i).selfLink()).single().block().getResource(); + Offer rOffer = client.readOffer(offers.get(i).getSelfLink()).single().block().getResource(); int oldThroughput = rOffer.getThroughput(); - Flux> readObservable = client.readOffer(offers.get(i).selfLink()); + Flux> readObservable = client.readOffer(offers.get(i).getSelfLink()); // validate offer read ResourceResponseValidator validatorForRead = new ResourceResponseValidator.Builder() @@ -80,7 +80,7 @@ public void readAndReplaceOffer() { public void beforeClass() { client = clientBuilder().build(); createdDatabase = createDatabase(client, databaseId); - createdCollection = createCollection(client, createdDatabase.id(), + createdCollection = createCollection(client, createdDatabase.getId(), getCollectionDefinition()); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java index 8f60fd8dc632..691c4a6ef6b5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/OrderbyDocumentQueryTest.java @@ -2,18 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.Resource; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.*; import com.azure.data.cosmos.internal.Utils.ValueHolder; import com.azure.data.cosmos.internal.query.CompositeContinuationToken; @@ -50,9 +40,9 @@ public class OrderbyDocumentQueryTest extends TestSuiteBase { private final double minQueryRequestChargePerPartition = 2.0; - private CosmosClient client; - private CosmosContainer createdCollection; - private CosmosDatabase createdDatabase; + private CosmosAsyncClient client; + private CosmosAsyncContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; private List createdDocuments = new ArrayList<>(); private int numberOfPartitions; @@ -73,17 +63,17 @@ public void queryDocumentsValidateContent(boolean qmEnabled) throws Exception { , expectedDocument.getString("propStr")); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(qmEnabled); Flux> queryObservable = createdCollection.queryItems(query, options); List expectedResourceIds = new ArrayList<>(); - expectedResourceIds.add(expectedDocument.resourceId()); + expectedResourceIds.add(expectedDocument.getResourceId()); Map> resourceIDToValidator = new HashMap<>(); - resourceIDToValidator.put(expectedDocument.resourceId(), + resourceIDToValidator.put(expectedDocument.getResourceId(), new ResourceValidator.Builder().areEqual(expectedDocument).build()); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -102,7 +92,7 @@ public void queryDocumentsValidateContent(boolean qmEnabled) throws Exception { public void queryDocuments_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2' ORDER BY r.propInt"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -125,7 +115,7 @@ public Object[][] sortOrder() { public void queryOrderBy(String sortOrder) throws Exception { String query = String.format("SELECT * FROM r ORDER BY r.propInt %s", sortOrder); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); int pageSize = 3; options.maxItemCount(pageSize); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -153,7 +143,7 @@ public void queryOrderBy(String sortOrder) throws Exception { public void queryOrderByInt() throws Exception { String query = "SELECT * FROM r ORDER BY r.propInt"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); int pageSize = 3; options.maxItemCount(pageSize); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -177,7 +167,7 @@ public void queryOrderByInt() throws Exception { public void queryOrderByString() throws Exception { String query = "SELECT * FROM r ORDER BY r.propStr"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); int pageSize = 3; options.maxItemCount(pageSize); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -207,7 +197,7 @@ public Object[][] topValueParameter() { public void queryOrderWithTop(int topValue) throws Exception { String query = String.format("SELECT TOP %d * FROM r ORDER BY r.propInt", topValue); FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); int pageSize = 3; options.maxItemCount(pageSize); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -235,7 +225,7 @@ private List sortDocumentsAndCollectResourceIds(String propName, Fun return createdDocuments.stream() .filter(d -> d.getMap().containsKey(propName)) // removes undefined .sorted((d1, d2) -> comparer.compare(extractProp.apply(d1), extractProp.apply(d2))) - .map(Resource::resourceId).collect(Collectors.toList()); + .map(Resource::getResourceId).collect(Collectors.toList()); } @Test(groups = { "simple" }, timeOut = TIMEOUT) @@ -267,12 +257,12 @@ public void queryScopedToSinglePartition_StartWithContinuationToken() throws Exc subscriber.assertNoErrors(); assertThat(subscriber.valueCount()).isEqualTo(1); FeedResponse page = (FeedResponse) subscriber.getEvents().get(0).get(0); - assertThat(page.results()).hasSize(3); + assertThat(page.getResults()).hasSize(3); - assertThat(page.continuationToken()).isNotEmpty(); + assertThat(page.getContinuationToken()).isNotEmpty(); - options.requestContinuation(page.continuationToken()); + options.requestContinuation(page.getContinuationToken()); queryObservable = createdCollection.queryItems(query, options); List expectedDocs = createdDocuments.stream() @@ -287,7 +277,7 @@ public void queryScopedToSinglePartition_StartWithContinuationToken() throws Exc validator = new FeedResponseListValidator.Builder() .containsExactly(expectedDocs.stream() .sorted((e1, e2) -> Integer.compare(e1.getInt("propScopedPartitionInt"), e2.getInt("propScopedPartitionInt"))) - .map(d -> d.resourceId()).collect(Collectors.toList())) + .map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -382,13 +372,13 @@ public void queryDocumentsWithInvalidOrderByContinuationTokensString(String sort this.assertInvalidContinuationToken(query, new int[] { 1, 5, 10, 100 }, expectedResourceIds); } - public CosmosItemProperties createDocument(CosmosContainer cosmosContainer, Map keyValueProps) + public CosmosItemProperties createDocument(CosmosAsyncContainer cosmosContainer, Map keyValueProps) throws CosmosClientException { CosmosItemProperties docDefinition = getDocumentDefinition(keyValueProps); - return cosmosContainer.createItem(docDefinition).block().properties(); + return cosmosContainer.createItem(docDefinition).block().getProperties(); } - public List bulkInsert(CosmosContainer cosmosContainer, List> keyValuePropsList) { + public List bulkInsert(CosmosAsyncContainer cosmosContainer, List> keyValuePropsList) { ArrayList result = new ArrayList(); @@ -408,7 +398,7 @@ public void beforeMethod() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -434,14 +424,14 @@ public void beforeClass() throws Exception { p.put("propScopedPartitionInt", i); CosmosItemProperties doc = getDocumentDefinition("duplicateParitionKeyValue", UUID.randomUUID().toString(), p); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(new PartitionKey(doc.get("mypk"))); - createdDocuments.add(createDocument(createdCollection, doc).read(options).block().properties()); + options.setPartitionKey(new PartitionKey(doc.get("mypk"))); + createdDocuments.add(createDocument(createdCollection, doc).read(options).block().getProperties()); } numberOfPartitions = CosmosBridgeInternal.getAsyncDocumentClient(client) - .readPartitionKeyRanges("dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(), null) - .flatMap(p -> Flux.fromIterable(p.results())).collectList().single().block().size(); + .readPartitionKeyRanges("dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(), null) + .flatMap(p -> Flux.fromIterable(p.getResults())).collectList().single().block().size(); waitIfNeededForReplicasToCatchUp(clientBuilder()); } @@ -456,8 +446,8 @@ private void assertInvalidContinuationToken(String query, int[] pageSize, List receivedDocuments = this.queryWithContinuationTokens(query, pageSize); List actualIds = new ArrayList(); for (CosmosItemProperties document : receivedDocuments) { - actualIds.add(document.resourceId()); + actualIds.add(document.getResourceId()); } assertThat(actualIds).containsExactlyElementsOf(expectedIds); @@ -496,8 +486,8 @@ private List queryWithContinuationTokens(String query, int do { FeedOptions options = new FeedOptions(); options.maxItemCount(pageSize); - options.enableCrossPartitionQuery(true); - options.maxDegreeOfParallelism(2); + options.setEnableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(2); options.requestContinuation(requestContinuation); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -510,8 +500,8 @@ private List queryWithContinuationTokens(String query, int testSubscriber.assertComplete(); FeedResponse firstPage = (FeedResponse) testSubscriber.getEvents().get(0).get(0); - requestContinuation = firstPage.continuationToken(); - receivedDocuments.addAll(firstPage.results()); + requestContinuation = firstPage.getContinuationToken(); + receivedDocuments.addAll(firstPage.getResults()); continuationTokens.add(requestContinuation); } while (requestContinuation != null); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java index f367b9ec71cc..0571e78b616b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParallelDocumentQueryTest.java @@ -2,18 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.*; -import com.azure.data.cosmos.Resource; import com.azure.data.cosmos.internal.Utils.ValueHolder; import com.azure.data.cosmos.internal.query.CompositeContinuationToken; import com.azure.data.cosmos.internal.routing.Range; @@ -39,14 +30,14 @@ //FIXME beforeClass times out inconsistently @Ignore public class ParallelDocumentQueryTest extends TestSuiteBase { - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; private List createdDocuments; - private CosmosClient client; + private CosmosAsyncClient client; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } @Factory(dataProvider = "clientBuildersWithDirect") @@ -69,9 +60,9 @@ public void queryDocuments(boolean qmEnabled) { String query = "SELECT * from c where c.prop = 99"; FeedOptions options = new FeedOptions(); options.maxItemCount(5); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(qmEnabled); - options.maxDegreeOfParallelism(2); + options.setMaxDegreeOfParallelism(2); Flux> queryObservable = createdCollection.queryItems(query, options); List expectedDocs = createdDocuments.stream().filter(d -> 99 == d.getInt("prop") ).collect(Collectors.toList()); @@ -79,7 +70,7 @@ public void queryDocuments(boolean qmEnabled) { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) .hasValidQueryMetrics(qmEnabled) @@ -93,14 +84,14 @@ public void queryMetricEquality() throws Exception { String query = "SELECT * from c where c.prop = 99"; FeedOptions options = new FeedOptions(); options.maxItemCount(5); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(true); - options.maxDegreeOfParallelism(0); + options.setMaxDegreeOfParallelism(0); Flux> queryObservable = createdCollection.queryItems(query, options); List> resultList1 = queryObservable.collectList().block(); - options.maxDegreeOfParallelism(4); + options.setMaxDegreeOfParallelism(4); Flux> threadedQueryObs = createdCollection.queryItems(query, options); List> resultList2 = threadedQueryObs.collectList().block(); @@ -128,7 +119,7 @@ private void compareQueryMetrics(Map qm1, Map> queryObservable = createdCollection.queryItems(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -147,8 +138,8 @@ public void queryDocumentsWithPageSize() { FeedOptions options = new FeedOptions(); int pageSize = 3; options.maxItemCount(pageSize); - options.maxDegreeOfParallelism(-1); - options.enableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(-1); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); List expectedDocs = createdDocuments; @@ -158,7 +149,7 @@ public void queryDocumentsWithPageSize() { .Builder() .exactlyContainsInAnyOrder(expectedDocs .stream() - .map(d -> d.resourceId()) + .map(d -> d.getResourceId()) .collect(Collectors.toList())) .numberOfPagesIsGreaterThanOrEqualTo((expectedDocs.size() + 1) / 3) .allPagesSatisfy(new FeedResponseValidator.Builder() @@ -173,7 +164,7 @@ public void queryDocumentsWithPageSize() { public void invalidQuerySyntax() { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); FailureValidator validator = new FailureValidator.Builder() @@ -203,13 +194,13 @@ public void partitionKeyRangeId() { for (String partitionKeyRangeId : CosmosBridgeInternal.getAsyncDocumentClient(client).readPartitionKeyRanges(getCollectionLink(), null) - .flatMap(p -> Flux.fromIterable(p.results())) - .map(Resource::id).collectList().single().block()) { + .flatMap(p -> Flux.fromIterable(p.getResults())) + .map(Resource::getId).collectList().single().block()) { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); partitionKeyRangeIdInternal(options, partitionKeyRangeId); int queryResultCount = createdCollection.queryItems(query, options) - .flatMap(p -> Flux.fromIterable(p.results())) + .flatMap(p -> Flux.fromIterable(p.getResults())) .collectList().block().size(); sum += queryResultCount; @@ -253,7 +244,7 @@ public void compositeContinuationTokenRoundTrip() throws Exception { } } - // TODO: This test has been timing out on build, related work item - https://msdata.visualstudio.com/CosmosDB/_workitems/edit/402438/ + // TODO: This test has been timing out on buildAsyncClient, related work item - https://msdata.visualstudio.com/CosmosDB/_workitems/edit/402438/ @Test(groups = { "non-emulator" }, timeOut = TIMEOUT * 10) public void queryDocumentsWithCompositeContinuationTokens() throws Exception { String query = "SELECT * FROM c"; @@ -267,7 +258,7 @@ public void queryDocumentsWithCompositeContinuationTokens() throws Exception { @BeforeClass(groups = { "simple", "non-emulator" }, timeOut = 2 * SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -307,7 +298,7 @@ public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); FailureValidator validator = new FailureValidator.Builder().instanceOf(CosmosClientException.class) @@ -315,11 +306,11 @@ public void invalidQuerySytax() throws Exception { validateQueryFailure(queryObservable, validator); } - public CosmosItemProperties createDocument(CosmosContainer cosmosContainer, int cnt) throws CosmosClientException { + public CosmosItemProperties createDocument(CosmosAsyncContainer cosmosContainer, int cnt) throws CosmosClientException { CosmosItemProperties docDefinition = getDocumentDefinition(cnt); - return cosmosContainer.createItem(docDefinition).block().properties(); + return cosmosContainer.createItem(docDefinition).block().getProperties(); } private void queryWithContinuationTokensAndPageSizes(String query, int[] pageSizes, List expectedDocs) { @@ -327,12 +318,12 @@ private void queryWithContinuationTokensAndPageSizes(String query, int[] pageSiz List receivedDocuments = this.queryWithContinuationTokens(query, pageSize); List actualIds = new ArrayList(); for (CosmosItemProperties document : receivedDocuments) { - actualIds.add(document.resourceId()); + actualIds.add(document.getResourceId()); } List expectedIds = new ArrayList(); for (CosmosItemProperties document : expectedDocs) { - expectedIds.add(document.resourceId()); + expectedIds.add(document.getResourceId()); } assertThat(actualIds).containsOnlyElementsOf(expectedIds); @@ -346,8 +337,8 @@ private List queryWithContinuationTokens(String query, int do { FeedOptions options = new FeedOptions(); options.maxItemCount(pageSize); - options.enableCrossPartitionQuery(true); - options.maxDegreeOfParallelism(2); + options.setEnableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(2); options.requestContinuation(requestContinuation); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -358,8 +349,8 @@ private List queryWithContinuationTokens(String query, int testSubscriber.assertComplete(); FeedResponse firstPage = (FeedResponse) testSubscriber.getEvents().get(0).get(0); - requestContinuation = firstPage.continuationToken(); - receivedDocuments.addAll(firstPage.results()); + requestContinuation = firstPage.getContinuationToken(); + receivedDocuments.addAll(firstPage.getResults()); continuationTokens.add(requestContinuation); } while (requestContinuation != null); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParsingEnvTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParsingEnvTest.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParsingEnvTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ParsingEnvTest.java diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java new file mode 100644 index 000000000000..fe896f02b227 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.data.cosmos.rx; + +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; +import com.azure.data.cosmos.internal.FailureValidator; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import reactor.core.publisher.Mono; + +import java.util.UUID; + +//TODO: change to use external TestSuiteBase +public class PermissionCrudTest extends TestSuiteBase { + + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncUser createdUser; + private final String databaseId = CosmosDatabaseForTest.generateId(); + + private CosmosAsyncClient client; + + @Factory(dataProvider = "clientBuilders") + public PermissionCrudTest(CosmosClientBuilder clientBuilder) { + super(clientBuilder); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void createPermission() throws Exception { + + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); + //create getPermission + CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() + .setId(UUID.randomUUID().toString()) + .setPermissionMode(PermissionMode.READ) + .setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); + + Mono createObservable = createdUser.createPermission(permissionSettings, null); + + // validate getPermission creation + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(permissionSettings.getId()) + .withPermissionMode(PermissionMode.READ) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(createObservable, validator); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void readPermission() throws Exception { + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); + + // create permission + CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() + .setId(UUID.randomUUID().toString()) + .setPermissionMode(PermissionMode.READ) + .setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); + CosmosAsyncPermissionResponse readBackPermission = createdUser.createPermission(permissionSettings, null) + .block(); + + // read Permission + Mono readObservable = readBackPermission.getPermission().read(null); + + // validate permission read + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(permissionSettings.getId()) + .withPermissionMode(PermissionMode.READ) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(readObservable, validator); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void deletePermission() throws Exception { + + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); + + // create getPermission + CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() + .setId(UUID.randomUUID().toString()) + .setPermissionMode(PermissionMode.READ) + .setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); + CosmosAsyncPermissionResponse readBackPermission = createdUser.createPermission(permissionSettings, null) + .block(); + // delete + Mono deleteObservable = readBackPermission.getPermission() + .delete(null); + + // validate delete permission + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .nullResource() + .build(); + validateSuccess(deleteObservable, validator); + + waitIfNeededForReplicasToCatchUp(clientBuilder()); + + // attempt to read the getPermission which was deleted + Mono readObservable = readBackPermission.getPermission() + .read( null); + FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); + validateFailure(readObservable, notFoundValidator); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void upsertPermission() throws Exception { + + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); + + // create permission + CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() + .setId(UUID.randomUUID().toString()) + .setPermissionMode(PermissionMode.READ) + .setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); + CosmosAsyncPermissionResponse readBackPermissionResponse = createdUser.createPermission(permissionSettings, null) + .block(); + CosmosPermissionProperties readBackPermission = readBackPermissionResponse.getProperties(); + // read Permission + Mono readObservable = readBackPermissionResponse.getPermission() + .read( null); + + // validate getPermission creation + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(readBackPermission.getId()) + .withPermissionMode(PermissionMode.READ) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(readObservable, validator); + + //update getPermission + readBackPermission = readBackPermission.setPermissionMode(PermissionMode.ALL); + + Mono updateObservable = createdUser.upsertPermission(readBackPermission, null); + + // validate permission update + CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() + .withId(readBackPermission.getId()) + .withPermissionMode(PermissionMode.ALL) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(updateObservable, validatorForUpdate); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void replacePermission() throws Exception { + + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); + + String id = UUID.randomUUID().toString(); + // create permission + CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() + .setId(id) + .setPermissionMode(PermissionMode.READ) + .setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); + CosmosAsyncPermissionResponse readBackPermissionResponse = createdUser.createPermission(permissionSettings, null) + .block(); + // read Permission + Mono readObservable = readBackPermissionResponse.getPermission() + .read(null); + + // validate getPermission creation + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(readBackPermissionResponse.getPermission().id()) + .withPermissionMode(PermissionMode.READ) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(readObservable, validator); + + //update getPermission + CosmosPermissionProperties readBackPermission = readBackPermissionResponse.getProperties(); + readBackPermission = readBackPermission.setPermissionMode(PermissionMode.ALL); + + CosmosAsyncPermission cosmosPermission = createdUser.getPermission(id); + Mono updateObservable = readBackPermissionResponse.getPermission() + .replace(readBackPermission, null); + + // validate permission replace + CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() + .withId(readBackPermission.getId()) + .withPermissionMode(PermissionMode.ALL) + .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") + .notNullEtag() + .build(); + validateSuccess(updateObservable, validatorForUpdate); + } + + @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) + public void beforeClass() { + client = clientBuilder().buildAsyncClient(); + createdDatabase = createDatabase(client, databaseId); + } + + @AfterClass(groups = { "simple" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) + public void afterClass() { + safeClose(client); + } + + private static CosmosUserProperties getUserDefinition() { + return new CosmosUserProperties() + .setId(UUID.randomUUID().toString()); + } + +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java index e9ad89b3ce60..7902d992d562 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionQueryTest.java @@ -46,7 +46,7 @@ public PermissionQueryTest(AsyncDocumentClient.Builder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryWithFilter() throws Exception { - String filterId = createdPermissions.get(0).id(); + String filterId = createdPermissions.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterId); FeedOptions options = new FeedOptions(); @@ -54,14 +54,14 @@ public void queryWithFilter() throws Exception { Flux> queryObservable = client .queryPermissions(getUserLink(), query, options); - List expectedDocs = createdPermissions.stream().filter(sp -> filterId.equals(sp.id()) ).collect(Collectors.toList()); + List expectedDocs = createdPermissions.stream().filter(sp -> filterId.equals(sp.getId()) ).collect(Collectors.toList()); assertThat(expectedDocs).isNotEmpty(); int expectedPageSize = (expectedDocs.size() + options.maxItemCount() - 1) / options.maxItemCount(); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -74,7 +74,7 @@ public void query_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = client .queryPermissions(getUserLink(), query, options); @@ -93,7 +93,7 @@ public void queryAll() throws Exception { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); options.maxItemCount(3); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = client .queryPermissions(getUserLink(), query, options); @@ -103,7 +103,7 @@ public void queryAll() throws Exception { .Builder() .exactlyContainsInAnyOrder(createdPermissions .stream() - .map(d -> d.resourceId()) + .map(d -> d.getResourceId()) .collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() @@ -116,7 +116,7 @@ public void queryAll() throws Exception { public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = client .queryPermissions(getUserLink(), query, options); @@ -132,9 +132,9 @@ public void invalidQuerySytax() throws Exception { public void beforeClass() { client = clientBuilder().build(); Database d = new Database(); - d.id(databaseId); + d.setId(databaseId); createdDatabase = createDatabase(client, d); - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); for(int i = 0; i < 5; i++) { createdPermissions.add(createPermissions(client, i)); @@ -151,16 +151,16 @@ public void afterClass() { private static User getUserDefinition() { User user = new User(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); return user; } public Permission createPermissions(AsyncDocumentClient client, int index) { DocumentCollection collection = new DocumentCollection(); - collection.id(UUID.randomUUID().toString()); + collection.setId(UUID.randomUUID().toString()); Permission permission = new Permission(); - permission.id(UUID.randomUUID().toString()); + permission.setId(UUID.randomUUID().toString()); permission.setPermissionMode(PermissionMode.READ); permission.setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgT" + Integer.toString(index) + "="); @@ -172,10 +172,10 @@ private String getUserLink() { } private String getDatabaseId() { - return createdDatabase.id(); + return createdDatabase.getId(); } private String getUserId() { - return createdUser.id(); + return createdUser.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java similarity index 71% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java index 357c39ae3b3b..ef384eec50da 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ProxyHostTest.java @@ -2,15 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.ConnectionPolicy; -import com.azure.data.cosmos.ConsistencyLevel; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.CosmosResponseValidator; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.TestConfigurations; import com.azure.data.cosmos.rx.proxy.HttpProxyServer; import org.apache.log4j.Level; @@ -42,10 +35,10 @@ */ public class ProxyHostTest extends TestSuiteBase { - private static CosmosDatabase createdDatabase; - private static CosmosContainer createdCollection; + private static CosmosAsyncDatabase createdDatabase; + private static CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; private final String PROXY_HOST = "localhost"; private final int PROXY_PORT = 8080; private HttpProxyServer httpProxyServer; @@ -56,7 +49,7 @@ public ProxyHostTest() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); createdCollection = getSharedMultiPartitionCosmosContainer(client); httpProxyServer = new HttpProxyServer(); @@ -72,19 +65,19 @@ public void beforeClass() throws Exception { */ @Test(groups = { "simple" }, timeOut = TIMEOUT) public void createDocumentWithValidHttpProxy() throws Exception { - CosmosClient clientWithRightProxy = null; + CosmosAsyncClient clientWithRightProxy = null; try { ConnectionPolicy connectionPolicy =new ConnectionPolicy(); - connectionPolicy.proxy(PROXY_HOST, PROXY_PORT); - clientWithRightProxy = CosmosClient.builder().endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY) - .connectionPolicy(connectionPolicy) - .consistencyLevel(ConsistencyLevel.SESSION).build(); + connectionPolicy.setProxy(PROXY_HOST, PROXY_PORT); + clientWithRightProxy = CosmosAsyncClient.builder().setEndpoint(TestConfigurations.HOST) + .setKey(TestConfigurations.MASTER_KEY) + .setConnectionPolicy(connectionPolicy) + .setConsistencyLevel(ConsistencyLevel.SESSION).buildAsyncClient(); CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = clientWithRightProxy.getDatabase(createdDatabase.id()).getContainer(createdCollection.id()) + Mono createObservable = clientWithRightProxy.getDatabase(createdDatabase.getId()).getContainer(createdCollection.getId()) .createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()) .build(); validateSuccess(createObservable, validator); } finally { @@ -103,23 +96,23 @@ public void createDocumentWithValidHttpProxy() throws Exception { public void createDocumentWithValidHttpProxyWithNettyWireLogging() throws Exception { LogManager.getRootLogger().setLevel(Level.INFO); LogManager.getLogger(LogLevelTest.NETWORK_LOGGING_CATEGORY).setLevel(Level.TRACE); - CosmosClient clientWithRightProxy = null; + CosmosAsyncClient clientWithRightProxy = null; try { StringWriter consoleWriter = new StringWriter(); WriterAppender appender = new WriterAppender(new PatternLayout(), consoleWriter); Logger.getLogger(LogLevelTest.NETWORK_LOGGING_CATEGORY).addAppender(appender); ConnectionPolicy connectionPolicy =new ConnectionPolicy(); - connectionPolicy.proxy(PROXY_HOST, PROXY_PORT); - clientWithRightProxy = CosmosClient.builder().endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY) - .connectionPolicy(connectionPolicy) - .consistencyLevel(ConsistencyLevel.SESSION).build(); + connectionPolicy.setProxy(PROXY_HOST, PROXY_PORT); + clientWithRightProxy = CosmosAsyncClient.builder().setEndpoint(TestConfigurations.HOST) + .setKey(TestConfigurations.MASTER_KEY) + .setConnectionPolicy(connectionPolicy) + .setConsistencyLevel(ConsistencyLevel.SESSION).buildAsyncClient(); CosmosItemProperties docDefinition = getDocumentDefinition(); - Mono createObservable = clientWithRightProxy.getDatabase(createdDatabase.id()).getContainer(createdCollection.id()) + Mono createObservable = clientWithRightProxy.getDatabase(createdDatabase.getId()).getContainer(createdCollection.getId()) .createItem(docDefinition, new CosmosItemRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(docDefinition.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(docDefinition.getId()) .build(); validateSuccess(createObservable, validator); @@ -135,7 +128,7 @@ public void createDocumentWithValidHttpProxyWithNettyWireLogging() throws Except public void afterClass() throws Exception { safeClose(client); httpProxyServer.shutDown(); - // wait for proxy server to be shutdown + // wait for getProxy server to be shutdown TimeUnit.SECONDS.sleep(1); LogManager.resetConfiguration(); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java similarity index 75% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java index 4f2f951877ed..4666389cfc11 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedCollectionsTest.java @@ -2,16 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.PartitionKeyDefinition; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.AfterClass; @@ -33,10 +25,10 @@ public class ReadFeedCollectionsTest extends TestSuiteBase { public final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosDatabase createdDatabase; - private List createdCollections = new ArrayList<>(); + private CosmosAsyncDatabase createdDatabase; + private List createdCollections = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public ReadFeedCollectionsTest(CosmosClientBuilder clientBuilder) { @@ -55,7 +47,7 @@ public void readCollections() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdCollections.size()) - .exactlyContainsInAnyOrder(createdCollections.stream().map(d -> d.read().block().properties().resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(createdCollections.stream().map(d -> d.read().block().getProperties().getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -67,7 +59,7 @@ public void readCollections() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, databaseId); for(int i = 0; i < 3; i++) { @@ -81,12 +73,12 @@ public void afterClass() { safeClose(client); } - public CosmosContainer createCollections(CosmosDatabase database) { + public CosmosAsyncContainer createCollections(CosmosAsyncDatabase database) { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collection = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); - return database.createContainer(collection, new CosmosContainerRequestOptions()).block().container(); + return database.createContainer(collection, new CosmosContainerRequestOptions()).block().getContainer(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java index c8be67ea4b7c..655dc7f51652 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDatabasesTest.java @@ -2,12 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.CosmosDatabaseRequestOptions; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.AfterClass; @@ -27,7 +23,7 @@ public class ReadFeedDatabasesTest extends TestSuiteBase { private List createdDatabases = new ArrayList<>(); private List allDatabases = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public ReadFeedDatabasesTest(CosmosClientBuilder clientBuilder) { @@ -45,7 +41,7 @@ public void readDatabases() throws Exception { int expectedPageSize = (allDatabases.size() + options.maxItemCount() - 1) / options.maxItemCount(); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(allDatabases.size()) - .exactlyContainsInAnyOrder(allDatabases.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(allDatabases.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -56,9 +52,9 @@ public void readDatabases() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws URISyntaxException { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); allDatabases = client.readAllDatabases(null) - .map(frp -> frp.results()) + .map(frp -> frp.getResults()) .collectList() .map(list -> list.stream().flatMap(x -> x.stream()).collect(Collectors.toList())) .block(); @@ -68,15 +64,15 @@ public void beforeClass() throws URISyntaxException { allDatabases.addAll(createdDatabases); } - public CosmosDatabaseProperties createDatabase(CosmosClient client) { + public CosmosDatabaseProperties createDatabase(CosmosAsyncClient client) { CosmosDatabaseProperties db = new CosmosDatabaseProperties(UUID.randomUUID().toString()); - return client.createDatabase(db, new CosmosDatabaseRequestOptions()).block().properties(); + return client.createDatabase(db, new CosmosDatabaseRequestOptions()).block().getProperties(); } @AfterClass(groups = { "simple" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { for (int i = 0; i < 5; i ++) { - safeDeleteDatabase(client.getDatabase(createdDatabases.get(i).id())); + safeDeleteDatabase(client.getDatabase(createdDatabases.get(i).getId())); } safeClose(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java index 1268614a9757..f941205f4e6f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedDocumentsTest.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; @@ -29,11 +23,11 @@ @Ignore public class ReadFeedDocumentsTest extends TestSuiteBase { - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; private List createdDocuments; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public ReadFeedDocumentsTest(CosmosClientBuilder clientBuilder) { @@ -43,14 +37,14 @@ public ReadFeedDocumentsTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = FEED_TIMEOUT) public void readDocuments() { FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(2); Flux> feedObservable = createdCollection.readAllItems(options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdDocuments.size()) .numberOfPagesIsGreaterThanOrEqualTo(1) - .exactlyContainsInAnyOrder(createdDocuments.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(createdDocuments.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0) .pageSizeIsLessThanOrEqualTo(options.maxItemCount()) @@ -77,7 +71,7 @@ public void readDocuments_withoutEnableCrossPartitionQuery() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -112,10 +106,10 @@ public String getCollectionLink() { } private String getCollectionId() { - return createdCollection.id(); + return createdCollection.getId(); } private String getDatabaseId() { - return createdDatabase.id(); + return createdDatabase.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java index d1468ed0e21a..93062088c516 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedExceptionHandlingTest.java @@ -2,11 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import io.reactivex.subscribers.TestSubscriber; import org.mockito.Mockito; import org.testng.annotations.AfterClass; @@ -21,7 +18,7 @@ public class ReadFeedExceptionHandlingTest extends TestSuiteBase { - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public ReadFeedExceptionHandlingTest(CosmosClientBuilder clientBuilder) { @@ -43,7 +40,7 @@ public void readFeedException() throws Exception { .mergeWith(Flux.error(BridgeInternal.createCosmosClientException(0))) .mergeWith(Flux.fromIterable(frps)); - final CosmosClient mockClient = Mockito.spy(client); + final CosmosAsyncClient mockClient = Mockito.spy(client); Mockito.when(mockClient.readAllDatabases(null)).thenReturn(response); TestSubscriber> subscriber = new TestSubscriber>(); mockClient.readAllDatabases(null).subscribe(subscriber); @@ -55,7 +52,7 @@ public void readFeedException() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); } @AfterClass(groups = { "simple" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java similarity index 93% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java index f291d9b4914e..f7676ccc2446 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedOffersTest.java @@ -53,7 +53,7 @@ public void readOffers() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(allOffers.size()) - .exactlyContainsInAnyOrder(allOffers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(allOffers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -71,7 +71,7 @@ public void beforeClass() { } allOffers = client.readOffers(null) - .map(FeedResponse::results) + .map(FeedResponse::getResults) .collectList() .map(list -> list.stream().flatMap(Collection::stream).collect(Collectors.toList())) .single() @@ -86,18 +86,18 @@ public void afterClass() { public DocumentCollection createCollections(AsyncDocumentClient client) { DocumentCollection collection = new DocumentCollection(); - collection.id(UUID.randomUUID().toString()); + collection.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); collection.setPartitionKey(partitionKeyDef); return client.createCollection(getDatabaseLink(), collection, null).single().block().getResource(); } private String getDatabaseLink() { - return "dbs/" + createdDatabase.id(); + return "dbs/" + createdDatabase.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java similarity index 90% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java index 81c7ad6b5884..ba3c668befda 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPermissionsTest.java @@ -50,7 +50,7 @@ public void readPermissions() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdPermissions.size()) .numberOfPages(expectedPageSize) - .exactlyContainsInAnyOrder(createdPermissions.stream().map(Resource::resourceId).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(createdPermissions.stream().map(Resource::getResourceId).collect(Collectors.toList())) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) .build(); @@ -61,9 +61,9 @@ public void readPermissions() throws Exception { public void beforeClass() { client = clientBuilder().build(); Database d = new Database(); - d.id(databaseId); + d.setId(databaseId); createdDatabase = createDatabase(client, d); - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); + createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); for(int i = 0; i < 5; i++) { createdPermissions.add(createPermissions(client, i)); @@ -80,13 +80,13 @@ public void afterClass() { private static User getUserDefinition() { User user = new User(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); return user; } public Permission createPermissions(AsyncDocumentClient client, int index) { Permission permission = new Permission(); - permission.id(UUID.randomUUID().toString()); + permission.setId(UUID.randomUUID().toString()); permission.setPermissionMode(PermissionMode.READ); permission.setResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgT" + Integer.toString(index) + "="); return client.createPermission(getUserLink(), permission, null).single().block().getResource(); @@ -97,10 +97,10 @@ private String getUserLink() { } private String getDatabaseId() { - return createdDatabase.id(); + return createdDatabase.getId(); } private String getUserId() { - return createdUser.id(); + return createdUser.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java index cf429130e39e..0a995ac371cc 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedPkrTests.java @@ -2,14 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; +import com.azure.data.cosmos.*; import com.azure.data.cosmos.internal.AsyncDocumentClient; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.PartitionKeyRange; import org.testng.annotations.AfterClass; @@ -21,8 +16,8 @@ public class ReadFeedPkrTests extends TestSuiteBase { - private CosmosDatabase createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncDatabase createdDatabase; + private CosmosAsyncContainer createdCollection; private AsyncDocumentClient client; @@ -48,8 +43,8 @@ public void readPartitionKeyRanges() throws Exception { @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = CosmosBridgeInternal.getAsyncDocumentClient(clientBuilder().build()); - createdDatabase = getSharedCosmosDatabase(clientBuilder().build()); + client = CosmosBridgeInternal.getAsyncDocumentClient(clientBuilder().buildAsyncClient()); + createdDatabase = getSharedCosmosDatabase(clientBuilder().buildAsyncClient()); createdCollection = createCollection(createdDatabase, getCollectionDefinition(), new CosmosContainerRequestOptions()); @@ -62,6 +57,6 @@ public void afterClass() { } private String getCollectionLink() { - return "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id(); + return "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java similarity index 81% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java index ff3ab1df574e..d3017535b41d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedStoredProceduresTest.java @@ -2,13 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.Factory; @@ -27,10 +22,10 @@ @Ignore public class ReadFeedStoredProceduresTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdStoredProcedures = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public ReadFeedStoredProceduresTest(CosmosClientBuilder clientBuilder) { @@ -51,7 +46,7 @@ public void readStoredProcedures() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdStoredProcedures.size()) .exactlyContainsInAnyOrder( - createdStoredProcedures.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + createdStoredProcedures.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -61,7 +56,7 @@ public void readStoredProcedures() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -77,11 +72,11 @@ public void afterClass() { safeClose(client); } - public CosmosStoredProcedureProperties createStoredProcedures(CosmosContainer cosmosContainer) { + public CosmosStoredProcedureProperties createStoredProcedures(CosmosAsyncContainer cosmosContainer) { CosmosStoredProcedureProperties sproc = new CosmosStoredProcedureProperties(); - sproc.id(UUID.randomUUID().toString()); - sproc.body("function() {var x = 10;}"); + sproc.setId(UUID.randomUUID().toString()); + sproc.setBody("function() {var x = 10;}"); return cosmosContainer.getScripts().createStoredProcedure(sproc, new CosmosStoredProcedureRequestOptions()) - .block().properties(); + .block().getProperties(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java similarity index 74% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java index a390051f74b8..78634a06e5e8 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedTriggersTest.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.TriggerOperation; -import com.azure.data.cosmos.TriggerType; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.Factory; @@ -28,10 +22,10 @@ @Ignore public class ReadFeedTriggersTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdTriggers = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public ReadFeedTriggersTest(CosmosClientBuilder clientBuilder) { @@ -51,7 +45,7 @@ public void readTriggers() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdTriggers.size()) .exactlyContainsInAnyOrder( - createdTriggers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + createdTriggers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -61,7 +55,7 @@ public void readTriggers() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -77,12 +71,12 @@ public void afterClass() { safeClose(client); } - public CosmosTriggerProperties createTriggers(CosmosContainer cosmosContainer) { + public CosmosTriggerProperties createTriggers(CosmosAsyncContainer cosmosContainer) { CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); - return cosmosContainer.getScripts().createTrigger(trigger).block().properties(); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); + return cosmosContainer.getScripts().createTrigger(trigger).block().getProperties(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java similarity index 82% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java index 27708f6f248a..5c34dc864bd7 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUdfsTest.java @@ -2,13 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.Database; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.Factory; @@ -28,10 +24,10 @@ public class ReadFeedUdfsTest extends TestSuiteBase { private Database createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdUserDefinedFunctions = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public ReadFeedUdfsTest(CosmosClientBuilder clientBuilder) { @@ -53,7 +49,7 @@ public void readUserDefinedFunctions() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdUserDefinedFunctions.size()) .exactlyContainsInAnyOrder( - createdUserDefinedFunctions.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + createdUserDefinedFunctions.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -63,7 +59,7 @@ public void readUserDefinedFunctions() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -79,12 +75,12 @@ public void afterClass() { safeClose(client); } - public CosmosUserDefinedFunctionProperties createUserDefinedFunctions(CosmosContainer cosmosContainer) { + public CosmosUserDefinedFunctionProperties createUserDefinedFunctions(CosmosAsyncContainer cosmosContainer) { CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); return cosmosContainer.getScripts().createUserDefinedFunction(udf).block() - .properties(); + .getProperties(); } private String getCollectionLink() { @@ -92,10 +88,10 @@ private String getCollectionLink() { } private String getCollectionId() { - return createdCollection.id(); + return createdCollection.getId(); } private String getDatabaseId() { - return createdDatabase.id(); + return createdDatabase.getId(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java similarity index 78% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java index 2acad9621f4e..13e19180ac52 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ReadFeedUsersTest.java @@ -2,13 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.AfterClass; @@ -25,9 +20,9 @@ public class ReadFeedUsersTest extends TestSuiteBase { public final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosDatabase createdDatabase; + private CosmosAsyncDatabase createdDatabase; - private CosmosClient client; + private CosmosAsyncClient client; private List createdUsers = new ArrayList<>(); @Factory(dataProvider = "clientBuilders") @@ -47,7 +42,7 @@ public void readUsers() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdUsers.size()) - .exactlyContainsInAnyOrder(createdUsers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(createdUsers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -57,7 +52,7 @@ public void readUsers() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, databaseId); for(int i = 0; i < 5; i++) { @@ -73,9 +68,9 @@ public void afterClass() { safeClose(client); } - public CosmosUserProperties createUsers(CosmosDatabase cosmosDatabase) { + public CosmosUserProperties createUsers(CosmosAsyncDatabase cosmosDatabase) { CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); - return cosmosDatabase.createUser(user).block().properties(); + user.setId(UUID.randomUUID().toString()); + return cosmosDatabase.createUser(user).block().getProperties(); } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java similarity index 74% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java index 3a1eebb636fc..a3853b314a82 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/ResourceTokenTest.java @@ -87,23 +87,23 @@ public ResourceTokenTest(AsyncDocumentClient.Builder clientBuilder) { public void beforeClass() throws Exception { client = clientBuilder().build(); Database d = new Database(); - d.id(databaseId); + d.setId(databaseId); createdDatabase = createDatabase(client, d); // CREATE collection - createdCollection = createCollection(client, createdDatabase.id(), getCollectionDefinitionWithPartitionKey(PARTITION_KEY_PATH_2)); + createdCollection = createCollection(client, createdDatabase.getId(), getCollectionDefinitionWithPartitionKey(PARTITION_KEY_PATH_2)); // CREATE document - createdDocument = createDocument(client, createdDatabase.id(),createdCollection.id(), getDocument()); - // CREATE collection with partition key - createdCollectionWithPartitionKey = createCollection(client, createdDatabase.id(), getCollectionDefinitionWithPartitionKey(PARTITION_KEY_PATH_1)); - // CREATE document with partition key - createdDocumentWithPartitionKey = createDocument(client, createdDatabase.id(), createdCollectionWithPartitionKey.id(), + createdDocument = createDocument(client, createdDatabase.getId(),createdCollection.getId(), getDocument()); + // CREATE collection with partition getKey + createdCollectionWithPartitionKey = createCollection(client, createdDatabase.getId(), getCollectionDefinitionWithPartitionKey(PARTITION_KEY_PATH_1)); + // CREATE document with partition getKey + createdDocumentWithPartitionKey = createDocument(client, createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), getDocumentDefinitionWithPartitionKey()); - // CREATE second document with partition key - createdDocumentWithPartitionKey2 = createDocument(client, createdDatabase.id(),createdCollectionWithPartitionKey.id(), + // CREATE second document with partition getKey + createdDocumentWithPartitionKey2 = createDocument(client, createdDatabase.getId(),createdCollectionWithPartitionKey.getId(), getDocumentDefinitionWithPartitionKey2()); - // CREATE user - createdUser = createUser(client, createdDatabase.id(), getUserDefinition()); - // CREATE permission for collection + // CREATE getUser + createdUser = createUser(client, createdDatabase.getId(), getUserDefinition()); + // CREATE getPermission for collection createdCollPermission = client.createPermission(getUserLink(), getCollPermission(), null).single().block() .getResource(); createdCollPermissionWithName = client.createPermission(getUserLink(), getCollPermissionWithName(), null).single().block() @@ -146,40 +146,40 @@ public void beforeClass() throws Exception { @DataProvider(name = "collectionAndPermissionData") public Object[][] collectionAndPermissionData() { return new Object[][]{ - //This test will try to read collection from its own permission and validate it, both with request Id and name. - {createdCollection.selfLink(), createdCollPermission}, - {TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()), createdDocPermissionWithName}, + //This test will try to read collection from its own getPermission and validate it, both with request Id and getName. + {createdCollection.getSelfLink(), createdCollPermission}, + {TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()), createdDocPermissionWithName}, }; } @DataProvider(name = "documentAndPermissionData") public Object[][] documentAndPermissionData() { return new Object[][]{ - //These tests will try to read document from its own permission and validate it, both with request Id and name. - {createdDocument.selfLink(), createdDocPermission, createdDocument.id(), null}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollection.id(), createdDocument.id()), createdDocPermissionWithName, createdDocument.id(), null}, + //These tests will try to read document from its own getPermission and validate it, both with request Id and getName. + {createdDocument.getSelfLink(), createdDocPermission, createdDocument.getId(), null}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollection.getId(), createdDocument.getId()), createdDocPermissionWithName, createdDocument.getId(), null}, - //These tests will try to read document from its permission having partition key 1 and validate it, both with request Id and name. - {createdDocumentWithPartitionKey.selfLink(), createdDocPermissionWithPartitionKey, createdDocumentWithPartitionKey.id(), PARTITION_KEY_VALUE}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey.id()), createdDocPermissionWithPartitionKeyWithName - , createdDocumentWithPartitionKey.id(), PARTITION_KEY_VALUE}, + //These tests will try to read document from its getPermission having partition getKey 1 and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey.getSelfLink(), createdDocPermissionWithPartitionKey, createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey.getId()), createdDocPermissionWithPartitionKeyWithName + , createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, - //These tests will try to read document from its permission having partition key 2 and validate it, both with request Id and name. - {createdDocumentWithPartitionKey2.selfLink(), createdDocPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.id(), PARTITION_KEY_VALUE_2}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey2.id()), - createdDocPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.id(), PARTITION_KEY_VALUE_2}, + //These tests will try to read document from its getPermission having partition getKey 2 and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey2.getSelfLink(), createdDocPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey2.getId()), + createdDocPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2}, - // These tests will try to read document from its parent collection permission and validate it, both with request Id and name. - {createdDocument.selfLink(), createdCollPermission, createdDocument.id(), null}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollection.id(), createdDocument.id()), createdCollPermissionWithName, createdDocument.id(), null}, + // These tests will try to read document from its parent collection getPermission and validate it, both with request Id and getName. + {createdDocument.getSelfLink(), createdCollPermission, createdDocument.getId(), null}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollection.getId(), createdDocument.getId()), createdCollPermissionWithName, createdDocument.getId(), null}, - //This test will try to read document from collection permission having partition key 1 and validate it, both with request Id and name. - {createdDocumentWithPartitionKey.selfLink(), createdColPermissionWithPartitionKey, createdDocumentWithPartitionKey.id(), PARTITION_KEY_VALUE}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey.id()), createdColPermissionWithPartitionKeyWithName, createdDocumentWithPartitionKey.id(), PARTITION_KEY_VALUE}, + //This test will try to read document from collection getPermission having partition getKey 1 and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey.getSelfLink(), createdColPermissionWithPartitionKey, createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey.getId()), createdColPermissionWithPartitionKeyWithName, createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, - //This test will try to read document from collection permission having partition key 2 and validate it, both with request Id and name. - {createdDocumentWithPartitionKey2.selfLink(), createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.id(), PARTITION_KEY_VALUE_2}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey2.id()), createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.id(), PARTITION_KEY_VALUE_2} + //This test will try to read document from collection getPermission having partition getKey 2 and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey2.getSelfLink(), createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey2.getId()), createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2} }; } @@ -188,9 +188,9 @@ public Object[][] documentAndPermissionData() { public Object[][] documentAndPermissionDataForResourceNotFound() { return new Object[][]{ //This test will try to read document from its resource token directly and validate it. - {createdDocumentWithPartitionKey2.selfLink(), createdColPermissionWithPartitionKey, PARTITION_KEY_VALUE}, + {createdDocumentWithPartitionKey2.getSelfLink(), createdColPermissionWithPartitionKey, PARTITION_KEY_VALUE}, //This test will try to read document from its parent collection resource token directly and validate it. - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey2.id()), + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey2.getId()), createdColPermissionWithPartitionKeyWithName, PARTITION_KEY_VALUE} }; } @@ -198,17 +198,17 @@ public Object[][] documentAndPermissionDataForResourceNotFound() { @DataProvider(name = "documentAndMultipleCollPermissionData") public Object[][] documentAndMultipleCollPermissionData() { return new Object[][]{ - //These tests will try to read document from partition 1 with two collection permissions having different partition keys and validate it, both with request Id and name. - {createdDocumentWithPartitionKey.selfLink(), createdColPermissionWithPartitionKey, createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey.id(), + //These tests will try to read document from partition 1 with two collection getPermissions having different partition keys and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey.getSelfLink(), createdColPermissionWithPartitionKey, createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey.id()), createdColPermissionWithPartitionKeyWithName - , createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey.id(), PARTITION_KEY_VALUE}, + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey.getId()), createdColPermissionWithPartitionKeyWithName + , createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey.getId(), PARTITION_KEY_VALUE}, - //These tests will try to read document from partition 1 with two collection permissions having different partition keys and validate it, both with request Id and name. - {createdDocumentWithPartitionKey2.selfLink(), createdColPermissionWithPartitionKey, createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.id(), + //These tests will try to read document from partition 1 with two collection getPermissions having different partition keys and validate it, both with request Id and getName. + {createdDocumentWithPartitionKey2.getSelfLink(), createdColPermissionWithPartitionKey, createdColPermissionWithPartitionKey2, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2}, - {TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey2.id()), createdColPermissionWithPartitionKeyWithName - , createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.id(), PARTITION_KEY_VALUE_2} + {TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey2.getId()), createdColPermissionWithPartitionKeyWithName + , createdColPermissionWithPartitionKey2WithName, createdDocumentWithPartitionKey2.getId(), PARTITION_KEY_VALUE_2} }; } @@ -234,13 +234,13 @@ public void readCollectionFromPermissionFeed(String collectionUrl, Permission pe List permissionFeed = new ArrayList<>(); permissionFeed.add(permission); asyncClientResourceToken = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) - .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.defaultPolicy()) + .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); Flux> readObservable = asyncClientResourceToken .readCollection(collectionUrl, null); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(createdCollection.id()).build(); + .withId(createdCollection.getId()).build(); validateSuccess(readObservable, validator); } finally { safeClose(asyncClientResourceToken); @@ -259,7 +259,7 @@ public void readDocumentFromPermissionFeed(String documentUrl, Permission permis List permissionFeed = new ArrayList<>(); permissionFeed.add(permission); asyncClientResourceToken = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) - .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.defaultPolicy()) + .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); RequestOptions options = new RequestOptions(); if (StringUtils.isNotEmpty(partitionKey)) { @@ -288,14 +288,14 @@ public void readDocumentFromResouceToken(String resourceToken) throws Exception try { asyncClientResourceToken = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(resourceToken) - .withConnectionPolicy(ConnectionPolicy.defaultPolicy()).withConsistencyLevel(ConsistencyLevel.SESSION) + .withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()).withConsistencyLevel(ConsistencyLevel.SESSION) .build(); RequestOptions options = new RequestOptions(); options.setPartitionKey(PartitionKey.None); Flux> readObservable = asyncClientResourceToken - .readDocument(createdDocument.selfLink(), options); + .readDocument(createdDocument.getSelfLink(), options); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(createdDocument.id()).build(); + .withId(createdDocument.getId()).build(); validateSuccess(readObservable, validator); } finally { safeClose(asyncClientResourceToken); @@ -315,7 +315,7 @@ public void readDocumentOfParKeyFromTwoCollPermissionWithDiffPartitionKeys(Strin permissionFeed.add(collPermission1); permissionFeed.add(collPermission2); asyncClientResourceToken = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) - .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.defaultPolicy()) + .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(partitionKey)); @@ -342,7 +342,7 @@ public void readDocumentFromCollPermissionWithDiffPartitionKey_ResourceNotFound( List permissionFeed = new ArrayList<>(); permissionFeed.add(permission); asyncClientResourceToken = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) - .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.defaultPolicy()) + .withPermissionFeed(permissionFeed).withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) .withConsistencyLevel(ConsistencyLevel.SESSION).build(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(partitionKey)); @@ -369,14 +369,14 @@ public void readDocumentFromCollPermissionWithDiffPartitionKey_WithException() t permissionFeed.add(createdColPermissionWithPartitionKey); asyncClientResourceToken = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) - .withConnectionPolicy(ConnectionPolicy.defaultPolicy()) + .withConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) .withConsistencyLevel(ConsistencyLevel.SESSION) .withPermissionFeed(permissionFeed) .build(); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey(PARTITION_KEY_VALUE_2)); Flux> readObservable = asyncClientResourceToken - .readDocument(createdDocumentWithPartitionKey.selfLink(), options); + .readDocument(createdDocumentWithPartitionKey.getSelfLink(), options); FailureValidator validator = new FailureValidator.Builder().resourceTokenNotFound().build(); validateFailure(readObservable, validator); } finally { @@ -392,7 +392,7 @@ public void afterClass() { private static User getUserDefinition() { User user = new User(); - user.id(USER_NAME); + user.setId(USER_NAME); return user; } @@ -403,99 +403,99 @@ private static Document getDocument() { private Permission getCollPermission() { Permission permission = new Permission(); - permission.id(PERMISSION_FOR_COLL); + permission.setId(PERMISSION_FOR_COLL); permission.setPermissionMode(PermissionMode.READ); - permission.setResourceLink(createdCollection.selfLink()); + permission.setResourceLink(createdCollection.getSelfLink()); return permission; } private Permission getCollPermissionWithName() { Permission permission = new Permission(); - permission.id(PERMISSION_FOR_COLL_WITH_NAME); + permission.setId(PERMISSION_FOR_COLL_WITH_NAME); permission.setPermissionMode(PermissionMode.READ); - permission.setResourceLink(TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id())); + permission.setResourceLink(TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId())); return permission; } private Permission getDocPermission() { Permission permission = new Permission(); - permission.id(PERMISSION_FOR_DOC); + permission.setId(PERMISSION_FOR_DOC); permission.setPermissionMode(PermissionMode.READ); - permission.setResourceLink(createdDocument.selfLink()); + permission.setResourceLink(createdDocument.getSelfLink()); return permission; } private Permission getDocPermissionWithName() { Permission permission = new Permission(); - permission.id(PERMISSION_FOR_DOC_WITH_NAME); + permission.setId(PERMISSION_FOR_DOC_WITH_NAME); permission.setPermissionMode(PermissionMode.READ); - permission.setResourceLink(TestUtils.getDocumentNameLink(createdDatabase.id(),createdCollection.id(),createdDocument.id())); + permission.setResourceLink(TestUtils.getDocumentNameLink(createdDatabase.getId(),createdCollection.getId(),createdDocument.getId())); return permission; } private Permission getDocPermissionWithPartitionKey() { - String permissionStr = String.format(PERMISSION_DEFINITION, createdDocumentWithPartitionKey.selfLink(), + String permissionStr = String.format(PERMISSION_DEFINITION, createdDocumentWithPartitionKey.getSelfLink(), PARTITION_KEY_VALUE); Permission permission = new Permission(permissionStr); return permission; } private Permission getDocPermissionWithPartitionKeyWithName() { - String permissionStr = String.format(PERMISSION_DEFINITION, TestUtils.getDocumentNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id(), createdDocumentWithPartitionKey.id()), + String permissionStr = String.format(PERMISSION_DEFINITION, TestUtils.getDocumentNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId(), createdDocumentWithPartitionKey.getId()), PARTITION_KEY_VALUE); Permission permission = new Permission(permissionStr); - permission.id("PermissionForDocWithPartitionKeyWithName"); + permission.setId("PermissionForDocWithPartitionKeyWithName"); return permission; } private Permission getDocPermissionWithPartitionKey2() { - String permissionStr = String.format(PERMISSION_DEFINITION, createdDocumentWithPartitionKey2.selfLink(), + String permissionStr = String.format(PERMISSION_DEFINITION, createdDocumentWithPartitionKey2.getSelfLink(), PARTITION_KEY_VALUE_2); Permission permission = new Permission(permissionStr); - permission.id("PermissionForDocWithPartitionKey2"); + permission.setId("PermissionForDocWithPartitionKey2"); return permission; } private Permission getDocPermissionWithPartitionKey2WithName() { - String permissionStr = String.format(PERMISSION_DEFINITION, TestUtils.getDocumentNameLink(createdDatabase.id(),createdCollectionWithPartitionKey.id(),createdDocumentWithPartitionKey2.id()), + String permissionStr = String.format(PERMISSION_DEFINITION, TestUtils.getDocumentNameLink(createdDatabase.getId(),createdCollectionWithPartitionKey.getId(),createdDocumentWithPartitionKey2.getId()), PARTITION_KEY_VALUE_2); Permission permission = new Permission(permissionStr); - permission.id("PermissionForDocWithPartitionKey2WithName"); + permission.setId("PermissionForDocWithPartitionKey2WithName"); return permission; } private Permission getColPermissionWithPartitionKey() { - String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, createdCollectionWithPartitionKey.selfLink(), + String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, createdCollectionWithPartitionKey.getSelfLink(), PARTITION_KEY_VALUE); Permission permission = new Permission(permissionStr); return permission; } private Permission getColPermissionWithPartitionKeyWithName() { - String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id()), + String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId()), PARTITION_KEY_VALUE); Permission permission = new Permission(permissionStr); - permission.id("PermissionForColWithPartitionKeyWithName"); + permission.setId("PermissionForColWithPartitionKeyWithName"); return permission; } private Permission getColPermissionWithPartitionKey2() { - String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, createdCollectionWithPartitionKey.selfLink(), + String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, createdCollectionWithPartitionKey.getSelfLink(), PARTITION_KEY_VALUE_2); Permission permission = new Permission(permissionStr); - permission.id("PermissionForColWithPartitionKey2"); + permission.setId("PermissionForColWithPartitionKey2"); return permission; } private Permission getColPermissionWithPartitionKey2WithName() { - String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollectionWithPartitionKey.id()), + String permissionStr = String.format(COLLECTION_PERMISSION_DEFINITION, TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollectionWithPartitionKey.getId()), PARTITION_KEY_VALUE_2); Permission permission = new Permission(permissionStr); - permission.id("PermissionForColWithPartitionKey2WithName"); + permission.setId("PermissionForColWithPartitionKey2WithName"); return permission; } private String getUserLink() { - return createdUser.selfLink(); + return createdUser.getSelfLink(); } private Document getDocumentDefinitionWithPartitionKey() { @@ -513,12 +513,12 @@ private DocumentCollection getCollectionDefinitionWithPartitionKey(String pkDefP PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add(pkDefPath); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); DocumentCollection collectionDefinition = new DocumentCollection(); - collectionDefinition.id(UUID.randomUUID().toString()); + collectionDefinition.setId(UUID.randomUUID().toString()); collectionDefinition.setPartitionKey(partitionKeyDef); return collectionDefinition; } -} \ No newline at end of file +} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java similarity index 91% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java index 7b60ec95e4b4..058fbc86cc25 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SimpleSerializationTest.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; +import com.azure.data.cosmos.CosmosAsyncClient; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonMappingException; @@ -24,8 +24,8 @@ public class SimpleSerializationTest extends TestSuiteBase { - private CosmosContainer createdCollection; - private CosmosClient client; + private CosmosAsyncContainer createdCollection; + private CosmosAsyncClient client; private static class TestObject { public static class BadSerializer extends JsonSerializer { @@ -70,7 +70,7 @@ public void createDocument() throws InterruptedException { @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java similarity index 87% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java index 892b879de541..de272e8da503 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionDocumentQueryTest.java @@ -2,18 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.Database; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.SqlParameter; -import com.azure.data.cosmos.SqlParameterList; -import com.azure.data.cosmos.SqlQuerySpec; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; @@ -38,13 +29,13 @@ public class SinglePartitionDocumentQueryTest extends TestSuiteBase { private Database createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdDocuments = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } @Factory(dataProvider = "clientBuildersWithDirect") @@ -61,7 +52,7 @@ public void queryDocuments(boolean queryMetricsEnabled) throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(5); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.populateQueryMetrics(queryMetricsEnabled); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -72,7 +63,7 @@ public void queryDocuments(boolean queryMetricsEnabled) throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -90,7 +81,7 @@ public void queryDocuments_ParameterizedQueryWithInClause() throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(5); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(sqs, options); List expectedDocs = createdDocuments.stream().filter(d -> (3 == d.getInt("prop") || 4 == d.getInt("prop"))).collect(Collectors.toList()); @@ -100,7 +91,7 @@ public void queryDocuments_ParameterizedQueryWithInClause() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -117,7 +108,7 @@ public void queryDocuments_ParameterizedQuery() throws Exception { FeedOptions options = new FeedOptions(); options.maxItemCount(5); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(sqs, options); List expectedDocs = createdDocuments.stream().filter(d -> 3 == d.getInt("prop")).collect(Collectors.toList()); @@ -127,7 +118,7 @@ public void queryDocuments_ParameterizedQuery() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -141,7 +132,7 @@ public void queryDocuments_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -159,7 +150,7 @@ public void queryDocumentsWithPageSize() throws Exception { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); options.maxItemCount(3); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); List expectedDocs = createdDocuments; @@ -169,7 +160,7 @@ public void queryDocumentsWithPageSize() throws Exception { .Builder() .exactlyContainsInAnyOrder(createdDocuments .stream() - .map(d -> d.resourceId()) + .map(d -> d.getResourceId()) .collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() @@ -184,7 +175,7 @@ public void queryOrderBy() throws Exception { String query = "SELECT * FROM r ORDER BY r.prop ASC"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(3); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -194,7 +185,7 @@ public void queryOrderBy() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .containsExactly(createdDocuments.stream() .sorted((e1, e2) -> Integer.compare(e1.getInt("prop"), e2.getInt("prop"))) - .map(d -> d.resourceId()).collect(Collectors.toList())) + .map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -207,7 +198,7 @@ public void queryOrderBy() throws Exception { public void continuationToken() throws Exception { String query = "SELECT * FROM r ORDER BY r.prop ASC"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(3); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -219,12 +210,12 @@ public void continuationToken() throws Exception { subscriber.assertNoErrors(); assertThat(subscriber.valueCount()).isEqualTo(1); FeedResponse page = ((FeedResponse) subscriber.getEvents().get(0).get(0)); - assertThat(page.results()).hasSize(3); + assertThat(page.getResults()).hasSize(3); - assertThat(page.continuationToken()).isNotEmpty(); + assertThat(page.getContinuationToken()).isNotEmpty(); - options.requestContinuation(page.continuationToken()); + options.requestContinuation(page.getContinuationToken()); queryObservable = createdCollection.queryItems(query, options); List expectedDocs = createdDocuments.stream().filter(d -> (d.getInt("prop") > 2)).collect(Collectors.toList()); @@ -235,7 +226,7 @@ public void continuationToken() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .containsExactly(expectedDocs.stream() .sorted((e1, e2) -> Integer.compare(e1.getInt("prop"), e2.getInt("prop"))) - .map(d -> d.resourceId()).collect(Collectors.toList())) + .map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -247,7 +238,7 @@ public void continuationToken() throws Exception { public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.queryItems(query, options); FailureValidator validator = new FailureValidator.Builder() @@ -258,14 +249,14 @@ public void invalidQuerySytax() throws Exception { validateQueryFailure(queryObservable, validator); } - public CosmosItemProperties createDocument(CosmosContainer cosmosContainer, int cnt) { + public CosmosItemProperties createDocument(CosmosAsyncContainer cosmosContainer, int cnt) { CosmosItemProperties docDefinition = getDocumentDefinition(cnt); - return cosmosContainer.createItem(docDefinition, new CosmosItemRequestOptions()).block().properties(); + return cosmosContainer.createItem(docDefinition, new CosmosItemRequestOptions()).block().getProperties(); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedSinglePartitionCosmosContainer(client); truncateCollection(createdCollection); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java index f10436ab1667..50cc9eea486b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/SinglePartitionReadFeedDocumentsTest.java @@ -2,12 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import org.testng.annotations.AfterClass; @@ -23,10 +19,10 @@ public class SinglePartitionReadFeedDocumentsTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdDocuments; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public SinglePartitionReadFeedDocumentsTest(CosmosClientBuilder clientBuilder) { @@ -36,7 +32,7 @@ public SinglePartitionReadFeedDocumentsTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = FEED_TIMEOUT) public void readDocuments() { final FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(2); final Flux> feedObservable = createdCollection.readAllItems(options); final int expectedPageSize = (createdDocuments.size() + options.maxItemCount() - 1) / options.maxItemCount(); @@ -44,7 +40,7 @@ public void readDocuments() { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(createdDocuments.size()) .numberOfPages(expectedPageSize) - .exactlyContainsInAnyOrder(createdDocuments.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(createdDocuments.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) .build(); @@ -53,7 +49,7 @@ public void readDocuments() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedSinglePartitionCosmosContainer(client); truncateCollection(createdCollection); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java similarity index 53% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java index 10e802ff0c39..276d2c10ac0c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureCrudTest.java @@ -2,15 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosStoredProcedure; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.CosmosStoredProcedureResponse; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -24,8 +17,8 @@ public class StoredProcedureCrudTest extends TestSuiteBase { - private CosmosClient client; - private CosmosContainer container; + private CosmosAsyncClient client; + private CosmosAsyncContainer container; @Factory(dataProvider = "clientBuildersWithDirect") public StoredProcedureCrudTest(CosmosClientBuilder clientBuilder) { @@ -36,13 +29,13 @@ public StoredProcedureCrudTest(CosmosClientBuilder clientBuilder) { public void createStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); - Mono createObservable = container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()); + Mono createObservable = container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(storedProcedureDef.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(storedProcedureDef.getId()) .withStoredProcedureBody("function() {var x = 10;}") .notNullEtag() .build(); @@ -54,15 +47,15 @@ public void createStoredProcedure() throws Exception { public void readStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); - CosmosStoredProcedure storedProcedure = container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block().storedProcedure(); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); + CosmosAsyncStoredProcedure storedProcedure = container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block().getStoredProcedure(); waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = storedProcedure.read(null); + Mono readObservable = storedProcedure.read(null); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(storedProcedureDef.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(storedProcedureDef.getId()) .withStoredProcedureBody("function() {var x = 10;}") .notNullEtag() .build(); @@ -74,13 +67,13 @@ public void readStoredProcedure() throws Exception { public void deleteStoredProcedure() throws Exception { CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); - CosmosStoredProcedure storedProcedure = this.container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block().storedProcedure(); - Mono deleteObservable = storedProcedure.delete(new CosmosStoredProcedureRequestOptions()); + CosmosAsyncStoredProcedure storedProcedure = this.container.getScripts().createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block().getStoredProcedure(); + Mono deleteObservable = storedProcedure.delete(new CosmosStoredProcedureRequestOptions()); - CosmosResponseValidator validator = new CosmosResponseValidator.Builder<>() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource() .build(); @@ -88,7 +81,7 @@ public void deleteStoredProcedure() throws Exception { waitIfNeededForReplicasToCatchUp(this.clientBuilder()); - Mono readObservable = storedProcedure.read(null); + Mono readObservable = storedProcedure.read(null); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(readObservable, notFoundValidator); } @@ -96,7 +89,7 @@ public void deleteStoredProcedure() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = 10_000 * SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); - this.client = clientBuilder().build(); + this.client = clientBuilder().buildAsyncClient(); this.container = getSharedMultiPartitionCosmosContainer(this.client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java similarity index 85% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java index 6c82848b423d..60a5b3cb7c0d 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureQueryTest.java @@ -2,13 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; @@ -30,10 +25,10 @@ @Ignore public class StoredProcedureQueryTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdStoredProcs = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public StoredProcedureQueryTest(CosmosClientBuilder clientBuilder) { @@ -43,7 +38,7 @@ public StoredProcedureQueryTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryWithFilter() throws Exception { - String filterId = createdStoredProcs.get(0).id(); + String filterId = createdStoredProcs.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterId); FeedOptions options = new FeedOptions(); @@ -52,14 +47,14 @@ public void queryWithFilter() throws Exception { .queryStoredProcedures(query, options); List expectedDocs = createdStoredProcs.stream() - .filter(sp -> filterId.equals(sp.id())).collect(Collectors.toList()); + .filter(sp -> filterId.equals(sp.getId())).collect(Collectors.toList()); assertThat(expectedDocs).isNotEmpty(); int expectedPageSize = (expectedDocs.size() + options.maxItemCount() - 1) / options.maxItemCount(); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -73,7 +68,7 @@ public void query_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts() .queryStoredProcedures(query, options); @@ -91,7 +86,7 @@ public void queryAll() throws Exception { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); options.maxItemCount(3); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts() .queryStoredProcedures(query, options); @@ -100,7 +95,7 @@ public void queryAll() throws Exception { int expectedPageSize = (expectedDocs.size() + options.maxItemCount() - 1) / options.maxItemCount(); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -113,7 +108,7 @@ public void queryAll() throws Exception { public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts() .queryStoredProcedures(query, options); @@ -122,14 +117,14 @@ public void invalidQuerySytax() throws Exception { validateQueryFailure(queryObservable, validator); } - public CosmosStoredProcedureProperties createStoredProc(CosmosContainer cosmosContainer) { + public CosmosStoredProcedureProperties createStoredProc(CosmosAsyncContainer cosmosContainer) { CosmosStoredProcedureProperties storedProcedure = getStoredProcedureDef(); - return cosmosContainer.getScripts().createStoredProcedure(storedProcedure).block().properties(); + return cosmosContainer.getScripts().createStoredProcedure(storedProcedure).block().getProperties(); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -147,8 +142,8 @@ public void afterClass() { private static CosmosStoredProcedureProperties getStoredProcedureDef() { CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); return storedProcedureDef; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java similarity index 60% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java index ab2df249453d..441c953d63ee 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/StoredProcedureUpsertReplaceTest.java @@ -2,16 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosStoredProcedure; -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.CosmosStoredProcedureResponse; -import com.azure.data.cosmos.PartitionKey; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.testng.annotations.Factory; import org.testng.annotations.Test; import org.testng.annotations.Ignore; @@ -25,9 +17,9 @@ public class StoredProcedureUpsertReplaceTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public StoredProcedureUpsertReplaceTest(CosmosClientBuilder clientBuilder) { @@ -39,31 +31,31 @@ public void replaceStoredProcedure() throws Exception { // create a stored procedure CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(); - storedProcedureDef.id(UUID.randomUUID().toString()); - storedProcedureDef.body("function() {var x = 10;}"); + storedProcedureDef.setId(UUID.randomUUID().toString()); + storedProcedureDef.setBody("function() {var x = 10;}"); CosmosStoredProcedureProperties readBackSp = createdCollection.getScripts() .createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block() - .properties(); + .getProperties(); // read stored procedure to validate creation waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = createdCollection.getScripts() - .getStoredProcedure(readBackSp.id()).read(null); + Mono readObservable = createdCollection.getScripts() + .getStoredProcedure(readBackSp.getId()).read(null); // validate stored procedure creation - CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() - .withId(readBackSp.id()).withStoredProcedureBody("function() {var x = 10;}").notNullEtag().build(); + CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() + .withId(readBackSp.getId()).withStoredProcedureBody("function() {var x = 10;}").notNullEtag().build(); validateSuccess(readObservable, validatorForRead); // update stored procedure - readBackSp.body("function() {var x = 11;}"); + readBackSp.setBody("function() {var x = 11;}"); - Mono replaceObservable = createdCollection.getScripts() - .getStoredProcedure(readBackSp.id()).replace(readBackSp); + Mono replaceObservable = createdCollection.getScripts() + .getStoredProcedure(readBackSp.getId()).replace(readBackSp); // validate stored procedure replace - CosmosResponseValidator validatorForReplace = new CosmosResponseValidator.Builder() - .withId(readBackSp.id()).withStoredProcedureBody("function() {var x = 11;}").notNullEtag().build(); + CosmosResponseValidator validatorForReplace = new CosmosResponseValidator.Builder() + .withId(readBackSp.getId()).withStoredProcedureBody("function() {var x = 11;}").notNullEtag().build(); validateSuccess(replaceObservable, validatorForReplace); } @@ -77,24 +69,24 @@ public void executeStoredProcedure() throws Exception { + " 'body':" + " 'function () {" + " for (var i = 0; i < 10; i++) {" + " getContext().getResponse().appendValue(\"Body\", i);" + " }" + " }'" + "}"); - CosmosStoredProcedure storedProcedure = null; + CosmosAsyncStoredProcedure storedProcedure = null; storedProcedure = createdCollection.getScripts() .createStoredProcedure(storedProcedureDef, new CosmosStoredProcedureRequestOptions()).block() - .storedProcedure(); + .getStoredProcedure(); String result = null; CosmosStoredProcedureRequestOptions options = new CosmosStoredProcedureRequestOptions(); - options.partitionKey(PartitionKey.None); - result = storedProcedure.execute(null, options).block().responseAsString(); + options.setPartitionKey(PartitionKey.None); + result = storedProcedure.execute(null, options).block().getResponseAsString(); assertThat(result).isEqualTo("\"0123456789\""); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java similarity index 73% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java index 9a6387ae9e7e..a91724c4597b 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TestSuiteBase.java @@ -2,44 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CompositePath; -import com.azure.data.cosmos.CompositePathSortOrder; -import com.azure.data.cosmos.ConnectionMode; -import com.azure.data.cosmos.ConnectionPolicy; -import com.azure.data.cosmos.ConsistencyLevel; -import com.azure.data.cosmos.CosmosBridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosClientTest; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerRequestOptions; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.CosmosDatabaseResponse; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.CosmosKeyCredential; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosStoredProcedureRequestOptions; -import com.azure.data.cosmos.CosmosUser; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.DataType; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.IncludedPath; -import com.azure.data.cosmos.Index; -import com.azure.data.cosmos.IndexingPolicy; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.PartitionKeyDefinition; -import com.azure.data.cosmos.Resource; -import com.azure.data.cosmos.RetryOptions; -import com.azure.data.cosmos.SqlQuerySpec; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.Configs; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; @@ -47,8 +11,8 @@ import com.azure.data.cosmos.internal.TestConfigurations; import com.azure.data.cosmos.internal.Utils; import com.azure.data.cosmos.internal.directconnectivity.Protocol; -import com.azure.data.cosmos.sync.CosmosSyncClient; -import com.azure.data.cosmos.sync.CosmosSyncDatabase; +import com.azure.data.cosmos.CosmosClient; +import com.azure.data.cosmos.CosmosDatabase; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -81,7 +45,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.spy; -public class TestSuiteBase extends CosmosClientTest { +public class TestSuiteBase extends CosmosAsyncClientTest { private static final int DEFAULT_BULK_INSERT_CONCURRENCY_LEVEL = 500; private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -106,28 +70,28 @@ public class TestSuiteBase extends CosmosClientTest { protected int subscriberValidationTimeout = TIMEOUT; - private static CosmosDatabase SHARED_DATABASE; - private static CosmosContainer SHARED_MULTI_PARTITION_COLLECTION; - private static CosmosContainer SHARED_MULTI_PARTITION_COLLECTION_WITH_COMPOSITE_AND_SPATIAL_INDEXES; - private static CosmosContainer SHARED_SINGLE_PARTITION_COLLECTION; + private static CosmosAsyncDatabase SHARED_DATABASE; + private static CosmosAsyncContainer SHARED_MULTI_PARTITION_COLLECTION; + private static CosmosAsyncContainer SHARED_MULTI_PARTITION_COLLECTION_WITH_COMPOSITE_AND_SPATIAL_INDEXES; + private static CosmosAsyncContainer SHARED_SINGLE_PARTITION_COLLECTION; public TestSuiteBase(CosmosClientBuilder clientBuilder) { super(clientBuilder); } - protected static CosmosDatabase getSharedCosmosDatabase(CosmosClient client) { + protected static CosmosAsyncDatabase getSharedCosmosDatabase(CosmosAsyncClient client) { return CosmosBridgeInternal.getCosmosDatabaseWithNewClient(SHARED_DATABASE, client); } - protected static CosmosContainer getSharedMultiPartitionCosmosContainer(CosmosClient client) { + protected static CosmosAsyncContainer getSharedMultiPartitionCosmosContainer(CosmosAsyncClient client) { return CosmosBridgeInternal.getCosmosContainerWithNewClient(SHARED_MULTI_PARTITION_COLLECTION, SHARED_DATABASE, client); } - protected static CosmosContainer getSharedMultiPartitionCosmosContainerWithCompositeAndSpatialIndexes(CosmosClient client) { + protected static CosmosAsyncContainer getSharedMultiPartitionCosmosContainerWithCompositeAndSpatialIndexes(CosmosAsyncClient client) { return CosmosBridgeInternal.getCosmosContainerWithNewClient(SHARED_MULTI_PARTITION_COLLECTION_WITH_COMPOSITE_AND_SPATIAL_INDEXES, SHARED_DATABASE, client); } - protected static CosmosContainer getSharedSinglePartitionCosmosContainer(CosmosClient client) { + protected static CosmosAsyncContainer getSharedSinglePartitionCosmosContainer(CosmosAsyncClient client) { return CosmosBridgeInternal.getCosmosContainerWithNewClient(SHARED_SINGLE_PARTITION_COLLECTION, SHARED_DATABASE, client); } @@ -158,13 +122,13 @@ private static ImmutableList immutableListOrNull(List list) { } private static class DatabaseManagerImpl implements CosmosDatabaseForTest.DatabaseManager { - public static DatabaseManagerImpl getInstance(CosmosClient client) { + public static DatabaseManagerImpl getInstance(CosmosAsyncClient client) { return new DatabaseManagerImpl(client); } - private final CosmosClient client; + private final CosmosAsyncClient client; - private DatabaseManagerImpl(CosmosClient client) { + private DatabaseManagerImpl(CosmosAsyncClient client) { this.client = client; } @@ -174,12 +138,12 @@ public Flux> queryDatabases(SqlQuerySpec } @Override - public Mono createDatabase(CosmosDatabaseProperties databaseDefinition) { + public Mono createDatabase(CosmosDatabaseProperties databaseDefinition) { return client.createDatabase(databaseDefinition); } @Override - public CosmosDatabase getDatabase(String id) { + public CosmosAsyncDatabase getDatabase(String id) { return client.getDatabase(id); } } @@ -189,7 +153,7 @@ public static void beforeSuite() { logger.info("beforeSuite Started"); - try (CosmosClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().build()) { + try (CosmosAsyncClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().buildAsyncClient()) { CosmosDatabaseForTest dbForTest = CosmosDatabaseForTest.create(DatabaseManagerImpl.getInstance(houseKeepingClient)); SHARED_DATABASE = dbForTest.createdDatabase; CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); @@ -204,27 +168,27 @@ public static void afterSuite() { logger.info("afterSuite Started"); - try (CosmosClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().build()) { + try (CosmosAsyncClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().buildAsyncClient()) { safeDeleteDatabase(SHARED_DATABASE); CosmosDatabaseForTest.cleanupStaleTestDatabases(DatabaseManagerImpl.getInstance(houseKeepingClient)); } } - protected static void truncateCollection(CosmosContainer cosmosContainer) { - CosmosContainerProperties cosmosContainerProperties = cosmosContainer.read().block().properties(); - String cosmosContainerId = cosmosContainerProperties.id(); + protected static void truncateCollection(CosmosAsyncContainer cosmosContainer) { + CosmosContainerProperties cosmosContainerProperties = cosmosContainer.read().block().getProperties(); + String cosmosContainerId = cosmosContainerProperties.getId(); logger.info("Truncating collection {} ...", cosmosContainerId); - List paths = cosmosContainerProperties.partitionKeyDefinition().paths(); + List paths = cosmosContainerProperties.getPartitionKeyDefinition().getPaths(); FeedOptions options = new FeedOptions(); - options.maxDegreeOfParallelism(-1); - options.enableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(-1); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(100); - logger.info("Truncating collection {} documents ...", cosmosContainer.id()); + logger.info("Truncating collection {} documents ...", cosmosContainer.getId()); cosmosContainer.queryItems("SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(doc -> { Object propertyValue = null; @@ -236,57 +200,63 @@ protected static void truncateCollection(CosmosContainer cosmosContainer) { } } - return cosmosContainer.getItem(doc.id(), propertyValue).delete(); + return cosmosContainer.getItem(doc.getId(), propertyValue).delete(); }).then().block(); logger.info("Truncating collection {} triggers ...", cosmosContainerId); cosmosContainer.getScripts().queryTriggers("SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(trigger -> { // if (paths != null && !paths.isEmpty()) { // Object propertyValue = trigger.getObjectByPath(PathParser.getPathParts(paths.get(0))); // requestOptions.partitionKey(new PartitionKey(propertyValue)); +// Object propertyValue = getTrigger.getObjectByPath(PathParser.getPathParts(getPaths.get(0))); +// requestOptions.getPartitionKey(new PartitionKey(propertyValue)); // } - return cosmosContainer.getScripts().getTrigger(trigger.id()).delete(); + return cosmosContainer.getScripts().getTrigger(trigger.getId()).delete(); }).then().block(); logger.info("Truncating collection {} storedProcedures ...", cosmosContainerId); cosmosContainer.getScripts().queryStoredProcedures("SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(storedProcedure -> { +// if (getPaths != null && !getPaths.isEmpty()) { // if (paths != null && !paths.isEmpty()) { // Object propertyValue = storedProcedure.getObjectByPath(PathParser.getPathParts(paths.get(0))); // requestOptions.partitionKey(new PartitionKey(propertyValue)); +// requestOptions.getPartitionKey(new PartitionKey(propertyValue)); // } - return cosmosContainer.getScripts().getStoredProcedure(storedProcedure.id()).delete(new CosmosStoredProcedureRequestOptions()); + return cosmosContainer.getScripts().getStoredProcedure(storedProcedure.getId()).delete(new CosmosStoredProcedureRequestOptions()); }).then().block(); logger.info("Truncating collection {} udfs ...", cosmosContainerId); cosmosContainer.getScripts().queryUserDefinedFunctions("SELECT * FROM root", options) .publishOn(Schedulers.parallel()) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .flatMap(udf -> { +// if (getPaths != null && !getPaths.isEmpty()) { // if (paths != null && !paths.isEmpty()) { // Object propertyValue = udf.getObjectByPath(PathParser.getPathParts(paths.get(0))); // requestOptions.partitionKey(new PartitionKey(propertyValue)); +// requestOptions.getPartitionKey(new PartitionKey(propertyValue)); // } - return cosmosContainer.getScripts().getUserDefinedFunction(udf.id()).delete(); + return cosmosContainer.getScripts().getUserDefinedFunction(udf.getId()).delete(); }).then().block(); logger.info("Finished truncating collection {}.", cosmosContainerId); } protected static void waitIfNeededForReplicasToCatchUp(CosmosClientBuilder clientBuilder) { - switch (clientBuilder.consistencyLevel()) { + switch (clientBuilder.getConsistencyLevel()) { case EVENTUAL: case CONSISTENT_PREFIX: logger.info(" additional wait in EVENTUAL mode so the replica catch up"); @@ -305,14 +275,14 @@ protected static void waitIfNeededForReplicasToCatchUp(CosmosClientBuilder clien } } - public static CosmosContainer createCollection(CosmosDatabase database, CosmosContainerProperties cosmosContainerProperties, - CosmosContainerRequestOptions options, int throughput) { - return database.createContainer(cosmosContainerProperties, throughput, options).block().container(); + public static CosmosAsyncContainer createCollection(CosmosAsyncDatabase database, CosmosContainerProperties cosmosContainerProperties, + CosmosContainerRequestOptions options, int throughput) { + return database.createContainer(cosmosContainerProperties, throughput, options).block().getContainer(); } - public static CosmosContainer createCollection(CosmosDatabase database, CosmosContainerProperties cosmosContainerProperties, - CosmosContainerRequestOptions options) { - return database.createContainer(cosmosContainerProperties, options).block().container(); + public static CosmosAsyncContainer createCollection(CosmosAsyncDatabase database, CosmosContainerProperties cosmosContainerProperties, + CosmosContainerRequestOptions options) { + return database.createContainer(cosmosContainerProperties, options).block().getContainer(); } private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWithCompositeAndSpatialIndexes() { @@ -332,7 +302,7 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); ArrayList partitionKeyPaths = new ArrayList(); partitionKeyPaths.add("/" + PARTITION_KEY); - partitionKeyDefinition.paths(partitionKeyPaths); + partitionKeyDefinition.setPaths(partitionKeyPaths); CosmosContainerProperties cosmosContainerProperties = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDefinition); @@ -342,12 +312,12 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi //Simple ArrayList compositeIndexSimple = new ArrayList(); CompositePath compositePath1 = new CompositePath(); - compositePath1.path("/" + NUMBER_FIELD); - compositePath1.order(CompositePathSortOrder.ASCENDING); + compositePath1.setPath("/" + NUMBER_FIELD); + compositePath1.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath2 = new CompositePath(); - compositePath2.path("/" + STRING_FIELD); - compositePath2.order(CompositePathSortOrder.DESCENDING); + compositePath2.setPath("/" + STRING_FIELD); + compositePath2.setOrder(CompositePathSortOrder.DESCENDING); compositeIndexSimple.add(compositePath1); compositeIndexSimple.add(compositePath2); @@ -355,20 +325,20 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi //Max Columns ArrayList compositeIndexMaxColumns = new ArrayList(); CompositePath compositePath3 = new CompositePath(); - compositePath3.path("/" + NUMBER_FIELD); - compositePath3.order(CompositePathSortOrder.DESCENDING); + compositePath3.setPath("/" + NUMBER_FIELD); + compositePath3.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath4 = new CompositePath(); - compositePath4.path("/" + STRING_FIELD); - compositePath4.order(CompositePathSortOrder.ASCENDING); + compositePath4.setPath("/" + STRING_FIELD); + compositePath4.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath5 = new CompositePath(); - compositePath5.path("/" + NUMBER_FIELD_2); - compositePath5.order(CompositePathSortOrder.DESCENDING); + compositePath5.setPath("/" + NUMBER_FIELD_2); + compositePath5.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath6 = new CompositePath(); - compositePath6.path("/" + STRING_FIELD_2); - compositePath6.order(CompositePathSortOrder.ASCENDING); + compositePath6.setPath("/" + STRING_FIELD_2); + compositePath6.setOrder(CompositePathSortOrder.ASCENDING); compositeIndexMaxColumns.add(compositePath3); compositeIndexMaxColumns.add(compositePath4); @@ -378,20 +348,20 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi //Primitive Values ArrayList compositeIndexPrimitiveValues = new ArrayList(); CompositePath compositePath7 = new CompositePath(); - compositePath7.path("/" + NUMBER_FIELD); - compositePath7.order(CompositePathSortOrder.DESCENDING); + compositePath7.setPath("/" + NUMBER_FIELD); + compositePath7.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath8 = new CompositePath(); - compositePath8.path("/" + STRING_FIELD); - compositePath8.order(CompositePathSortOrder.ASCENDING); + compositePath8.setPath("/" + STRING_FIELD); + compositePath8.setOrder(CompositePathSortOrder.ASCENDING); CompositePath compositePath9 = new CompositePath(); - compositePath9.path("/" + BOOL_FIELD); - compositePath9.order(CompositePathSortOrder.DESCENDING); + compositePath9.setPath("/" + BOOL_FIELD); + compositePath9.setOrder(CompositePathSortOrder.DESCENDING); CompositePath compositePath10 = new CompositePath(); - compositePath10.path("/" + NULL_FIELD); - compositePath10.order(CompositePathSortOrder.ASCENDING); + compositePath10.setPath("/" + NULL_FIELD); + compositePath10.setOrder(CompositePathSortOrder.ASCENDING); compositeIndexPrimitiveValues.add(compositePath7); compositeIndexPrimitiveValues.add(compositePath8); @@ -401,16 +371,16 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi //Long Strings ArrayList compositeIndexLongStrings = new ArrayList(); CompositePath compositePath11 = new CompositePath(); - compositePath11.path("/" + STRING_FIELD); + compositePath11.setPath("/" + STRING_FIELD); CompositePath compositePath12 = new CompositePath(); - compositePath12.path("/" + SHORT_STRING_FIELD); + compositePath12.setPath("/" + SHORT_STRING_FIELD); CompositePath compositePath13 = new CompositePath(); - compositePath13.path("/" + MEDIUM_STRING_FIELD); + compositePath13.setPath("/" + MEDIUM_STRING_FIELD); CompositePath compositePath14 = new CompositePath(); - compositePath14.path("/" + LONG_STRING_FIELD); + compositePath14.setPath("/" + LONG_STRING_FIELD); compositeIndexLongStrings.add(compositePath11); compositeIndexLongStrings.add(compositePath12); @@ -422,63 +392,63 @@ private static CosmosContainerProperties getCollectionDefinitionMultiPartitionWi compositeIndexes.add(compositeIndexPrimitiveValues); compositeIndexes.add(compositeIndexLongStrings); - indexingPolicy.compositeIndexes(compositeIndexes); - cosmosContainerProperties.indexingPolicy(indexingPolicy); + indexingPolicy.setCompositeIndexes(compositeIndexes); + cosmosContainerProperties.setIndexingPolicy(indexingPolicy); return cosmosContainerProperties; } - public static CosmosContainer createCollection(CosmosClient client, String dbId, CosmosContainerProperties collectionDefinition) { - return client.getDatabase(dbId).createContainer(collectionDefinition).block().container(); + public static CosmosAsyncContainer createCollection(CosmosAsyncClient client, String dbId, CosmosContainerProperties collectionDefinition) { + return client.getDatabase(dbId).createContainer(collectionDefinition).block().getContainer(); } - public static void deleteCollection(CosmosClient client, String dbId, String collectionId) { + public static void deleteCollection(CosmosAsyncClient client, String dbId, String collectionId) { client.getDatabase(dbId).getContainer(collectionId).delete().block(); } - public static CosmosItem createDocument(CosmosContainer cosmosContainer, CosmosItemProperties item) { - return cosmosContainer.createItem(item).block().item(); + public static CosmosAsyncItem createDocument(CosmosAsyncContainer cosmosContainer, CosmosItemProperties item) { + return cosmosContainer.createItem(item).block().getItem(); } - public Flux bulkInsert(CosmosContainer cosmosContainer, - List documentDefinitionList, - int concurrencyLevel) { - List> result = new ArrayList<>(documentDefinitionList.size()); + public Flux bulkInsert(CosmosAsyncContainer cosmosContainer, + List documentDefinitionList, + int concurrencyLevel) { + List> result = new ArrayList<>(documentDefinitionList.size()); for (CosmosItemProperties docDef : documentDefinitionList) { result.add(cosmosContainer.createItem(docDef)); } return Flux.merge(Flux.fromIterable(result), concurrencyLevel); } - public List bulkInsertBlocking(CosmosContainer cosmosContainer, + public List bulkInsertBlocking(CosmosAsyncContainer cosmosContainer, List documentDefinitionList) { return bulkInsert(cosmosContainer, documentDefinitionList, DEFAULT_BULK_INSERT_CONCURRENCY_LEVEL) .publishOn(Schedulers.parallel()) - .map(CosmosItemResponse::properties) + .map(CosmosAsyncItemResponse::getProperties) .collectList() .block(); } - public void voidBulkInsertBlocking(CosmosContainer cosmosContainer, - List documentDefinitionList) { + public void voidBulkInsertBlocking(CosmosAsyncContainer cosmosContainer, + List documentDefinitionList) { bulkInsert(cosmosContainer, documentDefinitionList, DEFAULT_BULK_INSERT_CONCURRENCY_LEVEL) .publishOn(Schedulers.parallel()) - .map(CosmosItemResponse::properties) + .map(CosmosAsyncItemResponse::getProperties) .then() .block(); } - public static CosmosUser createUser(CosmosClient client, String databaseId, CosmosUserProperties userSettings) { - return client.getDatabase(databaseId).read().block().database().createUser(userSettings).block().user(); + public static CosmosAsyncUser createUser(CosmosAsyncClient client, String databaseId, CosmosUserProperties userSettings) { + return client.getDatabase(databaseId).read().block().getDatabase().createUser(userSettings).block().getUser(); } - public static CosmosUser safeCreateUser(CosmosClient client, String databaseId, CosmosUserProperties user) { - deleteUserIfExists(client, databaseId, user.id()); + public static CosmosAsyncUser safeCreateUser(CosmosAsyncClient client, String databaseId, CosmosUserProperties user) { + deleteUserIfExists(client, databaseId, user.getId()); return createUser(client, databaseId, user); } - private static CosmosContainer safeCreateCollection(CosmosClient client, String databaseId, CosmosContainerProperties collection, CosmosContainerRequestOptions options) { - deleteCollectionIfExists(client, databaseId, collection.id()); + private static CosmosAsyncContainer safeCreateCollection(CosmosAsyncClient client, String databaseId, CosmosContainerProperties collection, CosmosContainerRequestOptions options) { + deleteCollectionIfExists(client, databaseId, collection.getId()); return createCollection(client.getDatabase(databaseId), collection, options); } @@ -486,7 +456,7 @@ static protected CosmosContainerProperties getCollectionDefinition() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); @@ -497,33 +467,33 @@ static protected CosmosContainerProperties getCollectionDefinitionWithRangeRange PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList<>(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); IndexingPolicy indexingPolicy = new IndexingPolicy(); List includedPaths = new ArrayList<>(); IncludedPath includedPath = new IncludedPath(); - includedPath.path("/*"); + includedPath.setPath("/*"); Collection indexes = new ArrayList<>(); Index stringIndex = Index.Range(DataType.STRING); - BridgeInternal.setProperty(stringIndex, "precision", -1); + BridgeInternal.setProperty(stringIndex, "getPrecision", -1); indexes.add(stringIndex); Index numberIndex = Index.Range(DataType.NUMBER); BridgeInternal.setProperty(numberIndex, "precision", -1); indexes.add(numberIndex); - includedPath.indexes(indexes); + includedPath.setIndexes(indexes); includedPaths.add(includedPath); indexingPolicy.setIncludedPaths(includedPaths); CosmosContainerProperties cosmosContainerProperties = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); - cosmosContainerProperties.indexingPolicy(indexingPolicy); + cosmosContainerProperties.setIndexingPolicy(indexingPolicy); return cosmosContainerProperties; } - public static void deleteCollectionIfExists(CosmosClient client, String databaseId, String collectionId) { - CosmosDatabase database = client.getDatabase(databaseId).read().block().database(); + public static void deleteCollectionIfExists(CosmosAsyncClient client, String databaseId, String collectionId) { + CosmosAsyncDatabase database = client.getDatabase(databaseId).read().block().getDatabase(); List res = database.queryContainers(String.format("SELECT * FROM root r where r.id = '%s'", collectionId), null) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .collectList() .block(); @@ -532,21 +502,21 @@ public static void deleteCollectionIfExists(CosmosClient client, String database } } - public static void deleteCollection(CosmosDatabase cosmosDatabase, String collectionId) { + public static void deleteCollection(CosmosAsyncDatabase cosmosDatabase, String collectionId) { cosmosDatabase.getContainer(collectionId).delete().block(); } - public static void deleteCollection(CosmosContainer cosmosContainer) { + public static void deleteCollection(CosmosAsyncContainer cosmosContainer) { cosmosContainer.delete().block(); } - public static void deleteDocumentIfExists(CosmosClient client, String databaseId, String collectionId, String docId) { + public static void deleteDocumentIfExists(CosmosAsyncClient client, String databaseId, String collectionId, String docId) { FeedOptions options = new FeedOptions(); options.partitionKey(new PartitionKey(docId)); - CosmosContainer cosmosContainer = client.getDatabase(databaseId).read().block().database().getContainer(collectionId).read().block().container(); + CosmosAsyncContainer cosmosContainer = client.getDatabase(databaseId).read().block().getDatabase().getContainer(collectionId).read().block().getContainer(); List res = cosmosContainer .queryItems(String.format("SELECT * FROM root r where r.id = '%s'", docId), options) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .collectList().block(); if (!res.isEmpty()) { @@ -554,72 +524,72 @@ public static void deleteDocumentIfExists(CosmosClient client, String databaseId } } - public static void safeDeleteDocument(CosmosContainer cosmosContainer, String documentId, Object partitionKey) { + public static void safeDeleteDocument(CosmosAsyncContainer cosmosContainer, String documentId, Object partitionKey) { if (cosmosContainer != null && documentId != null) { try { - cosmosContainer.getItem(documentId, partitionKey).read().block().item().delete().block(); + cosmosContainer.getItem(documentId, partitionKey).read().block().getItem().delete().block(); } catch (Exception e) { CosmosClientException dce = Utils.as(e, CosmosClientException.class); - if (dce == null || dce.statusCode() != 404) { + if (dce == null || dce.getStatusCode() != 404) { throw e; } } } } - public static void deleteDocument(CosmosContainer cosmosContainer, String documentId) { - cosmosContainer.getItem(documentId, PartitionKey.None).read().block().item().delete(); + public static void deleteDocument(CosmosAsyncContainer cosmosContainer, String documentId) { + cosmosContainer.getItem(documentId, PartitionKey.None).read().block().getItem().delete(); } - public static void deleteUserIfExists(CosmosClient client, String databaseId, String userId) { - CosmosDatabase database = client.getDatabase(databaseId).read().block().database(); + public static void deleteUserIfExists(CosmosAsyncClient client, String databaseId, String userId) { + CosmosAsyncDatabase database = client.getDatabase(databaseId).read().block().getDatabase(); List res = database .queryUsers(String.format("SELECT * FROM root r where r.id = '%s'", userId), null) - .flatMap(page -> Flux.fromIterable(page.results())) + .flatMap(page -> Flux.fromIterable(page.getResults())) .collectList().block(); if (!res.isEmpty()) { deleteUser(database, userId); } } - public static void deleteUser(CosmosDatabase database, String userId) { - database.getUser(userId).read().block().user().delete().block(); + public static void deleteUser(CosmosAsyncDatabase database, String userId) { + database.getUser(userId).read().block().getUser().delete().block(); } - static private CosmosDatabase safeCreateDatabase(CosmosClient client, CosmosDatabaseProperties databaseSettings) { - safeDeleteDatabase(client.getDatabase(databaseSettings.id())); - return client.createDatabase(databaseSettings).block().database(); + static private CosmosAsyncDatabase safeCreateDatabase(CosmosAsyncClient client, CosmosDatabaseProperties databaseSettings) { + safeDeleteDatabase(client.getDatabase(databaseSettings.getId())); + return client.createDatabase(databaseSettings).block().getDatabase(); } - static protected CosmosDatabase createDatabase(CosmosClient client, String databaseId) { + static protected CosmosAsyncDatabase createDatabase(CosmosAsyncClient client, String databaseId) { CosmosDatabaseProperties databaseSettings = new CosmosDatabaseProperties(databaseId); - return client.createDatabase(databaseSettings).block().database(); + return client.createDatabase(databaseSettings).block().getDatabase(); } - static protected CosmosSyncDatabase createSyncDatabase(CosmosSyncClient client, String databaseId) { + static protected CosmosDatabase createSyncDatabase(CosmosClient client, String databaseId) { CosmosDatabaseProperties databaseSettings = new CosmosDatabaseProperties(databaseId); try { - return client.createDatabase(databaseSettings).database(); + return client.createDatabase(databaseSettings).getDatabase(); } catch (CosmosClientException e) { e.printStackTrace(); } return null; } - static protected CosmosDatabase createDatabaseIfNotExists(CosmosClient client, String databaseId) { + static protected CosmosAsyncDatabase createDatabaseIfNotExists(CosmosAsyncClient client, String databaseId) { List res = client.queryDatabases(String.format("SELECT * FROM r where r.id = '%s'", databaseId), null) - .flatMap(p -> Flux.fromIterable(p.results())) + .flatMap(p -> Flux.fromIterable(p.getResults())) .collectList() .block(); if (res.size() != 0) { - return client.getDatabase(databaseId).read().block().database(); + return client.getDatabase(databaseId).read().block().getDatabase(); } else { CosmosDatabaseProperties databaseSettings = new CosmosDatabaseProperties(databaseId); - return client.createDatabase(databaseSettings).block().database(); + return client.createDatabase(databaseSettings).block().getDatabase(); } } - static protected void safeDeleteDatabase(CosmosDatabase database) { + static protected void safeDeleteDatabase(CosmosAsyncDatabase database) { if (database != null) { try { database.delete().block(); @@ -628,7 +598,7 @@ static protected void safeDeleteDatabase(CosmosDatabase database) { } } - static protected void safeDeleteSyncDatabase(CosmosSyncDatabase database) { + static protected void safeDeleteSyncDatabase(CosmosDatabase database) { if (database != null) { try { database.delete(); @@ -638,20 +608,20 @@ static protected void safeDeleteSyncDatabase(CosmosSyncDatabase database) { } } - static protected void safeDeleteAllCollections(CosmosDatabase database) { + static protected void safeDeleteAllCollections(CosmosAsyncDatabase database) { if (database != null) { List collections = database.readAllContainers() - .flatMap(p -> Flux.fromIterable(p.results())) + .flatMap(p -> Flux.fromIterable(p.getResults())) .collectList() .block(); for(CosmosContainerProperties collection: collections) { - database.getContainer(collection.id()).delete().block(); + database.getContainer(collection.getId()).delete().block(); } } } - static protected void safeDeleteCollection(CosmosContainer collection) { + static protected void safeDeleteCollection(CosmosAsyncContainer collection) { if (collection != null) { try { collection.delete().block(); @@ -660,7 +630,7 @@ static protected void safeDeleteCollection(CosmosContainer collection) { } } - static protected void safeDeleteCollection(CosmosDatabase database, String collectionId) { + static protected void safeDeleteCollection(CosmosAsyncDatabase database, String collectionId) { if (database != null && collectionId != null) { try { database.getContainer(collectionId).delete().block(); @@ -669,7 +639,7 @@ static protected void safeDeleteCollection(CosmosDatabase database, String colle } } - static protected void safeCloseAsync(CosmosClient client) { + static protected void safeCloseAsync(CosmosAsyncClient client) { if (client != null) { new Thread(() -> { try { @@ -681,7 +651,7 @@ static protected void safeCloseAsync(CosmosClient client) { } } - static protected void safeClose(CosmosClient client) { + static protected void safeClose(CosmosAsyncClient client) { if (client != null) { try { client.close(); @@ -691,7 +661,7 @@ static protected void safeClose(CosmosClient client) { } } - static protected void safeCloseSyncClient(CosmosSyncClient client) { + static protected void safeCloseSyncClient(CosmosClient client) { if (client != null) { try { client.close(); @@ -853,8 +823,8 @@ private static Object[][] simpleClientBuildersWithDirect(Protocol... protocols) } cosmosConfigurations.forEach(c -> logger.info("Will Use ConnectionMode [{}], Consistency [{}], Protocol [{}]", - c.connectionPolicy().connectionMode(), - c.consistencyLevel(), + c.getConnectionPolicy().getConnectionMode(), + c.getConsistencyLevel(), extractConfigs(c).getProtocol() )); @@ -944,8 +914,8 @@ private static Object[][] clientBuildersWithDirect(List testCo } cosmosConfigurations.forEach(c -> logger.info("Will Use ConnectionMode [{}], Consistency [{}], Protocol [{}]", - c.connectionPolicy().connectionMode(), - c.consistencyLevel(), + c.getConnectionPolicy().getConnectionMode(), + c.getConsistencyLevel(), extractConfigs(c).getProtocol() )); @@ -956,25 +926,25 @@ private static Object[][] clientBuildersWithDirect(List testCo static protected CosmosClientBuilder createGatewayHouseKeepingDocumentClient() { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); RetryOptions options = new RetryOptions(); - options.maxRetryWaitTimeInSeconds(SUITE_SETUP_TIMEOUT); - connectionPolicy.retryOptions(options); - return CosmosClient.builder().endpoint(TestConfigurations.HOST) - .cosmosKeyCredential(cosmosKeyCredential) - .connectionPolicy(connectionPolicy) - .consistencyLevel(ConsistencyLevel.SESSION); + options.setMaxRetryWaitTimeInSeconds(SUITE_SETUP_TIMEOUT); + connectionPolicy.setRetryOptions(options); + return CosmosAsyncClient.builder().setEndpoint(TestConfigurations.HOST) + .setCosmosKeyCredential(cosmosKeyCredential) + .setConnectionPolicy(connectionPolicy) + .setConsistencyLevel(ConsistencyLevel.SESSION); } static protected CosmosClientBuilder createGatewayRxDocumentClient(ConsistencyLevel consistencyLevel, boolean multiMasterEnabled, List preferredLocations) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.GATEWAY); - connectionPolicy.usingMultipleWriteLocations(multiMasterEnabled); - connectionPolicy.preferredLocations(preferredLocations); - return CosmosClient.builder().endpoint(TestConfigurations.HOST) - .cosmosKeyCredential(cosmosKeyCredential) - .connectionPolicy(connectionPolicy) - .consistencyLevel(consistencyLevel); + connectionPolicy.setConnectionMode(ConnectionMode.GATEWAY); + connectionPolicy.setUsingMultipleWriteLocations(multiMasterEnabled); + connectionPolicy.setPreferredLocations(preferredLocations); + return CosmosAsyncClient.builder().setEndpoint(TestConfigurations.HOST) + .setCosmosKeyCredential(cosmosKeyCredential) + .setConnectionPolicy(connectionPolicy) + .setConsistencyLevel(consistencyLevel); } static protected CosmosClientBuilder createGatewayRxDocumentClient() { @@ -986,23 +956,23 @@ static protected CosmosClientBuilder createDirectRxDocumentClient(ConsistencyLev boolean multiMasterEnabled, List preferredLocations) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(ConnectionMode.DIRECT); + connectionPolicy.setConnectionMode(ConnectionMode.DIRECT); if (preferredLocations != null) { - connectionPolicy.preferredLocations(preferredLocations); + connectionPolicy.setPreferredLocations(preferredLocations); } if (multiMasterEnabled && consistencyLevel == ConsistencyLevel.SESSION) { - connectionPolicy.usingMultipleWriteLocations(true); + connectionPolicy.setUsingMultipleWriteLocations(true); } Configs configs = spy(new Configs()); doAnswer((Answer)invocation -> protocol).when(configs).getProtocol(); - CosmosClientBuilder builder = CosmosClient.builder().endpoint(TestConfigurations.HOST) - .cosmosKeyCredential(cosmosKeyCredential) - .connectionPolicy(connectionPolicy) - .consistencyLevel(consistencyLevel); + CosmosClientBuilder builder = CosmosAsyncClient.builder().setEndpoint(TestConfigurations.HOST) + .setCosmosKeyCredential(cosmosKeyCredential) + .setConnectionPolicy(connectionPolicy) + .setConsistencyLevel(consistencyLevel); return injectConfigs(builder, configs); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java similarity index 89% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java index 94d8e958a9e2..a5a4b96541f5 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TokenResolverTest.java @@ -82,12 +82,12 @@ public void beforeClass() { client = clientBuilder().build(); - userWithReadPermission = createUser(client, createdDatabase.id(), getUserDefinition()); - readPermission = client.createPermission(userWithReadPermission.selfLink(), getPermission(createdCollection, "ReadPermissionOnColl", PermissionMode.READ), null).single().block() + userWithReadPermission = createUser(client, createdDatabase.getId(), getUserDefinition()); + readPermission = client.createPermission(userWithReadPermission.getSelfLink(), getPermission(createdCollection, "ReadPermissionOnColl", PermissionMode.READ), null).single().block() .getResource(); - userWithAllPermission = createUser(client, createdDatabase.id(), getUserDefinition()); - allPermission = client.createPermission(userWithAllPermission.selfLink(), getPermission(createdCollection, "AllPermissionOnColl", PermissionMode.ALL), null).single().block() + userWithAllPermission = createUser(client, createdDatabase.getId(), getUserDefinition()); + allPermission = client.createPermission(userWithAllPermission.getSelfLink(), getPermission(createdCollection, "AllPermissionOnColl", PermissionMode.ALL), null).single().block() .getResource(); } @@ -104,9 +104,9 @@ public void readDocumentWithReadPermission(ConnectionMode connectionMode) { HashMap properties = new HashMap(); properties.put("UserId", "readUser"); requestOptions.setProperties(properties); - Flux> readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().selfLink(), requestOptions); + Flux> readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().getSelfLink(), requestOptions); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(resourceResponse.getResource().id()).build(); + .withId(resourceResponse.getResource().getId()).build(); validateSuccess(readObservable, validator); } finally { safeClose(asyncClientWithTokenResolver); @@ -123,7 +123,7 @@ public void deleteDocumentWithReadPermission(ConnectionMode connectionMode) { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.READ); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(resourceResponse.getResource().get("mypk"))); - Flux> readObservable = asyncClientWithTokenResolver.deleteDocument(resourceResponse.getResource().selfLink(), requestOptions); + Flux> readObservable = asyncClientWithTokenResolver.deleteDocument(resourceResponse.getResource().getSelfLink(), requestOptions); FailureValidator validator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.FORBIDDEN).build(); validateFailure(readObservable, validator); } finally { @@ -136,7 +136,7 @@ public void writeDocumentWithReadPermission(ConnectionMode connectionMode) { AsyncDocumentClient asyncClientWithTokenResolver = null; try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.READ); - Flux> readObservable = asyncClientWithTokenResolver.createDocument(createdCollection.selfLink(), getDocumentDefinition(), null, true); + Flux> readObservable = asyncClientWithTokenResolver.createDocument(createdCollection.getSelfLink(), getDocumentDefinition(), null, true); FailureValidator validator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.FORBIDDEN).build(); validateFailure(readObservable, validator); } finally { @@ -152,9 +152,9 @@ public void writeDocumentWithAllPermission(ConnectionMode connectionMode) { try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.ALL); Document documentDefinition = getDocumentDefinition(); - Flux> readObservable = asyncClientWithTokenResolver.createDocument(createdCollection.selfLink(), documentDefinition, null, true); + Flux> readObservable = asyncClientWithTokenResolver.createDocument(createdCollection.getSelfLink(), documentDefinition, null, true); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(documentDefinition.id()).build(); + .withId(documentDefinition.getId()).build(); validateSuccess(readObservable, validator); } finally { safeClose(asyncClientWithTokenResolver); @@ -171,7 +171,7 @@ public void deleteDocumentWithAllPermission(ConnectionMode connectionMode) { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.ALL); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(resourceResponse.getResource().get("mypk"))); - Flux> readObservable = asyncClientWithTokenResolver.deleteDocument(resourceResponse.getResource().selfLink(), requestOptions); + Flux> readObservable = asyncClientWithTokenResolver.deleteDocument(resourceResponse.getResource().getSelfLink(), requestOptions); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() .nullResource().build(); validateSuccess(readObservable, validator); @@ -185,9 +185,9 @@ public void readCollectionWithReadPermission(ConnectionMode connectionMode) { AsyncDocumentClient asyncClientWithTokenResolver = null; try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.READ); - Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), null); + Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), null); ResourceResponseValidator validator = new ResourceResponseValidator.Builder() - .withId(createdCollection.id()).build(); + .withId(createdCollection.getId()).build(); validateSuccess(readObservable, validator); } finally { safeClose(asyncClientWithTokenResolver); @@ -199,7 +199,7 @@ public void deleteCollectionWithReadPermission(ConnectionMode connectionMode) { AsyncDocumentClient asyncClientWithTokenResolver = null; try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.READ); - Flux> readObservable = asyncClientWithTokenResolver.deleteCollection(createdCollection.selfLink(), null); + Flux> readObservable = asyncClientWithTokenResolver.deleteCollection(createdCollection.getSelfLink(), null); FailureValidator validator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.FORBIDDEN).build(); validateFailure(readObservable, validator); } finally { @@ -215,7 +215,7 @@ public void verifyingAuthTokenAPISequence(ConnectionMode connectionMode) { AsyncDocumentClient asyncClientWithTokenResolver = null; try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(connectionMode); + connectionPolicy.setConnectionMode(connectionMode); //Unauthorized error with invalid token resolver, valid master key and valid permission feed, making it sure tokenResolver has higher priority than all. List permissionFeed = new ArrayList<>(); @@ -230,7 +230,7 @@ public void verifyingAuthTokenAPISequence(ConnectionMode connectionMode) { .build(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(resourceResponse.getResource().get("mypk"))); - Flux> readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().selfLink(), requestOptions); + Flux> readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().getSelfLink(), requestOptions); FailureValidator failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.UNAUTHORIZED).build(); validateFailure(readObservable, failureValidator); @@ -243,9 +243,9 @@ public void verifyingAuthTokenAPISequence(ConnectionMode connectionMode) { .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withPermissionFeed(permissionFeed) .build(); - readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().selfLink(), requestOptions); + readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().getSelfLink(), requestOptions); ResourceResponseValidator sucessValidator = new ResourceResponseValidator.Builder() - .withId(resourceResponse.getResource().id()).build(); + .withId(resourceResponse.getResource().getId()).build(); validateSuccess(readObservable, sucessValidator); @@ -256,7 +256,7 @@ public void verifyingAuthTokenAPISequence(ConnectionMode connectionMode) { .withConsistencyLevel(ConsistencyLevel.SESSION) .withPermissionFeed(permissionFeed) .build(); - readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().selfLink(), requestOptions); + readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().getSelfLink(), requestOptions); validateSuccess(readObservable, sucessValidator); @@ -267,7 +267,7 @@ public void verifyingAuthTokenAPISequence(ConnectionMode connectionMode) { .withConsistencyLevel(ConsistencyLevel.SESSION) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .build(); - readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().selfLink(), requestOptions); + readObservable = asyncClientWithTokenResolver.readDocument(resourceResponse.getResource().getSelfLink(), requestOptions); validateSuccess(readObservable, sucessValidator); } finally { @@ -297,14 +297,14 @@ public void createAndExecuteSprocWithWritePermission(ConnectionMode connectionMo " }'" + "}"); - Flux> createObservable = asyncClientWithTokenResolver.createStoredProcedure(createdCollection.selfLink(), sproc, null); + Flux> createObservable = asyncClientWithTokenResolver.createStoredProcedure(createdCollection.getSelfLink(), sproc, null); ResourceResponseValidator createSucessValidator = new ResourceResponseValidator.Builder() .withId(sprocId).build(); validateSuccess(createObservable, createSucessValidator); RequestOptions options = new RequestOptions(); options.setPartitionKey(new PartitionKey("")); - String sprocLink = "dbs/" + createdDatabase.id() + "/colls/" + createdCollection.id() + "/sprocs/" + sprocId; + String sprocLink = "dbs/" + createdDatabase.getId() + "/colls/" + createdCollection.getId() + "/sprocs/" + sprocId; StoredProcedureResponse result = asyncClientWithTokenResolver.executeStoredProcedure(sprocLink, options, null).single().block(); assertThat(result.getResponseAsString()).isEqualTo("\"Success!\""); } finally { @@ -320,20 +320,20 @@ public void readDocumentsWithAllPermission(ConnectionMode connectionMode) { try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.ALL); - Document document1 = asyncClientWithTokenResolver.createDocument(createdCollection.selfLink(), new Document("{'id': '" + id1 + "'}"), null, false) + Document document1 = asyncClientWithTokenResolver.createDocument(createdCollection.getSelfLink(), new Document("{'id': '" + id1 + "'}"), null, false) .single().block().getResource(); - Document document2 = asyncClientWithTokenResolver.createDocument(createdCollection.selfLink(), new Document("{'id': '" + id2 + "'}"), null, false) + Document document2 = asyncClientWithTokenResolver.createDocument(createdCollection.getSelfLink(), new Document("{'id': '" + id2 + "'}"), null, false) .single().block().getResource(); List expectedIds = new ArrayList(); - String rid1 = document1.resourceId(); - String rid2 = document2.resourceId(); + String rid1 = document1.getResourceId(); + String rid2 = document2.getResourceId(); expectedIds.add(rid1); expectedIds.add(rid2); String query = "SELECT * FROM r WHERE r._rid=\"" + rid1 + "\" or r._rid=\"" + rid2 + "\""; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); - Flux> queryObservable = asyncClientWithTokenResolver.queryDocuments(createdCollection.selfLink(), query, options); + options.setEnableCrossPartitionQuery(true); + Flux> queryObservable = asyncClientWithTokenResolver.queryDocuments(createdCollection.getSelfLink(), query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(2) .exactlyContainsInAnyOrder(expectedIds).build(); @@ -354,13 +354,13 @@ public void readChangeFeedWithAllPermission(ConnectionMode connectionMode) throw AsyncDocumentClient asyncClientWithTokenResolver = null; String id1 = UUID.randomUUID().toString(); String id2 = UUID.randomUUID().toString(); - String partitionKey = createdCollection.getPartitionKey().paths().get(0).substring(1); + String partitionKey = createdCollection.getPartitionKey().getPaths().get(0).substring(1); String partitionKeyValue = "pk"; Document document1 = new Document(); - document1.id(id1); + document1.setId(id1); BridgeInternal.setProperty(document1, partitionKey, partitionKeyValue); Document document2 = new Document(); - document2.id(id2); + document2.setId(id2); BridgeInternal.setProperty(document2, partitionKey, partitionKeyValue); try { asyncClientWithTokenResolver = buildClient(connectionMode, PermissionMode.ALL); @@ -368,24 +368,24 @@ public void readChangeFeedWithAllPermission(ConnectionMode connectionMode) throw Thread.sleep(1500); document1 = asyncClientWithTokenResolver - .createDocument(createdCollection.selfLink(), document1, null, false).single().block() + .createDocument(createdCollection.getSelfLink(), document1, null, false).single().block() .getResource(); document2 = asyncClientWithTokenResolver - .createDocument(createdCollection.selfLink(), document2, null, false).single().block() + .createDocument(createdCollection.getSelfLink(), document2, null, false).single().block() .getResource(); List expectedIds = new ArrayList(); - String rid1 = document1.resourceId(); - String rid2 = document2.resourceId(); + String rid1 = document1.getResourceId(); + String rid2 = document2.getResourceId(); expectedIds.add(rid1); expectedIds.add(rid2); ChangeFeedOptions options = new ChangeFeedOptions(); - options.partitionKey(new PartitionKey(partitionKeyValue)); - options.startDateTime(befTime); + options.setPartitionKey(new PartitionKey(partitionKeyValue)); + options.setStartDateTime(befTime); Thread.sleep(1000); Flux> queryObservable = asyncClientWithTokenResolver - .queryDocumentChangeFeed(createdCollection.selfLink(), options); + .queryDocumentChangeFeed(createdCollection.getSelfLink(), options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .exactlyContainsInAnyOrder(expectedIds).build(); validateQuerySuccess(queryObservable, validator, 10000); @@ -400,7 +400,7 @@ public void verifyRuntimeExceptionWhenUserModifiesProperties(ConnectionMode conn try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(connectionMode); + connectionPolicy.setConnectionMode(connectionMode); asyncClientWithTokenResolver = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -410,7 +410,7 @@ public void verifyRuntimeExceptionWhenUserModifiesProperties(ConnectionMode conn RequestOptions options = new RequestOptions(); options.setProperties(new HashMap()); - Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), options); + Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), options); FailureValidator validator = new FailureValidator.Builder().withRuntimeExceptionClass(UnsupportedOperationException.class).build(); validateFailure(readObservable, validator); } finally { @@ -427,7 +427,7 @@ public void verifyBlockListedUserThrows(ConnectionMode connectionMode) { AsyncDocumentClient asyncClientWithTokenResolver = null; try { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(connectionMode); + connectionPolicy.setConnectionMode(connectionMode); asyncClientWithTokenResolver = new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -439,15 +439,15 @@ public void verifyBlockListedUserThrows(ConnectionMode connectionMode) { HashMap properties = new HashMap(); properties.put(field, blockListedUser); options.setProperties(properties); - Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), options); + Flux> readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), options); FailureValidator validator = new FailureValidator.Builder().withRuntimeExceptionMessage(errorMessage).build(); validateFailure(readObservable, validator); properties.put(field, new UserClass("valid user", 1)); options.setProperties(properties); - readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.selfLink(), options); + readObservable = asyncClientWithTokenResolver.readCollection(createdCollection.getSelfLink(), options); ResourceResponseValidator sucessValidator = new ResourceResponseValidator.Builder() - .withId(createdCollection.id()).build(); + .withId(createdCollection.getId()).build(); validateSuccess(readObservable, sucessValidator); } finally { safeClose(asyncClientWithTokenResolver); @@ -472,7 +472,7 @@ private Document getDocumentDefinition() { private AsyncDocumentClient buildClient(ConnectionMode connectionMode, PermissionMode permissionMode) { ConnectionPolicy connectionPolicy = new ConnectionPolicy(); - connectionPolicy.connectionMode(connectionMode); + connectionPolicy.setConnectionMode(connectionMode); return new AsyncDocumentClient.Builder() .withServiceEndpoint(TestConfigurations.HOST) .withConnectionPolicy(connectionPolicy) @@ -483,15 +483,15 @@ private AsyncDocumentClient buildClient(ConnectionMode connectionMode, Permissio private static User getUserDefinition() { User user = new User(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); return user; } private Permission getPermission(Resource resource, String permissionId, PermissionMode permissionMode) { Permission permission = new Permission(); - permission.id(permissionId); + permission.setId(permissionId); permission.setPermissionMode(permissionMode); - permission.setResourceLink(resource.selfLink()); + permission.setResourceLink(resource.getSelfLink()); return permission; } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java similarity index 88% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java index 6e862ceb8bbe..1519fae23722 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TopQueryTests.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.PartitionKey; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.RetryAnalyzer; import com.azure.data.cosmos.internal.Utils.ValueHolder; @@ -31,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class TopQueryTests extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private ArrayList docs = new ArrayList(); private String partitionKey = "mypk"; @@ -39,7 +33,7 @@ public class TopQueryTests extends TestSuiteBase { private int secondPk = 1; private String field = "field"; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public TopQueryTests(CosmosClientBuilder clientBuilder) { @@ -52,9 +46,9 @@ public TopQueryTests(CosmosClientBuilder clientBuilder) { public void queryDocumentsWithTop(boolean qmEnabled) throws Exception { FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); options.maxItemCount(9); - options.maxDegreeOfParallelism(2); + options.setMaxDegreeOfParallelism(2); options.populateQueryMetrics(qmEnabled); int expectedTotalSize = 20; @@ -86,7 +80,7 @@ public void queryDocumentsWithTop(boolean qmEnabled) throws Exception { if (i == 0) { options.partitionKey(new PartitionKey(firstPk)); - options.enableCrossPartitionQuery(false); + options.setEnableCrossPartitionQuery(false); expectedTotalSize = 10; expectedNumberOfPages = 2; @@ -131,7 +125,7 @@ private void queryWithContinuationTokensAndPageSizes(String query, int[] pageSiz List receivedDocuments = this.queryWithContinuationTokens(query, pageSize); Set actualIds = new HashSet(); for (CosmosItemProperties document : receivedDocuments) { - actualIds.add(document.resourceId()); + actualIds.add(document.getResourceId()); } assertThat(actualIds.size()).describedAs("total number of results").isEqualTo(topCount); @@ -146,8 +140,8 @@ private List queryWithContinuationTokens(String query, int do { FeedOptions options = new FeedOptions(); options.maxItemCount(pageSize); - options.enableCrossPartitionQuery(true); - options.maxDegreeOfParallelism(2); + options.setEnableCrossPartitionQuery(true); + options.setMaxDegreeOfParallelism(2); options.requestContinuation(requestContinuation); Flux> queryObservable = createdCollection.queryItems(query, options); @@ -159,15 +153,15 @@ private List queryWithContinuationTokens(String query, int testSubscriber.assertComplete(); FeedResponse firstPage = (FeedResponse) testSubscriber.getEvents().get(0).get(0); - requestContinuation = firstPage.continuationToken(); - receivedDocuments.addAll(firstPage.results()); + requestContinuation = firstPage.getContinuationToken(); + receivedDocuments.addAll(firstPage.getResults()); continuationTokens.add(requestContinuation); } while (requestContinuation != null); return receivedDocuments; } - public void bulkInsert(CosmosClient client) { + public void bulkInsert(CosmosAsyncClient client) { generateTestData(); for (int i = 0; i < docs.size(); i++) { @@ -179,7 +173,7 @@ public void generateTestData() { for (int i = 0; i < 10; i++) { CosmosItemProperties d = new CosmosItemProperties(); - d.id(Integer.toString(i)); + d.setId(Integer.toString(i)); BridgeInternal.setProperty(d, field, i); BridgeInternal.setProperty(d, partitionKey, firstPk); docs.add(d); @@ -187,7 +181,7 @@ public void generateTestData() { for (int i = 10; i < 20; i++) { CosmosItemProperties d = new CosmosItemProperties(); - d.id(Integer.toString(i)); + d.setId(Integer.toString(i)); BridgeInternal.setProperty(d, field, i); BridgeInternal.setProperty(d, partitionKey, secondPk); docs.add(d); @@ -201,7 +195,7 @@ public void afterClass() { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedSinglePartitionCosmosContainer(client); truncateCollection(createdCollection); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java similarity index 53% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java index 1338ae6f3111..c1df35d4b3b0 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerCrudTest.java @@ -2,16 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosTrigger; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.CosmosTriggerResponse; -import com.azure.data.cosmos.TriggerOperation; -import com.azure.data.cosmos.TriggerType; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.testng.annotations.Factory; import org.testng.annotations.Test; import org.testng.annotations.Ignore; @@ -22,9 +14,9 @@ import java.util.UUID; public class TriggerCrudTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public TriggerCrudTest(CosmosClientBuilder clientBuilder) { @@ -36,16 +28,16 @@ public void createTrigger() throws Exception { // create a trigger CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); - Mono createObservable = createdCollection.getScripts().createTrigger(trigger); + Mono createObservable = createdCollection.getScripts().createTrigger(trigger); // validate trigger creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(trigger.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(trigger.getId()) .withTriggerBody("function() {var x = 10;}") .withTriggerInternals(TriggerType.PRE, TriggerOperation.CREATE) .notNullEtag() @@ -57,19 +49,19 @@ public void createTrigger() throws Exception { public void readTrigger() throws Exception { // create a trigger CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); - CosmosTrigger readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().trigger(); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); + CosmosAsyncTrigger readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().getTrigger(); // read trigger waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = readBackTrigger.read(); + Mono readObservable = readBackTrigger.read(); // validate read trigger - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(trigger.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(trigger.getId()) .withTriggerBody("function() {var x = 10;}") .withTriggerInternals(TriggerType.PRE, TriggerOperation.CREATE) .notNullEtag() @@ -83,17 +75,17 @@ public void readTrigger() throws Exception { public void deleteTrigger() throws Exception { // create a trigger CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); - CosmosTrigger readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().trigger(); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); + CosmosAsyncTrigger readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().getTrigger(); // delete trigger - Mono deleteObservable = readBackTrigger.delete(); + Mono deleteObservable = readBackTrigger.delete(); // validate delete trigger - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource() .build(); validateSuccess(deleteObservable, validator); @@ -101,7 +93,7 @@ public void deleteTrigger() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java similarity index 81% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java index 2105614ae79a..d98a7658fcfb 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerQueryTest.java @@ -2,16 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; -import com.azure.data.cosmos.Resource; -import com.azure.data.cosmos.TriggerOperation; -import com.azure.data.cosmos.TriggerType; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; @@ -33,10 +25,10 @@ @Ignore public class TriggerQueryTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private static final List createdTriggers = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public TriggerQueryTest(CosmosClientBuilder clientBuilder) { @@ -46,7 +38,7 @@ public TriggerQueryTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryWithFilter() throws Exception { - String filterId = createdTriggers.get(0).id(); + String filterId = createdTriggers.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterId); FeedOptions options = new FeedOptions(); @@ -55,7 +47,7 @@ public void queryWithFilter() throws Exception { List expectedDocs = createdTriggers .stream() - .filter(sp -> filterId.equals(sp.id()) ) + .filter(sp -> filterId.equals(sp.getId()) ) .collect(Collectors.toList()); assertThat(expectedDocs).isNotEmpty(); @@ -63,7 +55,7 @@ public void queryWithFilter() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(Resource::resourceId).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(Resource::getResourceId).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -77,7 +69,7 @@ public void query_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryTriggers(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -95,10 +87,10 @@ public void queryAll() throws Exception { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); options.maxItemCount(3); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryTriggers(query, options); - createdTriggers.forEach(cosmosTriggerSettings -> logger.info("Created trigger in method: {}", cosmosTriggerSettings.resourceId())); + createdTriggers.forEach(cosmosTriggerSettings -> logger.info("Created trigger in method: {}", cosmosTriggerSettings.getResourceId())); List expectedDocs = createdTriggers; @@ -108,7 +100,7 @@ public void queryAll() throws Exception { .Builder() .exactlyContainsInAnyOrder(expectedDocs .stream() - .map(Resource::resourceId) + .map(Resource::getResourceId) .collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() @@ -121,7 +113,7 @@ public void queryAll() throws Exception { public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryTriggers(query, options); FailureValidator validator = new FailureValidator.Builder() @@ -132,14 +124,14 @@ public void invalidQuerySytax() throws Exception { validateQueryFailure(queryObservable, validator); } - public CosmosTriggerProperties createTrigger(CosmosContainer cosmosContainer) { + public CosmosTriggerProperties createTrigger(CosmosAsyncContainer cosmosContainer) { CosmosTriggerProperties storedProcedure = getTriggerDef(); - return cosmosContainer.getScripts().createTrigger(storedProcedure).block().properties(); + return cosmosContainer.getScripts().createTrigger(storedProcedure).block().getProperties(); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); createdTriggers.clear(); @@ -158,10 +150,10 @@ public void afterClass() { private static CosmosTriggerProperties getTriggerDef() { CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); return trigger; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java similarity index 56% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java index bb3766ba7242..9d22571b2f3f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/TriggerUpsertReplaceTest.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosTriggerProperties; -import com.azure.data.cosmos.CosmosTriggerResponse; -import com.azure.data.cosmos.TriggerOperation; -import com.azure.data.cosmos.TriggerType; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.testng.annotations.Factory; import org.testng.annotations.Test; import org.testng.annotations.Ignore; @@ -23,9 +17,9 @@ @Ignore public class TriggerUpsertReplaceTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public TriggerUpsertReplaceTest(CosmosClientBuilder clientBuilder) { @@ -37,33 +31,33 @@ public void replaceTrigger() throws Exception { // create a trigger CosmosTriggerProperties trigger = new CosmosTriggerProperties(); - trigger.id(UUID.randomUUID().toString()); - trigger.body("function() {var x = 10;}"); - trigger.triggerOperation(TriggerOperation.CREATE); - trigger.triggerType(TriggerType.PRE); - CosmosTriggerProperties readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().properties(); + trigger.setId(UUID.randomUUID().toString()); + trigger.setBody("function() {var x = 10;}"); + trigger.setTriggerOperation(TriggerOperation.CREATE); + trigger.setTriggerType(TriggerType.PRE); + CosmosTriggerProperties readBackTrigger = createdCollection.getScripts().createTrigger(trigger).block().getProperties(); // read trigger to validate creation waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = createdCollection.getScripts().getTrigger(readBackTrigger.id()).read(); + Mono readObservable = createdCollection.getScripts().getTrigger(readBackTrigger.getId()).read(); // validate trigger creation - CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() - .withId(readBackTrigger.id()) + CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() + .withId(readBackTrigger.getId()) .withTriggerBody("function() {var x = 10;}") .withTriggerInternals(TriggerType.PRE, TriggerOperation.CREATE) .notNullEtag() .build(); validateSuccess(readObservable, validatorForRead); - //update trigger - readBackTrigger.body("function() {var x = 11;}"); + //update getTrigger + readBackTrigger.setBody("function() {var x = 11;}"); - Mono updateObservable = createdCollection.getScripts().getTrigger(readBackTrigger.id()).replace(readBackTrigger); + Mono updateObservable = createdCollection.getScripts().getTrigger(readBackTrigger.getId()).replace(readBackTrigger); - // validate trigger replace - CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() - .withId(readBackTrigger.id()) + // validate getTrigger replace + CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() + .withId(readBackTrigger.getId()) .withTriggerBody("function() {var x = 11;}") .withTriggerInternals(TriggerType.PRE, TriggerOperation.CREATE) .notNullEtag() @@ -73,7 +67,7 @@ public void replaceTrigger() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java similarity index 58% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java index 9c18b99cd93e..db5c3bacfa40 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UniqueIndexTest.java @@ -2,30 +2,10 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.ConnectionPolicy; -import com.azure.data.cosmos.ConsistencyLevel; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosItem; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.DataType; -import com.azure.data.cosmos.ExcludedPath; -import com.azure.data.cosmos.HashIndex; -import com.azure.data.cosmos.IncludedPath; -import com.azure.data.cosmos.IndexingMode; -import com.azure.data.cosmos.IndexingPolicy; -import com.azure.data.cosmos.PartitionKey; -import com.azure.data.cosmos.PartitionKeyDefinition; -import com.azure.data.cosmos.UniqueKey; -import com.azure.data.cosmos.UniqueKeyPolicy; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.HttpConstants; import com.azure.data.cosmos.internal.TestConfigurations; -import com.azure.data.cosmos.internal.TestUtils; import com.azure.data.cosmos.internal.Utils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -50,40 +30,41 @@ public class UniqueIndexTest extends TestSuiteBase { protected static final int SHUTDOWN_TIMEOUT = 20000; private final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosClient client; - private CosmosDatabase database; + private CosmosAsyncClient client; + private CosmosAsyncDatabase database; - private CosmosContainer collection; + private CosmosAsyncContainer collection; @Test(groups = { "long" }, timeOut = TIMEOUT) public void insertWithUniqueIndex() throws Exception { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(); UniqueKey uniqueKey = new UniqueKey(); - uniqueKey.paths(ImmutableList.of("/name", "/description")); + uniqueKey.setPaths(ImmutableList.of("/name", "/description")); uniqueKeyPolicy.uniqueKeys(Lists.newArrayList(uniqueKey)); - collectionDefinition.uniqueKeyPolicy(uniqueKeyPolicy); + collectionDefinition.setUniqueKeyPolicy(uniqueKeyPolicy); IndexingPolicy indexingPolicy = new IndexingPolicy(); - indexingPolicy.indexingMode(IndexingMode.CONSISTENT); + indexingPolicy.setIndexingMode(IndexingMode.CONSISTENT); ExcludedPath excludedPath = new ExcludedPath(); - excludedPath.path("/*"); - indexingPolicy.excludedPaths(Collections.singletonList(excludedPath)); + excludedPath.setPath("/*"); + indexingPolicy.setExcludedPaths(Collections.singletonList(excludedPath)); IncludedPath includedPath1 = new IncludedPath(); - includedPath1.path("/name/?"); - includedPath1.indexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); + includedPath1.setPath("/name/?"); + includedPath1.setIndexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); + includedPath1.setIndexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); IncludedPath includedPath2 = new IncludedPath(); - includedPath2.path("/description/?"); - includedPath2.indexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); + includedPath2.setPath("/description/?"); + includedPath2.setIndexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); indexingPolicy.setIncludedPaths(ImmutableList.of(includedPath1, includedPath2)); - collectionDefinition.indexingPolicy(indexingPolicy); + collectionDefinition.setIndexingPolicy(indexingPolicy); ObjectMapper om = new ObjectMapper(); @@ -91,20 +72,20 @@ public void insertWithUniqueIndex() throws Exception { JsonNode doc2 = om.readValue("{\"name\":\"Alexander Pushkin\",\"description\":\"playwright\",\"id\": \"" + UUID.randomUUID().toString() + "\"}", JsonNode.class); JsonNode doc3 = om.readValue("{\"name\":\"حافظ شیرازی\",\"description\":\"poet\",\"id\": \"" + UUID.randomUUID().toString() + "\"}", JsonNode.class); - collection = database.createContainer(collectionDefinition).block().container(); + collection = database.createContainer(collectionDefinition).block().getContainer(); - CosmosItem item = collection.createItem(doc1).block().item(); + CosmosAsyncItem item = collection.createItem(doc1).block().getItem(); CosmosItemRequestOptions options = new CosmosItemRequestOptions(); - options.partitionKey(PartitionKey.None); - CosmosItemProperties itemSettings = item.read(options).block().properties(); - assertThat(itemSettings.id()).isEqualTo(doc1.get("id").textValue()); + options.setPartitionKey(PartitionKey.None); + CosmosItemProperties itemSettings = item.read(options).block().getProperties(); + assertThat(itemSettings.getId()).isEqualTo(doc1.get("id").textValue()); try { collection.createItem(doc1).block(); fail("Did not throw due to unique constraint (create)"); } catch (RuntimeException e) { - assertThat(getDocumentClientException(e).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(getDocumentClientException(e).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } collection.createItem(doc2).block(); @@ -116,16 +97,16 @@ public void replaceAndDeleteWithUniqueIndex() throws Exception { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(); UniqueKey uniqueKey = new UniqueKey(); - uniqueKey.paths(ImmutableList.of("/name", "/description")); + uniqueKey.setPaths(ImmutableList.of("/name", "/description")); uniqueKeyPolicy.uniqueKeys(Lists.newArrayList(uniqueKey)); - collectionDefinition.uniqueKeyPolicy(uniqueKeyPolicy); + collectionDefinition.setUniqueKeyPolicy(uniqueKeyPolicy); - collection = database.createContainer(collectionDefinition).block().container(); + collection = database.createContainer(collectionDefinition).block().getContainer(); ObjectMapper om = new ObjectMapper(); @@ -133,26 +114,26 @@ public void replaceAndDeleteWithUniqueIndex() throws Exception { ObjectNode doc3 = om.readValue("{\"name\":\"Rabindranath Tagore\",\"description\":\"poet\",\"id\": \""+ UUID.randomUUID().toString() +"\"}", ObjectNode.class); ObjectNode doc2 = om.readValue("{\"name\":\"عمر خیّام\",\"description\":\"mathematician\",\"id\": \""+ UUID.randomUUID().toString() +"\"}", ObjectNode.class); - CosmosItemProperties doc1Inserted = collection.createItem(doc1, new CosmosItemRequestOptions()).block().properties(); + CosmosItemProperties doc1Inserted = collection.createItem(doc1, new CosmosItemRequestOptions()).block().getProperties(); - collection.getItem(doc1.get("id").asText(), PartitionKey.None).replace(doc1Inserted, new CosmosItemRequestOptions()).block().properties(); // REPLACE with same values -- OK. + collection.getItem(doc1.get("id").asText(), PartitionKey.None).replace(doc1Inserted, new CosmosItemRequestOptions()).block().getProperties(); // REPLACE with same values -- OK. - CosmosItemProperties doc2Inserted = collection.createItem(doc2, new CosmosItemRequestOptions()).block().properties(); + CosmosItemProperties doc2Inserted = collection.createItem(doc2, new CosmosItemRequestOptions()).block().getProperties(); CosmosItemProperties doc2Replacement = new CosmosItemProperties(doc1Inserted.toJson()); - doc2Replacement.id( doc2Inserted.id()); + doc2Replacement.setId( doc2Inserted.getId()); try { - collection.getItem(doc2Inserted.id(), PartitionKey.None).replace(doc2Replacement, new CosmosItemRequestOptions()).block(); // REPLACE doc2 with values from doc1 -- Conflict. + collection.getItem(doc2Inserted.getId(), PartitionKey.None).replace(doc2Replacement, new CosmosItemRequestOptions()).block(); // REPLACE doc2 with values from doc1 -- Conflict. fail("Did not throw due to unique constraint"); } catch (RuntimeException ex) { - assertThat(getDocumentClientException(ex).statusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); + assertThat(getDocumentClientException(ex).getStatusCode()).isEqualTo(HttpConstants.StatusCodes.CONFLICT); } - doc3.put("id", doc1Inserted.id()); - collection.getItem(doc1Inserted.id(), PartitionKey.None).replace(doc3).block(); // REPLACE with values from doc3 -- OK. + doc3.put("id", doc1Inserted.getId()); + collection.getItem(doc1Inserted.getId(), PartitionKey.None).replace(doc3).block(); // REPLACE with values from doc3 -- OK. - collection.getItem(doc1Inserted.id(), PartitionKey.None).delete().block(); + collection.getItem(doc1Inserted.getId(), PartitionKey.None).delete().block(); collection.createItem(doc1, new CosmosItemRequestOptions()).block(); } @@ -161,42 +142,42 @@ public void uniqueKeySerializationDeserialization() { PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); ArrayList paths = new ArrayList(); paths.add("/mypk"); - partitionKeyDef.paths(paths); + partitionKeyDef.setPaths(paths); CosmosContainerProperties collectionDefinition = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef); UniqueKeyPolicy uniqueKeyPolicy = new UniqueKeyPolicy(); UniqueKey uniqueKey = new UniqueKey(); - uniqueKey.paths(ImmutableList.of("/name", "/description")); + uniqueKey.setPaths(ImmutableList.of("/name", "/description")); uniqueKeyPolicy.uniqueKeys(Lists.newArrayList(uniqueKey)); - collectionDefinition.uniqueKeyPolicy(uniqueKeyPolicy); + collectionDefinition.setUniqueKeyPolicy(uniqueKeyPolicy); IndexingPolicy indexingPolicy = new IndexingPolicy(); - indexingPolicy.indexingMode(IndexingMode.CONSISTENT); + indexingPolicy.setIndexingMode(IndexingMode.CONSISTENT); ExcludedPath excludedPath = new ExcludedPath(); - excludedPath.path("/*"); - indexingPolicy.excludedPaths(Collections.singletonList(excludedPath)); + excludedPath.setPath("/*"); + indexingPolicy.setExcludedPaths(Collections.singletonList(excludedPath)); IncludedPath includedPath1 = new IncludedPath(); - includedPath1.path("/name/?"); - includedPath1.indexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); + includedPath1.setPath("/name/?"); + includedPath1.setIndexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); IncludedPath includedPath2 = new IncludedPath(); - includedPath2.path("/description/?"); - includedPath2.indexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); + includedPath2.setPath("/description/?"); + includedPath2.setIndexes(Collections.singletonList(new HashIndex(DataType.STRING, 7))); indexingPolicy.setIncludedPaths(ImmutableList.of(includedPath1, includedPath2)); - collectionDefinition.indexingPolicy(indexingPolicy); + collectionDefinition.setIndexingPolicy(indexingPolicy); - CosmosContainer createdCollection = database.createContainer(collectionDefinition).block().container(); + CosmosAsyncContainer createdCollection = database.createContainer(collectionDefinition).block().getContainer(); - CosmosContainerProperties collection = createdCollection.read().block().properties(); + CosmosContainerProperties collection = createdCollection.read().block().getProperties(); - assertThat(collection.uniqueKeyPolicy()).isNotNull(); - assertThat(collection.uniqueKeyPolicy().uniqueKeys()).isNotNull(); - assertThat(collection.uniqueKeyPolicy().uniqueKeys()) - .hasSameSizeAs(collectionDefinition.uniqueKeyPolicy().uniqueKeys()); - assertThat(collection.uniqueKeyPolicy().uniqueKeys() - .stream().map(ui -> ui.paths()).collect(Collectors.toList())) + assertThat(collection.getUniqueKeyPolicy()).isNotNull(); + assertThat(collection.getUniqueKeyPolicy().uniqueKeys()).isNotNull(); + assertThat(collection.getUniqueKeyPolicy().uniqueKeys()) + .hasSameSizeAs(collectionDefinition.getUniqueKeyPolicy().uniqueKeys()); + assertThat(collection.getUniqueKeyPolicy().uniqueKeys() + .stream().map(ui -> ui.getPaths()).collect(Collectors.toList())) .containsExactlyElementsOf( ImmutableList.of(ImmutableList.of("/name", "/description"))); } @@ -210,11 +191,11 @@ private CosmosClientException getDocumentClientException(RuntimeException e) { @BeforeClass(groups = { "long" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { // set up the client - client = CosmosClient.builder() - .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY) - .connectionPolicy(ConnectionPolicy.defaultPolicy()) - .consistencyLevel(ConsistencyLevel.SESSION).build(); + client = CosmosAsyncClient.builder() + .setEndpoint(TestConfigurations.HOST) + .setKey(TestConfigurations.MASTER_KEY) + .setConnectionPolicy(ConnectionPolicy.getDefaultPolicy()) + .setConsistencyLevel(ConsistencyLevel.SESSION).buildAsyncClient(); database = createDatabase(client, databaseId); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java similarity index 56% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java index b521bbed23de..94e34b30874c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserCrudTest.java @@ -3,14 +3,8 @@ package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosUser; -import com.azure.data.cosmos.CosmosUserResponse; -import com.azure.data.cosmos.CosmosUserProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import com.azure.data.cosmos.internal.FailureValidator; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -24,9 +18,9 @@ public class UserCrudTest extends TestSuiteBase { public final String databaseId = CosmosDatabaseForTest.generateId(); - private CosmosDatabase createdDatabase; + private CosmosAsyncDatabase createdDatabase; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public UserCrudTest(CosmosClientBuilder clientBuilder) { @@ -37,13 +31,13 @@ public UserCrudTest(CosmosClientBuilder clientBuilder) { public void createUser() throws Exception { //create user CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); - Mono createObservable = createdDatabase.createUser(user); + Mono createObservable = createdDatabase.createUser(user); // validate user creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(user.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(user.getId()) .notNullEtag() .build(); validateSuccess(createObservable, validator); @@ -54,16 +48,16 @@ public void readUser() throws Exception { //create user CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); - CosmosUser readBackUser = createdDatabase.createUser(user).block().user(); + CosmosAsyncUser readBackUser = createdDatabase.createUser(user).block().getUser(); // read user - Mono readObservable = readBackUser.read(); + Mono readObservable = readBackUser.read(); //validate user read - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(readBackUser.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(readBackUser.getId()) .notNullEtag() .build(); @@ -74,21 +68,21 @@ public void readUser() throws Exception { public void deleteUser() throws Exception { //create user CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); - CosmosUser readBackUser = createdDatabase.createUser(user).block().user(); + CosmosAsyncUser readBackUser = createdDatabase.createUser(user).block().getUser(); // delete user - Mono deleteObservable = readBackUser.delete(); + Mono deleteObservable = readBackUser.delete(); // validate user delete - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource() .build(); validateSuccess(deleteObservable, validator); // attempt to read the user which was deleted - Mono readObservable = readBackUser.read(); + Mono readObservable = readBackUser.read(); FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); validateFailure(readObservable, notFoundValidator); } @@ -98,13 +92,13 @@ public void upsertUser() throws Exception { //create user CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); - Mono upsertObservable = createdDatabase.upsertUser(user); + Mono upsertObservable = createdDatabase.upsertUser(user); //validate user upsert - CosmosResponseValidator validatorForUpsert = new CosmosResponseValidator.Builder() - .withId(user.id()) + CosmosResponseValidator validatorForUpsert = new CosmosResponseValidator.Builder() + .withId(user.getId()) .notNullEtag() .build(); @@ -116,30 +110,30 @@ public void replaceUser() throws Exception { //create user CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); + user.setId(UUID.randomUUID().toString()); - CosmosUserProperties readBackUser = createdDatabase.createUser(user).block().properties(); + CosmosUserProperties readBackUser = createdDatabase.createUser(user).block().getProperties(); - // read user to validate creation - Mono readObservable = createdDatabase.getUser(user.id()).read(); + // read getUser to validate creation + Mono readObservable = createdDatabase.getUser(user.getId()).read(); //validate user read - CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() - .withId(readBackUser.id()) + CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() + .withId(readBackUser.getId()) .notNullEtag() .build(); validateSuccess(readObservable, validatorForRead); - //update user - String oldId = readBackUser.id(); - readBackUser.id(UUID.randomUUID().toString()); + //update getUser + String oldId = readBackUser.getId(); + readBackUser.setId(UUID.randomUUID().toString()); - Mono updateObservable = createdDatabase.getUser(oldId).replace(readBackUser); + Mono updateObservable = createdDatabase.getUser(oldId).replace(readBackUser); // validate user replace - CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() - .withId(readBackUser.id()) + CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() + .withId(readBackUser.getId()) .notNullEtag() .build(); @@ -148,7 +142,7 @@ public void replaceUser() throws Exception { @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, databaseId); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java similarity index 55% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java index db717e4f3878..3159d8ee6b4f 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionCrudTest.java @@ -2,14 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosUserDefinedFunction; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; -import com.azure.data.cosmos.CosmosUserDefinedFunctionResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; @@ -20,8 +14,8 @@ public class UserDefinedFunctionCrudTest extends TestSuiteBase { - private CosmosContainer createdCollection; - private CosmosClient client; + private CosmosAsyncContainer createdCollection; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public UserDefinedFunctionCrudTest(CosmosClientBuilder clientBuilder) { @@ -32,14 +26,14 @@ public UserDefinedFunctionCrudTest(CosmosClientBuilder clientBuilder) { public void createUserDefinedFunction() throws Exception { // create udf CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); - Mono createObservable = createdCollection.getScripts().createUserDefinedFunction(udf); + Mono createObservable = createdCollection.getScripts().createUserDefinedFunction(udf); // validate udf creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(udf.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(udf.getId()) .withUserDefinedFunctionBody("function() {var x = 10;}") .notNullEtag() .build(); @@ -50,17 +44,17 @@ public void createUserDefinedFunction() throws Exception { public void readUserDefinedFunction() throws Exception { // create a udf CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); - CosmosUserDefinedFunction readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().userDefinedFunction(); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); + CosmosAsyncUserDefinedFunction readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().getUserDefinedFunction(); // read udf waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = readBackUdf.read(); + Mono readObservable = readBackUdf.read(); //validate udf read - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(udf.id()) + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + .withId(udf.getId()) .withUserDefinedFunctionBody("function() {var x = 10;}") .notNullEtag() .build(); @@ -71,15 +65,15 @@ public void readUserDefinedFunction() throws Exception { public void deleteUserDefinedFunction() throws Exception { // create a udf CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); - CosmosUserDefinedFunction readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().userDefinedFunction(); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); + CosmosAsyncUserDefinedFunction readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().getUserDefinedFunction(); // delete udf - Mono deleteObservable = readBackUdf.delete(); + Mono deleteObservable = readBackUdf.delete(); // validate udf delete - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() + CosmosResponseValidator validator = new CosmosResponseValidator.Builder() .nullResource() .build(); validateSuccess(deleteObservable, validator); @@ -87,7 +81,7 @@ public void deleteUserDefinedFunction() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java similarity index 84% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java index 87b902834cfc..ab2c0f46675c 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionQueryTest.java @@ -2,14 +2,9 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosClientException; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncContainer; import com.azure.data.cosmos.internal.Database; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; import com.azure.data.cosmos.internal.FailureValidator; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; @@ -33,13 +28,13 @@ public class UserDefinedFunctionQueryTest extends TestSuiteBase { private Database createdDatabase; - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; private List createdUDF = new ArrayList<>(); - private CosmosClient client; + private CosmosAsyncClient client; public String getCollectionLink() { - return TestUtils.getCollectionNameLink(createdDatabase.id(), createdCollection.id()); + return TestUtils.getCollectionNameLink(createdDatabase.getId(), createdCollection.getId()); } @Factory(dataProvider = "clientBuildersWithDirect") @@ -50,21 +45,21 @@ public UserDefinedFunctionQueryTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryWithFilter() throws Exception { - String filterId = createdUDF.get(0).id(); + String filterId = createdUDF.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterId); FeedOptions options = new FeedOptions(); options.maxItemCount(5); Flux> queryObservable = createdCollection.getScripts().queryUserDefinedFunctions(query, options); - List expectedDocs = createdUDF.stream().filter(sp -> filterId.equals(sp.id()) ).collect(Collectors.toList()); + List expectedDocs = createdUDF.stream().filter(sp -> filterId.equals(sp.getId()) ).collect(Collectors.toList()); assertThat(expectedDocs).isNotEmpty(); int expectedPageSize = (expectedDocs.size() + options.maxItemCount() - 1) / options.maxItemCount(); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedDocs.size()) - .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -78,7 +73,7 @@ public void query_NoResults() throws Exception { String query = "SELECT * from root r where r.id = '2'"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryUserDefinedFunctions(query, options); FeedResponseListValidator validator = new FeedResponseListValidator.Builder() @@ -96,7 +91,7 @@ public void queryAll() throws Exception { String query = "SELECT * from root"; FeedOptions options = new FeedOptions(); options.maxItemCount(3); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryUserDefinedFunctions(query, options); List expectedDocs = createdUDF; @@ -107,7 +102,7 @@ public void queryAll() throws Exception { .Builder() .exactlyContainsInAnyOrder(expectedDocs .stream() - .map(d -> d.resourceId()) + .map(d -> d.getResourceId()) .collect(Collectors.toList())) .numberOfPages(expectedPageSize) .allPagesSatisfy(new FeedResponseValidator.Builder() @@ -120,7 +115,7 @@ public void queryAll() throws Exception { public void invalidQuerySytax() throws Exception { String query = "I am an invalid query"; FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> queryObservable = createdCollection.getScripts().queryUserDefinedFunctions(query, options); FailureValidator validator = new FailureValidator.Builder() @@ -131,14 +126,14 @@ public void invalidQuerySytax() throws Exception { validateQueryFailure(queryObservable, validator); } - public CosmosUserDefinedFunctionProperties createUserDefinedFunction(CosmosContainer cosmosContainer) { + public CosmosUserDefinedFunctionProperties createUserDefinedFunction(CosmosAsyncContainer cosmosContainer) { CosmosUserDefinedFunctionProperties storedProcedure = getUserDefinedFunctionDef(); - return cosmosContainer.getScripts().createUserDefinedFunction(storedProcedure).block().properties(); + return cosmosContainer.getScripts().createUserDefinedFunction(storedProcedure).block().getProperties(); } @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); @@ -156,8 +151,8 @@ public void afterClass() { private static CosmosUserDefinedFunctionProperties getUserDefinedFunctionDef() { CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); return udf; } } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java similarity index 60% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java index 6e10c3fc91c2..886cb6116c68 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserDefinedFunctionUpsertReplaceTest.java @@ -2,12 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosUserDefinedFunctionProperties; -import com.azure.data.cosmos.CosmosUserDefinedFunctionResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.testng.annotations.Factory; import org.testng.annotations.Test; import org.testng.annotations.Ignore; @@ -21,9 +17,9 @@ @Ignore public class UserDefinedFunctionUpsertReplaceTest extends TestSuiteBase { - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "clientBuildersWithDirect") public UserDefinedFunctionUpsertReplaceTest(CosmosClientBuilder clientBuilder) { @@ -35,33 +31,33 @@ public void replaceUserDefinedFunction() throws Exception { // create a udf CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(); - udf.id(UUID.randomUUID().toString()); - udf.body("function() {var x = 10;}"); + udf.setId(UUID.randomUUID().toString()); + udf.setBody("function() {var x = 10;}"); CosmosUserDefinedFunctionProperties readBackUdf = null; - readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().properties(); + readBackUdf = createdCollection.getScripts().createUserDefinedFunction(udf).block().getProperties(); // read udf to validate creation waitIfNeededForReplicasToCatchUp(clientBuilder()); - Mono readObservable = createdCollection.getScripts().getUserDefinedFunction(readBackUdf.id()).read(); + Mono readObservable = createdCollection.getScripts().getUserDefinedFunction(readBackUdf.getId()).read(); // validate udf creation - CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() - .withId(readBackUdf.id()) + CosmosResponseValidator validatorForRead = new CosmosResponseValidator.Builder() + .withId(readBackUdf.getId()) .withUserDefinedFunctionBody("function() {var x = 10;}") .notNullEtag() .build(); validateSuccess(readObservable, validatorForRead); //update udf - readBackUdf.body("function() {var x = 11;}"); + readBackUdf.setBody("function() {var x = 11;}"); - Mono replaceObservable = createdCollection.getScripts().getUserDefinedFunction(readBackUdf.id()).replace(readBackUdf); + Mono replaceObservable = createdCollection.getScripts().getUserDefinedFunction(readBackUdf.getId()).replace(readBackUdf); //validate udf replace - CosmosResponseValidator validatorForReplace = new CosmosResponseValidator.Builder() - .withId(readBackUdf.id()) + CosmosResponseValidator validatorForReplace = new CosmosResponseValidator.Builder() + .withId(readBackUdf.getId()) .withUserDefinedFunctionBody("function() {var x = 11;}") .notNullEtag() .build(); @@ -70,7 +66,7 @@ public void replaceUserDefinedFunction() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java similarity index 86% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java index 163d1a11c3be..78a3ec7bcb85 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/UserQueryTest.java @@ -2,13 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncDatabase; import com.azure.data.cosmos.internal.FeedResponseListValidator; import com.azure.data.cosmos.internal.FeedResponseValidator; import com.azure.data.cosmos.internal.TestUtils; @@ -33,8 +28,8 @@ public class UserQueryTest extends TestSuiteBase { private List createdUsers = new ArrayList<>(); - private CosmosClient client; - private CosmosDatabase createdDatabase; + private CosmosAsyncClient client; + private CosmosAsyncDatabase createdDatabase; @Factory(dataProvider = "clientBuilders") public UserQueryTest(CosmosClientBuilder clientBuilder) { @@ -46,7 +41,7 @@ public UserQueryTest(CosmosClientBuilder clientBuilder) { @Test(groups = { "simple" }, timeOut = TIMEOUT) public void queryUsersWithFilter() throws Exception { - String filterUserId = createdUsers.get(0).id(); + String filterUserId = createdUsers.get(0).getId(); String query = String.format("SELECT * from c where c.id = '%s'", filterUserId); FeedOptions options = new FeedOptions(); @@ -54,7 +49,7 @@ public void queryUsersWithFilter() throws Exception { Flux> queryObservable = createdDatabase.queryUsers(query, options); List expectedUsers = createdUsers.stream() - .filter(c -> StringUtils.equals(filterUserId, c.id()) ).collect(Collectors.toList()); + .filter(c -> StringUtils.equals(filterUserId, c.getId()) ).collect(Collectors.toList()); assertThat(expectedUsers).isNotEmpty(); @@ -62,7 +57,7 @@ public void queryUsersWithFilter() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedUsers.size()) - .exactlyContainsInAnyOrder(expectedUsers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedUsers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -89,7 +84,7 @@ public void queryAllUsers() throws Exception { FeedResponseListValidator validator = new FeedResponseListValidator.Builder() .totalSize(expectedUsers.size()) - .exactlyContainsInAnyOrder(expectedUsers.stream().map(d -> d.resourceId()).collect(Collectors.toList())) + .exactlyContainsInAnyOrder(expectedUsers.stream().map(d -> d.getResourceId()).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder() .requestChargeGreaterThanOrEqualTo(1.0).build()) @@ -116,14 +111,14 @@ public void queryUsers_NoResults() throws Exception { @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) public void beforeClass() throws Exception { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, databaseId); for(int i = 0; i < 5; i++) { CosmosUserProperties user = new CosmosUserProperties(); - user.id(UUID.randomUUID().toString()); - createdUsers.add(createUser(client, databaseId, user).read().block().properties()); + user.setId(UUID.randomUUID().toString()); + createdUsers.add(createUser(client, databaseId, user).read().block().getProperties()); } waitIfNeededForReplicasToCatchUp(clientBuilder()); diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java similarity index 79% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java index 622143774a10..9ec1bb92a013 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/VeryLargeDocumentQueryTest.java @@ -2,15 +2,8 @@ // Licensed under the MIT License. package com.azure.data.cosmos.rx; -import com.azure.data.cosmos.BridgeInternal; -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemRequestOptions; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.FeedOptions; -import com.azure.data.cosmos.FeedResponse; +import com.azure.data.cosmos.*; +import com.azure.data.cosmos.CosmosAsyncClient; import org.apache.commons.lang3.StringUtils; import org.testng.annotations.Factory; import org.testng.annotations.Ignore; @@ -34,9 +27,9 @@ public class VeryLargeDocumentQueryTest extends TestSuiteBase { private final static int TIMEOUT = 60000; private final static int SETUP_TIMEOUT = 60000; - private CosmosContainer createdCollection; + private CosmosAsyncContainer createdCollection; - private CosmosClient client; + private CosmosAsyncClient client; @Factory(dataProvider = "simpleClientBuildersWithDirect") public VeryLargeDocumentQueryTest(CosmosClientBuilder clientBuilder) { @@ -53,7 +46,7 @@ public void queryLargeDocuments() { } FeedOptions options = new FeedOptions(); - options.enableCrossPartitionQuery(true); + options.setEnableCrossPartitionQuery(true); Flux> feedResponseFlux = createdCollection.queryItems("SELECT * FROM r", options); @@ -61,7 +54,7 @@ public void queryLargeDocuments() { AtomicInteger totalCount = new AtomicInteger(); StepVerifier.create(feedResponseFlux.subscribeOn(Schedulers.single())) .thenConsumeWhile(feedResponse -> { - int size = feedResponse.results().size(); + int size = feedResponse.getResults().size(); totalCount.addAndGet(size); return true; }) @@ -76,17 +69,17 @@ private void createLargeDocument() { int size = (int) (ONE_MB * 1.999); BridgeInternal.setProperty(docDefinition, "largeString", StringUtils.repeat("x", size)); - Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); + Mono createObservable = createdCollection.createItem(docDefinition, new CosmosItemRequestOptions()); StepVerifier.create(createObservable.subscribeOn(Schedulers.single())) - .expectNextMatches(cosmosItemResponse -> cosmosItemResponse.properties().id().equals(docDefinition.id())) + .expectNextMatches(cosmosItemResponse -> cosmosItemResponse.getProperties().getId().equals(docDefinition.getId())) .expectComplete() .verify(Duration.ofMillis(subscriberValidationTimeout)); } @BeforeClass(groups = { "emulator" }, timeOut = 2 * SETUP_TIMEOUT) public void beforeClass() { - client = clientBuilder().build(); + client = clientBuilder().buildAsyncClient(); createdCollection = getSharedMultiPartitionCosmosContainer(client); truncateCollection(createdCollection); } diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyChannelInitializer.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyChannelInitializer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyChannelInitializer.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyChannelInitializer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHandler.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHandler.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHandler.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHandler.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHeader.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHeader.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHeader.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyClientHeader.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyRemoteHandler.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyRemoteHandler.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyRemoteHandler.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyRemoteHandler.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyServer.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyServer.java similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyServer.java rename to sdk/cosmos/azure-cosmos/src/test/java/com/azure/data/cosmos/rx/proxy/HttpProxyServer.java diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/Microsoft.jpg b/sdk/cosmos/azure-cosmos/src/test/resources/Microsoft.jpg similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/Microsoft.jpg rename to sdk/cosmos/azure-cosmos/src/test/resources/Microsoft.jpg diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/cosmosdb-1.png b/sdk/cosmos/azure-cosmos/src/test/resources/cosmosdb-1.png similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/cosmosdb-1.png rename to sdk/cosmos/azure-cosmos/src/test/resources/cosmosdb-1.png diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/databaseAccount.json b/sdk/cosmos/azure-cosmos/src/test/resources/databaseAccount.json similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/databaseAccount.json rename to sdk/cosmos/azure-cosmos/src/test/resources/databaseAccount.json diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/emulator-testng.xml b/sdk/cosmos/azure-cosmos/src/test/resources/emulator-testng.xml similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/emulator-testng.xml rename to sdk/cosmos/azure-cosmos/src/test/resources/emulator-testng.xml diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/fast-testng.xml b/sdk/cosmos/azure-cosmos/src/test/resources/fast-testng.xml similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/fast-testng.xml rename to sdk/cosmos/azure-cosmos/src/test/resources/fast-testng.xml diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/log4j.properties b/sdk/cosmos/azure-cosmos/src/test/resources/log4j.properties similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/log4j.properties rename to sdk/cosmos/azure-cosmos/src/test/resources/log4j.properties diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/long-testng.xml b/sdk/cosmos/azure-cosmos/src/test/resources/long-testng.xml similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/long-testng.xml rename to sdk/cosmos/azure-cosmos/src/test/resources/long-testng.xml diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/resources/sampleConflict.json b/sdk/cosmos/azure-cosmos/src/test/resources/sampleConflict.json similarity index 100% rename from sdk/cosmos/microsoft-azure-cosmos/src/test/resources/sampleConflict.json rename to sdk/cosmos/azure-cosmos/src/test/resources/sampleConflict.json diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictResponse.java deleted file mode 100644 index d4d70e71476b..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosConflictResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.Conflict; -import com.azure.data.cosmos.internal.ResourceResponse; - -public class CosmosConflictResponse extends CosmosResponse { - private CosmosContainer container; - private CosmosConflict conflictClient; - - CosmosConflictResponse(ResourceResponse response, CosmosContainer container) { - super(response); - this.container = container; - if(response.getResource() == null){ - super.resourceSettings(null); - }else{ - super.resourceSettings(new CosmosConflictProperties(response.getResource().toJson())); - conflictClient = new CosmosConflict(response.getResource().id(), container); - } - } - - CosmosContainer getContainer() { - return container; - } - - /** - * Get conflict client - * @return the cosmos conflict client - */ - public CosmosConflict conflict() { - return conflictClient; - } - - /** - * Get conflict properties object representing the resource on the server - * @return the conflict properties - */ - public CosmosConflictProperties properties() { - return resourceSettings(); - } -} \ No newline at end of file diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java deleted file mode 100644 index 7db9c67af184..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosDatabaseResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.Database; -import com.azure.data.cosmos.internal.ResourceResponse; - -public class CosmosDatabaseResponse extends CosmosResponse{ - private CosmosDatabase database; - - CosmosDatabaseResponse(ResourceResponse response, CosmosClient client) { - super(response); - if(response.getResource() == null){ - super.resourceSettings(null); - }else{ - super.resourceSettings(new CosmosDatabaseProperties(response)); - database = new CosmosDatabase(resourceSettings().id(), client); - } - } - - /** - * Gets the CosmosDatabase object - * - * @return {@link CosmosDatabase} - */ - public CosmosDatabase database() { - return database; - } - - /** - * Gets the cosmos database properties - * - * @return the cosmos database properties - */ - public CosmosDatabaseProperties properties() { - return resourceSettings(); - } - - /** - * Gets the Max Quota. - * - * @return the database quota. - */ - public long databaseQuota(){ - return resourceResponseWrapper.getDatabaseQuota(); - } - - /** - * Gets the current Usage. - * - * @return the current database usage. - */ - public long databaseUsage(){ - return resourceResponseWrapper.getDatabaseUsage(); - } - -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java deleted file mode 100644 index 4e9a2f87c79f..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosItemResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.Document; -import com.azure.data.cosmos.internal.ResourceResponse; - -public class CosmosItemResponse extends CosmosResponse{ - private CosmosItem itemClient; - - CosmosItemResponse(ResourceResponse response, PartitionKey partitionKey, CosmosContainer container) { - super(response); - if(response.getResource() == null){ - super.resourceSettings(null); - }else{ - super.resourceSettings(new CosmosItemProperties(response.getResource().toJson())); - itemClient = new CosmosItem(response.getResource().id(),partitionKey, container); - } - } - - /** - * Gets the itemSettings - * @return the itemSettings - */ - public CosmosItemProperties properties() { - return resourceSettings(); - } - - /** - * Gets the CosmosItem - * @return the cosmos item - */ - public CosmosItem item() { - return itemClient; - } -} \ No newline at end of file diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionResponse.java deleted file mode 100644 index 20512387bfd7..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosPermissionResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.Permission; -import com.azure.data.cosmos.internal.ResourceResponse; - -public class CosmosPermissionResponse extends CosmosResponse { - CosmosPermission permissionClient; - - CosmosPermissionResponse(ResourceResponse response, CosmosUser cosmosUser) { - super(response); - if(response.getResource() == null){ - super.resourceSettings(null); - }else{ - super.resourceSettings(new CosmosPermissionProperties(response.getResource().toJson())); - permissionClient = new CosmosPermission(response.getResource().id(), cosmosUser); - } - } - - /** - * Get the permission properties - * - * @return the permission properties - */ - public CosmosPermissionProperties properties() { - return super.resourceSettings(); - } - - /** - * Gets the CosmosPermission - * - * @return the cosmos permission - */ - public CosmosPermission permission() { - return permissionClient; - } -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java deleted file mode 100644 index b0bbb6e1f005..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserDefinedFunctionResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.ResourceResponse; -import com.azure.data.cosmos.internal.UserDefinedFunction; - -public class CosmosUserDefinedFunctionResponse extends CosmosResponse { - - private CosmosUserDefinedFunctionProperties cosmosUserDefinedFunctionProperties; - private CosmosUserDefinedFunction cosmosUserDefinedFunction; - - CosmosUserDefinedFunctionResponse(ResourceResponse response, CosmosContainer container) { - super(response); - if(response.getResource() != null) { - super.resourceSettings(new CosmosUserDefinedFunctionProperties(response)); - cosmosUserDefinedFunctionProperties = new CosmosUserDefinedFunctionProperties(response); - cosmosUserDefinedFunction = new CosmosUserDefinedFunction(cosmosUserDefinedFunctionProperties.id(), container); - } - } - - /** - * Gets the cosmos user defined function properties - * @return the cosmos user defined function properties - */ - public CosmosUserDefinedFunctionProperties properties() { - return cosmosUserDefinedFunctionProperties; - } - - /** - * Gets the cosmos user defined function object - * @return the cosmos user defined function object - */ - public CosmosUserDefinedFunction userDefinedFunction() { - return cosmosUserDefinedFunction; - } -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java deleted file mode 100644 index e67df7ec5494..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/CosmosUserResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos; - -import com.azure.data.cosmos.internal.ResourceResponse; -import com.azure.data.cosmos.internal.User; - -public class CosmosUserResponse extends CosmosResponse { - private CosmosUser user; - - CosmosUserResponse(ResourceResponse response, CosmosDatabase database) { - super(response); - if(response.getResource() == null){ - super.resourceSettings(null); - }else{ - super.resourceSettings(new CosmosUserProperties(response)); - this.user = new CosmosUser(resourceSettings().id(), database); - } - } - - /** - * Get cosmos user - * - * @return {@link CosmosUser} - */ - public CosmosUser user() { - return user; - } - - /** - * Gets the cosmos user properties - * - * @return {@link CosmosUserProperties} - */ - public CosmosUserProperties properties(){ - return resourceSettings(); - } -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainerResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainerResponse.java deleted file mode 100644 index 9e9a4d139af1..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncContainerResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosContainer; -import com.azure.data.cosmos.CosmosContainerProperties; -import com.azure.data.cosmos.CosmosContainerResponse; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.internal.DocumentCollection; -import com.azure.data.cosmos.internal.ResourceResponse; - -/** - * The synchronous cosmos container response - */ -public class CosmosSyncContainerResponse extends CosmosSyncResponse { - - private final CosmosContainerResponse responseWrapper; - private final CosmosSyncContainer container; - - CosmosSyncContainerResponse(CosmosContainerResponse response, CosmosSyncDatabase database, CosmosSyncClient client) { - super(response); - this.responseWrapper = response; - if (responseWrapper.container() != null) { - this.container = new CosmosSyncContainer(responseWrapper.container().id(), database, responseWrapper.container()); - } else { - // Delete will have null container client in response - this.container = null; - } - } - - /** - * Gets the progress of an index transformation, if one is underway. - * - * @return the progress of an index transformation. - */ - public long indexTransformationProgress() { - return responseWrapper.indexTransformationProgress(); - } - - /** - * Gets the container properties - * - * @return the cosmos container properties - */ - public CosmosContainerProperties properties() { - return responseWrapper.properties(); - } - - /** - * Gets the Container object - * - * @return the Cosmos container object - */ - public CosmosSyncContainer container() { - return container; - } -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseResponse.java deleted file mode 100644 index 0638999d6074..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncDatabaseResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosDatabaseProperties; -import com.azure.data.cosmos.CosmosDatabaseResponse; - -public class CosmosSyncDatabaseResponse extends CosmosSyncResponse { - private final CosmosDatabaseResponse responseWrapper; - private final CosmosSyncDatabase database; - - CosmosSyncDatabaseResponse(CosmosDatabaseResponse response, CosmosSyncClient client) { - super(response); - this.responseWrapper = response; - if (responseWrapper.database() != null) { - this.database = new CosmosSyncDatabase(responseWrapper.database().id(), client, responseWrapper.database()); - } else { - this.database = null; - } - } - - /** - * Gets the CosmosDatabase object - * - * @return {@link CosmosSyncDatabase} - */ - public CosmosSyncDatabase database() { - return database; - } - - /** - * Gets the cosmos database properties - * - * @return the cosmos database properties - */ - public CosmosDatabaseProperties properties() { - return responseWrapper.properties(); - } - - /** - * Gets the Max Quota. - * - * @return the database quota. - */ - public long databaseQuota() { - return responseWrapper.databaseQuota(); - } - - /** - * Gets the current Usage. - * - * @return the current database usage. - */ - public long databaseUsage() { - return responseWrapper.databaseUsage(); - } - -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItemResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItemResponse.java deleted file mode 100644 index 3926fc5fd948..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncItemResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosItemProperties; -import com.azure.data.cosmos.CosmosItemResponse; -import com.azure.data.cosmos.PartitionKey; - -public class CosmosSyncItemResponse extends CosmosSyncResponse { - private final CosmosItemResponse responseWrapper; - private final CosmosSyncItem item; - - - CosmosSyncItemResponse(CosmosItemResponse response, PartitionKey partitionKey, CosmosSyncContainer container) { - super(response); - this.responseWrapper = response; - if (responseWrapper.item() != null) { - this.item = new CosmosSyncItem(responseWrapper.item().id(), partitionKey, container, responseWrapper.item()); - } else { - // Delete will have null container client in response - this.item = null; - } - } - - /** - * Gets the itemSettings - * - * @return the itemSettings - */ - public CosmosItemProperties properties() { - return responseWrapper.properties(); - } - - /** - * Gets the CosmosItem - * - * @return the cosmos item - */ - public CosmosSyncItem item() { - return item; - } -} \ No newline at end of file diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncResponse.java deleted file mode 100644 index eb9ca39aec93..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncResponse.java +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosResponse; -import com.azure.data.cosmos.CosmosResponseDiagnostics; - -import java.time.Duration; -import java.util.Map; - -public class CosmosSyncResponse { - private final CosmosResponse resourceResponseWrapper; - - CosmosSyncResponse(CosmosResponse resourceResponse) { - this.resourceResponseWrapper = resourceResponse; - } - - /** - * Gets the maximum size limit for this entity (in megabytes (MB) for server resources and in count for master - * resources). - * - * @return the max resource quota. - */ - public String maxResourceQuota() { - return resourceResponseWrapper.maxResourceQuota(); - } - - /** - * Gets the current size of this entity (in megabytes (MB) for server resources and in count for master resources) - * - * @return the current resource quota usage. - */ - public String currentResourceQuotaUsage() { - return resourceResponseWrapper.currentResourceQuotaUsage(); - } - - /** - * Gets the Activity ID for the request. - * - * @return the activity id. - */ - public String activityId() { - return resourceResponseWrapper.activityId(); - } - - /** - * Gets the number of index paths (terms) generated by the operation. - * - * @return the request charge. - */ - public double requestCharge() { - return resourceResponseWrapper.requestCharge(); - } - - /** - * Gets the HTTP status code associated with the response. - * - * @return the status code. - */ - public int statusCode() { - return resourceResponseWrapper.statusCode(); - } - - /** - * Gets the token used for managing client's consistency requirements. - * - * @return the session token. - */ - public String sessionToken() { - return resourceResponseWrapper.sessionToken(); - } - - /** - * Gets the headers associated with the response. - * - * @return the response headers. - */ - public Map responseHeaders() { - return resourceResponseWrapper.responseHeaders(); - } - - /** - * Gets the diagnostics information for the current request to Azure Cosmos DB service. - * - * @return diagnostics information for the current request to Azure Cosmos DB service. - */ - public CosmosResponseDiagnostics cosmosResponseDiagnosticsString() { - return resourceResponseWrapper.cosmosResponseDiagnosticsString(); - } - - /** - * Gets the end-to-end request latency for the current request to Azure Cosmos DB service. - * - * @return end-to-end request latency for the current request to Azure Cosmos DB service. - */ - public Duration requestLatency() { - return resourceResponseWrapper.requestLatency(); - } -} diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedureResponse.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedureResponse.java deleted file mode 100644 index ecfd3dd0f093..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/CosmosSyncStoredProcedureResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.cosmos.sync; - -import com.azure.data.cosmos.CosmosStoredProcedureProperties; -import com.azure.data.cosmos.CosmosStoredProcedureResponse; - - -/** - * The type Cosmos sync stored procedure response. - */ -public class CosmosSyncStoredProcedureResponse extends CosmosSyncResponse { - private final CosmosSyncStoredProcedure cosmosSyncStoredProcedure; - private final CosmosStoredProcedureResponse asyncResponse; - - /** - * Instantiates a new Cosmos sync stored procedure response. - * - * @param resourceResponse the resource response - * @param storedProcedure the stored procedure - */ - CosmosSyncStoredProcedureResponse(CosmosStoredProcedureResponse resourceResponse, - CosmosSyncStoredProcedure storedProcedure) { - super(resourceResponse); - this.asyncResponse = resourceResponse; - this.cosmosSyncStoredProcedure = storedProcedure; - } - - /** - * Gets cosmos stored procedure properties. - * - * @return the cosmos stored procedure properties - */ - public CosmosStoredProcedureProperties properties() { - return asyncResponse.properties(); - } - - /** - * Gets cosmos sync stored procedure. - * - * @return the cosmos sync stored procedure - */ - public CosmosSyncStoredProcedure storedProcedure() { - return cosmosSyncStoredProcedure; - } - - @Override - public String activityId() { - return asyncResponse.activityId(); - } - - @Override - public String sessionToken() { - return asyncResponse.sessionToken(); - } - - @Override - public int statusCode() { - return asyncResponse.statusCode(); - } - - @Override - public double requestCharge() { - return asyncResponse.requestCharge(); - } - - /** - * Response as string string. - * - * @return the string - */ - public String responseAsString() { - return asyncResponse.responseAsString(); - } - - /** - * Script log string. - * - * @return the string - */ - public String scriptLog() { - return asyncResponse.scriptLog(); - } - - -} \ No newline at end of file diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/package-info.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/package-info.java deleted file mode 100644 index 3c6fba8deadd..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/sync/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * This package provides synchronous interfaces for interacting with Azure Cosmos DB. - */ -package com.azure.data.cosmos.sync; diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java b/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java deleted file mode 100644 index ae7e44ede996..000000000000 --- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/rx/PermissionCrudTest.java +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.data.cosmos.rx; - -import com.azure.data.cosmos.CosmosClient; -import com.azure.data.cosmos.CosmosClientBuilder; -import com.azure.data.cosmos.CosmosDatabase; -import com.azure.data.cosmos.CosmosDatabaseForTest; -import com.azure.data.cosmos.CosmosPermission; -import com.azure.data.cosmos.CosmosPermissionResponse; -import com.azure.data.cosmos.CosmosPermissionProperties; -import com.azure.data.cosmos.CosmosResponseValidator; -import com.azure.data.cosmos.CosmosUser; -import com.azure.data.cosmos.CosmosUserProperties; -import com.azure.data.cosmos.PermissionMode; -import com.azure.data.cosmos.internal.FailureValidator; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Factory; -import org.testng.annotations.Test; -import reactor.core.publisher.Mono; - -import java.util.UUID; - -//TODO: change to use external TestSuiteBase -public class PermissionCrudTest extends TestSuiteBase { - - private CosmosDatabase createdDatabase; - private CosmosUser createdUser; - private final String databaseId = CosmosDatabaseForTest.generateId(); - - private CosmosClient client; - - @Factory(dataProvider = "clientBuilders") - public PermissionCrudTest(CosmosClientBuilder clientBuilder) { - super(clientBuilder); - } - - @Test(groups = { "simple" }, timeOut = TIMEOUT) - public void createPermission() throws Exception { - - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); - //create permission - CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() - .id(UUID.randomUUID().toString()) - .permissionMode(PermissionMode.READ) - .resourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); - - Mono createObservable = createdUser.createPermission(permissionSettings, null); - - // validate permission creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(permissionSettings.id()) - .withPermissionMode(PermissionMode.READ) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(createObservable, validator); - } - - @Test(groups = { "simple" }, timeOut = TIMEOUT) - public void readPermission() throws Exception { - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); - - // create permission - CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() - .id(UUID.randomUUID().toString()) - .permissionMode(PermissionMode.READ) - .resourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); - CosmosPermissionResponse readBackPermission = createdUser.createPermission(permissionSettings, null) - .block(); - - // read Permission - Mono readObservable = readBackPermission.permission().read(null); - - // validate permission read - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(permissionSettings.id()) - .withPermissionMode(PermissionMode.READ) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(readObservable, validator); - } - - @Test(groups = { "simple" }, timeOut = TIMEOUT) - public void deletePermission() throws Exception { - - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); - - // create permission - CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() - .id(UUID.randomUUID().toString()) - .permissionMode(PermissionMode.READ) - .resourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); - CosmosPermissionResponse readBackPermission = createdUser.createPermission(permissionSettings, null) - .block(); - // delete - Mono deleteObservable = readBackPermission.permission() - .delete(null); - - // validate delete permission - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .nullResource() - .build(); - validateSuccess(deleteObservable, validator); - - waitIfNeededForReplicasToCatchUp(clientBuilder()); - - // attempt to read the permission which was deleted - Mono readObservable = readBackPermission.permission() - .read( null); - FailureValidator notFoundValidator = new FailureValidator.Builder().resourceNotFound().build(); - validateFailure(readObservable, notFoundValidator); - } - - @Test(groups = { "simple" }, timeOut = TIMEOUT) - public void upsertPermission() throws Exception { - - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); - - // create permission - CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() - .id(UUID.randomUUID().toString()) - .permissionMode(PermissionMode.READ) - .resourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); - CosmosPermissionResponse readBackPermissionResponse = createdUser.createPermission(permissionSettings, null) - .block(); - CosmosPermissionProperties readBackPermission = readBackPermissionResponse.properties(); - // read Permission - Mono readObservable = readBackPermissionResponse.permission() - .read( null); - - // validate permission creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(readBackPermission.id()) - .withPermissionMode(PermissionMode.READ) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(readObservable, validator); - - //update permission - readBackPermission = readBackPermission.permissionMode(PermissionMode.ALL); - - Mono updateObservable = createdUser.upsertPermission(readBackPermission, null); - - // validate permission update - CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() - .withId(readBackPermission.id()) - .withPermissionMode(PermissionMode.ALL) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(updateObservable, validatorForUpdate); - } - - @Test(groups = { "simple" }, timeOut = TIMEOUT) - public void replacePermission() throws Exception { - - createdUser = safeCreateUser(client, createdDatabase.id(), getUserDefinition()); - - String id = UUID.randomUUID().toString(); - // create permission - CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() - .id(id) - .permissionMode(PermissionMode.READ) - .resourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc="); - CosmosPermissionResponse readBackPermissionResponse = createdUser.createPermission(permissionSettings, null) - .block(); - // read Permission - Mono readObservable = readBackPermissionResponse.permission() - .read(null); - - // validate permission creation - CosmosResponseValidator validator = new CosmosResponseValidator.Builder() - .withId(readBackPermissionResponse.permission().id()) - .withPermissionMode(PermissionMode.READ) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(readObservable, validator); - - //update permission - CosmosPermissionProperties readBackPermission = readBackPermissionResponse.properties(); - readBackPermission = readBackPermission.permissionMode(PermissionMode.ALL); - - CosmosPermission cosmosPermission = createdUser.getPermission(id); - Mono updateObservable = readBackPermissionResponse.permission() - .replace(readBackPermission, null); - - // validate permission replace - CosmosResponseValidator validatorForUpdate = new CosmosResponseValidator.Builder() - .withId(readBackPermission.id()) - .withPermissionMode(PermissionMode.ALL) - .withPermissionResourceLink("dbs/AQAAAA==/colls/AQAAAJ0fgTc=") - .notNullEtag() - .build(); - validateSuccess(updateObservable, validatorForUpdate); - } - - @BeforeClass(groups = { "simple" }, timeOut = SETUP_TIMEOUT) - public void beforeClass() { - client = clientBuilder().build(); - createdDatabase = createDatabase(client, databaseId); - } - - @AfterClass(groups = { "simple" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) - public void afterClass() { - safeClose(client); - } - - private static CosmosUserProperties getUserDefinition() { - return new CosmosUserProperties() - .id(UUID.randomUUID().toString()); - } - -} diff --git a/sdk/cosmos/pom.service.xml b/sdk/cosmos/pom.service.xml index ed71b263af04..28d36830a6da 100644 --- a/sdk/cosmos/pom.service.xml +++ b/sdk/cosmos/pom.service.xml @@ -9,9 +9,9 @@ pom 1.0.0 - microsoft-azure-cosmos - microsoft-azure-cosmos-benchmark - microsoft-azure-cosmos-examples + azure-cosmos + azure-cosmos-benchmark + azure-cosmos-examples - \ No newline at end of file + diff --git a/sdk/cosmos/pom.xml b/sdk/cosmos/pom.xml index 532301e16c4d..0c0676da9471 100644 --- a/sdk/cosmos/pom.xml +++ b/sdk/cosmos/pom.xml @@ -8,12 +8,12 @@ Licensed under the MIT License. com.azure azure-data-sdk-parent 1.2.0 - ../../pom.data.xml + ../../pom.client.xml - com.microsoft.azure + com.azure azure-cosmos-parent - 3.3.0 + 4.0.0-preview.4 pom Microsoft Azure Cosmos DB SQL API @@ -54,7 +54,7 @@ Licensed under the MIT License. com.microsoft.azure azure-cosmos - 3.3.0 + 4.0.0-preview.4 @@ -391,9 +391,9 @@ Licensed under the MIT License. - microsoft-azure-cosmos - microsoft-azure-cosmos-benchmark - microsoft-azure-cosmos-examples + azure-cosmos + azure-cosmos-benchmark + azure-cosmos-examples