@Test public void checkPreconditions() { assertThat(c1).isNotNull(); assertThat(c2).isNotNull(); assertThat(c3).isNotNull(); assertThat(c4).isNotNull(); assertThat(c5).isNotNull(); assertThat(c6).isNotNull(); }
@Test public void shouldProducePartitionMap() { partition = source.partition(REPLICA_SET_NAME); assertThat(partition.get(SourceInfo.REPLICA_SET_NAME)).isEqualTo(REPLICA_SET_NAME); assertThat(partition.get(SourceInfo.SERVER_ID_KEY)).isEqualTo("serverX"); assertThat(partition.size()).isEqualTo(2); }
@Test public void shouldMatchCommaSeparatedRegexIncludes() { Predicate<String> p = Predicates.includes("1.*5,30"); assertThat(p.test("30")).isTrue(); assertThat(p.test("1005")).isTrue(); assertThat(p.test("105")).isTrue(); assertThat(p.test("15")).isTrue(); assertThat(p.test("215")).isFalse(); assertThat(p.test("150")).isFalse(); assertThat(p.test("015")).isFalse(); assertThat(p.test("5")).isFalse(); }
@Test public void shouldReturnLocalDateTimeInstanceWhenConvertingLocalDateToLocalDateTime() { LocalDate now = LocalDate.now(); assertThat(Conversions.toLocalDateTime(now)).isEqualTo(LocalDateTime.of(now, LocalTime.MIDNIGHT)); }
@Test public void shouldMaskStringsWithSpecificValue() { String maskValue = "*-*-*-*-*"; mappers = ColumnMappers.build().maskStrings(fullyQualifiedNames, maskValue).build(); // exact case converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("12345678901234567890")).isEqualTo(maskValue); assertThat(converter.convert("12345678901")).isEqualTo(maskValue); assertThat(converter.convert("1234567890")).isEqualTo(maskValue); assertThat(converter.convert("123456789")).isEqualTo(maskValue); assertThat(converter.convert(null)).isEqualTo(maskValue); // null values are masked, too }
@Test public void shouldParseMultiAbsolutePath() { path = parse("/a/b/c/d/e"); assertThat(path.isRoot()).isFalse(); assertThat(path.isSingle()).isFalse(); assertThat(path.size()).isEqualTo(5); assertThat(path.segment(0)).isEqualTo("a"); assertThat(path.segment(1)).isEqualTo("b"); assertThat(path.segment(2)).isEqualTo("c"); assertThat(path.segment(3)).isEqualTo("d"); assertThat(path.segment(4)).isEqualTo("e"); }
@Test public void maxHandlesSameUnit() { Duration hundredMillis = Duration.ofMillis(100); Duration thousandMillis = Duration.ofMillis(1000); assertThat(Temporals.max(hundredMillis, thousandMillis)).isEqualTo(thousandMillis); }
@Test public void shouldRemoveDirectory() throws Exception { Path path = Paths.get(Testing.Files.dataDir(), "test-dir"); assertThat(path.toFile().mkdirs()).isTrue(); Path file = path.resolve("file.txt"); assertThat(file.toFile().createNewFile()).isTrue(); Testing.Files.delete(path); assertThat(java.nio.file.Files.exists(path)).isFalse(); } }
@Test public void checkPreconditions() { assertThat(c1).isNotNull(); assertThat(c2).isNotNull(); assertThat(c3).isNotNull(); assertThat(c4).isNotNull(); }
@Test public void shouldMaskStringsToFixedNumberOfSpecifiedCharacters() { char maskChar = '='; String maskValue = Strings.createString(maskChar, 10); mappers = ColumnMappers.build().maskStrings(fullyQualifiedNames, maskValue.length(), maskChar).build(); converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("12345678901234567890")).isEqualTo(maskValue); assertThat(converter.convert("12345678901")).isEqualTo(maskValue); assertThat(converter.convert("1234567890")).isEqualTo(maskValue); assertThat(converter.convert("123456789")).isEqualTo(maskValue); assertThat(converter.convert(null)).isEqualTo(maskValue); // null values are masked, too }
@Test public void shouldParseDoubleRelativePath() { path = parse("a/b"); assertThat(path.isRoot()).isFalse(); assertThat(path.isSingle()).isFalse(); assertThat(path.size()).isEqualTo(2); assertThat(path.segment(0)).isEqualTo("a"); assertThat(path.segment(1)).isEqualTo("b"); }
@Test public void shouldReturnLocalDateInstanceWhenConvertingLocalDateTimeToLocalDate() { LocalDateTime now = LocalDateTime.now(); assertThat(Conversions.toLocalDate(now)).isEqualTo(now.toLocalDate()); }
@Test public void shouldDetermineIfColumnIsGeneratedUsingColumnName() { assertThat(table.isGenerated("C1")).isTrue(); assertThat(table.isGenerated("C2")).isFalse(); assertThat(table.isGenerated("C3")).isFalse(); assertThat(table.isGenerated("C4")).isFalse(); assertThat(table.isGenerated("non-existant")).isFalse(); }
@Test public void shouldNotFindMatchingDataTypeIfInvalidOrIncomplete() { pattern = parser.parse(TYPE, "DECIMAL(3)"); assertThat(pattern).isNotNull(); type = pattern.match(text("DECIMAL(3")); assertThat(type).isNull(); }
@Test public void shouldMapValuesUsingFunctionByClassName() { mappers = ColumnMappers.build().map(fullyQualifiedNames, RepeatingColumnMapper.class.getName()).build(); converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("1234")).isEqualTo("12341234"); assertThat(converter.convert("a")).isEqualTo("aa"); assertThat(converter.convert(null)).isNull(); }
@Test public void shouldParseDoubleAbsolutePath() { path = parse("/a/b"); assertThat(path.isRoot()).isFalse(); assertThat(path.isSingle()).isFalse(); assertThat(path.size()).isEqualTo(2); assertThat(path.segment(0)).isEqualTo("a"); assertThat(path.segment(1)).isEqualTo("b"); }
@Test public void maxHandlesDifferentUnits() { Duration sixtyOneMinutes = Duration.ofMinutes(61); Duration oneHour = Duration.ofHours(1); assertThat(Temporals.max(sixtyOneMinutes, oneHour)).isEqualTo(sixtyOneMinutes); }
@Test public void shouldReturnFalseFromMatchIfAllTypeValuesDoNotMatch() { makeCaseInsensitive(); assertThat(tokens.matches(BasicTokenizer.WORD, BasicTokenizer.DECIMAL)).isFalse(); assertThat(tokens.matches(BasicTokenizer.DECIMAL, BasicTokenizer.WORD)).isFalse(); }
@Test public void shouldAlwaysFindRecordMakerForCollection() { for (int i = 0; i != 100; ++i) { CollectionId id = new CollectionId("rs0", "dbA", "c" + i); RecordsForCollection records = recordMakers.forCollection(id); assertThat(records).isNotNull(); assertThat(records.collectionId()).isSameAs(id); } }
@Test public void shouldMapValuesUsingColumnMapperInstance() { RepeatingColumnMapper mapper = new RepeatingColumnMapper(); mappers = ColumnMappers.build().map(fullyQualifiedNames, mapper).build(); converter = mappers.mappingConverterFor(tableId, column); assertThat(converter).isNotNull(); assertThat(converter.convert("1234")).isEqualTo("12341234"); assertThat(converter.convert("a")).isEqualTo("aa"); assertThat(converter.convert(null)).isNull(); }