25
25
import java .util .concurrent .locks .Condition ;
26
26
import java .util .concurrent .locks .Lock ;
27
27
import javax .persistence .EntityNotFoundException ;
28
+
29
+ import gov .cms .ab2d .worker .service .coveragesnapshot .CoverageSnapshotService ;
28
30
import org .jetbrains .annotations .NotNull ;
29
31
import org .junit .jupiter .api .AfterEach ;
30
32
import org .junit .jupiter .api .BeforeEach ;
33
35
import org .junit .jupiter .api .extension .ExtendWith ;
34
36
import org .mockito .Mock ;
35
37
import org .mockito .junit .jupiter .MockitoExtension ;
38
+ import org .springframework .beans .factory .annotation .Autowired ;
36
39
import org .springframework .test .util .ReflectionTestUtils ;
37
40
38
41
@@ -71,6 +74,9 @@ class CoverageDriverUnitTest {
71
74
72
75
private PropertiesService propertiesService = new PropertyServiceStub ();
73
76
77
+ @ Autowired
78
+ private CoverageSnapshotService snapshotService ;
79
+
74
80
@ Mock
75
81
private ContractToContractCoverageMapping mapping ;
76
82
@@ -144,7 +150,7 @@ public Condition newCondition() {
144
150
145
151
@ BeforeEach
146
152
void before () {
147
- driver = new CoverageDriverImpl (null , null , coverageService , null , null , null ,mapping );
153
+ driver = new CoverageDriverImpl (null , null , coverageService , null , null , null ,mapping , snapshotService );
148
154
}
149
155
150
156
@ AfterEach
@@ -298,7 +304,7 @@ void failureToLockCausesExceptions() {
298
304
299
305
when (lockWrapper .getCoverageLock ()).thenReturn (tryLockFalse );
300
306
301
- CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , propertiesService , null , lockWrapper ,null );
307
+ CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , propertiesService , null , lockWrapper ,null , snapshotService );
302
308
303
309
CoverageDriverException exception = assertThrows (CoverageDriverException .class , driver ::discoverCoveragePeriods );
304
310
assertTrue (exception .getMessage ().contains ("could not retrieve lock" ));
@@ -318,7 +324,7 @@ void whenLockInterruptedPropagateException() {
318
324
Job job = new Job ();
319
325
job .setContractNumber (contract .getContractNumber ());
320
326
321
- CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , propertiesService , null , lockWrapper ,null );
327
+ CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , propertiesService , null , lockWrapper ,null , snapshotService );
322
328
323
329
assertThrows (InterruptedException .class , driver ::discoverCoveragePeriods );
324
330
assertThrows (InterruptedException .class , driver ::queueStaleCoveragePeriods );
@@ -333,7 +339,7 @@ void failureToLockCoverageAvailableFailsQuietly() {
333
339
when (coverageService .coveragePeriodStuckJobs (any ())).thenReturn (Collections .emptyList ());
334
340
when (coverageService .coveragePeriodNotUpdatedSince (anyInt (), anyInt (), any ())).thenReturn (Collections .emptyList ());
335
341
336
- CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , null , null , lockWrapper ,null );
342
+ CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , null , null , lockWrapper ,null , snapshotService );
337
343
338
344
ContractDTO contract = new ContractDTO (null , "contractNum" , null , null , null );
339
345
Job job = new Job ();
@@ -351,7 +357,7 @@ void failureToLockCoverageAvailableFailsQuietly() {
351
357
void failureToPageCausesExceptions () {
352
358
when (coverageService .pageCoverage (any ())).thenThrow (RuntimeException .class );
353
359
354
- CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , null , null , null ,null );
360
+ CoverageDriver driver = new CoverageDriverImpl (null , null , coverageService , null , null , null ,null , snapshotService );
355
361
356
362
ContractForCoverageDTO contract = new ContractForCoverageDTO ();
357
363
contract .setContractNumber ("contractNum" );
@@ -364,7 +370,7 @@ void failureToPageCausesExceptions() {
364
370
@ Test
365
371
void loadMappingFailsQuietly () {
366
372
CoverageDriverImpl driver = spy (new CoverageDriverImpl (null , null ,
367
- coverageService , propertiesService , coverageProcessor , lockWrapper ,null )
373
+ coverageService , propertiesService , coverageProcessor , lockWrapper ,null , snapshotService )
368
374
);
369
375
370
376
propertiesService .updateProperty (MAINTENANCE_MODE , "true" );
0 commit comments