|
19 | 19 |
|
20 | 20 | import com.alipay.oceanbase.rpc.exception.ObTableException; |
21 | 21 | import com.alipay.oceanbase.rpc.get.Get; |
| 22 | +import com.alipay.oceanbase.rpc.get.result.GetResult; |
22 | 23 | import com.alipay.oceanbase.rpc.mutation.BatchOperation; |
23 | 24 | import com.alipay.oceanbase.rpc.mutation.result.BatchOperationResult; |
24 | 25 | import com.alipay.oceanbase.rpc.util.ObTableClientTestUtil; |
25 | 26 | import org.junit.Assert; |
26 | 27 | import org.junit.Before; |
27 | 28 | import org.junit.Test; |
28 | 29 |
|
| 30 | +import java.util.List; |
29 | 31 | import java.util.Map; |
30 | 32 |
|
31 | 33 | import static com.alipay.oceanbase.rpc.mutation.MutationFactory.colVal; |
32 | 34 | import static com.alipay.oceanbase.rpc.mutation.MutationFactory.row; |
33 | | -import static org.junit.Assert.assertThrows; |
34 | | -import static org.junit.Assert.assertTrue; |
| 35 | +import static org.junit.Assert.*; |
| 36 | +import static org.junit.Assert.assertEquals; |
35 | 37 |
|
36 | 38 | /* |
37 | 39 | CREATE TABLE IF NOT EXISTS `test_get` ( |
@@ -274,4 +276,37 @@ public void testBatchGet5() { |
274 | 276 | System.out.println(thrown.getMessage()); |
275 | 277 | assertTrue(thrown.getMessage().contains("[-4007][OB_NOT_SUPPORTED][operation is not supported to partially fill rowkey columns not supported]")); |
276 | 278 | } |
| 279 | + |
| 280 | + /* test same Get */ |
| 281 | + @Test |
| 282 | + public void testBatchGet6() throws Exception { |
| 283 | + try { |
| 284 | + // insert |
| 285 | + client.insertOrUpdate(tableName) |
| 286 | + .setRowKey(row(colVal("c1", "c1_val"), colVal("c2", "c2_val"))) |
| 287 | + .addMutateColVal(colVal("c3", "c3_val")).execute(); |
| 288 | + |
| 289 | + // select c1,c2 |
| 290 | + BatchOperation batch = client.batchOperation(tableName); |
| 291 | + Get get1 = client.get(tableName) |
| 292 | + .setRowKey(row(colVal("c1", "c1_val"), colVal("c2", "c2_val"))).select("c1", "c2", "c3"); |
| 293 | + Get get2 = client.get(tableName) |
| 294 | + .setRowKey(row(colVal("c1", "c1_val"), colVal("c2", "c2_val"))).select("c1", "c2", "c3"); |
| 295 | + batch.addOperation(get1, get2); |
| 296 | + BatchOperationResult res = batch.execute(); |
| 297 | + Assert.assertNotNull(res); |
| 298 | + List<Object> getResults = res.getResults(); |
| 299 | + assertEquals(2, getResults.size()); |
| 300 | + for (Object result : getResults) { |
| 301 | + GetResult getResult = (GetResult) result; |
| 302 | + Map<String, Object> row = getResult.getOperationRow().getMap(); |
| 303 | + assertEquals("c1_val", row.get("c1")); |
| 304 | + assertEquals("c2_val", row.get("c2")); |
| 305 | + assertEquals("c3_val", row.get("c3")); |
| 306 | + } |
| 307 | + } finally { |
| 308 | + client.delete(tableName).setRowKey(row(colVal("c1", "c1_val"), colVal("c2", "c2_val"))) |
| 309 | + .execute(); |
| 310 | + } |
| 311 | + } |
277 | 312 | } |
0 commit comments