DBZ-7811 Use invalid value logger, update tests
This commit is contained in:
parent
e356c0a06c
commit
65eb8d20d1
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user