Search in sources :

Example 1 with EntityWithKey

use of com.datastax.driver.mapping.entity.EntityWithKey in project cassandra-driver-mapping by valchkou.

the class MappingSessionAsyncTest method saveAndGetAndDeleteWithSimpleCompositeKeyTest.

@Test
public void saveAndGetAndDeleteWithSimpleCompositeKeyTest() throws Exception {
    SimpleKey key = new SimpleKey();
    key.setName("name");
    key.setRank(10);
    key.setT1(UUIDs.timeBased());
    key.setT2(UUIDs.timeBased());
    Date created = new Date();
    EntityWithKey obj = new EntityWithKey();
    obj.setKey(key);
    obj.setTimestamp(1000);
    obj.setAsof(created);
    EntityWithKey loaded = target.get(EntityWithKey.class, key);
    assertNull(loaded);
    ResultSetFuture f = target.saveAsync(obj);
    f.getUninterruptibly();
    loaded = target.get(EntityWithKey.class, key);
    assertEquals(obj, loaded);
    f = target.deleteAsync(loaded);
    f.getUninterruptibly();
    loaded = target.get(EntityWithKey.class, key);
    assertNull(loaded);
}
Also used : EntityWithKey(com.datastax.driver.mapping.entity.EntityWithKey) ResultSetFuture(com.datastax.driver.core.ResultSetFuture) Date(java.util.Date) SimpleKey(com.datastax.driver.mapping.entity.SimpleKey) Test(org.junit.Test)

Aggregations

ResultSetFuture (com.datastax.driver.core.ResultSetFuture)1 EntityWithKey (com.datastax.driver.mapping.entity.EntityWithKey)1 SimpleKey (com.datastax.driver.mapping.entity.SimpleKey)1 Date (java.util.Date)1 Test (org.junit.Test)1