use of com.datastax.driver.mapping.entity.EntityWithCollectionsOverride in project cassandra-driver-mapping by valchkou.
the class MappingSessionAsyncTest method testCollectionsOverride.
@Test
public void testCollectionsOverride() throws Exception {
EntityWithCollectionsOverride obj = new EntityWithCollectionsOverride();
UUID uuid = UUID.randomUUID();
obj.setId(uuid);
ResultSetFuture f = target.saveAsync(obj);
f.getUninterruptibly();
EntityWithCollectionsOverride loaded = target.get(EntityWithCollectionsOverride.class, uuid);
Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
map.put("key1", new BigDecimal(100.55));
map.put("key1", new BigDecimal(100.55555));
map.put("key1", new BigDecimal(101.5500000333));
obj.setRates(map);
List<Integer> list = new ArrayList<Integer>();
list.add(100);
list.add(200);
list.add(300);
obj.setTrades(list);
Set<String> set = new HashSet<String>();
set.add("100");
set.add("200");
set.add("300");
obj.setRefs(set);
f = target.saveAsync(obj);
f.getUninterruptibly();
loaded = target.get(EntityWithCollectionsOverride.class, uuid);
assertTrue(loaded.getRates() instanceof TreeMap);
assertTrue(loaded.getRefs() instanceof TreeSet);
assertTrue(loaded.getTrades() instanceof LinkedList);
}
Aggregations