for (TestRecord testRecord : this.createSpecificEntities(10)) {
assertTrue(dao.put(testRecord));
}
for (int i = 0; i < 10; ++i) {
PartitionKey partitionKey = dao.getPartitionStrategy().partitionKey(
"part1_" + i, "part2_" + i);
TestRecord record = dao.get(partitionKey);
assertEquals("field1_" + i, record.getField1());
assertEquals("field2_" + i, record.getField2());
assertEquals(TestEnum.ENUM3, record.getEnum$());
assertEquals("field3_value_1_" + i,
record.getField3().get("field3_key_1_" + i));
assertEquals("field3_value_2_" + i,
record.getField3().get("field3_key_2_" + i));
assertEquals("embedded1_" + i, record.getField4().getEmbeddedField1());
assertEquals(i, (long) record.getField4().getEmbeddedField2());
assertEquals(2, record.getField5().size());
// check 1st subrecord
assertEquals("subfield1_" + i, record.getField5().get(0).getSubfield1());
assertEquals(i, (long) record.getField5().get(0).getSubfield2());
assertEquals("subfield3_" + i, record.getField5().get(0).getSubfield3());
assertEquals("subfield4_" + i, record.getField5().get(1).getSubfield1());
assertEquals(i, (long) record.getField5().get(1).getSubfield2());
assertEquals("subfield6_" + i, record.getField5().get(1).getSubfield3());
}
int cnt = 0;
EntityScanner<TestRecord> entityScanner = dao.getScanner();
entityScanner.open();
try {
for (TestRecord entity : entityScanner) {
assertEquals("field1_" + cnt, entity.getField1());
assertEquals("field2_" + cnt, entity.getField2());
cnt++;
}
assertEquals(10, cnt);
} finally {
entityScanner.close();
}
// Test scanner with null keys
PartitionKey key1 = dao.getPartitionStrategy().partitionKey("part1_5");
entityScanner = dao.getScanner(key1, null);
entityScanner.open();
assertEquals("field1_5", entityScanner.iterator().next().getField1());
entityScanner = dao.getScanner(null, key1);
entityScanner.open();
assertEquals("field1_0", entityScanner.iterator().next().getField1());
PartitionKey deleteKey = dao.getPartitionStrategy().partitionKey("part1_5",
"part2_5");
dao.delete(deleteKey);
assertNull(dao.get(deleteKey));
}