DBZ-7811 Use invalid value logger, update tests

This commit is contained in:
twthorn 2024-04-24 14:03:16 -05:00 committed by Jiri Pechanec
parent e356c0a06c
commit 65eb8d20d1
2 changed files with 7 additions and 6 deletions

View File

@ -76,6 +76,7 @@
public abstract class BinlogValueConverters extends JdbcValueConverters {
private static final Logger LOGGER = LoggerFactory.getLogger(BinlogValueConverters.class);
private static final Logger INVALID_VALUE_LOGGER = LoggerFactory.getLogger(BinlogValueConverters.class.getName() + ".invalid_value");
/**
* Used to parse values of TIME columns. Format: 000:00:00.000000.
@ -901,7 +902,7 @@ public static LocalDate stringToLocalDate(String dateString, Column column, Tabl
final int day = Integer.parseInt(matcher.group(3));
if (month == 0 || day == 0) {
LOGGER.debug("Invalid value '{}' stored in column '{}' of table '{}' converted to empty value",
INVALID_VALUE_LOGGER.warn("Invalid value '{}' stored in column '{}' of table '{}' converted to empty value",
dateString, column.name(), table.id());
return null;
}
@ -928,7 +929,7 @@ public static boolean containsZeroValuesInDatePart(String timestampString, Colum
final int day = Integer.parseInt(matcher.group(3));
if (month == 0 || day == 0) {
LOGGER.debug("Invalid value '{}' stored in column '{}' of table '{}' converted to empty value",
INVALID_VALUE_LOGGER.warn("Invalid value '{}' stored in column '{}' of table '{}' converted to empty value",
timestampString, column.name(), table.id());
return true;
}

View File

@ -269,7 +269,7 @@ public void testZonedDateTimeWithMicrosecondPrecision() {
@Test
public void testInvalidLocalDate() {
LogInterceptor interceptor = new LogInterceptor(BinlogValueConverters.class);
LogInterceptor interceptorInvalid = new LogInterceptor(BinlogValueConverters.class.getName() + ".invalid_value");
String dateTable = "DATE_TABLE";
String sql = "CREATE TABLE " + dateTable + " (A DATE NOT NULL);";
@ -291,7 +291,7 @@ public void testInvalidLocalDate() {
LocalDate actual = BinlogValueConverters.stringToLocalDate("0000-00-00", colA, table);
assertThat(actual).isNull();
assertThat(interceptor.containsWarnMessage("Invalid value")).isFalse();
assertThat(interceptorInvalid.containsWarnMessage("Invalid value")).isTrue();
}
@Test
@ -320,7 +320,7 @@ public void testDateValidYear() {
@Test
public void testInvalidTimestamp() {
LogInterceptor interceptor = new LogInterceptor(BinlogValueConverters.class);
LogInterceptor interceptorInvalid = new LogInterceptor(BinlogValueConverters.class.getName() + ".invalid_value");
String dateTable = "TIMESTAMP_TABLE";
String sql = "CREATE TABLE " + dateTable + " (A TIMESTAMP(3) NOT NULL);";
@ -348,7 +348,7 @@ public void testInvalidTimestamp() {
Boolean actual = BinlogValueConverters.containsZeroValuesInDatePart(timestampString, colA, table);
assertThat(actual).isTrue();
assertThat(interceptor.containsWarnMessage("Invalid value")).isFalse();
assertThat(interceptorInvalid.containsWarnMessage("Invalid value")).isTrue();
}
@Test