Examples of MyTestBean


Examples of me.prettyprint.hom.beans.MyTestBean

public class EntityManagerTest extends CassandraTestBase {

  @Test
  public void testInitializeSaveLoad() {
    EntityManagerImpl em = new EntityManagerImpl(keyspace, "me.prettyprint.hom.beans");
    MyTestBean o1 = new MyTestBean();
    o1.setBaseId(UUID.randomUUID());
    o1.setIntProp1(1);
    o1.setBoolProp1(Boolean.TRUE);
    o1.setLongProp1(123L);
    em.persist(o1);
    MyTestBean o2 = em.find(MyTestBean.class, o1.getBaseId());

    assertEquals(o1.getBaseId(), o2.getBaseId());
    assertEquals(o1.getIntProp1(), o2.getIntProp1());
    assertEquals(o1.isBoolProp1(), o2.isBoolProp1());
    assertEquals(o1.getLongProp1(), o2.getLongProp1());
  }
View Full Code Here

Examples of me.prettyprint.hom.beans.MyTestBean

    slice.add("color", StringSerializer.get().toBytes(color.getName()));
    slice.add("serialProp", ObjectSerializer.get().toBytes(serialProp));
    slice.add("extra", StringSerializer.get().toBytes(extraProp));

    CFMappingDef<MyTestBean, UUID> cfMapDef = cacheMgr.getCfMapDef(MyTestBean.class, true);
    MyTestBean obj = new HectorObjectMapper(cacheMgr).createObject(cfMapDef, id, slice);

    assertEquals(id, obj.getBaseId());
    assertEquals(longProp1, obj.getLongProp1());
    assertEquals(longProp2, obj.getLongProp2());
    assertEquals(intProp1, obj.getIntProp1());
    assertEquals(intProp2, obj.getIntProp2());
    assertFalse(obj.isBoolProp1());
    assertTrue(obj.getBoolProp2());
    assertEquals(strProp, obj.getStrProp());
    assertEquals(uuidProp, obj.getUuidProp());
    assertEquals("somebytes", new String(obj.getBytesProp()));
    // TODO fixme
    //assertEquals(color, obj.getColor());
    assertEquals(dateProp.getTime(), obj.getDateProp().getTime());
    assertEquals(serialProp, obj.getSerialProp());
    // TODO fixme
    //assertEquals(1, obj.getAnonymousProps().size());
    assertEquals(extraProp, obj.getAnonymousProp("extra"));
  }
View Full Code Here

Examples of me.prettyprint.hom.beans.MyTestBean

    assertEquals(extraProp, obj.getAnonymousProp("extra"));
  }

  @Test
  public void testCreateColumnSet() {
    MyTestBean obj = new MyTestBean();
    obj.setBaseId(UUID.randomUUID());
    obj.setLongProp1(111L);
    obj.setLongProp2(222L);
    obj.setIntProp1(333);
    obj.setIntProp2(444);
    obj.setBoolProp1(false);
    obj.setBoolProp2(true);
    obj.setStrProp("aStr");
    obj.setUuidProp(UUID.randomUUID());
    obj.setDateProp(new Date());
    obj.setBytesProp("somebytes".getBytes());
    obj.setColor(Colors.BLUE);
    obj.setSerialProp(new MySerial(1, 2L));
    obj.addAnonymousProp("foo", "bar");
    obj.addAnonymousProp("rice", "beans");

    Map<String, HColumn<String, byte[]>> colMap =
      new HectorObjectMapper(cacheMgr).createColumnMap(obj);
    // TODO fixme
    //assertEquals(11 + 2, colMap.size());
    assertNull("id should not have been added to column collection", colMap.get("id"));
    assertEquals(obj.getLongProp1(), (long)LongSerializer.get().fromBytes(colMap.get("lp1").getValue()));
    assertEquals(obj.getLongProp2(), LongSerializer.get().fromBytes(colMap.get("lp2").getValue()));
    assertEquals(obj.getIntProp1(), (int)IntegerSerializer.get().fromBytes(colMap.get("ip1").getValue()));
    assertEquals(obj.getIntProp2(), IntegerSerializer.get().fromBytes(colMap.get("ip2").getValue()));
    assertEquals(obj.isBoolProp1(), BooleanSerializer.get().fromBytes(colMap.get("bp1").getValue()));
    assertEquals(obj.getBoolProp2(), BooleanSerializer.get().fromBytes(colMap.get("bp2").getValue()));
    assertEquals(obj.getStrProp(), StringSerializer.get().fromBytes(colMap.get("sp").getValue()));
    assertEquals(obj.getUuidProp(), UUIDSerializer.get().fromBytes(colMap.get("up").getValue()));
    assertEquals(obj.getDateProp(), DateSerializer.get().fromBytes(colMap.get("dp").getValue()));
    assertEquals("somebytes", new String(BytesArraySerializer.get().fromBytes(colMap.get("bytes").getValue())));
    // TODO fixme
    //assertEquals(obj.getColor().getName(), new String(StringSerializer.get().fromBytes(
      //  colMap.get("color").getValue())));
    assertEquals(obj.getSerialProp(), ObjectSerializer.get().fromBytes(colMap.get("serialProp").getValue()));

    assertEquals(2, obj.getAnonymousProps().size());
    assertEquals(obj.getAnonymousProp("foo"), StringSerializer.get().fromBytes(colMap.get("foo").getValue()));
    assertEquals(obj.getAnonymousProp("rice"), StringSerializer.get().fromBytes(colMap.get("rice").getValue()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.