use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testCreateWithCompositeKey.
@Test
public void testCreateWithCompositeKey() {
EntityTypeParser.getEntityMetadata(EntityWithCompositeKey.class).markUnSynced(keyspace);
SchemaSync.sync(keyspace, session, EntityWithCompositeKey.class);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithCompositeKey.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
assertNotNull(tableMetadata);
assertEquals("test_entity_composites", tableMetadata.getName());
assertEquals(8, tableMetadata.getColumns().size());
ColumnMetadata columnMetadata = tableMetadata.getColumn("timestamp");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("asof");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("created");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("email");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("name");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("rank");
assertNotNull(columnMetadata);
columnMetadata = tableMetadata.getColumn("key");
assertNull(columnMetadata);
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testCreateWithTimeUUID.
@Test
public void testCreateWithTimeUUID() {
EntityTypeParser.remove(EntityWithTimeUUID.class);
System.out.println(SchemaSync.getScript(keyspace, session, EntityWithTimeUUID.class));
SchemaSync.sync(keyspace, session, EntityWithTimeUUID.class);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithTimeUUID.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
assertNotNull(tableMetadata);
assertEquals("test_entity_timeuuid", tableMetadata.getName());
assertEquals(3, tableMetadata.getColumns().size());
ColumnMetadata columnMetadata = tableMetadata.getColumn("name");
assertNotNull(columnMetadata);
assertEquals(DataType.text(), columnMetadata.getType());
columnMetadata = tableMetadata.getColumn("convId");
assertNotNull(columnMetadata);
assertEquals(DataType.timeuuid(), columnMetadata.getType());
columnMetadata = tableMetadata.getColumn("msgId");
assertNotNull(columnMetadata);
assertEquals(DataType.timeuuid(), columnMetadata.getType());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDoNotAddColumn.
@Test
public void testDoNotAddColumn() {
SyncOptions opt = SyncOptions.withOptions().add(SyncOptionTypes.DoNotAddColumns);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexesV2.class, opt);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
// column counter2 should not be added
ColumnMetadata columnMetadata = tableMetadata.getColumn("counter2");
assertNull(columnMetadata);
// column counter should have been dropped
columnMetadata = tableMetadata.getColumn("counter");
assertNull(columnMetadata);
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDrop.
@Test
public void testDrop() {
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
assertNull(tableMetadata);
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method testDoNotDropColumn.
@Test
public void testDoNotDropColumn() {
SyncOptions opt = SyncOptions.withOptions().add(SyncOptionTypes.DoNotDropColumns);
SchemaSync.drop(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexes.class);
SchemaSync.sync(keyspace, session, EntityWithIndexesV2.class, opt);
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(EntityWithIndexes.class);
TableMetadata tableMetadata = cluster.getMetadata().getKeyspace(keyspace).getTable(entityMetadata.getTableName());
// column counter2 should not be added
ColumnMetadata columnMetadata = tableMetadata.getColumn("counter2");
assertNull(columnMetadata);
// column counter should have been dropped
columnMetadata = tableMetadata.getColumn("counter");
assertNotNull(columnMetadata);
}
Aggregations