|
13 | 13 | import static org.junit.jupiter.api.Assertions.*;
|
14 | 14 | import static org.mockito.ArgumentMatchers.anyString;
|
15 | 15 | import static org.mockito.ArgumentMatchers.eq;
|
16 |
| -import static org.mockito.Mockito.mock; |
17 |
| -import static org.mockito.Mockito.when; |
| 16 | +import static org.mockito.Mockito.*; |
18 | 17 |
|
19 | 18 | public class TTLAndWritetimeTest extends CommonMocks {
|
20 | 19 |
|
@@ -385,6 +384,7 @@ public void validateEmptyTTLColumn() {
|
385 | 384 |
|
386 | 385 | @Test
|
387 | 386 | public void validateInvalidCustomWritetimeColumn() {
|
| 387 | + when(propertyHelper.getLong(KnownProperties.TRANSFORM_CUSTOM_WRITETIME)).thenReturn(0L); |
388 | 388 | when(propertyHelper.getStringList(KnownProperties.ORIGIN_WRITETIME_NAMES)).thenReturn(Collections.singletonList("invalid"));
|
389 | 389 | when(originTable.indexOf("invalid")).thenReturn(-1);
|
390 | 390 | assertAll(
|
@@ -462,4 +462,24 @@ public void testZeroIncrementWithUnfrozenList() {
|
462 | 462 | assertTrue(feature.isEnabled());
|
463 | 463 | }
|
464 | 464 |
|
| 465 | + @Test |
| 466 | + public void customWriteTime_withAutoWritetime() { |
| 467 | + when(propertyHelper.getLong(KnownProperties.TRANSFORM_CUSTOM_WRITETIME)).thenReturn(12345L); |
| 468 | + when(propertyHelper.getStringList(KnownProperties.ORIGIN_WRITETIME_NAMES)).thenReturn(null); |
| 469 | + when(propertyHelper.getBoolean(KnownProperties.ORIGIN_WRITETIME_AUTO)).thenReturn(true); |
| 470 | + when(propertyHelper.getLong(KnownProperties.FILTER_WRITETS_MIN)).thenReturn(null); |
| 471 | + when(propertyHelper.getLong(KnownProperties.FILTER_WRITETS_MAX)).thenReturn(null); |
| 472 | + when(propertyHelper.getStringList(KnownProperties.ORIGIN_TTL_NAMES)).thenReturn(null); |
| 473 | + when(propertyHelper.getBoolean(KnownProperties.ORIGIN_TTL_AUTO)).thenReturn(false); |
| 474 | + |
| 475 | + feature.loadProperties(propertyHelper); |
| 476 | + feature.initializeAndValidate(originTable, targetTable); |
| 477 | + |
| 478 | + assertAll( |
| 479 | + () -> assertFalse(feature.hasWriteTimestampFilter(), "hasWriteTimestampFilter"), |
| 480 | + () -> assertTrue(feature.hasWritetimeColumns(), "hasWritetimeColumns") |
| 481 | + ); |
| 482 | + |
| 483 | + verify(originTable, times(0)).extendColumns(any(),any()); |
| 484 | + } |
465 | 485 | }
|
0 commit comments