public void should_allow_dynamic_schema_update_for_cluster_counter() throws Exception {
//Given
Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
UUID date = UUIDGen.getTimeUUID();
final Session session = CassandraEmbeddedServerBuilder
.withEntities(Arrays.<Class<?>>asList(CompleteBean.class))
.withKeyspaceName("schema_dynamic_update_counter")
.cleanDataFilesAtStartup(true)
.buildNativeSessionOnly();
session.execute("DROP TABLE IF EXISTS new_counter_field");
session.execute("CREATE TABLE new_counter_field(id bigint, date timeuuid, existing_counter counter, PRIMARY KEY(id,date))");
//When
final PersistenceManagerFactory pmf = PersistenceManagerFactoryBuilder.builder(session.getCluster())
.withEntities(Arrays.<Class<?>>asList(ClusteredCounterEntityWithNewCounterField.class))
.enableSchemaUpdate(true)
.build();
final PersistenceManager pm = pmf.createPersistenceManager();
pm.insert(new ClusteredCounterEntityWithNewCounterField(id, date, CounterBuilder.incr(12L)));
//Then
assertThat(pm.find(ClusteredCounterEntityWithNewCounterField.class, new ClusteredCounterEntityWithNewCounterField.Compound(id, date))).isNotNull();
session.close();
}