CassandraSchemaVersionManager { public Mono<Boolean> isBefore(SchemaVersion minimum) { if (initialSchemaVersion.isBefore(minimum)) { return computeVersion() .map(computedVersion -> computedVersion.isBefore(minimum)); } return Mono.just(false); } @Inject  CassandraSchemaVersionManager(CassandraSchemaVersionDAO schemaVersionDAO); @VisibleForTesting  CassandraSchemaVersionManager(CassandraSchemaVersionDAO schemaVersionDAO, SchemaVersion minVersion, SchemaVersion maxVersion); Mono<Boolean> isBefore(SchemaVersion minimum); Mono<SchemaVersion> computeVersion(); SchemaVersion getMinimumSupportedVersion(); SchemaVersion getMaximumSupportedVersion(); SchemaState computeSchemaState(); static final SchemaVersion MIN_VERSION; static final SchemaVersion MAX_VERSION; static final SchemaVersion DEFAULT_VERSION; }
@Test void isBeforeShouldReturnTrueWhenBefore() { SchemaVersion currentVersion = minVersion; when(schemaVersionDAO.getCurrentSchemaVersion()) .thenReturn(Mono.just(Optional.of(currentVersion))); CassandraSchemaVersionManager testee = new CassandraSchemaVersionManager( schemaVersionDAO, minVersion, maxVersion); assertThat(testee.isBefore(maxVersion).block()).isTrue(); }
@Test void isBeforeShouldReturnFalseWhenEquals() { SchemaVersion currentVersion = maxVersion; when(schemaVersionDAO.getCurrentSchemaVersion()) .thenReturn(Mono.just(Optional.of(currentVersion))); CassandraSchemaVersionManager testee = new CassandraSchemaVersionManager( schemaVersionDAO, minVersion, maxVersion); assertThat(testee.isBefore(maxVersion).block()).isFalse(); }
@Test void isBeforeShouldReturnFalseWhenUpdatedToEquals() { SchemaVersion currentVersion = maxVersion; when(schemaVersionDAO.getCurrentSchemaVersion()) .thenReturn(Mono.just(Optional.of(minVersion))); CassandraSchemaVersionManager testee = new CassandraSchemaVersionManager( schemaVersionDAO, minVersion, maxVersion); when(schemaVersionDAO.getCurrentSchemaVersion()) .thenReturn(Mono.just(Optional.of(maxVersion))); assertThat(testee.isBefore(maxVersion).block()).isFalse(); }