[MIFOSX-1047] Fixed failure Test Cases and updated Scheduler Job Test Cases
This commit is contained in:
+15
-2
@@ -34,7 +34,7 @@ public class SchedulerJobsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchedulerJobs() {
|
||||
public void testSchedulerJobs() throws InterruptedException {
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// Retrieving Status of Scheduler
|
||||
@@ -80,11 +80,24 @@ public class SchedulerJobsTest {
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
|
||||
// Retrieving Scheduler Job by ID
|
||||
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
|
||||
// Waiting for Job to complete
|
||||
while ((Boolean) schedulerJob.get("currentlyRunning") == true) {
|
||||
Thread.sleep(120000);
|
||||
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
System.out.println("Job is Still Running");
|
||||
}
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(((jobHistoryData.size()) - 1)).get("status"));
|
||||
jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+107
-24
@@ -96,8 +96,6 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Retrieving Scheduler Job by ID
|
||||
HashMap schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
@@ -111,9 +109,11 @@ public class SchedulerJobsTestResults {
|
||||
System.out.println("Job is Still Running");
|
||||
}
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(((jobHistoryData.size()) - 1)).get("status"));
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId);
|
||||
|
||||
Float chargeAmount = (Float) chargeData.get("amount");
|
||||
@@ -158,8 +158,6 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Retrieving Scheduler Job by ID
|
||||
HashMap schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
@@ -173,9 +171,11 @@ public class SchedulerJobsTestResults {
|
||||
System.out.println("Job is Still Running");
|
||||
}
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(((jobHistoryData.size()) - 1)).get("status"));
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
|
||||
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
@@ -242,8 +242,6 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Retrieving Scheduler Job by ID
|
||||
HashMap schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
@@ -257,9 +255,11 @@ public class SchedulerJobsTestResults {
|
||||
System.out.println("Job is Still Running");
|
||||
}
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(((jobHistoryData.size()) - 1)).get("status"));
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
|
||||
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
@@ -287,9 +287,6 @@ public class SchedulerJobsTestResults {
|
||||
Integer holidayId = this.holidayHelper.createHolidays(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(holidayId);
|
||||
|
||||
holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, holidayId.toString());
|
||||
Assert.assertNotNull(holidayId);
|
||||
|
||||
final Integer loanProductID = createLoanProduct();
|
||||
Assert.assertNotNull(loanProductID);
|
||||
|
||||
@@ -335,10 +332,11 @@ public class SchedulerJobsTestResults {
|
||||
final ArrayList<HashMap> repaymentScheduleDataBeforeJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
|
||||
this.responseSpec, loanID);
|
||||
|
||||
holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, holidayId.toString());
|
||||
Assert.assertNotNull(holidayId);
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Retrieving Scheduler Job by ID
|
||||
HashMap schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
@@ -350,15 +348,100 @@ public class SchedulerJobsTestResults {
|
||||
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
System.out.println("Job is Still Running");
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(((jobHistoryData.size()) - 1)).get("status"));
|
||||
|
||||
final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
|
||||
this.responseSpec, loanID);
|
||||
}
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
|
||||
final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
|
||||
this.responseSpec, loanID);
|
||||
|
||||
HashMap holidayData = this.holidayHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, holidayId.toString());
|
||||
ArrayList<Integer> repaymentsRescheduledDate = (ArrayList<Integer>) holidayData.get("repaymentsRescheduledTo");
|
||||
|
||||
ArrayList<Integer> rescheduleDateAfter = (ArrayList<Integer>) repaymentScheduleDataAfterJob.get(2).get("fromDate");
|
||||
|
||||
Assert.assertEquals("Verifying Repayment Rescheduled Date after Running Apply Holidays to Loans Scheduler Job",
|
||||
repaymentsRescheduledDate, repaymentsRescheduledDate);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyDueFeeChargesForSavingsJobOutcome() throws InterruptedException {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec,
|
||||
ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID,
|
||||
ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
final Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsSpecifiedDueDateJSON());
|
||||
Assert.assertNotNull(specifiedDueDateChargeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, specifiedDueDateChargeId);
|
||||
ArrayList<HashMap> chargesPendingState = this.savingsAccountHelper.getSavingsCharges(savingsId);
|
||||
Assert.assertEquals(1, chargesPendingState.size());
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
ArrayList<HashMap> allSchedulerJobsData = this.schedulerJobHelper.getAllSchedulerJobs(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(allSchedulerJobsData);
|
||||
|
||||
Integer jobId = (Integer) allSchedulerJobsData.get(7).get("jobId");
|
||||
|
||||
HashMap schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
|
||||
HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
// Executing Scheduler Job
|
||||
this.schedulerJobHelper.runSchedulerJob(this.requestSpec, this.responseSpecForSchedulerJob, jobId.toString());
|
||||
|
||||
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
|
||||
// Waiting for Job to complete
|
||||
while ((Boolean) schedulerJob.get("currentlyRunning") == true) {
|
||||
Thread.sleep(120000);
|
||||
schedulerJob = this.schedulerJobHelper.getSchedulerJobById(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
Assert.assertNotNull(schedulerJob);
|
||||
System.out.println("Job is Still Running");
|
||||
}
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = this.schedulerJobHelper.getSchedulerJobHistory(this.requestSpec, this.responseSpec,
|
||||
jobId.toString());
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
|
||||
HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||
|
||||
Float chargeAmount = (Float) chargeData.get("amount");
|
||||
|
||||
final Float balance = (Float) summaryBefore.get("accountBalance") - chargeAmount;
|
||||
|
||||
Assert.assertEquals("Verifying the Balance after running Pay due Savings Charges", balance,
|
||||
(Float) summaryAfter.get("accountBalance"));
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
|
||||
+9
-1
@@ -11,7 +11,7 @@ import com.jayway.restassured.specification.RequestSender;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused" })
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
public class HolidayHelper {
|
||||
|
||||
private static final String HOLIDAYS_URL = "/mifosng-provider/api/v1/holidays";
|
||||
@@ -62,5 +62,13 @@ public class HolidayHelper {
|
||||
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate";
|
||||
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
|
||||
}
|
||||
|
||||
public static HashMap getSchedulerJobById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String holidayID) {
|
||||
final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?tenantIdentifier=default";
|
||||
System.out.println("------------------------ RETRIEVING HOLIDAY BY ID -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_HOLIDAY_BY_ID_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user