|
12 | 12 | import com.alicloud.openservices.tablestore.model.DescribeTableResponse; |
13 | 13 | import com.alicloud.openservices.tablestore.model.IndexMeta; |
14 | 14 | import com.alicloud.openservices.tablestore.model.IndexType; |
15 | | -import com.alicloud.openservices.tablestore.model.PrimaryKey; |
16 | 15 | import com.alicloud.openservices.tablestore.model.PrimaryKeyBuilder; |
17 | | -import com.alicloud.openservices.tablestore.model.PrimaryKeyColumn; |
18 | 16 | import com.alicloud.openservices.tablestore.model.PrimaryKeyValue; |
19 | 17 | import com.alicloud.openservices.tablestore.model.PutRowRequest; |
20 | 18 | import com.alicloud.openservices.tablestore.model.PutRowResponse; |
|
24 | 22 | import com.alicloud.openservices.tablestore.model.RowPutChange; |
25 | 23 | import com.alicloud.openservices.tablestore.model.StartLocalTransactionResponse; |
26 | 24 | import com.alicloud.openservices.tablestore.model.TableMeta; |
27 | | -import com.alicloud.openservices.tablestore.model.search.ParallelScanRequest; |
28 | | -import com.alicloud.openservices.tablestore.model.search.ParallelScanResponse; |
29 | 25 | import com.alicloud.openservices.tablestore.model.sql.SQLQueryRequest; |
30 | 26 | import com.alicloud.openservices.tablestore.model.sql.SQLQueryResponse; |
31 | 27 | import com.google.protobuf.Timestamp; |
32 | 28 | import com.salesforce.multicloudj.common.exceptions.InvalidArgumentException; |
33 | | -import com.salesforce.multicloudj.common.exceptions.SubstrateSdkException; |
34 | 29 | import com.salesforce.multicloudj.common.exceptions.UnAuthorizedException; |
35 | 30 | import com.salesforce.multicloudj.docstore.client.Query; |
36 | 31 | import com.salesforce.multicloudj.docstore.driver.Action; |
|
68 | 63 | import static org.mockito.Mockito.when; |
69 | 64 |
|
70 | 65 | class AliDocStoreTest { |
71 | | - BookWithoutNest book = new BookWithoutNest("YellowBook", "Neil", "WA", Timestamp.newBuilder().setNanos(1000).build(), 3.99f); |
| 66 | + BookWithoutNest book = new BookWithoutNest("YellowBook", "Neil", "WA", Timestamp.newBuilder().setNanos(1000).build(), 3.99f, null); |
72 | 67 | TestDocStore docStore; |
73 | 68 | SyncClient syncClient; |
74 | 69 | IndexMeta localIndex1; |
@@ -148,8 +143,9 @@ void setup() { |
148 | 143 | .withInstanceId("something") |
149 | 144 | .withCollectionOptions( |
150 | 145 | new CollectionOptions.CollectionOptionsBuilder() |
151 | | - .withPartitionKey("title").withSortKey("publisher"). |
152 | | - withTableName("my-table").build() |
| 146 | + .withPartitionKey("title").withSortKey("publisher") |
| 147 | + .withTableName("my-table") |
| 148 | + .withRevisionField("docRevision").build() |
153 | 149 | ).withCredentialsOverrider(credsOverrider).withTableStoreClient(syncClient).build(); |
154 | 150 |
|
155 | 151 | localIndex1 = new IndexMeta("local_index_1"); |
@@ -330,7 +326,7 @@ void testRunGetsWithException() { |
330 | 326 | List<String> fp3 = new ArrayList<>(List.of("title")); |
331 | 327 | List<String> fp4 = new ArrayList<>(List.of("publisher")); |
332 | 328 |
|
333 | | - BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0); |
| 329 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, null); |
334 | 330 | List<Action> gets = new ArrayList<>(); |
335 | 331 |
|
336 | 332 | TestAction get1 = new TestAction(ActionKind.ACTION_KIND_GET, new Document(bookObj), fp1, null); |
@@ -375,7 +371,7 @@ void testRunGets() { |
375 | 371 | List<String> fp1 = new ArrayList<>(List.of("title", "publisher")); |
376 | 372 | List<String> fp2 = new ArrayList<>(List.of("publisher", "title")); // Different order of fp1, treated as a different fp. |
377 | 373 |
|
378 | | - BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0); |
| 374 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, null); |
379 | 375 | List<Action> gets = new ArrayList<>(); |
380 | 376 |
|
381 | 377 | TestAction get1 = new TestAction(ActionKind.ACTION_KIND_GET, new Document(bookObj), fp1, null); |
@@ -427,7 +423,7 @@ void testRunGets() { |
427 | 423 |
|
428 | 424 | @Test |
429 | 425 | void testBatchGetWithMissingKeys() { |
430 | | - BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0); |
| 426 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, null); |
431 | 427 | List<Action> gets = new ArrayList<>(); |
432 | 428 | List<String> fp1 = new ArrayList<>(List.of("d")); |
433 | 429 | TestAction get1 = new TestAction(ActionKind.ACTION_KIND_GET, new Document(bookObj), fp1, null); |
@@ -458,7 +454,7 @@ void testBatchGetWithMissingKeys() { |
458 | 454 |
|
459 | 455 | @Test |
460 | 456 | void testBatchGet() { |
461 | | - BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0); |
| 457 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, null); |
462 | 458 | List<Action> gets = new ArrayList<>(); |
463 | 459 | List<String> fp1 = new ArrayList<>(List.of("title", "publisher", "author")); |
464 | 460 | TestAction get1 = new TestAction(ActionKind.ACTION_KIND_GET, new Document(bookObj), fp1, null); |
@@ -510,7 +506,27 @@ void testBatchGet() { |
510 | 506 | @Test |
511 | 507 | void testCreate() { |
512 | 508 | Document document = new Document(book); |
513 | | - ali.getActions().create(document).run(); |
| 509 | + Assertions.assertDoesNotThrow(() -> ali.getActions().create(document).run()); |
| 510 | + } |
| 511 | + |
| 512 | + @Test |
| 513 | + void testPut() { |
| 514 | + Document document = new Document(book); |
| 515 | + Assertions.assertDoesNotThrow(() -> ali.getActions().put(document).run()); |
| 516 | + } |
| 517 | + |
| 518 | + @Test |
| 519 | + void testPutWithRevision() { |
| 520 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, "something"); |
| 521 | + Document document = new Document(bookObj); |
| 522 | + Assertions.assertDoesNotThrow(() -> ali.getActions().put(document).run()); |
| 523 | + } |
| 524 | + |
| 525 | + @Test |
| 526 | + void testDeleteWithRevision() { |
| 527 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, "something"); |
| 528 | + Document document = new Document(bookObj); |
| 529 | + Assertions.assertDoesNotThrow(() -> ali.getActions().delete(document).run()); |
514 | 530 | } |
515 | 531 |
|
516 | 532 | @Test |
@@ -577,7 +593,7 @@ void testRunDelete() { |
577 | 593 | .withAllowScans(false) |
578 | 594 | .withMaxOutstandingActionRPCs(10) |
579 | 595 | .build(); |
580 | | - BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0); |
| 596 | + BookWithoutNest bookObj = new BookWithoutNest("YellowBook", null, "WA", Timestamp.newBuilder().setNanos(1000).build(), 0, null); |
581 | 597 | List<Action> deletes = new ArrayList<>(); |
582 | 598 |
|
583 | 599 | TestAction delete1 = new TestAction(ActionKind.ACTION_KIND_DELETE, new Document(bookObj), null, null); |
|
0 commit comments