use of com.datastax.driver.mapping.entity.EntityWithCompositeKey in project cassandra-driver-mapping by valchkou.
the class MappingSessionAsyncTest method saveAndGetAndDeleteWithCompoundCompositeKeyTest.
@Test
public void saveAndGetAndDeleteWithCompoundCompositeKeyTest() throws Exception {
SimpleKey partition = new SimpleKey();
partition.setName("name");
partition.setRank(10);
partition.setT1(UUIDs.timeBased());
partition.setT2(UUIDs.timeBased());
CompositeKey key = new CompositeKey();
key.setKey(partition);
Date created = new Date();
key.setCreated(created);
key.setEmail("email@at");
EntityWithCompositeKey obj = new EntityWithCompositeKey();
obj.setKey(key);
obj.setTimestamp(1000);
obj.setAsof(created);
EntityWithCompositeKey loaded = target.get(EntityWithCompositeKey.class, key);
assertNull(loaded);
ResultSetFuture f = target.saveAsync(obj);
f.getUninterruptibly();
loaded = target.get(EntityWithCompositeKey.class, key);
assertEquals(obj, loaded);
f = target.deleteAsync(loaded);
f.getUninterruptibly();
loaded = target.get(EntityWithCompositeKey.class, key);
assertNull(loaded);
}
Aggregations