@@ -114,6 +114,8 @@ public void smokeTest_disabledFeature() {
114
114
when (propertyHelper .getStringList (KnownProperties .ORIGIN_TTL_NAMES )).thenReturn (null );
115
115
when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (null );
116
116
when (propertyHelper .getStringList (KnownProperties .ORIGIN_WRITETIME_NAMES )).thenReturn (null );
117
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_WRITETIME_AUTO )).thenReturn (Boolean .FALSE );
118
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_TTL_AUTO )).thenReturn (Boolean .FALSE );
117
119
118
120
assertAll (
119
121
() -> assertTrue (feature .loadProperties (propertyHelper ), "loadProperties" ),
@@ -126,6 +128,49 @@ public void smokeTest_disabledFeature() {
126
128
);
127
129
}
128
130
131
+
132
+ @ Test
133
+ public void smokeTest_enabledFeature_withOnlyWritetimeAuto () {
134
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MIN )).thenReturn (null );
135
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MAX )).thenReturn (null );
136
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_TTL_NAMES )).thenReturn (null );
137
+ when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (null );
138
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_WRITETIME_NAMES )).thenReturn (null );
139
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_WRITETIME_AUTO )).thenReturn (Boolean .TRUE );
140
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_TTL_AUTO )).thenReturn (Boolean .FALSE );
141
+
142
+ assertAll (
143
+ () -> assertTrue (feature .loadProperties (propertyHelper ), "loadProperties" ),
144
+ () -> assertTrue (feature .initializeAndValidate (originTable , targetTable ), "initializeAndValidate" ),
145
+ () -> assertTrue (feature .isEnabled (), "feature should be enabled" ),
146
+ () -> assertEquals (0L , feature .getCustomWritetime (), "customWritetime is not set" ),
147
+ () -> assertFalse (feature .hasWriteTimestampFilter (), "hasWriteTimestampFilter" ),
148
+ () -> assertTrue (feature .hasWritetimeColumns (), "hasWritetimeColumns with Auto set" ),
149
+ () -> assertFalse (feature .hasTTLColumns (), "hasTTLColumns" )
150
+ );
151
+ }
152
+
153
+ @ Test
154
+ public void smokeTest_enabledFeature_withOnlyTTLAuto () {
155
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MIN )).thenReturn (null );
156
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MAX )).thenReturn (null );
157
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_TTL_NAMES )).thenReturn (null );
158
+ when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (null );
159
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_WRITETIME_NAMES )).thenReturn (null );
160
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_WRITETIME_AUTO )).thenReturn (Boolean .FALSE );
161
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_TTL_AUTO )).thenReturn (Boolean .TRUE );
162
+
163
+ assertAll (
164
+ () -> assertTrue (feature .loadProperties (propertyHelper ), "loadProperties" ),
165
+ () -> assertTrue (feature .initializeAndValidate (originTable , targetTable ), "initializeAndValidate" ),
166
+ () -> assertTrue (feature .isEnabled (), "feature should be enabled" ),
167
+ () -> assertEquals (0L , feature .getCustomWritetime (), "customWritetime is not set" ),
168
+ () -> assertFalse (feature .hasWriteTimestampFilter (), "hasWriteTimestampFilter" ),
169
+ () -> assertFalse (feature .hasWritetimeColumns (), "hasWritetimeColumns" ),
170
+ () -> assertTrue (feature .hasTTLColumns (), "hasTTLColumns with ttlAuto set" )
171
+ );
172
+ }
173
+
129
174
@ Test
130
175
public void smoke_writetimeWithoutTTL () {
131
176
when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (0L );
@@ -250,7 +295,7 @@ public void counter_unconfigured() {
250
295
251
296
assertAll (
252
297
() -> assertFalse (feature .isEnabled (), "isEnabled" ),
253
- () -> assertTrue (feature .isValid , "isValid" )
298
+ () -> assertFalse (feature .isValid , "isValid" )
254
299
);
255
300
}
256
301
@@ -497,4 +542,52 @@ public void customWriteTime_withAutoWritetime() {
497
542
498
543
verify (originTable , times (0 )).extendColumns (any (),any ());
499
544
}
545
+
546
+ @ Test
547
+ public void specifiedColumnsOverrideAuto (){
548
+ when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (0L );
549
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_WRITETIME_NAMES )).thenReturn (Arrays .<String >asList ("writetime_ttl_col" ));
550
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_WRITETIME_AUTO )).thenReturn (true );
551
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MIN )).thenReturn (null );
552
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MAX )).thenReturn (null );
553
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_TTL_NAMES )).thenReturn (Arrays .<String >asList ("writetime_ttl_col" ));
554
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_TTL_AUTO )).thenReturn (true );
555
+
556
+ feature .loadProperties (propertyHelper );
557
+ feature .initializeAndValidate (originTable , targetTable );
558
+ assertAll (
559
+ () -> assertTrue (feature .hasTTLColumns (), "has TTL columns" ),
560
+ () -> assertTrue (feature .hasWritetimeColumns (), "has Writetime columns" ),
561
+ () -> assertEquals (1 , feature .getWritetimeNames ().size (), "has exactly 1 Writetime column" ),
562
+ () -> assertEquals (1 , feature .getTtlNames ().size (), "has exactly 1 TTL column" ),
563
+ () -> assertTrue (feature .isEnabled , "feature is enabled" )
564
+ );
565
+
566
+ //gets called once for adding TTL(..) columns and once for adding WRITETIME(..) columns
567
+ verify (originTable , times (2 )).extendColumns (any (),any ());
568
+ }
569
+
570
+ @ Test
571
+ public void autoFlagResultsInAllValueColumnsBeingUsed (){
572
+ when (propertyHelper .getLong (KnownProperties .TRANSFORM_CUSTOM_WRITETIME )).thenReturn (0L );
573
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_WRITETIME_NAMES )).thenReturn (null );
574
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_WRITETIME_AUTO )).thenReturn (true );
575
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MIN )).thenReturn (null );
576
+ when (propertyHelper .getLong (KnownProperties .FILTER_WRITETS_MAX )).thenReturn (null );
577
+ when (propertyHelper .getStringList (KnownProperties .ORIGIN_TTL_NAMES )).thenReturn (null );
578
+ when (propertyHelper .getBoolean (KnownProperties .ORIGIN_TTL_AUTO )).thenReturn (true );
579
+
580
+ feature .loadProperties (propertyHelper );
581
+ feature .initializeAndValidate (originTable , targetTable );
582
+ assertAll (
583
+ () -> assertTrue (feature .hasTTLColumns (), "has TTL columns" ),
584
+ () -> assertTrue (feature .hasWritetimeColumns (), "has Writetime columns" ),
585
+ () -> assertEquals (3 , feature .getWritetimeNames ().size (), "has exactly 1 Writetime column" ),
586
+ () -> assertEquals (3 , feature .getTtlNames ().size (), "has exactly 1 TTL column" ),
587
+ () -> assertTrue (feature .isEnabled , "feature is enabled" )
588
+ );
589
+
590
+ //gets called once for adding TTL(..) columns and once for adding WRITETIME(..) columns
591
+ verify (originTable , times (2 )).extendColumns (any (),any ());
592
+ }
500
593
}
0 commit comments