fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] 02/02: fix broken tests under JUnit 5 [FINERACT-1021]
Date Sun, 14 Jun 2020 15:21:21 GMT
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

commit 67e6e27b54ca51d6badf5e0e4a7e35c3bf4d2820
Author: Michael Vorburger <mike@vorburger.ch>
AuthorDate: Sun Jun 14 16:33:02 2020 +0200

    fix broken tests under JUnit 5 [FINERACT-1021]
---
 fineract-provider/dependencies.gradle                 |  1 +
 .../fineract/integrationtests/BatchApiTest.java       |  9 ++-------
 .../integrationtests/ClientLoanIntegrationTest.java   | 19 +++++++------------
 ...FlexibleSavingsInterestPostingIntegrationTest.java |  8 ++++----
 .../integrationtests/LoanRescheduleRequestTest.java   | 12 ++++++------
 .../EntityDatatableChecksIntegrationTest.java         |  5 -----
 .../common/system/DatatableHelper.java                |  2 +-
 7 files changed, 21 insertions(+), 35 deletions(-)

diff --git a/fineract-provider/dependencies.gradle b/fineract-provider/dependencies.gradle
index 5d77ed0..e059d85 100644
--- a/fineract-provider/dependencies.gradle
+++ b/fineract-provider/dependencies.gradle
@@ -119,6 +119,7 @@ dependencies {
 	//
     testImplementation( 'org.mockito:mockito-core',
             'org.mockito:mockito-junit-jupiter',
+            'org.junit.platform:junit-platform-runner', // required to be able to run tests
directly under Eclipse, see FINERACT-943 & FINERACT-1021
             'io.github.classgraph:classgraph',
             'org.awaitility:awaitility'
 	)
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchApiTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchApiTest.java
index 4fe1934..1b2d62b 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchApiTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchApiTest.java
@@ -56,17 +56,12 @@ public class BatchApiTest {
     private ResponseSpecification responseSpec;
     private RequestSpecification requestSpec;
 
-    public BatchApiTest() {
-        super();
-    }
-
     /**
      * Sets up the essential settings for the TEST like contentType,
      * expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit.
      */
     @BeforeEach
     public void setup() {
-
         Utils.initializeRESTAssured();
         this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
         this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
@@ -189,8 +184,8 @@ public class BatchApiTest {
         final JsonObject changes = new FromJsonHelper().parse(response.get(1).getBody()).getAsJsonObject().get("changes").getAsJsonObject();
 
         // Asserts the client information is successfully updated
-        Assertions.assertEquals("Verify Firstname", "TestFirstName", changes.get("firstname").getAsString());
-        Assertions.assertEquals("Verify Lastname", "TestLastName", changes.get("lastname").getAsString());
+        Assertions.assertEquals("TestFirstName", changes.get("firstname").getAsString());
+        Assertions.assertEquals("TestLastName", changes.get("lastname").getAsString());
     }
 
     /**
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
index 2c7de5b..8933dd4 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
@@ -916,16 +916,16 @@ public class ClientLoanIntegrationTest {
                 Float.valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountWaived"))))))
== 0);
     }
 
-    public void validateNumberForEqual(String val, String val2) {
+    private void validateNumberForEqual(String val, String val2) {
         Assertions.assertTrue(Float.valueOf(val).compareTo(Float.valueOf(val2)) == 0);
     }
 
-    public void validateNumberForEqualWithMsg(String msg, String val, String val2) {
+    private void validateNumberForEqualWithMsg(String msg, String val, String val2) {
         Assertions.assertTrue(Float.valueOf(val).compareTo(Float.valueOf(val2)) == 0,
                 msg + "expected " + val + " but was " + val2);
     }
 
-    public void validateNumberForEqualExcludePrecission(String val, String val2) {
+    private void validateNumberForEqualExcludePrecission(String val, String val2) {
         DecimalFormat twoDForm = new DecimalFormat("#");
         Assertions.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val)))
                 .compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0);
@@ -1266,8 +1266,7 @@ public class ClientLoanIntegrationTest {
         assertEquals(new ArrayList<>(Arrays.asList(2014, 7, 2)),
                 loanSchedule.get(1).get("dueDate"),
                 "Checking for Due Date for 1st Month");
-        validateNumberForEqualWithMsg(String.valueOf(loanSchedule.get(1).get("principalOriginalDue")),
-                "Checking for Principal Due for 1st Month", "0.0");
+        validateNumberForEqualWithMsg("Checking for Principal Due for 1st Month", String.valueOf(loanSchedule.get(1).get("principalOriginalDue")),
"0.0");
         assertEquals(Float.valueOf("200000"),
                 loanSchedule.get(1).get("interestOriginalDue"),
                 "Checking for Interest Due for 1st Month");
@@ -1275,8 +1274,7 @@ public class ClientLoanIntegrationTest {
         assertEquals(new ArrayList<>(Arrays.asList(2014, 8, 2)),
                 loanSchedule.get(2).get("dueDate"),
                 "Checking for Due Date for 2nd Month");
-        validateNumberForEqualWithMsg("0.0", String.valueOf(loanSchedule.get(2).get("principalOriginalDue")),
-                "Checking for Principal Due for 2nd Month");
+        validateNumberForEqualWithMsg("Checking for Principal Due for 2nd Month", "0.0",
String.valueOf(loanSchedule.get(2).get("principalOriginalDue")));
         assertEquals(Float.valueOf("200000"),
                 loanSchedule.get(2).get("interestOriginalDue"),
                 "Checking for Interest Due for 2nd Month");
@@ -1284,16 +1282,14 @@ public class ClientLoanIntegrationTest {
         assertEquals(new ArrayList<>(Arrays.asList(2014, 9, 2)),
                 loanSchedule.get(3).get("dueDate"),
                 "Checking for Due Date for 3rd Month");
-        validateNumberForEqualWithMsg("0.0", String.valueOf(loanSchedule.get(3).get("principalDue")),
-                "Checking for Principal Due for 3rd Month");
+        validateNumberForEqualWithMsg("Checking for Principal Due for 3rd Month", "0.0",
String.valueOf(loanSchedule.get(3).get("principalDue")));
         assertEquals(Float.valueOf("200000"), loanSchedule.get(3).get("interestOriginalDue"),
                 "Checking for Interest Due for 3rd Month");
 
         assertEquals(new ArrayList<>(Arrays.asList(2014, 10, 2)),
                 loanSchedule.get(4).get("dueDate"),
                 "Checking for Due Date for 4th Month");
-        validateNumberForEqualWithMsg("0", String.valueOf(loanSchedule.get(4).get("principalDue")),
-                "Checking for Principal Due for 4th Month");
+        validateNumberForEqualWithMsg("Checking for Principal Due for 4th Month", "0", String.valueOf(loanSchedule.get(4).get("principalDue")));
         assertEquals(Float.valueOf("200000"),
                 loanSchedule.get(4).get("interestOriginalDue"),
                 "Checking for Interest Due for 4th Month");
@@ -1356,7 +1352,6 @@ public class ClientLoanIntegrationTest {
         assertEquals(Float.valueOf("10500"),
                 loanSchedule.get(24).get("interestOriginalDue"),
                 "Checking for Interest Due for 24th Month");
-
     }
 
     private void addCharges(List<HashMap> charges, Integer chargeId, String amount,
String duedate) {
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
index 284b137..8053ccf 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FlexibleSavingsInterestPostingIntegrationTest.java
@@ -74,7 +74,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
 
         final Integer savingsId = createSavingsAccount(clientID, startDate);
 
-        Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId,
"1000", startDate,
+        this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
                 CommonConstants.RESPONSE_RESOURCE_ID);
 
         /***
@@ -86,12 +86,12 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
         ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String,
Object>>) accountDetails.get("transactions");
         HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size()
- 2);
         for (Entry<String, Object> entry : interestPostingTransaction.entrySet())
-            {LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());}
+        {LOG.info("{} - {}",entry.getKey(), entry.getValue().toString());}
         // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
         // balance
         // 33.7016 obtained from formula in excel provided by Subramanya
-        assertEquals("Equality check for interest posted amount", "33.7016", interestPostingTransaction.get("amount").toString());
-        assertEquals("Date check for Interest Posting transaction", "[2014, 3, 31]", interestPostingTransaction.get("date").toString());
+        assertEquals("33.7016", interestPostingTransaction.get("amount").toString(), "Equality
check for interest posted amount");
+        assertEquals("[2014, 3, 31]", interestPostingTransaction.get("date").toString(),
"Date check for Interest Posting transaction");
 
     }
 
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
index 33bf33a..4a81bc3 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRescheduleRequestTest.java
@@ -54,10 +54,10 @@ public class LoanRescheduleRequestTest {
     private Integer loanProductId;
     private Integer loanId;
     private Integer loanRescheduleRequestId;
-    private String loanPrincipalAmount = "100000.00";
-    private String numberOfRepayments = "12";
-    private String interestRatePerPeriod = "18";
-    private String dateString = "4 September 2014";
+    private final String loanPrincipalAmount = "100000.00";
+    private final String numberOfRepayments = "12";
+    private final String interestRatePerPeriod = "18";
+    private final String dateString = "4 September 2014";
 
     @BeforeEach
     public void initialize() {
@@ -212,8 +212,8 @@ public class LoanRescheduleRequestTest {
         final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec,
generalResponseSpec, loanId);
         final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
 
-        assertEquals("NUMBER OF REPAYMENTS SHOULD BE 16, NOT 12", "12", numberOfRepayments.toString());
-        assertEquals("TOTAL EXPECTED REPAYMENT MUST BE EQUAL TO 118000.0", "118000.0", totalExpectedRepayment.toString());
+        assertEquals(12, numberOfRepayments, "NUMBER OF REPAYMENTS is NOK");
+        assertEquals(118000, totalExpectedRepayment, "TOTAL EXPECTED REPAYMENT is NOK");
 
         LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId);
     }
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
index 32a507e..baff70f 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
@@ -49,7 +49,6 @@ import org.slf4j.LoggerFactory;
  * Entity Datatable Checks Integration Test for checking Creation, Deletion and
  * Retrieval of Entity-Datatable Check
  */
-
 public class EntityDatatableChecksIntegrationTest {
     private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class);
     private RequestSpecification requestSpec;
@@ -70,10 +69,6 @@ public class EntityDatatableChecksIntegrationTest {
 
     public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
 
-    public EntityDatatableChecksIntegrationTest() {
-        // TODO Auto-generated constructor stub
-    }
-
     @BeforeEach
     public void setup() {
         Utils.initializeRESTAssured();
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/DatatableHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/DatatableHelper.java
index 0e9bc9c..2606c43 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/DatatableHelper.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/DatatableHelper.java
@@ -63,7 +63,7 @@ public class DatatableHelper {
         LOG.info("------------------------------CHECK DATATABLE DETAILS------------------------------------\n");
         final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec,
DATATABLE_URL + "/"
                 + generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName");
-        assertEquals("ERROR IN CREATING THE DATATABLE", generatedDatatableName, responseRegisteredTableName);
+        assertEquals(generatedDatatableName, responseRegisteredTableName, "ERROR IN CREATING
THE DATATABLE");
     }
 
     public static String getTestDatatableAsJSON(final String apptableName, final boolean
multiRow) {


Mime
View raw message