25
25
import io .airbyte .api .model .generated .JobRead ;
26
26
import io .airbyte .api .model .generated .JobWithAttemptsRead ;
27
27
import io .airbyte .api .model .generated .LogRead ;
28
+ import io .airbyte .api .model .generated .ResetConfig ;
28
29
import io .airbyte .api .model .generated .SourceDefinitionRead ;
30
+ import io .airbyte .api .model .generated .StreamDescriptor ;
29
31
import io .airbyte .commons .enums .Enums ;
30
32
import io .airbyte .commons .version .AirbyteVersion ;
31
33
import io .airbyte .config .Configs .WorkerEnvironment ;
32
34
import io .airbyte .config .FailureReason ;
33
35
import io .airbyte .config .FailureReason .FailureOrigin ;
34
36
import io .airbyte .config .FailureReason .FailureType ;
35
- import io .airbyte .config .JobCheckConnectionConfig ;
36
37
import io .airbyte .config .JobConfig ;
38
+ import io .airbyte .config .JobConfig .ConfigType ;
37
39
import io .airbyte .config .JobOutput ;
38
40
import io .airbyte .config .JobOutput .OutputType ;
41
+ import io .airbyte .config .JobResetConnectionConfig ;
42
+ import io .airbyte .config .JobSyncConfig ;
43
+ import io .airbyte .config .ResetSourceConfiguration ;
39
44
import io .airbyte .config .StandardSyncOutput ;
40
45
import io .airbyte .config .StandardSyncSummary ;
41
46
import io .airbyte .config .StreamSyncStats ;
42
47
import io .airbyte .config .SyncStats ;
43
48
import io .airbyte .config .helpers .LogConfigs ;
49
+ import io .airbyte .protocol .models .AirbyteStream ;
50
+ import io .airbyte .protocol .models .ConfiguredAirbyteCatalog ;
51
+ import io .airbyte .protocol .models .ConfiguredAirbyteStream ;
44
52
import io .airbyte .scheduler .models .Attempt ;
45
53
import io .airbyte .scheduler .models .AttemptStatus ;
46
54
import io .airbyte .scheduler .models .Job ;
47
55
import io .airbyte .scheduler .models .JobStatus ;
48
56
import java .nio .file .Path ;
49
57
import java .util .ArrayList ;
58
+ import java .util .Collections ;
59
+ import java .util .List ;
50
60
import java .util .Optional ;
51
61
import java .util .UUID ;
52
62
import java .util .stream .Collectors ;
@@ -60,10 +70,7 @@ class JobConverterTest {
60
70
private static final String JOB_CONFIG_ID = "123" ;
61
71
private static final JobStatus JOB_STATUS = JobStatus .RUNNING ;
62
72
private static final AttemptStatus ATTEMPT_STATUS = AttemptStatus .RUNNING ;
63
- private static final JobConfig .ConfigType CONFIG_TYPE = JobConfig .ConfigType .CHECK_CONNECTION_SOURCE ;
64
- private static final JobConfig JOB_CONFIG = new JobConfig ()
65
- .withConfigType (CONFIG_TYPE )
66
- .withCheckConnection (new JobCheckConnectionConfig ());
73
+ private static final JobConfig .ConfigType CONFIG_TYPE = ConfigType .SYNC ;
67
74
private static final Path LOG_PATH = Path .of ("log_path" );
68
75
private static final long CREATED_AT = System .currentTimeMillis () / 1000 ;
69
76
private static final long RECORDS_EMITTED = 15L ;
@@ -76,6 +83,12 @@ class JobConverterTest {
76
83
private static final String FAILURE_STACKTRACE = "stacktrace" ;
77
84
private static final boolean PARTIAL_SUCCESS = false ;
78
85
86
+ private static final JobConfig JOB_CONFIG = new JobConfig ()
87
+ .withConfigType (CONFIG_TYPE )
88
+ .withSync (new JobSyncConfig ().withConfiguredAirbyteCatalog (new ConfiguredAirbyteCatalog ().withStreams (List .of (
89
+ new ConfiguredAirbyteStream ().withStream (new AirbyteStream ().withName ("users" )),
90
+ new ConfiguredAirbyteStream ().withStream (new AirbyteStream ().withName ("accounts" ))))));
91
+
79
92
private static final JobOutput JOB_OUTPUT = new JobOutput ()
80
93
.withOutputType (OutputType .SYNC )
81
94
.withSync (new StandardSyncOutput ()
@@ -104,7 +117,7 @@ class JobConverterTest {
104
117
.id (JOB_ID )
105
118
.configId (JOB_CONFIG_ID )
106
119
.status (io .airbyte .api .model .generated .JobStatus .RUNNING )
107
- .configType (JobConfigType .CHECK_CONNECTION_SOURCE )
120
+ .configType (JobConfigType .SYNC )
108
121
.createdAt (CREATED_AT )
109
122
.updatedAt (CREATED_AT ))
110
123
.attempts (Lists .newArrayList (new AttemptInfoRead ()
@@ -149,7 +162,7 @@ class JobConverterTest {
149
162
.id (JOB_ID )
150
163
.configId (JOB_CONFIG_ID )
151
164
.status (io .airbyte .api .model .generated .JobStatus .RUNNING )
152
- .configType (JobConfigType .CHECK_CONNECTION_SOURCE )
165
+ .configType (JobConfigType .SYNC )
153
166
.airbyteVersion (airbyteVersion .serialize ())
154
167
.sourceDefinition (sourceDefinitionRead )
155
168
.destinationDefinition (destinationDefinitionRead );
@@ -192,31 +205,56 @@ public void setUp() {
192
205
}
193
206
194
207
@ Test
195
- public void testGetJobInfoRead () {
208
+ void testGetJobInfoRead () {
196
209
assertEquals (JOB_INFO , jobConverter .getJobInfoRead (job ));
197
210
}
198
211
199
212
@ Test
200
- public void testGetDebugJobInfoRead () {
201
- assertEquals (JOB_DEBUG_INFO , jobConverter .getDebugJobInfoRead (JOB_INFO , sourceDefinitionRead , destinationDefinitionRead , airbyteVersion ));
213
+ void testGetDebugJobInfoRead () {
214
+ assertEquals (JOB_DEBUG_INFO , JobConverter .getDebugJobInfoRead (JOB_INFO , sourceDefinitionRead , destinationDefinitionRead , airbyteVersion ));
202
215
}
203
216
204
217
@ Test
205
- public void testGetJobWithAttemptsRead () {
206
- assertEquals (JOB_WITH_ATTEMPTS_READ , jobConverter .getJobWithAttemptsRead (job ));
218
+ void testGetJobWithAttemptsRead () {
219
+ assertEquals (JOB_WITH_ATTEMPTS_READ , JobConverter .getJobWithAttemptsRead (job ));
207
220
}
208
221
209
222
@ Test
210
- public void testGetJobRead () {
211
- final JobWithAttemptsRead jobReadActual = jobConverter .getJobWithAttemptsRead (job );
223
+ void testGetJobRead () {
224
+ final JobWithAttemptsRead jobReadActual = JobConverter .getJobWithAttemptsRead (job );
212
225
assertEquals (JOB_WITH_ATTEMPTS_READ , jobReadActual );
213
226
}
214
227
215
228
@ Test
216
- public void testEnumConversion () {
229
+ void testEnumConversion () {
217
230
assertTrue (Enums .isCompatible (JobConfig .ConfigType .class , JobConfigType .class ));
218
231
assertTrue (Enums .isCompatible (JobStatus .class , io .airbyte .api .model .generated .JobStatus .class ));
219
232
assertTrue (Enums .isCompatible (AttemptStatus .class , io .airbyte .api .model .generated .AttemptStatus .class ));
220
233
}
221
234
235
+ // this test intentionally only looks at the reset config as the rest is the same here.
236
+ @ Test
237
+ void testResetJobIncludesResetConfig () {
238
+ final JobConfig resetConfig = new JobConfig ()
239
+ .withConfigType (ConfigType .RESET_CONNECTION )
240
+ .withResetConnection (new JobResetConnectionConfig ().withResetSourceConfiguration (new ResetSourceConfiguration ().withStreamsToReset (List .of (
241
+ new io .airbyte .config .StreamDescriptor ().withName ("users" ),
242
+ new io .airbyte .config .StreamDescriptor ().withName ("accounts" )))));
243
+ final Job resetJob = new Job (
244
+ JOB_ID ,
245
+ ConfigType .RESET_CONNECTION ,
246
+ JOB_CONFIG_ID ,
247
+ resetConfig ,
248
+ Collections .emptyList (),
249
+ JobStatus .SUCCEEDED ,
250
+ CREATED_AT ,
251
+ CREATED_AT ,
252
+ CREATED_AT );
253
+
254
+ final ResetConfig expectedResetConfig = new ResetConfig ().streamsToReset (List .of (
255
+ new StreamDescriptor ().name ("users" ),
256
+ new StreamDescriptor ().name ("accounts" )));
257
+ assertEquals (expectedResetConfig , jobConverter .getJobInfoRead (resetJob ).getJob ().getResetConfig ());
258
+ }
259
+
222
260
}
0 commit comments