use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataOverrideDataType.
@Test
public void testGetEntityMetadataOverrideDataType() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityOverrideDataType.class);
assertEquals(2, meta.getFields().size());
EntityFieldMetaData fd = meta.getFieldMetadata("uid");
assertEquals(DataType.Name.TIMEUUID, fd.getDataType());
fd = meta.getFieldMetadata("name");
assertEquals(DataType.Name.VARCHAR, fd.getDataType());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataForSimplePojo.
@Test
public void testGetEntityMetadataForSimplePojo() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(Simple.class);
assertEquals("Simple", meta.getTableName());
assertEquals(0, meta.getIndexes().size());
assertEquals(6, meta.getFields().size());
PrimaryKeyMetadata pkm = meta.getPrimaryKeyMetadata();
assertNotNull(pkm);
assertFalse(pkm.isCompound());
assertFalse(pkm.hasPartitionKey());
assertEquals("id", pkm.getOwnField().getColumnName());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetKeyDataSimpleKey.
@Test
public void testGetKeyDataSimpleKey() {
SimpleKey sk = new SimpleKey();
sk.setName("name");
sk.setRank(10);
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityWithKey.class);
List<String> cols = meta.getPkColumns();
assertEquals(4, cols.size());
assertEquals("name", cols.get(0));
assertEquals("rank", cols.get(1));
assertEquals("t1", cols.get(2));
assertEquals("t2", cols.get(3));
List<Object> vals = meta.getIdValues(sk);
assertEquals(4, vals.size());
assertEquals("name", vals.get(0));
assertEquals(10, vals.get(1));
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataWithEnum.
@Test
public void testGetEntityMetadataWithEnum() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityWithEnum.class);
assertEquals("entity_with_enum", meta.getTableName());
assertEquals(2, meta.getFields().size());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class MappingSessionTest method getByQueryTest.
@Test
public void getByQueryTest() throws Exception {
for (int i = 0; i < 3; i++) {
EntityWithIndexes obj = new EntityWithIndexes();
obj.setCount(100);
obj.setEmail("email@test");
obj.setName("test" + i);
obj.setTimeStamp(new Date());
obj.setUuid(UUID.randomUUID());
target.save(obj);
}
EntityTypeMetadata emeta = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
EntityFieldMetaData fdata = emeta.getFieldMetadata("email");
Statement query = QueryBuilder.select().all().from(keyspace, emeta.getTableName()).where(eq(fdata.getColumnName(), "email@test"));
List<EntityWithIndexes> items = target.getByQuery(EntityWithIndexes.class, query);
assertEquals(3, items.size());
}
Aggregations