This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new e0d4a1f  make SchedulerJobsTest preserve scheduler and job states 
(FINERACT-922)
     new f7f52f0  Merge pull request #852 from 
vorburger/FINERACT-922_SchedulerJobsTest-reset-world-as-found
e0d4a1f is described below

commit e0d4a1f376e241f0acd48db26b2557574ccd8422
Author: Michael Vorburger <[email protected]>
AuthorDate: Sat May 9 02:31:03 2020 +0200

    make SchedulerJobsTest preserve scheduler and job states (FINERACT-922)
---
 .../integrationtests/SchedulerJobsTest.java        | 23 ++++++++++++++++++++--
 .../common/SchedulerJobHelper.java                 |  6 +++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git 
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java
 
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java
index fd49a71..2118152 100644
--- 
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java
+++ 
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTest.java
@@ -27,10 +27,13 @@ import io.restassured.builder.RequestSpecBuilder;
 import io.restassured.http.ContentType;
 import io.restassured.specification.RequestSpecification;
 import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.fineract.infrastructure.jobs.service.JobName;
 import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
 import org.apache.fineract.integrationtests.common.Utils;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -39,6 +42,8 @@ public class SchedulerJobsTest {
 
     private RequestSpecification requestSpec;
     private SchedulerJobHelper schedulerJobHelper;
+    private Boolean originalSchedulerStatus;
+    private final Map<Integer, Boolean> originalJobStatus = new HashMap<>();
 
     @Before
     public void setup() {
@@ -47,6 +52,20 @@ public class SchedulerJobsTest {
         requestSpec.header("Authorization", "Basic " + 
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
         requestSpec.header("Fineract-Platform-TenantId", "default");
         schedulerJobHelper = new SchedulerJobHelper(requestSpec);
+        originalSchedulerStatus = schedulerJobHelper.getSchedulerStatus();
+        for (Integer jobId : schedulerJobHelper.getAllSchedulerJobIds()) {
+            Map<String, Object> schedulerJob = 
schedulerJobHelper.getSchedulerJobById(jobId);
+            Boolean active = (Boolean) schedulerJob.get("active");
+            originalJobStatus.put(jobId, active);
+        }
+    }
+
+    @After
+    public void tearDown() {
+        schedulerJobHelper.updateSchedulerStatus(originalSchedulerStatus);
+        for (int jobId = 1; jobId < JobName.values().length; jobId++) {
+            schedulerJobHelper.updateSchedulerJob(jobId, 
originalJobStatus.get(jobId));
+        }
     }
 
     @Test // FINERACT-926
@@ -54,7 +73,7 @@ public class SchedulerJobsTest {
         // must start scheduler and make job active to have nextRunTime (which 
is a
         // java.util.Date)
         schedulerJobHelper.updateSchedulerStatus(true);
-        schedulerJobHelper.updateSchedulerJob(1, "true");
+        schedulerJobHelper.updateSchedulerJob(1, true);
         String nextRunTimeText = await().until(
                 () -> (String) 
schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"),
                 nextRunTime -> nextRunTime != null);
@@ -93,7 +112,7 @@ public class SchedulerJobsTest {
             active = !active;
 
             // Updating Scheduler Job
-            Map<String, Object> changes = 
schedulerJobHelper.updateSchedulerJob(jobId, active.toString());
+            Map<String, Object> changes = 
schedulerJobHelper.updateSchedulerJob(jobId, active);
 
             // Verifying Scheduler Job updates
             assertEquals("Verifying Scheduler Job Updates", active, 
changes.get("active"));
diff --git 
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SchedulerJobHelper.java
 
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SchedulerJobHelper.java
index 027b15a..8382ca7 100644
--- 
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SchedulerJobHelper.java
+++ 
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SchedulerJobHelper.java
@@ -88,7 +88,7 @@ public class SchedulerJobHelper {
         Utils.performServerPost(requestSpec, response202Spec, 
UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null);
     }
 
-    public Map<String, Object> updateSchedulerJob(int jobId, final String 
active) {
+    public Map<String, Object> updateSchedulerJob(int jobId, final boolean 
active) {
         final String UPDATE_SCHEDULER_JOB_URL = 
"/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
         LOG.info("------------------------ UPDATING SCHEDULER JOB 
-------------------------");
         final Map<String, Object> response = 
Utils.performServerPut(requestSpec, response200Spec, UPDATE_SCHEDULER_JOB_URL,
@@ -96,9 +96,9 @@ public class SchedulerJobHelper {
         return response;
     }
 
-    private static String updateSchedulerJobAsJSON(final String active) {
+    private static String updateSchedulerJobAsJSON(final boolean active) {
         final Map<String, String> map = new HashMap<>();
-        map.put("active", active);
+        map.put("active", Boolean.toString(active));
         LOG.info("map :  {}" , map);
         return new Gson().toJson(map);
     }

Reply via email to