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 @@ -12,7 +12,7 @@ public class CosmosContainerResponse extends CosmosResponse<CosmosContainerPrope
private final CosmosContainer container;

CosmosContainerResponse(CosmosAsyncContainerResponse response, CosmosDatabase database, CosmosClient client) {
super(response.getProperties());
super(response.resourceResponseWrapper, response.getProperties());
Copy link
Member

@kirankumarkolli kirankumarkolli Oct 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't sending wrapper out break design abstractions?
Or what should be the right abstraction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapper is already being used in all the public API classes as to fetch the properties. This won't break out the abstraction design.
This will just make sure to assign the wrapper in the parent class from the response object.

this.responseWrapper = response;
if (responseWrapper.getContainer() != null) {
this.container = new CosmosContainer(responseWrapper.getContainer().getId(), database, responseWrapper.getContainer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CosmosDatabaseResponse extends CosmosResponse<CosmosDatabasePropert
private final CosmosDatabase database;

CosmosDatabaseResponse(CosmosAsyncDatabaseResponse response, CosmosClient client) {
super(response.getProperties());
super(response.resourceResponseWrapper, response.getProperties());
this.responseWrapper = response;
if (responseWrapper.getDatabase() != null) {
this.database = new CosmosDatabase(responseWrapper.getDatabase().getId(), client, responseWrapper.getDatabase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CosmosItemResponse extends CosmosResponse<CosmosItemProperties> {


CosmosItemResponse(CosmosAsyncItemResponse response, PartitionKey partitionKey, CosmosContainer container) {
super(response.getProperties());
super(response.resourceResponseWrapper, response.getProperties());
this.responseWrapper = response;
if (responseWrapper.getItem() != null) {
this.item = new CosmosItem(responseWrapper.getItem().getId(), partitionKey, container, responseWrapper.getItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,24 @@ public class CosmosResponse<T extends Resource> {
CosmosResponse(ResourceResponse resourceResponse){
this.resourceResponseWrapper = resourceResponse;
}

CosmosResponse(T properties){
this.properties = properties;
}

CosmosResponse(ResourceResponse resourceResponse, T properties) {
this.resourceResponseWrapper = resourceResponse;
this.properties = properties;
}

// Only used in CosmosAsyncStoredProcedureResponse compatibility with StoredProcedureResponse
CosmosResponse(StoredProcedureResponse response) {
}

public T getProperties() {
return properties;
}

CosmosResponse<T> setProperties(T resourceSettings){
this.properties = resourceSettings;
return this;
Expand Down Expand Up @@ -96,7 +101,7 @@ public String getSessionToken(){
public Map<String, String> getResponseHeaders() {
return resourceResponseWrapper.getResponseHeaders();
}

/**
* Gets the diagnostics information for the current request to Azure Cosmos DB service.
*
Expand All @@ -113,5 +118,5 @@ public CosmosResponseDiagnostics getCosmosResponseDiagnosticsString() {
*/
public Duration getRequestLatency() {
return resourceResponseWrapper.getRequestLatency();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CosmosTriggerResponse extends CosmosResponse<CosmosTriggerPropertie
*/
CosmosTriggerResponse(CosmosAsyncTriggerResponse asyncResponse,
CosmosTrigger syncTrigger) {
super(asyncResponse.getProperties());
super(asyncResponse.resourceResponseWrapper, asyncResponse.getProperties());
this.asyncResponse = asyncResponse;
this.syncTrigger = syncTrigger;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CosmosUserDefinedFunctionResponse extends CosmosResponse<CosmosUser
*/
CosmosUserDefinedFunctionResponse(CosmosAsyncUserDefinedFunctionResponse resourceResponse,
CosmosUserDefinedFunction userDefinedFunction) {
super(resourceResponse.getProperties());
super(resourceResponse.resourceResponseWrapper, resourceResponse.getProperties());
this.asyncResponse = resourceResponse;
this.userDefinedFunction = userDefinedFunction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CosmosUserResponse extends CosmosResponse<CosmosUserProperties> {
* @param database the database
*/
CosmosUserResponse(CosmosAsyncUserResponse response, CosmosDatabase database) {
super(response.getProperties());
super(response.resourceResponseWrapper, response.getProperties());
this.asyncResponse = response;
if (response.getUser() != null) {
this.user = new CosmosUser(response.getUser(), database, response.getUser().getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.azure.cosmos.rx.TestSuiteBase;
import com.azure.cosmos.internal.HttpConstants;
import com.azure.cosmos.rx.TestSuiteBase;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
Expand Down Expand Up @@ -67,6 +66,7 @@ public void createContainer_withProperties() throws Exception {
CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName);

CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties);
assertThat(containerResponse.getRequestCharge()).isGreaterThan(0);
validateContainerResponse(containerProperties, containerResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.azure.cosmos.rx.TestSuiteBase;
import com.azure.cosmos.internal.HttpConstants;
import com.azure.cosmos.rx.TestSuiteBase;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
Expand Down Expand Up @@ -65,6 +64,7 @@ public void createDatabase_withProperties() throws Exception {
CosmosDatabaseProperties databaseProperties = new CosmosDatabaseProperties(databaseDefinition.getId());

CosmosDatabaseResponse createResponse = client.createDatabase(databaseProperties);
assertThat(createResponse.getRequestCharge()).isGreaterThan(0);
validateDatabaseResponse(databaseDefinition, createResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.azure.cosmos.rx.TestSuiteBase;
import com.azure.cosmos.internal.HttpConstants;
import com.azure.cosmos.rx.TestSuiteBase;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
Expand Down Expand Up @@ -52,6 +51,7 @@ public void afterClass() {
public void createItem() throws Exception {
CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString());
CosmosItemResponse itemResponse = container.createItem(properties);
assertThat(itemResponse.getRequestCharge()).isGreaterThan(0);
validateItemResponse(properties, itemResponse);

properties = getDocumentDefinition(UUID.randomUUID().toString());
Expand Down