From 99b0136f40928a8d061533aaedb74edcfb1300e4 Mon Sep 17 00:00:00 2001 From: Percy Ayuk Ashu Date: Fri, 5 Jun 2020 09:10:18 +0100 Subject: [PATCH] FINERACT-822 Enabling AssertEqualsArgumentOrderChecker check (#982) --- fineract-provider/build.gradle | 2 +- .../AccountNumberPreferencesTest.java | 2 +- .../fineract/integrationtests/BatchApiTest.java | 4 ++-- .../integrationtests/ClientStatusChecker.java | 12 ++++++------ .../integrationtests/FundsIntegrationTest.java | 2 +- .../LoanDisbursementDetailsIntegrationTest.java | 4 ++-- .../apache/fineract/integrationtests/RolesTest.java | 8 ++++---- .../apache/fineract/integrationtests/StaffTest.java | 8 ++++---- .../fineract/integrationtests/SystemCodeTest.java | 6 +++--- .../integrationtests/common/BatchHelper.java | 4 ++-- .../integrationtests/common/ClientChargesTest.java | 2 +- .../apache/fineract/notification/StorageTest.java | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index d7e256e49..2d7a25655 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -318,7 +318,6 @@ tasks.withType(JavaCompile) { "BigDecimalEquals", "ImmutableEnumChecker", "EqualsUnsafeCast", - "AssertEqualsArgumentOrderChecker", "BoxedPrimitiveEquality", "BadImport", "UnusedMethod", @@ -339,6 +338,7 @@ tasks.withType(JavaCompile) { "ThreeLetterTimeZoneID", "VariableNameSameAsType", "UnnecessaryParentheses", + "AssertEqualsArgumentOrderChecker", // "ReturnMissingNullable", // "InconsistentOverloads", // "MethodCanBeStatic", diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java index 4e28a5671..d236bde0b 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountNumberPreferencesTest.java @@ -376,7 +376,7 @@ public class AccountNumberPreferencesTest { Assert.assertEquals(accountNumber.length(), prefix.length() + 9); Assert.assertTrue(accountNumber.startsWith(prefix)); } else { - Assert.assertEquals(accountNumber.length(), 9); + Assert.assertEquals(9, accountNumber.length()); } } 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 1dd3d9c46..28d0a8c8f 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 @@ -155,7 +155,7 @@ public class BatchApiTest { BatchHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, "TestExtId12"); // Asserts that all the transactions have been successfully rolled back - Assert.assertEquals(response.size(), 1); + Assert.assertEquals(1, response.size()); Assert.assertEquals("Verify Status code 400", (long) 400, (long) response.get(0).getStatusCode()); } @@ -532,4 +532,4 @@ public class BatchApiTest { Assert.assertEquals("Verify Status Code 200 for approve Loan", 200L, (long) response.get(2).getStatusCode()); Assert.assertEquals("Verify Status Code 200 for disburse Loan", 200L, (long) response.get(3).getStatusCode()); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientStatusChecker.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientStatusChecker.java index f7892bafb..3e684f775 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientStatusChecker.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientStatusChecker.java @@ -28,41 +28,41 @@ public class ClientStatusChecker { private final static Logger LOG = LoggerFactory.getLogger(ClientStatusChecker.class); public static void verifyClientIsActive(final HashMap clientStatusHashMap) { - assertEquals((int) clientStatusHashMap.get("id"), 300); + assertEquals(300, (int) clientStatusHashMap.get("id")); } public static void verifyClientClosed(final HashMap clientStatusHashMap) { LOG.info( "\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------"); - assertEquals((int) clientStatusHashMap.get("id"), 600); + assertEquals(600, (int) clientStatusHashMap.get("id")); LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientPending(final HashMap clientStatusHashMap) { LOG.info( "\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------"); - assertEquals((int) clientStatusHashMap.get("id"), 100); + assertEquals(100, (int) clientStatusHashMap.get("id")); LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientRejected(final HashMap clientStatusHashMap) { LOG.info( "\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------"); - assertEquals((int) clientStatusHashMap.get("id"), 700); + assertEquals(700, (int) clientStatusHashMap.get("id")); LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientActiavted(final HashMap clientStatusHashMap) { LOG.info( "\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------"); - assertEquals((int) clientStatusHashMap.get("id"), 300); + assertEquals(300, (int) clientStatusHashMap.get("id")); LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientWithdrawn(final HashMap clientStatusHashMap) { LOG.info( "\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------"); - assertEquals((int) clientStatusHashMap.get("id"), 800); + assertEquals(800, (int) clientStatusHashMap.get("id")); LOG.info("Client Status: {} \n", clientStatusHashMap); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java index 7281b2d59..81800d4b7 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FundsIntegrationTest.java @@ -202,7 +202,7 @@ public class FundsIntegrationTest { ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build(); String jsonData = FundsResourceHandler.retrieveFund(Long.MAX_VALUE, this.requestSpec, responseSpec); HashMap map = new Gson().fromJson(jsonData, new TypeToken>(){}.getType()); - assertEquals(map.get("userMessageGlobalisationCode"), "error.msg.resource.not.found"); + assertEquals("error.msg.resource.not.found", map.get("userMessageGlobalisationCode")); } @Test diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursementDetailsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursementDetailsIntegrationTest.java index 8da7b08c8..d125806c4 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursementDetailsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursementDetailsIntegrationTest.java @@ -94,7 +94,7 @@ public class LoanDisbursementDetailsIntegrationTest { loanIDWithEmi, "repaymentSchedule"); ArrayList periods = (ArrayList) repaymentScheduleWithEmi.get("periods"); - assertEquals(periods.size(), 15); + assertEquals(15, periods.size()); this.validateRepaymentScheduleWithEMI(periods); @@ -115,7 +115,7 @@ public class LoanDisbursementDetailsIntegrationTest { loanIDWithoutEmi, "repaymentSchedule"); ArrayList periods1 = (ArrayList) repaymentScheduleWithEmi.get("periods"); - assertEquals(periods1.size(), 15); + assertEquals(15, periods1.size()); LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}" , loanIDWithoutEmi); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RolesTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RolesTest.java index 46697fb82..5f13c2518 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RolesTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RolesTest.java @@ -81,7 +81,7 @@ public class RolesTest { assertEquals(disableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - assertEquals((Boolean) role.get("disabled"), true); + assertEquals(true, (Boolean) role.get("disabled")); } @@ -102,14 +102,14 @@ public class RolesTest { assertEquals(disableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - assertEquals((Boolean) role.get("disabled"), true); + assertEquals(true, (Boolean) role.get("disabled")); LOG.info("--------------------------------- ENABLING ROLE -------------------------------"); final Integer enableRoleId = RolesHelper.enableRole(this.requestSpec, this.responseSpec, roleId); assertEquals(enableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - assertEquals((Boolean) role.get("disabled"), false); + assertEquals(false,(Boolean) role.get("disabled")); } @@ -164,4 +164,4 @@ public class RolesTest { assertNotEquals(deletedRoleId, roleId); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java index d95949fc6..8b895cba9 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java @@ -55,7 +55,7 @@ public class StaffTest { Map response = StaffHelper.createStaffMap(requestSpec, responseSpec); Assert.assertNotNull(response); - Assert.assertEquals(response.get("officeId"), 1); + Assert.assertEquals(1, response.get("officeId")); Assert.assertNotNull(response.get("resourceId")); } @@ -120,7 +120,7 @@ public class StaffTest { Map response = StaffHelper.getStaff(requestSpec, responseSpec, 1); Assert.assertNotNull(response); Assert.assertNotNull(response.get("id")); - Assert.assertEquals(response.get("id"), 1); + Assert.assertEquals(1, response.get("id")); } @Test @@ -138,7 +138,7 @@ public class StaffTest { List> responseActive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active"); for(final Map staff : responseActive) { Assert.assertNotNull(staff.get("id")); - Assert.assertEquals(staff.get("isActive"), true); + Assert.assertEquals(true, staff.get("isActive")); } } @@ -147,7 +147,7 @@ public class StaffTest { List> responseInactive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive"); for(final Map staff : responseInactive) { Assert.assertNotNull(staff.get("id")); - Assert.assertEquals(staff.get("isActive"), false); + Assert.assertEquals(false, staff.get("isActive")); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SystemCodeTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SystemCodeTest.java index 01a49090e..078fddd52 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SystemCodeTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SystemCodeTest.java @@ -237,9 +237,9 @@ public class SystemCodeTest { final HashMap codeValueChanges = (HashMap) CodeHelper.updateCodeValue(this.requestSpec, this.responseSpec, createCodeResponseId, createCodeValueResponseId1, codeValue1 + "CHANGE", codeDescription1 + "CHANGE", 4, "changes"); - assertEquals("Verify changed code value name", codeValueChanges.get("name"), codeValue1 + "CHANGE"); + assertEquals("Verify changed code value name", codeValue1 + "CHANGE", codeValueChanges.get("name")); - assertEquals("Verify changed code value description", codeValueChanges.get("description"), codeDescription1 + "CHANGE"); + assertEquals("Verify changed code value description", codeDescription1 + "CHANGE", codeValueChanges.get("description")); // delete code value Integer deletedCodeValueResponseId1 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec, @@ -278,4 +278,4 @@ public class SystemCodeTest { } -} \ No newline at end of file +} diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/BatchHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/BatchHelper.java index 3e9cf171a..72e35d59c 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/BatchHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/BatchHelper.java @@ -427,6 +427,6 @@ public class BatchHelper { LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); final String CLIENT_URL = "/fineract-provider/api/v1/clients?externalId=" + externalId + "&" + Utils.TENANT_IDENTIFIER; final Integer responseRecords = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "totalFilteredRecords"); - Assert.assertEquals("No records found with given externalId", (long) responseRecords, (long) 0); + Assert.assertEquals("No records found with given externalId", (long) 0, (long) responseRecords); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientChargesTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientChargesTest.java index 37a06b0e0..e75d77d9b 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientChargesTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientChargesTest.java @@ -175,7 +175,7 @@ public class ClientChargesTest { * @param expectedAmount */ private void isValidOutstandingAmount(Object outStandingAmount, Object expectedAmount) { - Assert.assertEquals((float) outStandingAmount, expectedAmount); + Assert.assertEquals(expectedAmount, (float) outStandingAmount); } } diff --git a/fineract-provider/src/test/java/org/apache/fineract/notification/StorageTest.java b/fineract-provider/src/test/java/org/apache/fineract/notification/StorageTest.java index 70f511e72..efe585f60 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/notification/StorageTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/notification/StorageTest.java @@ -126,7 +126,7 @@ public class StorageTest { verify(this.notificationGeneratorWritePlatformService, times(1)).create(refEq(notification, "createdAt")); verify(this.notificationMapperWritePlatformService, times(1)).create(refEq(notificationMapper, "createdAt")); verify(this.notificationGeneratorReadRepositoryWrapper, times(1)).findById(1L); - assertEquals(actualGeneratedNotificationId, Long.valueOf(1)); + assertEquals(Long.valueOf(1),actualGeneratedNotificationId); } private String getCurrentDateTime() {