6
6
7
7
import static org .mockito .ArgumentMatchers .any ;
8
8
import static org .mockito .Mockito .when ;
9
-
9
+ import io . airbyte . api . client . generated . ConnectionApi ;
10
10
import io .airbyte .config .BasicSchedule ;
11
11
import io .airbyte .config .Cron ;
12
12
import io .airbyte .config .Schedule ;
@@ -55,6 +55,9 @@ class ConfigFetchActivityTest {
55
55
@ Mock
56
56
private Job mJob ;
57
57
58
+ @ Mock
59
+ private ConnectionApi mConnectionApi ;
60
+
58
61
private ConfigFetchActivityImpl configFetchActivity ;
59
62
60
63
private final static UUID connectionId = UUID .randomUUID ();
@@ -102,7 +105,7 @@ class ConfigFetchActivityTest {
102
105
void setup () {
103
106
configFetchActivity =
104
107
new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , mWorkspaceHelper , SYNC_JOB_MAX_ATTEMPTS ,
105
- () -> Instant .now ().getEpochSecond ());
108
+ () -> Instant .now ().getEpochSecond (), mConnectionApi );
106
109
}
107
110
108
111
@ Nested
@@ -170,7 +173,8 @@ void testDeleted() throws IOException, JsonValidationException, ConfigNotFoundEx
170
173
@ Test
171
174
@ DisplayName ("Test we will wait the required amount of time with legacy config" )
172
175
void testWait () throws IOException , JsonValidationException , ConfigNotFoundException {
173
- configFetchActivity = new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 3 );
176
+ configFetchActivity =
177
+ new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 3 , mConnectionApi );
174
178
175
179
when (mJob .getStartedAtInSecond ())
176
180
.thenReturn (Optional .of (60L ));
@@ -192,7 +196,8 @@ void testWait() throws IOException, JsonValidationException, ConfigNotFoundExcep
192
196
@ Test
193
197
@ DisplayName ("Test we will not wait if we are late in the legacy schedule schema" )
194
198
void testNotWaitIfLate () throws IOException , JsonValidationException , ConfigNotFoundException {
195
- configFetchActivity = new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 10 );
199
+ configFetchActivity =
200
+ new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 10 , mConnectionApi );
196
201
197
202
when (mJob .getStartedAtInSecond ())
198
203
.thenReturn (Optional .of (60L ));
@@ -247,7 +252,7 @@ void testBasicScheduleTypeFirstRun() throws IOException, JsonValidationException
247
252
@ Test
248
253
@ DisplayName ("Test that we will wait the required amount of time with a BASIC_SCHEDULE type on a subsequent run" )
249
254
void testBasicScheduleSubsequentRun () throws IOException , JsonValidationException , ConfigNotFoundException {
250
- configFetchActivity = new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 3 );
255
+ configFetchActivity = new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , SYNC_JOB_MAX_ATTEMPTS , () -> 60L * 3 , mConnectionApi );
251
256
252
257
when (mJob .getStartedAtInSecond ())
253
258
.thenReturn (Optional .of (60L ));
@@ -279,7 +284,7 @@ void testCronScheduleSubsequentRun() throws IOException, JsonValidationException
279
284
280
285
configFetchActivity =
281
286
new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , mWorkspaceHelper , SYNC_JOB_MAX_ATTEMPTS ,
282
- () -> mockRightNow .getTimeInMillis () / 1000L );
287
+ () -> mockRightNow .getTimeInMillis () / 1000L , mConnectionApi );
283
288
284
289
when (mJobPersistence .getLastReplicationJob (connectionId ))
285
290
.thenReturn (Optional .of (mJob ));
@@ -308,7 +313,7 @@ void testCronScheduleMinimumInterval() throws IOException, JsonValidationExcepti
308
313
309
314
configFetchActivity =
310
315
new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , mWorkspaceHelper , SYNC_JOB_MAX_ATTEMPTS ,
311
- () -> mockRightNow .getTimeInMillis () / 1000L );
316
+ () -> mockRightNow .getTimeInMillis () / 1000L , mConnectionApi );
312
317
313
318
when (mJob .getStartedAtInSecond ()).thenReturn (Optional .of (mockRightNow .getTimeInMillis () / 1000L ));
314
319
when (mJobPersistence .getLastReplicationJob (connectionId ))
@@ -338,7 +343,7 @@ void testCronSchedulingNoise() throws IOException, JsonValidationException, Conf
338
343
339
344
configFetchActivity =
340
345
new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , mWorkspaceHelper , SYNC_JOB_MAX_ATTEMPTS ,
341
- () -> mockRightNow .getTimeInMillis () / 1000L );
346
+ () -> mockRightNow .getTimeInMillis () / 1000L , mConnectionApi );
342
347
343
348
when (mJob .getStartedAtInSecond ()).thenReturn (Optional .of (mockRightNow .getTimeInMillis () / 1000L ));
344
349
when (mJobPersistence .getLastReplicationJob (connectionId ))
@@ -362,7 +367,8 @@ class TestGetMaxAttempt {
362
367
@ DisplayName ("Test that we are using to right service to get the maximum amount of attempt" )
363
368
void testGetMaxAttempt () {
364
369
final int maxAttempt = 15031990 ;
365
- configFetchActivity = new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , maxAttempt , () -> Instant .now ().getEpochSecond ());
370
+ configFetchActivity =
371
+ new ConfigFetchActivityImpl (mConfigRepository , mJobPersistence , maxAttempt , () -> Instant .now ().getEpochSecond (), mConnectionApi );
366
372
Assertions .assertThat (configFetchActivity .getMaxAttempt ().getMaxAttempt ())
367
373
.isEqualTo (maxAttempt );
368
374
}
0 commit comments