public void unquoteIdentifierPartShouldReturnNullForNull() { assertThat(Strings.unquoteIdentifierPart(null)).isNull(); }
protected void assertVariable(String name, String expectedValue) { String actualValue = parser.systemVariables().getVariable(name); if (expectedValue == null) { assertThat(actualValue).isNull(); } else { assertThat(actualValue).isEqualToIgnoringCase(expectedValue); } }
@FixFor("DBZ-107") @Test public void shouldNotSetNullGtidSet() { source.setCompletedGtidSet(null); assertThat(source.gtidSet()).isNull(); }
@FixFor("DBZ-107") @Test public void shouldNotSetBlankGtidSet() { source.setCompletedGtidSet(""); assertThat(source.gtidSet()).isNull(); }
protected void assertVariable(SystemVariables.Scope scope, String name, String expectedValue) { String actualValue = parser.systemVariables().getVariable(name, scope); if (expectedValue == null) { assertThat(actualValue).isNull(); } else { assertThat(actualValue).isEqualToIgnoringCase(expectedValue); } }
@Test public void shouldRecoverSourceInfoFromOffsetWithFilterData() { final String databaseWhitelist = "a,b"; final String tableWhitelist = "c.foo,d.bar,d.baz"; Map<String, String> offset = offset(10, 10); offset.put(SourceInfo.DATABASE_WHITELIST_KEY, databaseWhitelist); offset.put(SourceInfo.TABLE_WHITELIST_KEY, tableWhitelist); sourceWith(offset); assertThat(source.hasFilterInfo()).isTrue(); assertEquals(databaseWhitelist, source.getDatabaseWhitelist()); assertEquals(tableWhitelist, source.getTableWhitelist()); // confirm other filter info is null assertThat(source.getDatabaseBlacklist()).isNull(); assertThat(source.getTableBlacklist()).isNull(); }
@Test public void shouldParseHostStringWithStandaloneAddress() { sets = ReplicaSets.parse("localhost:27017"); assertThat(sets.replicaSetCount()).isEqualTo(1); assertThat(sets.hosts()).isEqualTo("localhost:27017"); rs = sets.all().get(0); assertThat(rs.hasReplicaSetName()).isFalse(); assertThat(rs.isStandaloneServer()).isTrue(); assertThat(rs.replicaSetName()).isNull(); assertThat(rs.shardName()).isNull(); ServerAddress expected = new ServerAddress("localhost", 27017); assertThat(rs.addresses().size()).isEqualTo(1); assertThat(rs.addresses()).containsOnly(expected); }
@Test public void shouldCreateColumnWithAllFieldsSetToDefaults() { Column column = editor.create(); assertThat(column.name()).isNull(); assertThat(column.typeName()).isNull(); assertThat(column.jdbcType()).isEqualTo(Types.INTEGER); assertThat(column.length()).isEqualTo(-1); Assert.assertFalse(column.scale().isPresent()); assertThat(column.position()).isEqualTo(1); assertThat(column.isOptional()).isTrue(); assertThat(column.isAutoIncremented()).isFalse(); assertThat(column.isGenerated()).isFalse(); }
@Test public void shouldParseHostStringWithAddressForOneReplicaSet() { sets = ReplicaSets.parse("myReplicaSet/localhost:27017"); assertThat(sets.replicaSetCount()).isEqualTo(1); assertThat(sets.hosts()).isEqualTo("myReplicaSet/localhost:27017"); rs = sets.all().get(0); assertThat(rs.hasReplicaSetName()).isTrue(); assertThat(rs.isStandaloneServer()).isFalse(); assertThat(rs.replicaSetName()).isEqualTo("myReplicaSet"); assertThat(rs.shardName()).isNull(); ServerAddress expected = new ServerAddress("localhost", 27017); assertThat(rs.addresses().size()).isEqualTo(1); assertThat(rs.addresses()).containsOnly(expected); }
@Test public void shouldParseHostStringWithIpv6AddressForOneReplicaSet() { sets = ReplicaSets.parse("myReplicaSet/[fe80::601:9bff:feab:ec01]:27017"); assertThat(sets.replicaSetCount()).isEqualTo(1); assertThat(sets.hosts()).isEqualTo("myReplicaSet/[fe80::601:9bff:feab:ec01]:27017"); rs = sets.all().get(0); assertThat(rs.hasReplicaSetName()).isTrue(); assertThat(rs.isStandaloneServer()).isFalse(); assertThat(rs.replicaSetName()).isEqualTo("myReplicaSet"); assertThat(rs.shardName()).isNull(); ServerAddress expected = new ServerAddress("[fe80::601:9bff:feab:ec01]", 27017); assertThat(rs.addresses().size()).isEqualTo(1); assertThat(rs.addresses()).containsOnly(expected); }
@Test public void shouldRecoverSourceInfoFromOffsetWithZeroBinlogCoordinatesAndSnapshot() { sourceWith(offset(0, 0, true)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(0); assertThat(source.rowsToSkipUponRestart()).isEqualTo(0); assertThat(source.isSnapshotInEffect()).isTrue(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithNonZeroBinlogCoordinates() { sourceWith(offset(100, 0)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(100); assertThat(source.rowsToSkipUponRestart()).isEqualTo(0); assertThat(source.isSnapshotInEffect()).isFalse(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithNonZeroBinlogCoordinatesAndNonZeroRowAndSnapshot() { sourceWith(offset(100, 5, true)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(100); assertThat(source.rowsToSkipUponRestart()).isEqualTo(5); assertThat(source.isSnapshotInEffect()).isTrue(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithZeroBinlogCoordinates() { sourceWith(offset(0, 0)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(0); assertThat(source.rowsToSkipUponRestart()).isEqualTo(0); assertThat(source.isSnapshotInEffect()).isFalse(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithZeroBinlogCoordinatesAndNonZeroRow() { sourceWith(offset(0, 5)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(0); assertThat(source.rowsToSkipUponRestart()).isEqualTo(5); assertThat(source.isSnapshotInEffect()).isFalse(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithZeroBinlogCoordinatesAndNonZeroRowAndSnapshot() { sourceWith(offset(0, 5, true)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(0); assertThat(source.rowsToSkipUponRestart()).isEqualTo(5); assertThat(source.isSnapshotInEffect()).isTrue(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithNonZeroBinlogCoordinatesAndNonZeroRow() { sourceWith(offset(100, 5)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(100); assertThat(source.rowsToSkipUponRestart()).isEqualTo(5); assertThat(source.isSnapshotInEffect()).isFalse(); }
@Test public void shouldRecoverSourceInfoFromOffsetWithNonZeroBinlogCoordinatesAndSnapshot() { sourceWith(offset(100, 0, true)); assertThat(source.gtidSet()).isNull(); assertThat(source.binlogFilename()).isEqualTo(FILENAME); assertThat(source.binlogPosition()).isEqualTo(100); assertThat(source.rowsToSkipUponRestart()).isEqualTo(0); assertThat(source.isSnapshotInEffect()).isTrue(); }
@Test public void shouldBuildWithSimpleOptionalTypesForBeforeAndAfter() { Envelope env = Envelope.defineSchema() .withName("someName") .withRecord(Schema.OPTIONAL_STRING_SCHEMA) .withSource(Schema.OPTIONAL_INT64_SCHEMA) .build(); assertThat(env.schema()).isNotNull(); assertThat(env.schema().name()).isEqualTo("someName"); assertThat(env.schema().doc()).isNull(); assertThat(env.schema().version()).isNull(); assertOptionalField(env, Envelope.FieldName.AFTER, Schema.OPTIONAL_STRING_SCHEMA); assertOptionalField(env, Envelope.FieldName.BEFORE, Schema.OPTIONAL_STRING_SCHEMA); assertOptionalField(env, Envelope.FieldName.SOURCE, Schema.OPTIONAL_INT64_SCHEMA); assertRequiredField(env, Envelope.FieldName.OPERATION, Schema.STRING_SCHEMA); }