fix broken tests under JUnit 5 [FINERACT-1021]

This commit is contained in:
Michael Vorburger
2020-06-14 17:21:07 +02:00
committed by Michael Vorburger ⛑️
parent 508e915b4f
commit 67e6e27b54
7 changed files with 21 additions and 35 deletions
+1
View File
@@ -119,6 +119,7 @@ dependencies {
// //
testImplementation( 'org.mockito:mockito-core', testImplementation( 'org.mockito:mockito-core',
'org.mockito:mockito-junit-jupiter', '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', 'io.github.classgraph:classgraph',
'org.awaitility:awaitility' 'org.awaitility:awaitility'
) )
@@ -56,17 +56,12 @@ public class BatchApiTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
public BatchApiTest() {
super();
}
/** /**
* Sets up the essential settings for the TEST like contentType, * Sets up the essential settings for the TEST like contentType,
* expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit. * expectedStatusCode. It uses the '@BeforeEach' annotation provided by jUnit.
*/ */
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); 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(); final JsonObject changes = new FromJsonHelper().parse(response.get(1).getBody()).getAsJsonObject().get("changes").getAsJsonObject();
// Asserts the client information is successfully updated // Asserts the client information is successfully updated
Assertions.assertEquals("Verify Firstname", "TestFirstName", changes.get("firstname").getAsString()); Assertions.assertEquals("TestFirstName", changes.get("firstname").getAsString());
Assertions.assertEquals("Verify Lastname", "TestLastName", changes.get("lastname").getAsString()); Assertions.assertEquals("TestLastName", changes.get("lastname").getAsString());
} }
/** /**
@@ -916,16 +916,16 @@ public class ClientLoanIntegrationTest {
Float.valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountWaived")))))) == 0); 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); 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, Assertions.assertTrue(Float.valueOf(val).compareTo(Float.valueOf(val2)) == 0,
msg + "expected " + val + " but was " + val2); msg + "expected " + val + " but was " + val2);
} }
public void validateNumberForEqualExcludePrecission(String val, String val2) { private void validateNumberForEqualExcludePrecission(String val, String val2) {
DecimalFormat twoDForm = new DecimalFormat("#"); DecimalFormat twoDForm = new DecimalFormat("#");
Assertions.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))) Assertions.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val)))
.compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); .compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0);
@@ -1266,8 +1266,7 @@ public class ClientLoanIntegrationTest {
assertEquals(new ArrayList<>(Arrays.asList(2014, 7, 2)), assertEquals(new ArrayList<>(Arrays.asList(2014, 7, 2)),
loanSchedule.get(1).get("dueDate"), loanSchedule.get(1).get("dueDate"),
"Checking for Due Date for 1st Month"); "Checking for Due Date for 1st Month");
validateNumberForEqualWithMsg(String.valueOf(loanSchedule.get(1).get("principalOriginalDue")), validateNumberForEqualWithMsg("Checking for Principal Due for 1st Month", String.valueOf(loanSchedule.get(1).get("principalOriginalDue")), "0.0");
"Checking for Principal Due for 1st Month", "0.0");
assertEquals(Float.valueOf("200000"), assertEquals(Float.valueOf("200000"),
loanSchedule.get(1).get("interestOriginalDue"), loanSchedule.get(1).get("interestOriginalDue"),
"Checking for Interest Due for 1st Month"); "Checking for Interest Due for 1st Month");
@@ -1275,8 +1274,7 @@ public class ClientLoanIntegrationTest {
assertEquals(new ArrayList<>(Arrays.asList(2014, 8, 2)), assertEquals(new ArrayList<>(Arrays.asList(2014, 8, 2)),
loanSchedule.get(2).get("dueDate"), loanSchedule.get(2).get("dueDate"),
"Checking for Due Date for 2nd Month"); "Checking for Due Date for 2nd Month");
validateNumberForEqualWithMsg("0.0", String.valueOf(loanSchedule.get(2).get("principalOriginalDue")), validateNumberForEqualWithMsg("Checking for Principal Due for 2nd Month", "0.0", String.valueOf(loanSchedule.get(2).get("principalOriginalDue")));
"Checking for Principal Due for 2nd Month");
assertEquals(Float.valueOf("200000"), assertEquals(Float.valueOf("200000"),
loanSchedule.get(2).get("interestOriginalDue"), loanSchedule.get(2).get("interestOriginalDue"),
"Checking for Interest Due for 2nd Month"); "Checking for Interest Due for 2nd Month");
@@ -1284,16 +1282,14 @@ public class ClientLoanIntegrationTest {
assertEquals(new ArrayList<>(Arrays.asList(2014, 9, 2)), assertEquals(new ArrayList<>(Arrays.asList(2014, 9, 2)),
loanSchedule.get(3).get("dueDate"), loanSchedule.get(3).get("dueDate"),
"Checking for Due Date for 3rd Month"); "Checking for Due Date for 3rd Month");
validateNumberForEqualWithMsg("0.0", String.valueOf(loanSchedule.get(3).get("principalDue")), validateNumberForEqualWithMsg("Checking for Principal Due for 3rd Month", "0.0", String.valueOf(loanSchedule.get(3).get("principalDue")));
"Checking for Principal Due for 3rd Month");
assertEquals(Float.valueOf("200000"), loanSchedule.get(3).get("interestOriginalDue"), assertEquals(Float.valueOf("200000"), loanSchedule.get(3).get("interestOriginalDue"),
"Checking for Interest Due for 3rd Month"); "Checking for Interest Due for 3rd Month");
assertEquals(new ArrayList<>(Arrays.asList(2014, 10, 2)), assertEquals(new ArrayList<>(Arrays.asList(2014, 10, 2)),
loanSchedule.get(4).get("dueDate"), loanSchedule.get(4).get("dueDate"),
"Checking for Due Date for 4th Month"); "Checking for Due Date for 4th Month");
validateNumberForEqualWithMsg("0", String.valueOf(loanSchedule.get(4).get("principalDue")), validateNumberForEqualWithMsg("Checking for Principal Due for 4th Month", "0", String.valueOf(loanSchedule.get(4).get("principalDue")));
"Checking for Principal Due for 4th Month");
assertEquals(Float.valueOf("200000"), assertEquals(Float.valueOf("200000"),
loanSchedule.get(4).get("interestOriginalDue"), loanSchedule.get(4).get("interestOriginalDue"),
"Checking for Interest Due for 4th Month"); "Checking for Interest Due for 4th Month");
@@ -1356,7 +1352,6 @@ public class ClientLoanIntegrationTest {
assertEquals(Float.valueOf("10500"), assertEquals(Float.valueOf("10500"),
loanSchedule.get(24).get("interestOriginalDue"), loanSchedule.get(24).get("interestOriginalDue"),
"Checking for Interest Due for 24th Month"); "Checking for Interest Due for 24th Month");
} }
private void addCharges(List<HashMap> charges, Integer chargeId, String amount, String duedate) { private void addCharges(List<HashMap> charges, Integer chargeId, String amount, String duedate) {
@@ -74,7 +74,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
final Integer savingsId = createSavingsAccount(clientID, startDate); 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); CommonConstants.RESPONSE_RESOURCE_ID);
/*** /***
@@ -86,12 +86,12 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions"); ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2); HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
for (Entry<String, Object> entry : interestPostingTransaction.entrySet()) 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 // 1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily
// balance // balance
// 33.7016 obtained from formula in excel provided by Subramanya // 33.7016 obtained from formula in excel provided by Subramanya
assertEquals("Equality check for interest posted amount", "33.7016", interestPostingTransaction.get("amount").toString()); assertEquals("33.7016", interestPostingTransaction.get("amount").toString(), "Equality check for interest posted amount");
assertEquals("Date check for Interest Posting transaction", "[2014, 3, 31]", interestPostingTransaction.get("date").toString()); assertEquals("[2014, 3, 31]", interestPostingTransaction.get("date").toString(), "Date check for Interest Posting transaction");
} }
@@ -54,10 +54,10 @@ public class LoanRescheduleRequestTest {
private Integer loanProductId; private Integer loanProductId;
private Integer loanId; private Integer loanId;
private Integer loanRescheduleRequestId; private Integer loanRescheduleRequestId;
private String loanPrincipalAmount = "100000.00"; private final String loanPrincipalAmount = "100000.00";
private String numberOfRepayments = "12"; private final String numberOfRepayments = "12";
private String interestRatePerPeriod = "18"; private final String interestRatePerPeriod = "18";
private String dateString = "4 September 2014"; private final String dateString = "4 September 2014";
@BeforeEach @BeforeEach
public void initialize() { public void initialize() {
@@ -212,8 +212,8 @@ public class LoanRescheduleRequestTest {
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId); final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment"); final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
assertEquals("NUMBER OF REPAYMENTS SHOULD BE 16, NOT 12", "12", numberOfRepayments.toString()); assertEquals(12, numberOfRepayments, "NUMBER OF REPAYMENTS is NOK");
assertEquals("TOTAL EXPECTED REPAYMENT MUST BE EQUAL TO 118000.0", "118000.0", totalExpectedRepayment.toString()); assertEquals(118000, totalExpectedRepayment, "TOTAL EXPECTED REPAYMENT is NOK");
LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId); LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId);
} }
@@ -49,7 +49,6 @@ import org.slf4j.LoggerFactory;
* Entity Datatable Checks Integration Test for checking Creation, Deletion and * Entity Datatable Checks Integration Test for checking Creation, Deletion and
* Retrieval of Entity-Datatable Check * Retrieval of Entity-Datatable Check
*/ */
public class EntityDatatableChecksIntegrationTest { public class EntityDatatableChecksIntegrationTest {
private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class); private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class);
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -70,10 +69,6 @@ public class EntityDatatableChecksIntegrationTest {
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm"; public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public EntityDatatableChecksIntegrationTest() {
// TODO Auto-generated constructor stub
}
@BeforeEach @BeforeEach
public void setup() { public void setup() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
@@ -63,7 +63,7 @@ public class DatatableHelper {
LOG.info("------------------------------CHECK DATATABLE DETAILS------------------------------------\n"); LOG.info("------------------------------CHECK DATATABLE DETAILS------------------------------------\n");
final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec, DATATABLE_URL + "/" final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec, DATATABLE_URL + "/"
+ generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName"); + 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) { public static String getTestDatatableAsJSON(final String apptableName, final boolean multiRow) {