Search in sources :

Example 1 with EntityWithCollectionsOverride

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);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) HashMap(java.util.HashMap) EntityWithCollectionsOverride(com.datastax.driver.mapping.entity.EntityWithCollectionsOverride) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) BigDecimal(java.math.BigDecimal) LinkedList(java.util.LinkedList) TreeSet(java.util.TreeSet) UUID(java.util.UUID) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ResultSetFuture (com.datastax.driver.core.ResultSetFuture)1 EntityWithCollectionsOverride (com.datastax.driver.mapping.entity.EntityWithCollectionsOverride)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 Test (org.junit.Test)1