38
38
import io .airbyte .featureflag .FeatureFlagClient ;
39
39
import io .airbyte .featureflag .TestClient ;
40
40
import io .airbyte .mappers .application .RecordMapper ;
41
+ import io .airbyte .mappers .transformations .DestinationCatalogGenerator ;
41
42
import io .airbyte .persistence .job .models .ReplicationInput ;
42
43
import io .airbyte .protocol .models .AirbyteAnalyticsTraceMessage ;
43
44
import io .airbyte .protocol .models .AirbyteLogMessage ;
@@ -93,6 +94,7 @@ class ReplicationWorkerHelperTest {
93
94
private ReplicationAirbyteMessageEventPublishingHelper replicationAirbyteMessageEventPublishingHelper ;
94
95
private RecordMapper recordMapper ;
95
96
private FeatureFlagClient featureFlagClient ;
97
+ private DestinationCatalogGenerator destinationCatalogGenerator ;
96
98
97
99
private final ReplicationContext replicationContext = new ReplicationContext (true , UUID .randomUUID (), UUID .randomUUID (), UUID .randomUUID (), 0L ,
98
100
1 , UUID .randomUUID (), SOURCE_IMAGE , DESTINATION_IMAGE , UUID .randomUUID (), UUID .randomUUID ());
@@ -120,6 +122,7 @@ void setUp() {
120
122
recordMapper = mock (RecordMapper .class );
121
123
featureFlagClient = mock (TestClient .class );
122
124
when (featureFlagClient .boolVariation (eq (EnableMappers .INSTANCE ), any ())).thenReturn (false );
125
+ destinationCatalogGenerator = mock (DestinationCatalogGenerator .class );
123
126
replicationWorkerHelper = spy (new ReplicationWorkerHelper (
124
127
mock (FieldSelector .class ),
125
128
mapper ,
@@ -136,7 +139,8 @@ void setUp() {
136
139
streamStatusCompletionTracker ,
137
140
streamStatusTrackerFactory ,
138
141
recordMapper ,
139
- featureFlagClient ));
142
+ featureFlagClient ,
143
+ destinationCatalogGenerator ));
140
144
}
141
145
142
146
@ AfterEach
@@ -150,6 +154,8 @@ void testGetReplicationOutput(final boolean supportRefreshes) throws IOException
150
154
mockSupportRefreshes (supportRefreshes );
151
155
// Need to pass in a replication context
152
156
final ConfiguredAirbyteCatalog catalog = buildConfiguredAirbyteCatalog ();
157
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
158
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
153
159
replicationWorkerHelper .initialize (
154
160
replicationContext ,
155
161
mock (ReplicationFeatureFlags .class ),
@@ -177,11 +183,14 @@ void testGetReplicationOutput(final boolean supportRefreshes) throws IOException
177
183
void testAnalyticsMessageHandling () throws IOException {
178
184
mockSupportRefreshes (false );
179
185
// Need to pass in a replication context
186
+ final ConfiguredAirbyteCatalog catalog = mock (ConfiguredAirbyteCatalog .class );
187
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
188
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
180
189
replicationWorkerHelper .initialize (
181
190
replicationContext ,
182
191
mock (ReplicationFeatureFlags .class ),
183
192
mock (Path .class ),
184
- mock ( ConfiguredAirbyteCatalog . class ) ,
193
+ catalog ,
185
194
mock (State .class ));
186
195
// Need to have a configured catalog for getReplicationOutput
187
196
replicationWorkerHelper .startDestination (
@@ -242,12 +251,15 @@ void testMessageMapIsRevertedBeforeProcessing() {
242
251
@ Test
243
252
void callsStreamStatusTrackerOnSourceMessage () throws IOException {
244
253
mockSupportRefreshes (true );
254
+ final ConfiguredAirbyteCatalog catalog = mock (ConfiguredAirbyteCatalog .class );
255
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
256
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
245
257
246
258
replicationWorkerHelper .initialize (
247
259
replicationContext ,
248
260
mock (ReplicationFeatureFlags .class ),
249
261
mock (Path .class ),
250
- mock ( ConfiguredAirbyteCatalog . class ) ,
262
+ catalog ,
251
263
mock (State .class ));
252
264
253
265
final AirbyteMessage message = mock (AirbyteMessage .class );
@@ -260,12 +272,14 @@ void callsStreamStatusTrackerOnSourceMessage() throws IOException {
260
272
@ Test
261
273
void callsStreamStatusTrackerOnDestinationMessage () throws IOException {
262
274
mockSupportRefreshes (true );
263
-
275
+ final ConfiguredAirbyteCatalog catalog = mock (ConfiguredAirbyteCatalog .class );
276
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
277
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
264
278
replicationWorkerHelper .initialize (
265
279
replicationContext ,
266
280
mock (ReplicationFeatureFlags .class ),
267
281
mock (Path .class ),
268
- mock ( ConfiguredAirbyteCatalog . class ) ,
282
+ catalog ,
269
283
mock (State .class ));
270
284
271
285
final AirbyteMessage message = mock (AirbyteMessage .class );
@@ -282,6 +296,8 @@ void testSupportRefreshesIsPassed(final boolean supportRefreshes) throws Excepti
282
296
mockSupportRefreshes (supportRefreshes );
283
297
// Need to pass in a replication context
284
298
final ConfiguredAirbyteCatalog catalog = buildConfiguredAirbyteCatalog ();
299
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
300
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
285
301
replicationWorkerHelper .initialize (
286
302
replicationContext ,
287
303
mock (ReplicationFeatureFlags .class ),
@@ -303,12 +319,15 @@ void testSupportRefreshesIsPassed(final boolean supportRefreshes) throws Excepti
303
319
@ ValueSource (booleans = {true , false })
304
320
void testApplyTransformationFlagDisableOrNoMapper (final boolean mappersEnabled ) throws IOException {
305
321
mockSupportRefreshes (false );
322
+ ConfiguredAirbyteCatalog catalog = mock (ConfiguredAirbyteCatalog .class );
323
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
324
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
306
325
// Need to pass in a replication context
307
326
replicationWorkerHelper .initialize (
308
327
replicationContext ,
309
328
mock (ReplicationFeatureFlags .class ),
310
329
mock (Path .class ),
311
- mock ( ConfiguredAirbyteCatalog . class ) ,
330
+ catalog ,
312
331
mock (State .class ));
313
332
314
333
final AirbyteMessage recordMessage = new AirbyteMessage ().withType (Type .RECORD )
@@ -335,7 +354,8 @@ void testApplyTransformationMapper() throws IOException {
335
354
when (stream .getMappers ()).thenReturn (mappers );
336
355
when (catalog .getStreams ()).thenReturn (List .of (stream ));
337
356
when (featureFlagClient .boolVariation (EnableMappers .INSTANCE , new Connection (replicationContext .getConnectionId ()))).thenReturn (true );
338
-
357
+ when (destinationCatalogGenerator .generateDestinationCatalog (any (), any ()))
358
+ .thenReturn (new DestinationCatalogGenerator .CatalogGenerationResult (catalog , Map .of ()));
339
359
// Need to pass in a replication context
340
360
replicationWorkerHelper .initialize (
341
361
replicationContext ,
0 commit comments