SessionWithInitializedTablesFactory implements Provider<Session> { @Override public Session get() { return session; } @Inject  SessionWithInitializedTablesFactory(KeyspaceConfiguration keyspaceConfiguration,
                                               Cluster cluster,
                                               CassandraModule module); @Override Session get(); @PreDestroy synchronized void destroy();  }
@Test void createSessionShouldSetTheLatestSchemaVersionWhenCreatingTypesAndTables() { assertThat(versionManager(testee.get()).computeVersion().block()) .isEqualTo(MAX_VERSION); }
@Test void createSessionShouldKeepTheSetSchemaVersionWhenTypesAndTablesHaveNotChanged() { Session session = testee.get(); assertThat(versionManager(session).computeVersion().block()) .isEqualTo(MAX_VERSION); new CassandraTableManager(MODULE, session).clearAllTables(); versionManagerDAO(session).updateVersion(MIN_VERSION); assertThat(versionManager(session).computeVersion().block()) .isEqualTo(MIN_VERSION); assertThat(versionManager(testee.get()).computeVersion().block()) .isEqualTo(MIN_VERSION); }
@Test void createSessionShouldKeepTheSetSchemaVersionWhenTypesAndTablesHavePartiallyChanged() { Session session = testee.get(); assertThat(versionManager(session).computeVersion().block()) .isEqualTo(MAX_VERSION); new CassandraTableManager(MODULE, session).clearAllTables(); versionManagerDAO(session).updateVersion(MIN_VERSION); assertThat(versionManager(session).computeVersion().block()) .isEqualTo(MIN_VERSION); session.execute(SchemaBuilder.dropTable(TABLE_NAME)); session.execute(SchemaBuilder.dropType(TYPE_NAME)); assertThat(versionManager(testee.get()).computeVersion().block()) .isEqualTo(MIN_VERSION); }