Pause Upon VF Module Failure
[vid.git] / vid-app-common / src / test / java / org / onap / vid / services / JobsBrokerServiceTest.java
index 20c9d14..df8f503 100644 (file)
@@ -103,6 +103,7 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
+import org.togglz.core.manager.FeatureManager;
 
 @ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, JobAdapterConfig.class})
 public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
@@ -115,7 +116,8 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
 
     private final Set<Long> threadsIds = new ConcurrentSkipListSet<>();
 
-    private final long FEW = 500;
+    private final long FEW = 1000;
+    private final long SOME = 2000;
 
     private final String JOBS_SHOULD_MATCH = "the jobs that added and those that pulled must be the same";
     private final String JOBS_PEEKED_SHOULD_MATCH = "the jobs that added and those that peeked must be the same";
@@ -123,6 +125,9 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
     private static final String DELETE_SERVICE_NOT_EXIST_EXCEPTION_MESSAGE = "Service does not exist";
     private JobsBrokerService broker;
 
+    @Mock
+    private FeatureManager featureManager;
+
     @Inject
     JobAdapter jobAdapter;
     @Inject
@@ -143,7 +148,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
     public void initializeBroker() {
         MockitoAnnotations.initMocks(this);
         when(versionService.retrieveBuildNumber()).thenReturn("aBuildNumber");
-        broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0, versionService);
+        broker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, 200, 0, versionService, featureManager);
         ((JobsBrokerServiceInDatabaseImpl) broker).deleteAll();
     }
 
@@ -219,7 +224,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
 
     private Job waitForFutureOptionalJob(Future<Optional<Job>> retrievedOptionalJobFuture) {
         try {
-            return retrievedOptionalJobFuture.get(FEW, MILLISECONDS).orElseThrow(NoJobException::new);
+            return retrievedOptionalJobFuture.get(SOME, MILLISECONDS).orElseThrow(NoJobException::new);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             throw new RuntimeException(e);
         }
@@ -227,7 +232,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
 
     private Job waitForFutureJob(Future<Job> retrievedJobFuture) {
         try {
-            return retrievedJobFuture.get(FEW, MILLISECONDS);
+            return retrievedJobFuture.get(SOME, MILLISECONDS);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             throw new RuntimeException(e);
         }
@@ -343,7 +348,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
     }
 
     @Test
-    public void givenManyJobs_getThemAllThenPushBackandGet_verifySameJobs() {
+    public void givenManyJobs_getThemAllThenPushBackAndGet_verifySameJobs() {
         final List<Job> retrievedJobs1 = putAndGetALotOfJobs(broker);
 
         pushBackJobs(retrievedJobs1, broker);
@@ -606,7 +611,7 @@ public class JobsBrokerServiceTest extends AbstractTestNGSpringContextTests {
 
     @Test(dataProvider = "jobs")
     public void givenSomeJobs_pullNextJob_returnNextOrNothingAsExpected(List<Jobber> jobbers, int msoLimit, int expectedIndexSelected, Job.JobStatus topic, String assertionReason) {
-        JobsBrokerServiceInDatabaseImpl aBroker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20, versionService);
+        JobsBrokerServiceInDatabaseImpl aBroker = new JobsBrokerServiceInDatabaseImpl(dataAccessService, sessionFactory, msoLimit, 20, versionService, featureManager);
         final List<JobDaoImpl> jobs = addJobsWithModifiedDate(jobbers, aBroker);
         Optional<Job> nextJob = aBroker.pull(topic, UUID.randomUUID().toString());
         boolean shouldAnyBeSelected = expectedIndexSelected >= 0;