Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ public T getResource() {
}

/**
* Gets the number of index paths (terms) generated by the operation.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public String getCurrentResourceQuotaUsage() {
}

/**
* Gets the number of normalized requests charged.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ public long getRetries() {
}

/**
* Gets the request charge for this continuation of the query.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the requestCharge
* @return the request charge.
*/
public double getRequestCharge() {
return requestCharge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ public String getActivityId() {
}

/**
* Gets the number of index paths (terms) generated by the operation.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public CosmosConflictProperties setId(String id) {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.conflict.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public String getActivityId() {
}

/**
* Gets the number of index paths (terms) generated by the operation.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public String getId() {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.permission.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public String getActivityId() {
}

/**
* Gets the number of index paths (terms) generated by the operation.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class CosmosStoredProcedureProperties {
/**
* Constructor.
*/
public CosmosStoredProcedureProperties() {
CosmosStoredProcedureProperties() {
this.storedProcedure = new StoredProcedure();
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public String getId() {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.storedProcedure.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ public final class CosmosTriggerProperties {
/**
* Constructor
*/
public CosmosTriggerProperties() {
CosmosTriggerProperties() {
this.trigger = new Trigger();
}

/**
* Constructor.
*
* @param id the id of the Cosmos trigger.
* @param body the body of the Cosmos trigger.
*/
public CosmosTriggerProperties(String id, String body) {
this.trigger = new Trigger();
trigger.setId(id);
trigger.setBody(body);
}

/**
* Constructor.
*
Expand Down Expand Up @@ -120,7 +132,7 @@ public String getId() {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.trigger.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@ public final class CosmosUserDefinedFunctionProperties {
private UserDefinedFunction userDefinedFunction;

/**
* Constructor
* Constructor.
*/
CosmosUserDefinedFunctionProperties() {
this.userDefinedFunction = new UserDefinedFunction();
}

/**
* Constructor.
*
* @param id the id of the Cosmos user defined function.
* @param body the body of the Cosmos user defined function.
*/
public CosmosUserDefinedFunctionProperties() {
public CosmosUserDefinedFunctionProperties(String id, String body) {
this.userDefinedFunction = new UserDefinedFunction();
userDefinedFunction.setId(id);
userDefinedFunction.setBody(body);
}

/**
* Constructor.
*
* @param jsonString the json string that represents the cosmos user defined function properties.
* @param jsonString the JSON string that represents the cosmos user defined function properties.
*/
CosmosUserDefinedFunctionProperties(String jsonString) {
this.userDefinedFunction = new UserDefinedFunction(jsonString);
Expand Down Expand Up @@ -81,7 +93,7 @@ public CosmosUserDefinedFunctionProperties setId(String id) {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.userDefinedFunction.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public final class CosmosUserProperties {

private User user;

/**
* Initialize a user object.
*/
Expand Down Expand Up @@ -80,7 +81,7 @@ public String getId() {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.user.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ public String getCurrentResourceQuotaUsage() {
}

/**
* Gets the number of index paths (terms) generated by the operation.
* Gets the request charge as request units (RU) consumed by the operation.
* <p>
* For more information about the RU and factors that can impact the effective charges please visit
* <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/request-units">Request Units in Azure Cosmos DB</a>
*
* @return the request charge.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static ThroughputProperties createManualThroughput(int throughput) {
}

/**
* Create auto scale throughput properties.
* Create auto-scale throughput properties.
*
* @param autoScaleMaxThroughput the max auto scale throughput
* @param autoUpgradethroughputIncrementPercentage the auto upgrade max throughput increment percentage
Expand Down Expand Up @@ -63,7 +63,7 @@ public Integer getManualThroughput() {
}

/**
* Gets offer autoscale properties.
* Gets offer auto-scale properties.
*
* @return the offer autoscale properties
*/
Expand All @@ -72,9 +72,9 @@ OfferAutoscaleSettings getOfferAutoscaleProperties() {
}

/**
* Gets max autoscale throughput.
* Gets max auto-scale throughput.
*
* @return the max autoscale throughput
* @return the max auto-scale throughput
*/
public int getAutoscaleMaxThroughput() {
return this.offer.getAutoscaleMaxThroughput();
Expand Down Expand Up @@ -122,7 +122,7 @@ public ThroughputProperties setId(String id) {
*
* @return the ID associated with the resource.
*/
public String getResourceId() {
String getResourceId() {
return this.offer.getResourceId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ public void replaceStoredProcedure() throws Exception {
}

private CosmosStoredProcedureProperties getCosmosStoredProcedureProperties() {
CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties();
storedProcedureDef.setId(UUID.randomUUID().toString());
storedProcedureDef.setBody("function() {var x = 10;}");
CosmosStoredProcedureProperties storedProcedureDef = new CosmosStoredProcedureProperties(
UUID.randomUUID().toString(),
"function() {var x = 10;}"
);

return storedProcedureDef;
}

Expand All @@ -146,9 +148,10 @@ public void deleteStoredProcedure() throws Exception {
}
@Test(groups = {"simple"}, timeOut = TIMEOUT)
public void executeStoredProcedure() throws Exception {
CosmosStoredProcedureProperties sproc = new CosmosStoredProcedureProperties()
.setId(UUID.randomUUID().toString());
sproc.setBody("function() {var x = 10;}");
CosmosStoredProcedureProperties sproc = new CosmosStoredProcedureProperties(
UUID.randomUUID().toString(),
"function() {var x = 10;}"
);

CosmosStoredProcedureResponse response = container.getScripts().createStoredProcedure(sproc);
CosmosStoredProcedureRequestOptions options = new CosmosStoredProcedureRequestOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ public void deleteUDF() throws Exception {
}

private CosmosUserDefinedFunctionProperties getCosmosUserDefinedFunctionProperties() {
CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties();
udf.setId(UUID.randomUUID().toString());
udf.setBody("function() {var x = 10;}");
CosmosUserDefinedFunctionProperties udf = new CosmosUserDefinedFunctionProperties(
UUID.randomUUID().toString(),
"function() {var x = 10;}"
);

return udf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ public void readAllTriggers() throws Exception {
}

private CosmosTriggerProperties getCosmosTriggerProperties() {
CosmosTriggerProperties trigger = new CosmosTriggerProperties();
trigger.setId(UUID.randomUUID().toString());
trigger.setBody("function() {var x = 10;}");
CosmosTriggerProperties trigger = new CosmosTriggerProperties(
UUID.randomUUID().toString(),
"function() {var x = 10;}"
);
trigger.setTriggerOperation(TriggerOperation.CREATE);
trigger.setTriggerType(TriggerType.PRE);

return trigger;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ public void validate(List<FeedResponse<T>> feedList) {
return this;
}

public Builder<T> exactlyContainsIdsInAnyOrder(List<String> expectedIds) {
validators.add(new FeedResponseListValidator<T>() {
@Override
public void validate(List<FeedResponse<T>> feedList) {
List<String> actualIds = feedList
.stream()
.flatMap(f -> f.getResults().stream())
.map(r -> getResource(r).getId())
.collect(Collectors.toList());
assertThat(actualIds)
.describedAs("IDs of results")
.containsOnlyElementsOf(expectedIds);
}
});
return this;
}

public Builder<T> numberOfPages(int expectedNumberOfPages) {
validators.add(new FeedResponseListValidator<T>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void queryWithFilter() throws Exception {

FeedResponseListValidator<CosmosPermissionProperties> validator = new FeedResponseListValidator.Builder<CosmosPermissionProperties>()
.totalSize(expectedDocs.size())
.exactlyContainsInAnyOrder(expectedDocs.stream().map(d -> d.getResourceId()).collect(Collectors.toList()))
.exactlyContainsIdsInAnyOrder(expectedDocs.stream().map(CosmosPermissionProperties::getId).collect(Collectors.toList()))
.numberOfPages(expectedPageSize)
.pageSatisfy(0, new FeedResponseValidator.Builder<CosmosPermissionProperties>()
.requestChargeGreaterThanOrEqualTo(1.0).build())
Expand Down Expand Up @@ -94,9 +94,9 @@ public void queryAll() throws Exception {

FeedResponseListValidator<CosmosPermissionProperties> validator = new FeedResponseListValidator
.Builder<CosmosPermissionProperties>()
.exactlyContainsInAnyOrder(createdPermissions
.exactlyContainsIdsInAnyOrder(createdPermissions
.stream()
.map(d -> d.getResourceId())
.map(CosmosPermissionProperties::getId)
.collect(Collectors.toList()))
.numberOfPages(expectedPageSize)
.allPagesSatisfy(new FeedResponseValidator.Builder<CosmosPermissionProperties>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void readPermissions() throws Exception {
FeedResponseListValidator<CosmosPermissionProperties> validator = new FeedResponseListValidator.Builder<CosmosPermissionProperties>()
.totalSize(createdPermissions.size())
.numberOfPages(expectedPageSize)
.exactlyContainsInAnyOrder(createdPermissions.stream().map(
p -> p.getResourceId()).collect(Collectors.toList()))
.exactlyContainsIdsInAnyOrder(createdPermissions.stream().map(
CosmosPermissionProperties::getId).collect(Collectors.toList()))
.allPagesSatisfy(new FeedResponseValidator.Builder<CosmosPermissionProperties>()
.requestChargeGreaterThanOrEqualTo(1.0).build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void readStoredProcedures() throws Exception {

FeedResponseListValidator<CosmosStoredProcedureProperties> validator = new FeedResponseListValidator.Builder<CosmosStoredProcedureProperties>()
.totalSize(createdStoredProcedures.size())
.exactlyContainsInAnyOrder(
createdStoredProcedures.stream().map(d -> d.getResourceId()).collect(Collectors.toList()))
.exactlyContainsIdsInAnyOrder(
createdStoredProcedures.stream().map(CosmosStoredProcedureProperties::getId).collect(Collectors.toList()))
.numberOfPages(expectedPageSize)
.allPagesSatisfy(new FeedResponseValidator.Builder<CosmosStoredProcedureProperties>()
.requestChargeGreaterThanOrEqualTo(1.0).build())
Expand All @@ -73,9 +73,11 @@ public void afterClass() {
}

public CosmosStoredProcedureProperties createStoredProcedures(CosmosAsyncContainer cosmosContainer) {
CosmosStoredProcedureProperties sproc = new CosmosStoredProcedureProperties();
sproc.setId(UUID.randomUUID().toString());
sproc.setBody("function() {var x = 10;}");
CosmosStoredProcedureProperties sproc = new CosmosStoredProcedureProperties(
UUID.randomUUID().toString(),
"function() {var x = 10;}"
);

return cosmosContainer.getScripts().createStoredProcedure(sproc, new CosmosStoredProcedureRequestOptions())
.block().getProperties();
}
Expand Down
Loading