2020
2121import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
2222
23- public class ThinClientE2ETest extends com . azure . cosmos . rx . TestSuiteBase {
23+ public class ThinClientE2ETest {
2424 @ Test (groups = {"thinclient" })
2525 public void testThinClientDocumentPointOperations () {
2626 CosmosAsyncClient client = null ;
@@ -38,12 +38,14 @@ public void testThinClientDocumentPointOperations() {
3838 .consistencyLevel (ConsistencyLevel .SESSION )
3939 .buildAsyncClient ();
4040
41- CosmosAsyncContainer container = client .getDatabase ("updatedd-thin-client-test-db" ).getContainer ("thin-client-test-container-1" );
41+ CosmosAsyncContainer container = client .getDatabase ("db1" ).getContainer ("c2" );
42+ String idName = "id" ;
43+ String partitionKeyName = "partitionKey" ;
4244 ObjectMapper mapper = new ObjectMapper ();
4345 ObjectNode doc = mapper .createObjectNode ();
4446 String idValue = UUID .randomUUID ().toString ();
45- doc .put ("id" , idValue );
46- doc .put ("pk" , idValue );
47+ doc .put (idName , idValue );
48+ doc .put (partitionKeyName , idValue );
4749
4850 // create
4951 CosmosItemResponse <ObjectNode > createResponse = container .createItem (doc ).block ();
@@ -57,8 +59,8 @@ public void testThinClientDocumentPointOperations() {
5759
5860 ObjectNode doc2 = mapper .createObjectNode ();
5961 String idValue2 = UUID .randomUUID ().toString ();
60- doc2 .put ("id" , idValue2 );
61- doc2 .put ("pk" , idValue );
62+ doc2 .put (idName , idValue2 );
63+ doc2 .put (partitionKeyName , idValue );
6264
6365 // replace
6466 CosmosItemResponse <ObjectNode > replaceResponse = container .replaceItem (doc2 , idValue , new PartitionKey (idValue )).block ();
@@ -67,12 +69,12 @@ public void testThinClientDocumentPointOperations() {
6769 CosmosItemResponse <ObjectNode > readAfterReplaceResponse = container .readItem (idValue2 , new PartitionKey (idValue ), ObjectNode .class ).block ();
6870 assertThat (readAfterReplaceResponse .getStatusCode ()).isEqualTo (200 );
6971 ObjectNode replacedItemFromRead = readAfterReplaceResponse .getItem ();
70- assertThat (replacedItemFromRead .get ("id" ).asText ()).isEqualTo (idValue2 );
71- assertThat (replacedItemFromRead .get ("pk" ).asText ()).isEqualTo (idValue );
72+ assertThat (replacedItemFromRead .get (idName ).asText ()).isEqualTo (idValue2 );
73+ assertThat (replacedItemFromRead .get (partitionKeyName ).asText ()).isEqualTo (idValue );
7274
7375 ObjectNode doc3 = mapper .createObjectNode ();
74- doc3 .put ("id" , idValue2 );
75- doc3 .put ("pk" , idValue );
76+ doc3 .put (idName , idValue2 );
77+ doc3 .put (partitionKeyName , idValue );
7678 doc3 .put ("newField" , "newValue" );
7779
7880 // upsert
@@ -81,8 +83,8 @@ public void testThinClientDocumentPointOperations() {
8183 assertThat (upsertResponse .getRequestCharge ()).isGreaterThan (0.0 );
8284 CosmosItemResponse <ObjectNode > readAfterUpsertResponse = container .readItem (idValue2 , new PartitionKey (idValue ), ObjectNode .class ).block ();
8385 ObjectNode upsertedItemFromRead = readAfterUpsertResponse .getItem ();
84- assertThat (upsertedItemFromRead .get ("id" ).asText ()).isEqualTo (idValue2 );
85- assertThat (upsertedItemFromRead .get ("pk" ).asText ()).isEqualTo (idValue );
86+ assertThat (upsertedItemFromRead .get (idName ).asText ()).isEqualTo (idValue2 );
87+ assertThat (upsertedItemFromRead .get (partitionKeyName ).asText ()).isEqualTo (idValue );
8688 assertThat (upsertedItemFromRead .get ("newField" ).asText ()).isEqualTo ("newValue" );
8789
8890 // patch
@@ -94,8 +96,8 @@ public void testThinClientDocumentPointOperations() {
9496 assertThat (patchResponse .getRequestCharge ()).isGreaterThan (0.0 );
9597 CosmosItemResponse <ObjectNode > readAfterPatchResponse = container .readItem (idValue2 , new PartitionKey (idValue ), ObjectNode .class ).block ();
9698 ObjectNode patchedItemFromRead = readAfterPatchResponse .getItem ();
97- assertThat (patchedItemFromRead .get ("id" ).asText ()).isEqualTo (idValue2 );
98- assertThat (patchedItemFromRead .get ("pk" ).asText ()).isEqualTo (idValue );
99+ assertThat (patchedItemFromRead .get (idName ).asText ()).isEqualTo (idValue2 );
100+ assertThat (patchedItemFromRead .get (partitionKeyName ).asText ()).isEqualTo (idValue );
99101 assertThat (patchedItemFromRead .get ("newField" ).asText ()).isEqualTo ("patchedNewField" );
100102 assertThat (patchedItemFromRead .get ("anotherNewField" ).asText ()).isEqualTo ("anotherNewValue" );
101103
0 commit comments