use of com.datastax.driver.mapping.entity.EntityWithStringEnum in project cassandra-driver-mapping by valchkou.
the class MappingSessionAsyncTest method saveEntityWithStringEnumTest.
@Test
public void saveEntityWithStringEnumTest() throws Exception {
UUID uuid = UUID.randomUUID();
EntityWithStringEnum obj = new EntityWithStringEnum();
obj.setId(uuid);
obj.setPage(Page.GITHUB);
EntityWithStringEnum loaded = target.get(EntityWithStringEnum.class, uuid);
assertNull(loaded);
ResultSetFuture f = target.saveAsync(obj);
f.getUninterruptibly();
loaded = target.get(EntityWithStringEnum.class, uuid);
assertEquals(obj, loaded);
obj.setPage(Page.CASSANDRA);
f = target.saveAsync(obj);
f.getUninterruptibly();
loaded = target.get(EntityWithStringEnum.class, uuid);
assertEquals(obj, loaded);
f = target.deleteAsync(loaded);
f.getUninterruptibly();
loaded = target.get(EntityWithStringEnum.class, uuid);
assertNull(loaded);
}
use of com.datastax.driver.mapping.entity.EntityWithStringEnum in project cassandra-driver-mapping by valchkou.
the class MappingSessionAsyncTest method updateIndividualPropertyTest.
@Test
public void updateIndividualPropertyTest() throws Exception {
UUID uuid = UUID.randomUUID();
Simple obj = new Simple();
obj.setName("myName");
obj.setAge(55);
obj.setId(uuid);
ResultSetFuture f = target.saveAsync(obj);
f.getUninterruptibly();
f = target.updateValueAsync(uuid, Simple.class, "name", "yourName");
f.getUninterruptibly();
f = target.updateValueAsync(uuid, Simple.class, "age", 25);
f.getUninterruptibly();
Simple loaded = target.get(Simple.class, uuid);
assertEquals(25, loaded.getAge());
assertEquals("yourName", loaded.getName());
// String-Enum
EntityWithStringEnum seobj = new EntityWithStringEnum();
seobj.setId(uuid);
seobj.setPage(Page.DATASTAX);
f = target.saveAsync(seobj);
f.getUninterruptibly();
f = target.updateValueAsync(uuid, EntityWithStringEnum.class, "page", Page.CASSANDRA.toString());
f.getUninterruptibly();
EntityWithStringEnum eloaded = target.get(EntityWithStringEnum.class, uuid);
assertEquals(Page.CASSANDRA, Page.getPage(eloaded.getPage()));
}
Aggregations