diff --git a/fineract-provider/config/checkstyle/checkstyle.xml b/fineract-provider/config/checkstyle/checkstyle.xml index b628aa93a..7663dc1a0 100644 --- a/fineract-provider/config/checkstyle/checkstyle.xml +++ b/fineract-provider/config/checkstyle/checkstyle.xml @@ -47,7 +47,13 @@ --> + + + + + + @@ -84,12 +90,6 @@ - - - - - - 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 bd9609bf5..4e28a5671 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 @@ -43,9 +43,12 @@ import org.apache.fineract.integrationtests.common.system.CodeHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountNumberPreferencesTest { + private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; private ResponseSpecification responseValidationError; @@ -149,10 +152,10 @@ public class AccountNumberPreferencesTest { Integer id = (Integer) preferenceId.get("id"); HashMap delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec, ""); - System.out.println("Successfully deleted account number preference (ID: " + delResponse.get("resourceId") + ")"); + LOG.info("Successfully deleted account number preference (ID: {} )",delResponse.get("resourceId")); } /* Deletion of invalid account preference ID should fail */ - System.out.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------"); + LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------"); HashMap deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10, this.responseNotFoundError, ""); @@ -179,23 +182,23 @@ public class AccountNumberPreferencesTest { private void createAccountNumberPreference() { this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference( this.responseSpec, "resourceId"); - System.out.println("Successfully created account number preferences for Client (ID: " + this.clientAccountNumberPreferenceId); + LOG.info("Successfully created account number preferences for Client (ID: {})",this.clientAccountNumberPreferenceId); this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference( this.responseSpec, "resourceId"); - System.out.println("Successfully created account number preferences for Loan (ID: " + this.loanAccountNumberPreferenceId); + LOG.info("Successfully created account number preferences for Loan (ID: {} )", this.loanAccountNumberPreferenceId); this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference( this.responseSpec, "resourceId"); - System.out.println("Successfully created account number preferences for Savings (ID: " + this.savingsAccountNumberPreferenceId); + LOG.info("Successfully created account number preferences for Savings (ID: {})" , this.savingsAccountNumberPreferenceId); this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference( this.responseSpec, "resourceId"); - System.out.println("Successfully created account number preferences for Groups (ID: " + this.groupsAccountNumberPreferenceId); + LOG.info("Successfully created account number preferences for Groups (ID: {})" , this.groupsAccountNumberPreferenceId); this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference( this.responseSpec, "resourceId"); - System.out.println("Successfully created account number preferences for Center (ID: " + this.centerAccountNumberPreferenceId); + LOG.info("Successfully created account number preferences for Center (ID: {})" ,this.centerAccountNumberPreferenceId); this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId, this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId, @@ -208,7 +211,7 @@ public class AccountNumberPreferencesTest { private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) { /* Creating account Preference with duplicate data should fail */ - System.out.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------"); + LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------"); HashMap creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( this.responseForbiddenError, accountType, prefixType, ""); @@ -221,7 +224,7 @@ public class AccountNumberPreferencesTest { private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) { /* Creating account Preference with invalid data should fail */ - System.out.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); + LOG.info("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); HashMap creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData( this.responseValidationError, accountType, prefixType, ""); @@ -241,14 +244,14 @@ public class AccountNumberPreferencesTest { HashMap accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference( this.clientAccountNumberPreferenceId, "101", this.responseSpec, ""); - System.out.println("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID " - + accountNumberPreferences.get("resourceId")); + LOG.info("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID {}" + , accountNumberPreferences.get("resourceId")); this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"), this.responseSpec, this.requestSpec); /* Update invalid account preference id should fail */ - System.out.println("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); + LOG.info("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------"); /* Invalid Account Type */ HashMap updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101", @@ -380,20 +383,20 @@ public class AccountNumberPreferencesTest { private void createLoanProduct() { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); + LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount) .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod) .withInterestRateFrequencyTypeAsYear().build(null); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); - System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")"); + LOG.info("Successfully created loan product (ID: {} )" , this.loanProductId); } private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------"); + LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) .withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsMonths().withNumberOfRepayments(numberOfRepayments) @@ -402,7 +405,7 @@ public class AccountNumberPreferencesTest { .withSubmittedOnDate(dateString).withExpectedDisbursementDate(dateString).withPrincipalGrace("2").withInterestGrace("2") .build(this.clientId.toString(), this.loanProductId.toString(), null); - System.out.println("Loan Application :" + loanApplicationJSON); + LOG.info("Loan Application :{}" , loanApplicationJSON); this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId, @@ -419,17 +422,17 @@ public class AccountNumberPreferencesTest { this.loanProductId, "shortName"); this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName); } - System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")"); + LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION BASED ON ACCOUNT PREFERENCES (ID: {} )",this.loanId ); } else { this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null); - System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION (ID: " + loanId + ")"); + LOG.info("SUCCESSFULLY CREATED LOAN APPLICATION (ID: {} )",loanId); } } private void createSavingsProduct() { this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); @@ -446,7 +449,7 @@ public class AccountNumberPreferencesTest { .withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance) .withMinimumOpenningBalance(this.MINIMUM_OPENING_BALANCE).build(); this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec); - System.out.println("Sucessfully created savings product (ID: " + this.savingsProductId + ")"); + LOG.info("Sucessfully created savings product (ID: {} )",this.savingsProductId); } @@ -472,10 +475,10 @@ public class AccountNumberPreferencesTest { String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName"); this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName); } - System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")"); + LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION BASED ON ACCOUNT PREFERENCES (ID: {} )",this.loanId); } else { this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, null); - System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID: " + this.savingsId + ")"); + LOG.info("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID:{} )",this.savingsId); } } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountTransferTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountTransferTest.java index 5b7678507..e274a38f6 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountTransferTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountTransferTest.java @@ -49,6 +49,8 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * JUnit Test Cases for Account Transfer for. @@ -56,6 +58,7 @@ import org.junit.Test; @SuppressWarnings({ "rawtypes", "unused" }) public class AccountTransferTest { + private final static Logger LOG = LoggerFactory.getLogger(AccountTransferTest.class); public static final String MINIMUM_OPENING_BALANCE = "30000.0"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; public static final String ACCOUNT_TRANSFER_AMOUNT = "15000.0"; @@ -443,7 +446,7 @@ public class AccountTransferTest { private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String minOpenningBalance, final Account... accounts) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); final String savingsProductJSON = savingsProductHelper // .withInterestCompoundingPeriodTypeAsDaily() // @@ -454,7 +457,7 @@ public class AccountTransferTest { } private Integer createLoanProduct(final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("8,000.00") // .withNumberOfRepayments("4") // @@ -470,7 +473,7 @@ public class AccountTransferTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("8,000.00") // .withLoanTermFrequency("4") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java index 31d89abcf..3f56e8728 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/AccountingScenarioIntegrationTest.java @@ -64,10 +64,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) public class AccountingScenarioIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(AccountingScenarioIntegrationTest.class); private static RequestSpecification requestSpec; private static ResponseSpecification responseSpec; @@ -146,19 +148,19 @@ public class AccountingScenarioIntegrationTest { LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.DEBIT), new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry); - System.out.println("CHECKING INCOME: ******************************************"); + LOG.info("CHECKING INCOME: ******************************************"); final JournalEntry incomeJournalEntry = new JournalEntry(TOTAL_INTEREST, JournalEntry.TransactionType.CREDIT); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.EXPECTED_DISBURSAL_DATE, incomeJournalEntry); // MAKE 1 - System.out.println("Repayment 1 ......"); + LOG.info("Repayment 1 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID); final float FIRST_INTEREST = 200.0f; final float FIRST_PRINCIPAL = 2000.0f; @@ -167,10 +169,10 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); - System.out.println("Repayment 1 Done......"); + LOG.info("Repayment 1 Done......"); // REPAYMENT 2 - System.out.println("Repayment 2 ......"); + LOG.info("Repayment 2 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; @@ -179,10 +181,10 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); - System.out.println("Repayment 2 Done ......"); + LOG.info("Repayment 2 Done ......"); // WAIVE INTEREST - System.out.println("Waive Interest ......"); + LOG.info("Waive Interest ......"); this.loanTransactionHelper.waiveInterest(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID); final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT); @@ -190,41 +192,41 @@ public class AccountingScenarioIntegrationTest { final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry); - System.out.println("Waive Interest Done......"); + LOG.info("Waive Interest Done......"); // REPAYMENT 3 - System.out.println("Repayment 3 ......"); + LOG.info("Repayment 3 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); - System.out.println("Repayment 3 Done ......"); + LOG.info("Repayment 3 Done ......"); // REPAYMENT 4 - System.out.println("Repayment 4 ......"); + LOG.info("Repayment 4 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); - System.out.println("Repayment 4 Done ......"); + LOG.info("Repayment 4 Done ......"); // Repayment 5 - System.out.println("Repayment 5 ......"); + LOG.info("Repayment 5 ......"); final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); - System.out.println("Repayment 5 Done ......"); + LOG.info("Repayment 5 Done ......"); } private Integer createLoanProductWithUpfrontAccrualAccountingEnabled(final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() @@ -234,7 +236,7 @@ public class AccountingScenarioIntegrationTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()) .withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths().withNumberOfRepayments(this.LP_REPAYMENTS) .withRepaymentEveryAfter(this.LP_REPAYMENT_PERIOD).withRepaymentFrequencyTypeAsMonths() @@ -283,7 +285,7 @@ public class AccountingScenarioIntegrationTest { HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsID); assertEquals("Verifying Balance after Deposit", balance, summary.get("accountBalance")); - System.out.println("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------"); + LOG.info("----------------------Verifying Journal Entry after the Transaction Deposit----------------------------"); final JournalEntry[] assetAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, JournalEntry.TransactionType.DEBIT) }; final JournalEntry[] liabililityAccountFirstTransactionEntry = { new JournalEntry(this.SP_DEPOSIT_AMOUNT, @@ -299,7 +301,7 @@ public class AccountingScenarioIntegrationTest { summary = this.savingsAccountHelper.getSavingsSummary(savingsID); assertEquals("Verifying Balance after Withdrawal", balance, summary.get("accountBalance")); - System.out.println("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------"); + LOG.info("-------------------Verifying Journal Entry after the Transaction Withdrawal----------------------"); final JournalEntry[] assetAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, JournalEntry.TransactionType.CREDIT) }; final JournalEntry[] liabililityAccountSecondTransactionEntry = { new JournalEntry(this.SP_WITHDRAWAL_AMOUNT, @@ -506,7 +508,7 @@ public class AccountingScenarioIntegrationTest { } public static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() // .withInterestPostingPeriodTypeAsQuarterly() // .withInterestCalculationPeriodTypeAsDailyBalance() // @@ -515,7 +517,7 @@ public class AccountingScenarioIntegrationTest { } private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) { - System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); final String fixedDepositProductJSON = fixedDepositProductHelper // .withPeriodRangeChart()// @@ -525,7 +527,7 @@ public class AccountingScenarioIntegrationTest { private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom, final String validTo, final String submittedOnDate, final String penalInterestType) { - System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); return this.fixedDepositAccountHelper @@ -533,7 +535,7 @@ public class AccountingScenarioIntegrationTest { } private Integer createRecurringDepositProduct(final String validFrom, final String validTo, Account... accounts) { - System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); final String recurringDepositProductJSON = recurringDepositProductHelper // .withPeriodRangeChart()// @@ -543,7 +545,7 @@ public class AccountingScenarioIntegrationTest { private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) { - System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) @@ -577,7 +579,7 @@ public class AccountingScenarioIntegrationTest { LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), @@ -592,7 +594,7 @@ public class AccountingScenarioIntegrationTest { } // MAKE 1 - System.out.println("Repayment 1 ......"); + LOG.info("Repayment 1 ......"); final float FIRST_INTEREST = 200.0f; final float FIRST_PRINCIPAL = 2000.0f; final float FEE_PORTION = 0.0f; @@ -605,10 +607,10 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), new JournalEntry(FIRST_INTEREST + FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); - System.out.println("Repayment 1 Done......"); + LOG.info("Repayment 1 Done......"); // REPAYMENT 2 - System.out.println("Repayment 2 ......"); + LOG.info("Repayment 2 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; @@ -621,10 +623,10 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), new JournalEntry(SECOND_AND_THIRD_INTEREST + SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); - System.out.println("Repayment 2 Done ......"); + LOG.info("Repayment 2 Done ......"); // WAIVE INTEREST - System.out.println("Waive Interest ......"); + LOG.info("Waive Interest ......"); this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID); this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[5]), FIRST_INTEREST, @@ -636,37 +638,37 @@ public class AccountingScenarioIntegrationTest { final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry); - System.out.println("Waive Interest Done......"); + LOG.info("Waive Interest Done......"); // REPAYMENT 3 - System.out.println("Repayment 3 ......"); + LOG.info("Repayment 3 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); - System.out.println("Repayment 3 Done ......"); + LOG.info("Repayment 3 Done ......"); // REPAYMENT 4 - System.out.println("Repayment 4 ......"); + LOG.info("Repayment 4 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); - System.out.println("Repayment 4 Done ......"); + LOG.info("Repayment 4 Done ......"); // Repayment 5 - System.out.println("Repayment 5 ......"); + LOG.info("Repayment 5 ......"); final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); - System.out.println("Repayment 5 Done ......"); + LOG.info("Repayment 5 Done ......"); } @Test @@ -694,7 +696,7 @@ public class AccountingScenarioIntegrationTest { LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), @@ -709,7 +711,7 @@ public class AccountingScenarioIntegrationTest { } // MAKE 1 - System.out.println("Repayment 1 ......"); + LOG.info("Repayment 1 ......"); final float FIRST_INTEREST = 200.0f; final float FIRST_PRINCIPAL = 2000.0f; final float FEE_PORTION = 0.0f; @@ -724,7 +726,7 @@ public class AccountingScenarioIntegrationTest { this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f, JournalEntry.TransactionType.CREDIT)); - System.out.println("Repayment Done......"); + LOG.info("Repayment Done......"); } @@ -783,7 +785,7 @@ public class AccountingScenarioIntegrationTest { String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION))); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), @@ -902,7 +904,7 @@ public class AccountingScenarioIntegrationTest { dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION))); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), @@ -946,7 +948,7 @@ public class AccountingScenarioIntegrationTest { } private Integer createLoanProductWithPeriodicAccrualAccountingEnabled(final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() @@ -979,7 +981,7 @@ public class AccountingScenarioIntegrationTest { LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // CHECK ACCOUNT ENTRIES - System.out.println("Entries ......"); + LOG.info("Entries ......"); final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f; final float TOTAL_INTEREST = 1000.0f; final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT), @@ -987,7 +989,7 @@ public class AccountingScenarioIntegrationTest { this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry); // MAKE 1 - System.out.println("Repayment 1 ......"); + LOG.info("Repayment 1 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID); final float FIRST_INTEREST = 200.0f; final float FIRST_PRINCIPAL = 2000.0f; @@ -996,13 +998,13 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountFirstEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[1], JournalEntry.TransactionType.DEBIT), new JournalEntry(FIRST_PRINCIPAL, JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountFirstEntry); - System.out.println("CHECKING INCOME: ******************************************"); + LOG.info("CHECKING INCOME: ******************************************"); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[1], new JournalEntry(FIRST_INTEREST, JournalEntry.TransactionType.CREDIT)); - System.out.println("Repayment 1 Done......"); + LOG.info("Repayment 1 Done......"); // REPAYMENT 2 - System.out.println("Repayment 2 ......"); + LOG.info("Repayment 2 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[2], this.REPAYMENT_AMOUNT[2], loanID); final float SECOND_AND_THIRD_INTEREST = 400.0f; final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST; @@ -1011,13 +1013,13 @@ public class AccountingScenarioIntegrationTest { final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT), new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry); - System.out.println("CHECKING INCOME: ******************************************"); + LOG.info("CHECKING INCOME: ******************************************"); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry( SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT)); - System.out.println("Repayment 2 Done ......"); + LOG.info("Repayment 2 Done ......"); // WAIVE INTEREST - System.out.println("Waive Interest ......"); + LOG.info("Waive Interest ......"); Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID); // waive of fees and interest are not considered in cash based @@ -1025,38 +1027,38 @@ public class AccountingScenarioIntegrationTest { this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L" + transactionId); // REPAYMENT 3 - System.out.println("Repayment 3 ......"); + LOG.info("Repayment 3 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; final JournalEntry[] assetAccountThirdEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[3], JournalEntry.TransactionType.CREDIT) }; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry); - System.out.println("Repayment 3 Done ......"); + LOG.info("Repayment 3 Done ......"); // REPAYMENT 4 - System.out.println("Repayment 4 ......"); + LOG.info("Repayment 4 ......"); this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID); expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(4, expected_value, loanID); final JournalEntry[] assetAccountFourthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[4], JournalEntry.TransactionType.CREDIT) }; this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[4], assetAccountFourthEntry); - System.out.println("Repayment 4 Done ......"); + LOG.info("Repayment 4 Done ......"); // Repayment 5 - System.out.println("Repayment 5 ......"); + LOG.info("Repayment 5 ......"); final JournalEntry[] assetAccountFifthEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.DEBIT), new JournalEntry(this.REPAYMENT_AMOUNT[5], JournalEntry.TransactionType.CREDIT) }; expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD; this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[5], this.REPAYMENT_AMOUNT[5], loanID); this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(5, expected_value, loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry); - System.out.println("Repayment 5 Done ......"); + LOG.info("Repayment 5 Done ......"); } private Integer createLoanProductWithCashBasedAccountingEnabled(final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchRequestsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchRequestsIntegrationTest.java index 09c4cf1fe..d812a5b80 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchRequestsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/BatchRequestsIntegrationTest.java @@ -36,6 +36,8 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Test class for testing the integration of Batch API with custom batch @@ -46,6 +48,7 @@ import org.junit.Test; */ public class BatchRequestsIntegrationTest { + private final static Logger LOG = LoggerFactory.getLogger(BatchRequestsIntegrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -88,7 +91,7 @@ public class BatchRequestsIntegrationTest { for (Integer i = 0; i < clientsCount; i++) { clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec); groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString()); - System.out.println("client " + clientIDs[i] + " has been added to the group " + groupID); + LOG.info("client {} has been added to the group {}",clientIDs[i] , groupID); } // Generate a random count of number of new loan products to be created diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java index bae657e19..a1c914311 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/CenterIntegrationTest.java @@ -38,9 +38,11 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CenterIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(CenterIntegrationTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; @@ -198,7 +200,7 @@ public class CenterIntegrationTest { public void testStaffAssignmentDuringCenterCreation() { final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); - System.out.println("--------------creating first staff with id-------------" + staffId); + LOG.info("--------------creating first staff with id------------- {}" , staffId); Assert.assertNotNull(staffId); final int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId); @@ -212,7 +214,7 @@ public class CenterIntegrationTest { @Test public void testAssignStaffToCenter() { final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); - System.out.println("--------------creating first staff with id-------------" + staffId); + LOG.info("--------------creating first staff with id------------- {}" , staffId); Assert.assertNotNull(staffId); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); @@ -233,7 +235,7 @@ public class CenterIntegrationTest { @Test public void testUnassignStaffToCenter() { final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec); - System.out.println("--------------creating first staff with id-------------" + staffId); + LOG.info("--------------creating first staff with id------------- {}" , staffId); Assert.assertNotNull(staffId); final Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec); 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 ea9620ad2..c4a01ea08 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 @@ -59,6 +59,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Client Loan Integration Test for checking Loan Application Repayments @@ -67,7 +70,7 @@ import org.junit.Test; */ @SuppressWarnings({ "rawtypes", "unchecked" }) public class ClientLoanIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(ClientLoanIntegrationTest.class); public static final String MINIMUM_OPENING_BALANCE = "1000.0"; public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; @@ -90,7 +93,8 @@ public class ClientLoanIntegrationTest { public void setup() { Utils.initializeRESTAssured(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.requestSpec.header("Authorization", + "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); @@ -104,8 +108,8 @@ public class ClientLoanIntegrationTest { ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProduct(false, NONE); final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00"); - final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); + final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); } @@ -118,13 +122,14 @@ public class ClientLoanIntegrationTest { final Integer loanProductID = createLoanProduct(false, NONE); List charges = new ArrayList<>(); - Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON()); + Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, + ChargesHelper.getLoanDisbursementJSON()); Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1")); addCharges(charges, amountPercentage, "1", null); - Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); + Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); addCharges(charges, amountPlusInterestPercentage, "1", null); Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1")); @@ -136,7 +141,8 @@ public class ClientLoanIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap disbursementDetail = loanSchedule.get(0); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -156,13 +162,17 @@ public class ClientLoanIntegrationTest { validateCharge(flatDisbursement, loanCharges, "100.0", "100.0", "0.0", "0.0"); validateNumberForEqual("352.12", String.valueOf(disbursementDetail.get("feeChargesDue"))); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges) - .get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(flatDisbursement, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges).get("id"), + LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(flatDisbursement, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("150")); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -186,8 +196,8 @@ public class ClientLoanIntegrationTest { validateCharge(flatDisbursement, loanCharges, "150.0", "150.0", "0.0", "0.0"); validateNumberForEqual("570.2", String.valueOf(disbursementDetail.get("feeChargesDue"))); - this.loanTransactionHelper.updateLoan(loanID, - updateLoanJson(clientID, loanProductID, copyChargesForUpdate(loanCharges, flatDisbursement, "1"), null)); + this.loanTransactionHelper.updateLoan(loanID, updateLoanJson(clientID, loanProductID, + copyChargesForUpdate(loanCharges, flatDisbursement, "1"), null)); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -207,7 +217,8 @@ public class ClientLoanIntegrationTest { validateCharge(flatDisbursement, loanCharges, "100.0", "100.0", "0.0", "0.0"); validateNumberForEqual("100.0", String.valueOf(disbursementDetail.get("feeChargesDue"))); - this.loanTransactionHelper.deleteChargesForLoan(loanID, (Integer) getloanCharge(flatDisbursement, loanCharges).get("id")); + this.loanTransactionHelper.deleteChargesForLoan(loanID, + (Integer) getloanCharge(flatDisbursement, loanCharges).get("id")); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); disbursementDetail = loanSchedule.get(0); @@ -228,8 +239,8 @@ public class ClientLoanIntegrationTest { Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1")); addCharges(charges, amountPercentage, "1", null); - Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); + Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); addCharges(charges, amountPlusInterestPercentage, "1", null); Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1")); @@ -241,7 +252,8 @@ public class ClientLoanIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap disbursementDetail = loanSchedule.get(0); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -251,14 +263,14 @@ public class ClientLoanIntegrationTest { validateCharge(amountPlusInterestPercentage, loanCharges, "1.0", "126.06", "0.0", "0.0"); validateNumberForEqual("252.12", String.valueOf(disbursementDetail.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); // DISBURSE loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10000"); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -284,17 +296,18 @@ public class ClientLoanIntegrationTest { Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); Integer flatAccTransfer = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateWithAccountTransferJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); + ChargesHelper.getLoanSpecifiedDueDateWithAccountTransferJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, + "100", false)); - Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, amountPercentage, "1", "29 September 2011"); - Integer amountPlusInterestPercentage = ChargesHelper - .createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, + ChargesHelper.getLoanSpecifiedDueDateJSON( ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentage, "1", "29 September 2011"); - Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1", false)); + Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1", false)); addCharges(charges, interestPercentage, "1", "29 September 2011"); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); @@ -303,7 +316,8 @@ public class ClientLoanIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap firstInstallment = loanSchedule.get(1); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -314,8 +328,8 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("252.12", String.valueOf(firstInstallment.get("feeChargesDue"))); - this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper + .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), "29 September 2011", "100")); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); firstInstallment = loanSchedule.get(1); @@ -323,12 +337,15 @@ public class ClientLoanIntegrationTest { validateCharge(flat, loanCharges, "100.0", "100.0", "0.0", "0.0"); validateNumberForEqual("352.12", String.valueOf(firstInstallment.get("feeChargesDue"))); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), + LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges) - .get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(flat, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("150")); @@ -343,8 +360,8 @@ public class ClientLoanIntegrationTest { final Integer savingsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID, MINIMUM_OPENING_BALANCE); - this.loanTransactionHelper.updateLoan(loanID, - updateLoanJson(clientID, loanProductID, copyChargesForUpdate(loanCharges, null, null), String.valueOf(savingsId))); + this.loanTransactionHelper.updateLoan(loanID, updateLoanJson(clientID, loanProductID, + copyChargesForUpdate(loanCharges, null, null), String.valueOf(savingsId))); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -383,13 +400,13 @@ public class ClientLoanIntegrationTest { Assert.assertEquals(0, loanCharges.size()); validateNumberForEqual("0", String.valueOf(firstInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatAccTransfer), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper + .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatAccTransfer), "29 September 2011", "100")); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); firstInstallment = loanSchedule.get(1); @@ -398,11 +415,11 @@ public class ClientLoanIntegrationTest { // DISBURSE loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(amountPercentage), "29 September 2011", "1")); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper + .getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(amountPercentage), "29 September 2011", "1")); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); firstInstallment = loanSchedule.get(1); @@ -410,7 +427,8 @@ public class ClientLoanIntegrationTest { validateCharge(flatAccTransfer, loanCharges, "100.0", "100.0", "0.0", "0.0"); validateNumberForEqual("200.0", String.valueOf(firstInstallment.get("feeChargesDue"))); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), ""); + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), ""); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); firstInstallment = loanSchedule.get(1); @@ -420,7 +438,8 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("100.0", String.valueOf(firstInstallment.get("feeChargesOutstanding"))); validateNumberForEqual("100.0", String.valueOf(firstInstallment.get("feeChargesWaived"))); - this.loanTransactionHelper.payChargesForLoan(loanID, (Integer) getloanCharge(flatAccTransfer, loanCharges).get("id"), + this.loanTransactionHelper.payChargesForLoan(loanID, + (Integer) getloanCharge(flatAccTransfer, loanCharges).get("id"), LoanTransactionHelper.getPayChargeJSON(SavingsAccountHelper.TRANSACTION_DATE, null)); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -443,17 +462,18 @@ public class ClientLoanIntegrationTest { List charges = new ArrayList<>(); Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); - Integer flatAccTransfer = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentWithAccountTransferJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); + Integer flatAccTransfer = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentWithAccountTransferJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); - Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer amountPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, amountPercentage, "1", "29 September 2011"); Integer amountPlusInterestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); + ChargesHelper.getLoanInstallmentJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentage, "1", "29 September 2011"); - Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1", false)); + Integer interestPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "1", false)); addCharges(charges, interestPercentage, "1", "29 September 2011"); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); @@ -462,7 +482,8 @@ public class ClientLoanIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); loanSchedule.remove(0); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -475,16 +496,19 @@ public class ClientLoanIntegrationTest { Float principalFee = principalDue / 100; Float interestFee = interestDue / 100; Float totalInstallmentFee = (principalFee * 2) + (interestFee * 2); - validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), String.valueOf(installment.get("feeChargesDue"))); + validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), + String.valueOf(installment.get("feeChargesDue"))); totalPerOfAmout = totalPerOfAmout + principalFee; totalPerOfAmoutPlusInt = totalPerOfAmoutPlusInt + principalFee + interestFee; totalPerOfint = totalPerOfint + interestFee; } - validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); - validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", "0.0"); - validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmoutPlusInt), "0.0", + validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); + validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", + "0.0"); + validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", + String.valueOf(totalPerOfAmoutPlusInt), "0.0", "0.0"); this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getInstallmentChargesForLoanAsJSON(String.valueOf(flat), "50")); @@ -500,24 +524,30 @@ public class ClientLoanIntegrationTest { Float principalFee = principalDue / 100; Float interestFee = interestDue / 100; Float totalInstallmentFee = (principalFee * 2) + (interestFee * 2) + 50; - validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), String.valueOf(installment.get("feeChargesDue"))); + validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), + String.valueOf(installment.get("feeChargesDue"))); totalPerOfAmout = totalPerOfAmout + principalFee; totalPerOfAmoutPlusInt = totalPerOfAmoutPlusInt + principalFee + interestFee; totalPerOfint = totalPerOfint + interestFee; } - validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); - validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", "0.0"); - validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmoutPlusInt), "0.0", + validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); + validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", + "0.0"); + validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", + String.valueOf(totalPerOfAmoutPlusInt), "0.0", "0.0"); validateChargeExcludePrecission(flat, loanCharges, "50.0", "200", "0.0", "0.0"); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(interestPercentage, loanCharges).get("id"), + LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); + this.loanTransactionHelper.updateChargesForLoan(loanID, + (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); - this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(amountPlusInterestPercentage, loanCharges) - .get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("2")); this.loanTransactionHelper.updateChargesForLoan(loanID, (Integer) getloanCharge(flat, loanCharges).get("id"), LoanTransactionHelper.getUpdateChargesForLoanAsJSON("100")); @@ -533,22 +563,25 @@ public class ClientLoanIntegrationTest { Float principalFee = principalDue * 2 / 100; Float interestFee = interestDue * 2 / 100; Float totalInstallmentFee = (principalFee * 2) + (interestFee * 2) + 100; - validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), String.valueOf(installment.get("feeChargesDue"))); + validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), + String.valueOf(installment.get("feeChargesDue"))); totalPerOfAmout = totalPerOfAmout + principalFee; totalPerOfAmoutPlusInt = totalPerOfAmoutPlusInt + principalFee + interestFee; totalPerOfint = totalPerOfint + interestFee; } - validateChargeExcludePrecission(amountPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); - validateChargeExcludePrecission(interestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfint), "0.0", "0.0"); - validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmoutPlusInt), "0.0", + validateChargeExcludePrecission(amountPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); + validateChargeExcludePrecission(interestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfint), "0.0", + "0.0"); + validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "2.0", + String.valueOf(totalPerOfAmoutPlusInt), "0.0", "0.0"); validateChargeExcludePrecission(flat, loanCharges, "100.0", "400", "0.0", "0.0"); final Integer savingsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID, MINIMUM_OPENING_BALANCE); - this.loanTransactionHelper.updateLoan(loanID, - updateLoanJson(clientID, loanProductID, copyChargesForUpdate(loanCharges, null, null), String.valueOf(savingsId))); + this.loanTransactionHelper.updateLoan(loanID, updateLoanJson(clientID, loanProductID, + copyChargesForUpdate(loanCharges, null, null), String.valueOf(savingsId))); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -562,16 +595,19 @@ public class ClientLoanIntegrationTest { Float principalFee = principalDue * 2 / 100; Float interestFee = interestDue * 2 / 100; Float totalInstallmentFee = (principalFee * 2) + (interestFee * 2) + 100; - validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), String.valueOf(installment.get("feeChargesDue"))); + validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), + String.valueOf(installment.get("feeChargesDue"))); totalPerOfAmout = totalPerOfAmout + principalFee; totalPerOfAmoutPlusInt = totalPerOfAmoutPlusInt + principalFee + interestFee; totalPerOfint = totalPerOfint + interestFee; } - validateChargeExcludePrecission(amountPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); - validateChargeExcludePrecission(interestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfint), "0.0", "0.0"); - validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmoutPlusInt), "0.0", + validateChargeExcludePrecission(amountPercentage, loanCharges, "2.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); + validateChargeExcludePrecission(interestPercentage, loanCharges, "2.0", String.valueOf(totalPerOfint), "0.0", + "0.0"); + validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "2.0", + String.valueOf(totalPerOfAmoutPlusInt), "0.0", "0.0"); validateChargeExcludePrecission(flat, loanCharges, "100.0", "400", "0.0", "0.0"); this.loanTransactionHelper.updateLoan(loanID, @@ -589,16 +625,19 @@ public class ClientLoanIntegrationTest { Float principalFee = principalDue / 100; Float interestFee = interestDue / 100; Float totalInstallmentFee = (principalFee * 2) + (interestFee * 2); - validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), String.valueOf(installment.get("feeChargesDue"))); + validateNumberForEqualExcludePrecission(String.valueOf(totalInstallmentFee), + String.valueOf(installment.get("feeChargesDue"))); totalPerOfAmout = totalPerOfAmout + principalFee; totalPerOfAmoutPlusInt = totalPerOfAmoutPlusInt + principalFee + interestFee; totalPerOfint = totalPerOfint + interestFee; } - validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); - validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", "0.0"); - validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmoutPlusInt), "0.0", + validateChargeExcludePrecission(amountPercentage, loanCharges, "1.0", String.valueOf(totalPerOfAmout), "0.0", "0.0"); + validateChargeExcludePrecission(interestPercentage, loanCharges, "1.0", String.valueOf(totalPerOfint), "0.0", + "0.0"); + validateChargeExcludePrecission(amountPlusInterestPercentage, loanCharges, "1.0", + String.valueOf(totalPerOfAmoutPlusInt), "0.0", "0.0"); charges.clear(); addCharges(charges, flat, "50", "29 September 2011"); @@ -620,7 +659,7 @@ public class ClientLoanIntegrationTest { validateNumberForEqualExcludePrecission("0", String.valueOf(installment.get("feeChargesDue"))); } - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -637,7 +676,7 @@ public class ClientLoanIntegrationTest { // DISBURSE loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); this.loanTransactionHelper.addChargesForLoan(loanID, @@ -661,10 +700,12 @@ public class ClientLoanIntegrationTest { for (HashMap installment : loanSchedule) { validateNumberForEqualExcludePrecission("150", String.valueOf(installment.get("feeChargesDue"))); if (waivePeriodnum == installment.get("period")) { - validateNumberForEqualExcludePrecission("100.0", String.valueOf(installment.get("feeChargesOutstanding"))); + validateNumberForEqualExcludePrecission("100.0", + String.valueOf(installment.get("feeChargesOutstanding"))); validateNumberForEqualExcludePrecission("50.0", String.valueOf(installment.get("feeChargesWaived"))); } else { - validateNumberForEqualExcludePrecission("150.0", String.valueOf(installment.get("feeChargesOutstanding"))); + validateNumberForEqualExcludePrecission("150.0", + String.valueOf(installment.get("feeChargesOutstanding"))); validateNumberForEqualExcludePrecission("0.0", String.valueOf(installment.get("feeChargesWaived"))); } @@ -673,21 +714,25 @@ public class ClientLoanIntegrationTest { validateChargeExcludePrecission(flat, loanCharges, "50.0", "150", "0.0", "50.0"); Integer payPeriodnum = 2; - this.loanTransactionHelper.payChargesForLoan(loanID, (Integer) getloanCharge(flatAccTransfer, loanCharges).get("id"), - LoanTransactionHelper.getPayChargeJSON(SavingsAccountHelper.TRANSACTION_DATE, String.valueOf(payPeriodnum))); + this.loanTransactionHelper.payChargesForLoan(loanID, + (Integer) getloanCharge(flatAccTransfer, loanCharges).get("id"), LoanTransactionHelper + .getPayChargeJSON(SavingsAccountHelper.TRANSACTION_DATE, String.valueOf(payPeriodnum))); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanSchedule.remove(0); for (HashMap installment : loanSchedule) { validateNumberForEqualExcludePrecission("150", String.valueOf(installment.get("feeChargesDue"))); if (payPeriodnum == installment.get("period")) { - validateNumberForEqualExcludePrecission("50.0", String.valueOf(installment.get("feeChargesOutstanding"))); + validateNumberForEqualExcludePrecission("50.0", + String.valueOf(installment.get("feeChargesOutstanding"))); validateNumberForEqualExcludePrecission("100.0", String.valueOf(installment.get("feeChargesPaid"))); } else if (waivePeriodnum == installment.get("period")) { - validateNumberForEqualExcludePrecission("100.0", String.valueOf(installment.get("feeChargesOutstanding"))); + validateNumberForEqualExcludePrecission("100.0", + String.valueOf(installment.get("feeChargesOutstanding"))); validateNumberForEqualExcludePrecission("50.0", String.valueOf(installment.get("feeChargesWaived"))); } else { - validateNumberForEqualExcludePrecission("150.0", String.valueOf(installment.get("feeChargesOutstanding"))); + validateNumberForEqualExcludePrecission("150.0", + String.valueOf(installment.get("feeChargesOutstanding"))); validateNumberForEqualExcludePrecission("0.0", String.valueOf(installment.get("feeChargesPaid"))); } @@ -709,13 +754,14 @@ public class ClientLoanIntegrationTest { final Integer savingsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID, MINIMUM_OPENING_BALANCE); - final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, savingsId.toString(), "12,000.00"); + final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, savingsId.toString(), + "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -725,8 +771,9 @@ public class ClientLoanIntegrationTest { assertEquals("Verifying opening Balance", balance, summary.get("accountBalance")); // DISBURSE - loanStatusHashMap = this.loanTransactionHelper.disburseLoanToSavings(SavingsAccountHelper.TRANSACTION_DATE, loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + loanStatusHashMap = this.loanTransactionHelper.disburseLoanToSavings(SavingsAccountHelper.TRANSACTION_DATE, + loanID); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); summary = savingsAccountHelper.getSavingsSummary(savingsId); @@ -754,25 +801,26 @@ public class ClientLoanIntegrationTest { tranches.add(createTrancheDetail("1 March 2014", "25000")); tranches.add(createTrancheDetail("23 April 2014", "20000")); - final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, null, null, "45,000.00", tranches); + final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, null, null, "45,000.00", + tranches); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 March 2014", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); // DISBURSE first Tranche loanStatusHashMap = this.loanTransactionHelper.disburseLoan("1 March 2014", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // DISBURSE Second Tranche loanStatusHashMap = this.loanTransactionHelper.disburseLoan("23 April 2014", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID); @@ -797,14 +845,14 @@ public class ClientLoanIntegrationTest { tranches.add(createTrancheDetail("1 March 2014", "25000")); tranches.add(createTrancheDetail("23 April 2014", "20000")); - final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, null, savingsId.toString(), "45,000.00", - tranches); + final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, null, savingsId.toString(), + "45,000.00", tranches); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 March 2014", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -815,7 +863,7 @@ public class ClientLoanIntegrationTest { // DISBURSE first Tranche loanStatusHashMap = this.loanTransactionHelper.disburseLoanToSavings("1 March 2014", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); summary = savingsAccountHelper.getSavingsSummary(savingsId); @@ -824,7 +872,7 @@ public class ClientLoanIntegrationTest { // DISBURSE Second Tranche loanStatusHashMap = this.loanTransactionHelper.disburseLoanToSavings("23 April 2014", loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); summary = savingsAccountHelper.getSavingsSummary(savingsId); @@ -841,27 +889,31 @@ public class ClientLoanIntegrationTest { } - private void validateCharge(Integer amountPercentage, final List loanCharges, final String amount, final String outstanding, - String amountPaid, String amountWaived) { + private void validateCharge(Integer amountPercentage, final List loanCharges, final String amount, + final String outstanding, String amountPaid, String amountWaived) { HashMap chargeDetail = getloanCharge(amountPercentage, loanCharges); - Assert.assertTrue(Float.valueOf(amount).compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountOrPercentage")))) == 0); - Assert.assertTrue(Float.valueOf(outstanding).compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountOutstanding")))) == 0); - Assert.assertTrue(Float.valueOf(amountPaid).compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountPaid")))) == 0); - Assert.assertTrue(Float.valueOf(amountWaived).compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountWaived")))) == 0); + Assert.assertTrue(Float.valueOf(amount) + .compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountOrPercentage")))) == 0); + Assert.assertTrue(Float.valueOf(outstanding) + .compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountOutstanding")))) == 0); + Assert.assertTrue(Float.valueOf(amountPaid) + .compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountPaid")))) == 0); + Assert.assertTrue(Float.valueOf(amountWaived) + .compareTo(Float.valueOf(String.valueOf(chargeDetail.get("amountWaived")))) == 0); } - private void validateChargeExcludePrecission(Integer amountPercentage, final List loanCharges, final String amount, - final String outstanding, String amountPaid, String amountWaived) { + private void validateChargeExcludePrecission(Integer amountPercentage, final List loanCharges, + final String amount, final String outstanding, String amountPaid, String amountWaived) { DecimalFormat twoDForm = new DecimalFormat("#"); HashMap chargeDetail = getloanCharge(amountPercentage, loanCharges); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amount))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(String - .valueOf(chargeDetail.get("amountOrPercentage")))))) == 0); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(outstanding))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(String - .valueOf(chargeDetail.get("amountOutstanding")))))) == 0); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amountPaid))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(String - .valueOf(chargeDetail.get("amountPaid")))))) == 0); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amountWaived))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(String - .valueOf(chargeDetail.get("amountWaived")))))) == 0); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amount))).compareTo(Float + .valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountOrPercentage")))))) == 0); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(outstanding))).compareTo(Float + .valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountOutstanding")))))) == 0); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amountPaid))).compareTo( + Float.valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountPaid")))))) == 0); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(amountWaived))).compareTo( + Float.valueOf(twoDForm.format(Float.valueOf(String.valueOf(chargeDetail.get("amountWaived")))))) == 0); } public void validateNumberForEqual(String val, String val2) { @@ -869,16 +921,19 @@ public class ClientLoanIntegrationTest { } public void validateNumberForEqualWithMsg(String msg, String val, String val2) { - Assert.assertTrue(msg + "expected " + val + " but was " + val2, Float.valueOf(val).compareTo(Float.valueOf(val2)) == 0); + Assert.assertTrue(msg + "expected " + val + " but was " + val2, + Float.valueOf(val).compareTo(Float.valueOf(val2)) == 0); } public void validateNumberForEqualExcludePrecission(String val, String val2) { DecimalFormat twoDForm = new DecimalFormat("#"); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))) + .compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); } - private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, + final Account... accounts) { + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() // .withPrincipal("12,000.00") // .withNumberOfRepayments("4") // @@ -897,8 +952,9 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanProductId(loanProductJSON); } - private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, + final String repaymentStrategy) { + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("10000000.00") // .withNumberOfRepayments("24") // @@ -913,9 +969,9 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanProductId(loanProductJSON); } - private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy, - final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, + final String repaymentStrategy, final String accountingRule, final Account... accounts) { + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("10000000.00") // .withNumberOfRepayments("24") // @@ -926,12 +982,14 @@ public class ClientLoanIntegrationTest { .withRepaymentStrategy(repaymentStrategy) // .withAmortizationTypeAsEqualPrincipalPayment() // .withInterestTypeAsDecliningBalance() // - .currencyDetails(digitsAfterDecimal, inMultiplesOf).withAccounting(accountingRule, accounts).build(null); + .currencyDetails(digitsAfterDecimal, inMultiplesOf).withAccounting(accountingRule, accounts) + .build(null); return this.loanTransactionHelper.getLoanProductId(loanProductJSON); } - private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, + String graceOnPrincipalPayment) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000000.00") // .withLoanTermFrequency("24") // @@ -951,7 +1009,7 @@ public class ClientLoanIntegrationTest { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, List charges, final String savingsId, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // @@ -969,9 +1027,9 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } - private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, List charges, - final String savingsId, String principal, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, + List charges, final String savingsId, String principal, List tranches) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // @@ -991,8 +1049,9 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } - private String updateLoanJson(final Integer clientID, final Integer loanProductID, List charges, String savingsId) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private String updateLoanJson(final Integer clientID, final Integer loanProductID, List charges, + String savingsId) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10,000.00") // .withLoanTermFrequency("4") // @@ -1010,9 +1069,9 @@ public class ClientLoanIntegrationTest { return loanApplicationJSON; } - private Integer applyForLoanApplicationWithPaymentStrategy(final Integer clientID, final Integer loanProductID, List charges, - final String savingsId, String principal, final String repaymentStrategy) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplicationWithPaymentStrategy(final Integer clientID, final Integer loanProductID, + List charges, final String savingsId, String principal, final String repaymentStrategy) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // @@ -1031,9 +1090,10 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } - private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, final Integer loanProductID, - List charges, final String savingsId, String principal, final String repaymentStrategy, final int month) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplicationWithPaymentStrategyAndPastMonth(final Integer clientID, + final Integer loanProductID, List charges, final String savingsId, String principal, + final String repaymentStrategy, final int month) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); Calendar fourMonthsfromNowCalendar = Calendar.getInstance(Utils.getTimeZoneOfTenant()); fourMonthsfromNowCalendar.add(Calendar.MONTH, month); @@ -1059,122 +1119,180 @@ public class ClientLoanIntegrationTest { } private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule) { - System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); + LOG.info( + "--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); - assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 20)), loanSchedule.get(1) - .get("dueDate")); - assertEquals("Checking for Principal Due for 1st Month", Float.valueOf("2911.49"), loanSchedule.get(1).get("principalOriginalDue")); - assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("240.00"), loanSchedule.get(1).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 20)), + loanSchedule.get(1).get("dueDate")); + assertEquals("Checking for Principal Due for 1st Month", Float.valueOf("2911.49"), + loanSchedule.get(1).get("principalOriginalDue")); + assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("240.00"), + loanSchedule.get(1).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 20)), loanSchedule.get(2) - .get("dueDate")); - assertEquals("Checking for Principal Due for 2nd Month", Float.valueOf("2969.72"), loanSchedule.get(2).get("principalDue")); - assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("181.77"), loanSchedule.get(2).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 20)), + loanSchedule.get(2).get("dueDate")); + assertEquals("Checking for Principal Due for 2nd Month", Float.valueOf("2969.72"), + loanSchedule.get(2).get("principalDue")); + assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("181.77"), + loanSchedule.get(2).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 20)), loanSchedule.get(3) - .get("dueDate")); - assertEquals("Checking for Principal Due for 3rd Month", Float.valueOf("3029.11"), loanSchedule.get(3).get("principalDue")); - assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("122.38"), loanSchedule.get(3).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 20)), + loanSchedule.get(3).get("dueDate")); + assertEquals("Checking for Principal Due for 3rd Month", Float.valueOf("3029.11"), + loanSchedule.get(3).get("principalDue")); + assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("122.38"), + loanSchedule.get(3).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 20)), loanSchedule.get(4).get("dueDate")); - assertEquals("Checking for Principal Due for 4th Month", Float.valueOf("3089.68"), loanSchedule.get(4).get("principalDue")); - assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("61.79"), loanSchedule.get(4).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 20)), + loanSchedule.get(4).get("dueDate")); + assertEquals("Checking for Principal Due for 4th Month", Float.valueOf("3089.68"), + loanSchedule.get(4).get("principalDue")); + assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("61.79"), + loanSchedule.get(4).get("interestOriginalDue")); } private void verifyLoanRepaymentScheduleForEqualPrincipal(final ArrayList loanSchedule) { - System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); + LOG.info( + "--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); - assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2014, 7, 2)), loanSchedule.get(1).get("dueDate")); - assertEquals("Checking for Principal Due for 1st Month", Float.valueOf("416700"), loanSchedule.get(1).get("principalOriginalDue")); - assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("200000"), loanSchedule.get(1).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2014, 7, 2)), + loanSchedule.get(1).get("dueDate")); + assertEquals("Checking for Principal Due for 1st Month", Float.valueOf("416700"), + loanSchedule.get(1).get("principalOriginalDue")); + assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("200000"), + loanSchedule.get(1).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2014, 8, 2)), loanSchedule.get(2).get("dueDate")); - assertEquals("Checking for Principal Due for 2nd Month", Float.valueOf("416700"), loanSchedule.get(2).get("principalDue")); - assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("191700"), loanSchedule.get(2).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2014, 8, 2)), + loanSchedule.get(2).get("dueDate")); + assertEquals("Checking for Principal Due for 2nd Month", Float.valueOf("416700"), + loanSchedule.get(2).get("principalDue")); + assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("191700"), + loanSchedule.get(2).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2014, 9, 2)), loanSchedule.get(3).get("dueDate")); - assertEquals("Checking for Principal Due for 3rd Month", Float.valueOf("416700"), loanSchedule.get(3).get("principalDue")); - assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("183300"), loanSchedule.get(3).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2014, 9, 2)), + loanSchedule.get(3).get("dueDate")); + assertEquals("Checking for Principal Due for 3rd Month", Float.valueOf("416700"), + loanSchedule.get(3).get("principalDue")); + assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("183300"), + loanSchedule.get(3).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2014, 10, 2)), loanSchedule.get(4).get("dueDate")); - assertEquals("Checking for Principal Due for 4th Month", Float.valueOf("416700"), loanSchedule.get(4).get("principalDue")); - assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("175000"), loanSchedule.get(4).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2014, 10, 2)), + loanSchedule.get(4).get("dueDate")); + assertEquals("Checking for Principal Due for 4th Month", Float.valueOf("416700"), + loanSchedule.get(4).get("principalDue")); + assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("175000"), + loanSchedule.get(4).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 5th Month", new ArrayList<>(Arrays.asList(2014, 11, 2)), loanSchedule.get(5).get("dueDate")); - assertEquals("Checking for Principal Due for 5th Month", Float.valueOf("416700"), loanSchedule.get(5).get("principalDue")); - assertEquals("Checking for Interest Due for 5th Month", Float.valueOf("166700"), loanSchedule.get(5).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 5th Month", new ArrayList<>(Arrays.asList(2014, 11, 2)), + loanSchedule.get(5).get("dueDate")); + assertEquals("Checking for Principal Due for 5th Month", Float.valueOf("416700"), + loanSchedule.get(5).get("principalDue")); + assertEquals("Checking for Interest Due for 5th Month", Float.valueOf("166700"), + loanSchedule.get(5).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 6th Month", new ArrayList<>(Arrays.asList(2014, 12, 2)), loanSchedule.get(6).get("dueDate")); - assertEquals("Checking for Principal Due for 6th Month", Float.valueOf("416700"), loanSchedule.get(6).get("principalDue")); - assertEquals("Checking for Interest Due for 6th Month", Float.valueOf("158300"), loanSchedule.get(6).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 6th Month", new ArrayList<>(Arrays.asList(2014, 12, 2)), + loanSchedule.get(6).get("dueDate")); + assertEquals("Checking for Principal Due for 6th Month", Float.valueOf("416700"), + loanSchedule.get(6).get("principalDue")); + assertEquals("Checking for Interest Due for 6th Month", Float.valueOf("158300"), + loanSchedule.get(6).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 10th Month", new ArrayList<>(Arrays.asList(2015, 4, 2)), loanSchedule.get(10) - .get("dueDate")); - assertEquals("Checking for Principal Due for 10th Month", Float.valueOf("416700"), loanSchedule.get(10).get("principalDue")); - assertEquals("Checking for Interest Due for 10th Month", Float.valueOf("125000"), loanSchedule.get(10).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 10th Month", new ArrayList<>(Arrays.asList(2015, 4, 2)), + loanSchedule.get(10).get("dueDate")); + assertEquals("Checking for Principal Due for 10th Month", Float.valueOf("416700"), + loanSchedule.get(10).get("principalDue")); + assertEquals("Checking for Interest Due for 10th Month", Float.valueOf("125000"), + loanSchedule.get(10).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 20th Month", new ArrayList<>(Arrays.asList(2016, 2, 2)), loanSchedule.get(20) - .get("dueDate")); - assertEquals("Checking for Principal Due for 20th Month", Float.valueOf("416700"), loanSchedule.get(20).get("principalDue")); - assertEquals("Checking for Interest Due for 20th Month", Float.valueOf("41700"), loanSchedule.get(20).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 20th Month", new ArrayList<>(Arrays.asList(2016, 2, 2)), + loanSchedule.get(20).get("dueDate")); + assertEquals("Checking for Principal Due for 20th Month", Float.valueOf("416700"), + loanSchedule.get(20).get("principalDue")); + assertEquals("Checking for Interest Due for 20th Month", Float.valueOf("41700"), + loanSchedule.get(20).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 24th Month", new ArrayList<>(Arrays.asList(2016, 6, 2)), loanSchedule.get(24) - .get("dueDate")); - assertEquals("Checking for Principal Due for 24th Month", Float.valueOf("415900"), loanSchedule.get(24).get("principalDue")); - assertEquals("Checking for Interest Due for 24th Month", Float.valueOf("8300"), loanSchedule.get(24).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 24th Month", new ArrayList<>(Arrays.asList(2016, 6, 2)), + loanSchedule.get(24).get("dueDate")); + assertEquals("Checking for Principal Due for 24th Month", Float.valueOf("415900"), + loanSchedule.get(24).get("principalDue")); + assertEquals("Checking for Interest Due for 24th Month", Float.valueOf("8300"), + loanSchedule.get(24).get("interestOriginalDue")); } private void verifyLoanRepaymentScheduleForEqualPrincipalWithGrace(final ArrayList loanSchedule) { - System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); + LOG.info( + "--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); - assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2014, 7, 2)), loanSchedule.get(1).get("dueDate")); + assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2014, 7, 2)), + loanSchedule.get(1).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for 1st Month", "0.0", String.valueOf(loanSchedule.get(1).get("principalOriginalDue"))); - assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("200000"), loanSchedule.get(1).get("interestOriginalDue")); + assertEquals("Checking for Interest Due for 1st Month", Float.valueOf("200000"), + loanSchedule.get(1).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2014, 8, 2)), loanSchedule.get(2).get("dueDate")); + assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2014, 8, 2)), + loanSchedule.get(2).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for 2nd Month", "0.0", String.valueOf(loanSchedule.get(2).get("principalOriginalDue"))); - assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("200000"), loanSchedule.get(2).get("interestOriginalDue")); + assertEquals("Checking for Interest Due for 2nd Month", Float.valueOf("200000"), + loanSchedule.get(2).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2014, 9, 2)), loanSchedule.get(3).get("dueDate")); + assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2014, 9, 2)), + loanSchedule.get(3).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for 3rd Month", "0.0", String.valueOf(loanSchedule.get(3).get("principalDue"))); - assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("200000"), loanSchedule.get(3).get("interestOriginalDue")); + assertEquals("Checking for Interest Due for 3rd Month", Float.valueOf("200000"), + loanSchedule.get(3).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2014, 10, 2)), loanSchedule.get(4).get("dueDate")); + assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2014, 10, 2)), + loanSchedule.get(4).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for 4th Month", "0", String.valueOf(loanSchedule.get(4).get("principalDue"))); - assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("200000"), loanSchedule.get(4).get("interestOriginalDue")); + assertEquals("Checking for Interest Due for 4th Month", Float.valueOf("200000"), + loanSchedule.get(4).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 5th Month", new ArrayList<>(Arrays.asList(2014, 11, 2)), loanSchedule.get(5).get("dueDate")); + assertEquals("Checking for Due Date for 5th Month", new ArrayList<>(Arrays.asList(2014, 11, 2)), + loanSchedule.get(5).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for 5th Month", "0", String.valueOf(loanSchedule.get(5).get("principalDue"))); - assertEquals("Checking for Interest Due for 5th Month", Float.valueOf("200000"), loanSchedule.get(5).get("interestOriginalDue")); + assertEquals("Checking for Interest Due for 5th Month", Float.valueOf("200000"), + loanSchedule.get(5).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 6th Month", new ArrayList<>(Arrays.asList(2014, 12, 2)), loanSchedule.get(6).get("dueDate")); - assertEquals("Checking for Principal Due for 6th Month", Float.valueOf("526300"), loanSchedule.get(6).get("principalDue")); - assertEquals("Checking for Interest Due for 6th Month", Float.valueOf("200000"), loanSchedule.get(6).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 6th Month", new ArrayList<>(Arrays.asList(2014, 12, 2)), + loanSchedule.get(6).get("dueDate")); + assertEquals("Checking for Principal Due for 6th Month", Float.valueOf("526300"), + loanSchedule.get(6).get("principalDue")); + assertEquals("Checking for Interest Due for 6th Month", Float.valueOf("200000"), + loanSchedule.get(6).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 7th Month", new ArrayList<>(Arrays.asList(2015, 1, 2)), loanSchedule.get(7).get("dueDate")); - assertEquals("Checking for Principal Due for 7th Month", Float.valueOf("526300"), loanSchedule.get(7).get("principalDue")); - assertEquals("Checking for Interest Due for 7th Month", Float.valueOf("189500"), loanSchedule.get(7).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 7th Month", new ArrayList<>(Arrays.asList(2015, 1, 2)), + loanSchedule.get(7).get("dueDate")); + assertEquals("Checking for Principal Due for 7th Month", Float.valueOf("526300"), + loanSchedule.get(7).get("principalDue")); + assertEquals("Checking for Interest Due for 7th Month", Float.valueOf("189500"), + loanSchedule.get(7).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 10th Month", new ArrayList<>(Arrays.asList(2015, 4, 2)), loanSchedule.get(10) - .get("dueDate")); - assertEquals("Checking for Principal Due for 10th Month", Float.valueOf("526300"), loanSchedule.get(10).get("principalDue")); - assertEquals("Checking for Interest Due for 10th Month", Float.valueOf("157900"), loanSchedule.get(10).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 10th Month", new ArrayList<>(Arrays.asList(2015, 4, 2)), + loanSchedule.get(10).get("dueDate")); + assertEquals("Checking for Principal Due for 10th Month", Float.valueOf("526300"), + loanSchedule.get(10).get("principalDue")); + assertEquals("Checking for Interest Due for 10th Month", Float.valueOf("157900"), + loanSchedule.get(10).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 20th Month", new ArrayList<>(Arrays.asList(2016, 2, 2)), loanSchedule.get(20) - .get("dueDate")); - assertEquals("Checking for Principal Due for 20th Month", Float.valueOf("526300"), loanSchedule.get(20).get("principalDue")); - assertEquals("Checking for Interest Due for 20th Month", Float.valueOf("52600"), loanSchedule.get(20).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 20th Month", new ArrayList<>(Arrays.asList(2016, 2, 2)), + loanSchedule.get(20).get("dueDate")); + assertEquals("Checking for Principal Due for 20th Month", Float.valueOf("526300"), + loanSchedule.get(20).get("principalDue")); + assertEquals("Checking for Interest Due for 20th Month", Float.valueOf("52600"), + loanSchedule.get(20).get("interestOriginalDue")); - assertEquals("Checking for Due Date for 24th Month", new ArrayList<>(Arrays.asList(2016, 6, 2)), loanSchedule.get(24) - .get("dueDate")); - assertEquals("Checking for Principal Due for 24th Month", Float.valueOf("526600"), loanSchedule.get(24).get("principalDue")); - assertEquals("Checking for Interest Due for 24th Month", Float.valueOf("10500"), loanSchedule.get(24).get("interestOriginalDue")); + assertEquals("Checking for Due Date for 24th Month", new ArrayList<>(Arrays.asList(2016, 6, 2)), + loanSchedule.get(24).get("dueDate")); + assertEquals("Checking for Principal Due for 24th Month", Float.valueOf("526600"), + loanSchedule.get(24).get("principalDue")); + assertEquals("Checking for Interest Due for 24th Month", Float.valueOf("10500"), + loanSchedule.get(24).get("interestOriginalDue")); } @@ -1236,8 +1354,8 @@ public class ClientLoanIntegrationTest { } /*** - * Test case for checking CashBasedAccounting functionality adding charges - * with calculation type flat + * Test case for checking CashBasedAccounting functionality adding charges with + * calculation type flat */ @Test public void loanWithFlatCahargesAndCashBasedAccountingEnabled() { @@ -1248,7 +1366,8 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); - Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON()); + Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, + ChargesHelper.getLoanDisbursementJSON()); addCharges(charges, flatDisbursement, "100", null); Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); @@ -1262,13 +1381,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, + overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1288,26 +1409,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("50.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatDisbursement, loanCharges, "100", "0.00", "100.0", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3301.49"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1315,39 +1438,41 @@ public class ClientLoanIntegrationTest { validateCharge(flatSpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); validateCharge(flatInstallmentFee, loanCharges, "50", "150.00", "50.0", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2911.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2911.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("150.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240.00"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatSpecifiedDueDate), "29 October 2011", "100")); + new JournalEntry(Float.valueOf("150.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240.00"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate), + "29 October 2011", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("150.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatInstallmentFee, loanCharges, "50", "100.00", "50.0", "50.0"); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3251.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2969.72"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2969.72"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("181.77"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("181.77"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -1356,8 +1481,9 @@ public class ClientLoanIntegrationTest { Integer flatPenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatPenaltySpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); @@ -1367,33 +1493,35 @@ public class ClientLoanIntegrationTest { secondInstallment = loanSchedule.get(2); validateNumberForEqual("100", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2811.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2811.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("150.00"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("150.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3129.11"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3129.11"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("50.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("122.38"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); + new JournalEntry(Float.valueOf("50.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("122.38"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("100", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3239.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("100"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("100"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.DEBIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); @@ -1402,18 +1530,18 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3139.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3139.68"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3139.68"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3089.68"), - JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry( - Float.valueOf("50.00"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3139.68"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3089.68"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", + new JournalEntry(Float.valueOf("50.00"), JournalEntry.TransactionType.CREDIT)); } /*** - * Test case for checking CashBasedAccounting functionality adding charges - * with calculation type percentage of amount + * Test case for checking CashBasedAccounting functionality adding charges with + * calculation type percentage of amount */ @Test public void loanWithCahargesOfTypeAmountPercentageAndCashBasedAccountingEnabled() { @@ -1428,12 +1556,12 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1")); addCharges(charges, percentageDisbursementCharge, "1", null); - Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29 September 2011"); - Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -1441,13 +1569,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, + overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1467,26 +1597,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("29.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0", "120.00", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3300.60"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1494,49 +1626,52 @@ public class ClientLoanIntegrationTest { validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "120.0", "0.0"); validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89", "29.11", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2911.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2911.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("149.11"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240.00"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); + new JournalEntry(Float.valueOf("149.11"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240.00"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("149.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentageInstallmentFee, loanCharges, "1", "61.19", "29.11", "29.70"); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3271.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2969.72"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2969.72"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("181.77"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("181.77"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); + Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentagePenaltySpecifiedDueDate, loanCharges, "1", "0.00", "120.0", "0.0"); @@ -1546,33 +1681,35 @@ public class ClientLoanIntegrationTest { secondInstallment = loanSchedule.get(2); validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2791.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2791.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("149.11"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("149.11"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.78"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3149.11"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3149.11"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("30.29"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("122.38"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); + new JournalEntry(Float.valueOf("30.29"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("122.38"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3240.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); @@ -1581,18 +1718,18 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3120.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3120.58"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3120.58"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3089.68"), - JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry( - Float.valueOf("30.90"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3120.58"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3089.68"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", + new JournalEntry(Float.valueOf("30.90"), JournalEntry.TransactionType.CREDIT)); } /*** - * Test case for checking CashBasedAccounting functionality adding charges - * with calculation type percentage of amount plus interest + * Test case for checking CashBasedAccounting functionality adding charges with + * calculation type percentage of amount plus interest */ @Test public void loanWithCahargesOfTypeAmountPlusInterestPercentageAndCashBasedAccountingEnabled() { @@ -1604,16 +1741,18 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); + ChargesHelper.getLoanDisbursementJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null); - Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper - .createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentageSpecifiedDueDateCharge, "1", "29 September 2011"); Integer amountPlusInterestPercentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); + ChargesHelper.getLoanInstallmentJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -1621,13 +1760,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, CASH_BASED, assetAccount, incomeAccount, expenseAccount, + overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1647,26 +1788,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("31.51", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(amountPlusInterestPercentageDisbursementCharge, loanCharges, "1", "0.0", "126.06", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3309.06"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1674,14 +1817,13 @@ public class ClientLoanIntegrationTest { validateCharge(amountPlusInterestPercentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "126.06", "0.0"); validateCharge(amountPlusInterestPercentageInstallmentFee, loanCharges, "1", "94.53", "31.51", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2911.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2911.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("157.57"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240.00"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + new JournalEntry(Float.valueOf("157.57"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240.00"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); @@ -1696,30 +1838,30 @@ public class ClientLoanIntegrationTest { loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(amountPlusInterestPercentageInstallmentFee, loanCharges, "1", "63.02", "31.51", "31.51"); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3277.55"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2969.72"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2969.72"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("181.77"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("181.77"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); @@ -1731,22 +1873,23 @@ public class ClientLoanIntegrationTest { secondInstallment = loanSchedule.get(2); validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2791.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2791.49"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 October 2011", - new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("157.57"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("157.57"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3303"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry(Float.valueOf("3303"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3149.11"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3149.11"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 November 2011", - new JournalEntry(Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("122.38"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + new JournalEntry(Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("122.38"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); @@ -1755,10 +1898,10 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3241.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT)); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); @@ -1767,18 +1910,18 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3121.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3121.19"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3121.19"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3089.68"), - JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", new JournalEntry( - Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3121.19"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3089.68"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 January 2012", + new JournalEntry(Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT)); } /*** - * Test case for checking AccuralUpfrontAccounting functionality adding - * charges with calculation type flat + * Test case for checking AccuralUpfrontAccounting functionality adding charges + * with calculation type flat */ @Test public void loanWithFlatCahargesAndUpfrontAccrualAccountingEnabled() { @@ -1789,7 +1932,8 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); - Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON()); + Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, + ChargesHelper.getLoanDisbursementJSON()); addCharges(charges, flatDisbursement, "100", null); Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); @@ -1803,14 +1947,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1829,28 +1974,31 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("50.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("200.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", - new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("100.00"), - JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("200.00"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatSpecifiedDueDate), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate), + "29 September 2011", "100")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1862,7 +2010,7 @@ public class ClientLoanIntegrationTest { this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "29 September 2011", new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT)); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3301.49"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -1870,41 +2018,43 @@ public class ClientLoanIntegrationTest { validateCharge(flatSpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); validateCharge(flatInstallmentFee, loanCharges, "50", "150.00", "50.0", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatSpecifiedDueDate), "29 October 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate), + "29 October 2011", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("150.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), + LOG.info("----------- Waive installment charge for 2nd installment ---------"); + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatInstallmentFee, loanCharges, "50", "100.00", "50.0", "50.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry(Float.valueOf("50.0"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("50.0"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 November 2011", new JournalEntry(Float.valueOf("50.0"), JournalEntry.TransactionType.DEBIT)); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3251.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3251.49"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -1912,15 +2062,16 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); Integer flatPenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatPenaltySpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); @@ -1931,47 +2082,50 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("100", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("100", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3239.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("100"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("100"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3139.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make over payment for repayment 4 ------------"); + LOG.info("----------Make over payment for repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3220.60"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3220.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3139.68"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3220.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3139.68"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, "20 January 2012", new JournalEntry(Float.valueOf("80.92"), JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap); } /*** - * Test case for checking AccuralUpfrontAccounting functionality adding - * charges with calculation type percentage of amount + * Test case for checking AccuralUpfrontAccounting functionality adding charges + * with calculation type percentage of amount */ @Test public void loanWithCahargesAndUpfrontAccrualAccountingEnabled() { @@ -1986,12 +2140,12 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1")); addCharges(charges, percentageDisbursementCharge, "1", null); - Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29 September 2011"); - Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -1999,14 +2153,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2026,32 +2181,34 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("29.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", - new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("120.00"), - JournalEntry.TransactionType.CREDIT), - new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("120.00"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0", "120.00", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3300.60"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2059,41 +2216,43 @@ public class ClientLoanIntegrationTest { validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "120.0", "0.0"); validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89", "29.11", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3300.60"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("149.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), + LOG.info("----------- Waive installment charge for 2nd installment ---------"); + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentageInstallmentFee, loanCharges, "1", "61.19", "29.11", "29.70"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry(Float.valueOf("29.7"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("29.7"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 November 2011", new JournalEntry(Float.valueOf("29.7"), JournalEntry.TransactionType.DEBIT)); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3271.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3271.49"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -2101,15 +2260,16 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); - Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); + Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentagePenaltySpecifiedDueDate, loanCharges, "1", "0.00", "120.0", "0.0"); @@ -2120,47 +2280,50 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3300.60"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.78"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.78"), - JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); + new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3240.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3120.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make over payment for repayment 4 ------------"); + LOG.info("----------Make over payment for repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3220.58"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3220.58"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3120.58"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3220.58"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3120.58"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, "20 January 2012", new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap); } /*** - * Test case for checking AccuralUpfrontAccounting functionality adding - * charges with calculation type percentage of amount plus interest + * Test case for checking AccuralUpfrontAccounting functionality adding charges + * with calculation type percentage of amount plus interest */ @Test public void loanWithCahargesOfTypeAmountPlusInterestPercentageAndUpfrontAccrualAccountingEnabled() { @@ -2172,15 +2335,17 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); + ChargesHelper.getLoanDisbursementJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null); - Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper - .createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); Integer amountPlusInterestPercentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); + ChargesHelper.getLoanInstallmentJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -2188,14 +2353,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_UPFRONT, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2214,28 +2380,29 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("31.51", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("126.04"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", - new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("126.06"), - JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("605.94"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("126.04"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentageSpecifiedDueDateCharge), "29 September 2011", "1")); @@ -2249,7 +2416,7 @@ public class ClientLoanIntegrationTest { this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "29 September 2011", new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT)); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3309.06"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2257,12 +2424,11 @@ public class ClientLoanIntegrationTest { validateCharge(amountPlusInterestPercentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "126.06", "0.0"); validateCharge(amountPlusInterestPercentageInstallmentFee, loanCharges, "1", "94.53", "31.51", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3309.06"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); @@ -2270,7 +2436,7 @@ public class ClientLoanIntegrationTest { secondInstallment = loanSchedule.get(2); validateNumberForEqual("157.57", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); + LOG.info("----------- Waive installment charge for 2nd installment ---------"); this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(amountPlusInterestPercentageInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); @@ -2278,23 +2444,23 @@ public class ClientLoanIntegrationTest { loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(amountPlusInterestPercentageInstallmentFee, loanCharges, "1", "63.02", "31.51", "31.51"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry( - Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("31.51"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 November 2011", new JournalEntry(Float.valueOf("31.51"), JournalEntry.TransactionType.DEBIT)); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3277.55"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3277.55"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -2302,15 +2468,15 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); - Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); @@ -2323,16 +2489,16 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3309.06"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3303"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry(Float.valueOf("3303"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.CREDIT)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); @@ -2341,30 +2507,32 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3241.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3121.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make over payment for repayment 4 ------------"); + LOG.info("----------Make over payment for repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3221.61"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3221.61"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3121.19"), - JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, "20 January 2012", new JournalEntry(Float.valueOf("100.42"), - JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3221.61"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3121.19"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, "20 January 2012", + new JournalEntry(Float.valueOf("100.42"), JournalEntry.TransactionType.CREDIT)); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap); } /*** - * Test case for checking AccuralPeriodicAccounting functionality adding - * charges with calculation type flat + * Test case for checking AccuralPeriodicAccounting functionality adding charges + * with calculation type flat */ @Test @Ignore // TODO FINERACT-885 @@ -2377,7 +2545,8 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); - Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanDisbursementJSON()); + Integer flatDisbursement = ChargesHelper.createCharges(requestSpec, responseSpec, + ChargesHelper.getLoanDisbursementJSON()); addCharges(charges, flatDisbursement, "100", null); Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); @@ -2391,14 +2560,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2418,26 +2588,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("50.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("100.00"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatDisbursement, loanCharges, "100", "0.00", "100.0", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3301.49"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2445,19 +2617,21 @@ public class ClientLoanIntegrationTest { validateCharge(flatSpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); validateCharge(flatInstallmentFee, loanCharges, "50", "150.00", "50.0", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatSpecifiedDueDate), "29 October 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate), + "29 October 2011", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("150.00", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), + LOG.info("----------- Waive installment charge for 2nd installment ---------"); + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(flatInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2467,9 +2641,8 @@ public class ClientLoanIntegrationTest { * this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, * "20 September 2011", new JournalEntry(Float.valueOf("50.0"), * JournalEntry.TransactionType.CREDIT)); - * this.journalEntryHelper.checkJournalEntryForExpenseAccount - * (expenseAccount, "20 September 2011", new - * JournalEntry(Float.valueOf("50.0"), + * this.journalEntryHelper.checkJournalEntryForExpenseAccount (expenseAccount, + * "20 September 2011", new JournalEntry(Float.valueOf("50.0"), * JournalEntry.TransactionType.DEBIT)); */ final String jobName = "Add Accrual Transactions"; @@ -2483,18 +2656,18 @@ public class ClientLoanIntegrationTest { loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); checkAccrualTransactions(loanSchedule, loanID); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3251.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3251.49"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3251.49"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -2502,15 +2675,16 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); Integer flatPenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "29 September 2011", "100")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(flatPenaltySpecifiedDueDate, loanCharges, "100", "0.00", "100.0", "0.0"); @@ -2521,46 +2695,49 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("100", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.49"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.49"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(flatPenaltySpecifiedDueDate), "10 January 2012", "100")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("100", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3239.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("100"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("100"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3139.68", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3139.68"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3139.68"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3139.68"), - JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3139.68"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3139.68"), JournalEntry.TransactionType.CREDIT)); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } /** - * Test case for checking AccuralPeriodicAccounting functionality adding - * charges with calculation type percentage of amount + * Test case for checking AccuralPeriodicAccounting functionality adding charges + * with calculation type percentage of amount */ @Test @Ignore // TODO FINERACT-885 @@ -2577,12 +2754,12 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1")); addCharges(charges, percentageDisbursementCharge, "1", null); - Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageSpecifiedDueDateCharge, "1", "29 September 2011"); - Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); + Integer percentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", false)); addCharges(charges, percentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -2590,14 +2767,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2617,26 +2795,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("29.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("120.00"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentageDisbursementCharge, loanCharges, "1", "0.0", "120.00", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3300.60"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2644,19 +2824,21 @@ public class ClientLoanIntegrationTest { validateCharge(percentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "120.0", "0.0"); validateCharge(percentageInstallmentFee, loanCharges, "1", "90.89", "29.11", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3300.60"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("149.70", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); - this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), + LOG.info("----------- Waive installment charge for 2nd installment ---------"); + this.loanTransactionHelper.waiveChargesForLoan(loanID, + (Integer) getloanCharge(percentageInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2666,9 +2848,8 @@ public class ClientLoanIntegrationTest { * this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, * "20 September 2011", new JournalEntry(Float.valueOf("29.7"), * JournalEntry.TransactionType.CREDIT)); - * this.journalEntryHelper.checkJournalEntryForExpenseAccount - * (expenseAccount, "20 September 2011", new - * JournalEntry(Float.valueOf("29.7"), + * this.journalEntryHelper.checkJournalEntryForExpenseAccount (expenseAccount, + * "20 September 2011", new JournalEntry(Float.valueOf("29.7"), * JournalEntry.TransactionType.DEBIT)); */ @@ -2683,18 +2864,18 @@ public class ClientLoanIntegrationTest { loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); checkAccrualTransactions(loanSchedule, loanID); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3271.49"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3271.49"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3271.49"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -2702,15 +2883,16 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); - Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); + Integer percentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(percentagePenaltySpecifiedDueDate, loanCharges, "1", "0.00", "120.0", "0.0"); @@ -2721,46 +2903,49 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3300.60"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3300.60"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3301.78"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3301.78"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3301.78"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( - String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + String.valueOf(percentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); HashMap fourthInstallment = loanSchedule.get(4); validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3240.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3120.58", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3120.58"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3120.58"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3120.58"), - JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3120.58"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3120.58"), JournalEntry.TransactionType.CREDIT)); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } /*** - * Test case for checking AccuralPeriodicAccounting functionality adding - * charges with calculation type percentage of amount and interest + * Test case for checking AccuralPeriodicAccounting functionality adding charges + * with calculation type percentage of amount and interest */ @Test @Ignore // TODO FINERACT-885 @@ -2774,16 +2959,18 @@ public class ClientLoanIntegrationTest { // Add charges with payment mode regular List charges = new ArrayList<>(); Integer amountPlusInterestPercentageDisbursementCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); + ChargesHelper.getLoanDisbursementJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1")); addCharges(charges, amountPlusInterestPercentageDisbursementCharge, "1", null); - Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper - .createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + Integer amountPlusInterestPercentageSpecifiedDueDateCharge = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentageSpecifiedDueDateCharge, "1", "29 September 2011"); Integer amountPlusInterestPercentageInstallmentFee = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); + ChargesHelper.getLoanInstallmentJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST, "1", false)); addCharges(charges, amountPlusInterestPercentageInstallmentFee, "1", "29 September 2011"); final Account assetAccount = this.accountHelper.createAssetAccount(); @@ -2791,14 +2978,15 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, expenseAccount, - overpaymentAccount); + final Integer loanProductID = createLoanProduct(false, ACCRUAL_PERIODIC, assetAccount, incomeAccount, + expenseAccount, overpaymentAccount); final Integer loanID = applyForLoanApplication(clientID, loanProductID, charges, null, "12,000.00"); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); List loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2818,26 +3006,28 @@ public class ClientLoanIntegrationTest { HashMap secondInstallment = loanSchedule.get(2); validateNumberForEqual("31.51", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 September 2011", + assetAccountInitialEntry); this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, "20 September 2011", new JournalEntry(Float.valueOf("126.06"), JournalEntry.TransactionType.CREDIT)); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); validateCharge(amountPlusInterestPercentageDisbursementCharge, loanCharges, "1", "0.0", "126.06", "0.0"); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("3309.06"), loanID); loanCharges.clear(); loanCharges = this.loanTransactionHelper.getLoanCharges(loanID); @@ -2845,12 +3035,11 @@ public class ClientLoanIntegrationTest { validateCharge(amountPlusInterestPercentageSpecifiedDueDateCharge, loanCharges, "1", "0.00", "126.06", "0.0"); validateCharge(amountPlusInterestPercentageInstallmentFee, loanCharges, "1", "94.53", "31.51", "0.0"); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3309.06"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentageSpecifiedDueDateCharge), "29 October 2011", "1")); loanSchedule.clear(); @@ -2858,7 +3047,7 @@ public class ClientLoanIntegrationTest { secondInstallment = loanSchedule.get(2); validateNumberForEqual("157.57", String.valueOf(secondInstallment.get("feeChargesDue"))); - System.out.println("----------- Waive installment charge for 2nd installment ---------"); + LOG.info("----------- Waive installment charge for 2nd installment ---------"); this.loanTransactionHelper.waiveChargesForLoan(loanID, (Integer) getloanCharge(amountPlusInterestPercentageInstallmentFee, loanCharges).get("id"), LoanTransactionHelper.getWaiveChargeJSON(String.valueOf(2))); @@ -2870,9 +3059,8 @@ public class ClientLoanIntegrationTest { * this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, * "20 September 2011", new JournalEntry( Float.valueOf("31.51"), * JournalEntry.TransactionType.CREDIT)); - * this.journalEntryHelper.checkJournalEntryForExpenseAccount - * (expenseAccount, "20 September 2011", new - * JournalEntry(Float.valueOf("31.51"), + * this.journalEntryHelper.checkJournalEntryForExpenseAccount (expenseAccount, + * "20 September 2011", new JournalEntry(Float.valueOf("31.51"), * JournalEntry.TransactionType.DEBIT)); */ @@ -2887,18 +3075,18 @@ public class ClientLoanIntegrationTest { loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); checkAccrualTransactions(loanSchedule, loanID); - System.out.println("----------Make repayment 2------------"); + LOG.info("----------Make repayment 2------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3277.55"), loanID); this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", - new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3277.55"), - JournalEntry.TransactionType.CREDIT)); + new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3277.55"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); secondInstallment = loanSchedule.get(2); validateNumberForEqual("0", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); - System.out.println("--------------Waive interest---------------"); + LOG.info("--------------Waive interest---------------"); this.loanTransactionHelper.waiveInterest("20 December 2011", String.valueOf(61.79), loanID); loanSchedule.clear(); @@ -2906,15 +3094,15 @@ public class ClientLoanIntegrationTest { HashMap thirdInstallment = loanSchedule.get(3); validateNumberForEqual("60.59", String.valueOf(thirdInstallment.get("interestOutstanding"))); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 December 2011", + new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.CREDIT)); this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, "20 December 2011", new JournalEntry(Float.valueOf("61.79"), JournalEntry.TransactionType.DEBIT)); - Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + Integer amountPlusInterestPercentagePenaltySpecifiedDueDate = ChargesHelper.createCharges(requestSpec, + responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON( + ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "1", true)); + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "29 September 2011", "1")); loanCharges.clear(); @@ -2927,17 +3115,17 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); // checking the journal entry as applied penalty has been collected - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", new JournalEntry( - Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3309.06"), - JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 October 2011", + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3309.06"), JournalEntry.TransactionType.CREDIT)); - System.out.println("----------Make repayment 3 advance------------"); + LOG.info("----------Make repayment 3 advance------------"); this.loanTransactionHelper.makeRepayment("20 November 2011", Float.valueOf("3303"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", new JournalEntry(Float.valueOf("3303"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 November 2011", + new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3303"), JournalEntry.TransactionType.CREDIT)); - this.loanTransactionHelper.addChargesForLoan( - loanID, + this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( String.valueOf(amountPlusInterestPercentagePenaltySpecifiedDueDate), "10 January 2012", "1")); loanSchedule.clear(); @@ -2946,22 +3134,24 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("120", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3241.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Pay applied penalty ------------"); + LOG.info("----------Pay applied penalty ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("120"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry(Float.valueOf("120"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("120"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); fourthInstallment = loanSchedule.get(4); validateNumberForEqual("0", String.valueOf(fourthInstallment.get("penaltyChargesOutstanding"))); validateNumberForEqual("3121.19", String.valueOf(fourthInstallment.get("totalOutstandingForPeriod"))); - System.out.println("----------Make repayment 4 ------------"); + LOG.info("----------Make repayment 4 ------------"); this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3121.19"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", new JournalEntry( - Float.valueOf("3121.19"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("3121.19"), - JournalEntry.TransactionType.CREDIT)); - loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status"); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, "20 January 2012", + new JournalEntry(Float.valueOf("3121.19"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("3121.19"), JournalEntry.TransactionType.CREDIT)); + loanStatusHashMap = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "status"); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } @@ -2973,8 +3163,8 @@ public class ClientLoanIntegrationTest { ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProduct("100", "0", LoanProductTestBuilder.DEFAULT_STRATEGY); final Integer loanID = applyForLoanApplication(clientID, loanProductID, null); - final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); + final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentScheduleForEqualPrincipal(loanSchedule); } @@ -2987,8 +3177,8 @@ public class ClientLoanIntegrationTest { ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProduct("100", "0", LoanProductTestBuilder.DEFAULT_STRATEGY); final Integer loanID = applyForLoanApplication(clientID, loanProductID, "5"); - final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); + final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); verifyLoanRepaymentScheduleForEqualPrincipalWithGrace(loanSchedule); } @@ -3014,22 +3204,23 @@ public class ClientLoanIntegrationTest { */ final String savingsId = null; final String principal = "12,000.00"; - final Integer loanID = applyForLoanApplicationWithPaymentStrategy(clientID, loanProductID, null, savingsId, principal, - LoanApplicationTestBuilder.RBI_INDIA_STRATEGY); + final Integer loanID = applyForLoanApplicationWithPaymentStrategy(clientID, loanProductID, null, savingsId, + principal, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap firstInstallment = loanSchedule.get(1); validateNumberForEqual("3200", String.valueOf(firstInstallment.get("totalOutstandingForPeriod"))); @@ -3062,18 +3253,17 @@ public class ClientLoanIntegrationTest { loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); /*** - * Verify 2nd and 3rd repayments after making excess payment for - * installment no 2 + * Verify 2nd and 3rd repayments after making excess payment for installment no + * 2 */ secondInstallment = loanSchedule.get(2); validateNumberForEqual("0.00", String.valueOf(secondInstallment.get("totalOutstandingForPeriod"))); /*** - * According to RBI Excess payment should go to principal portion of - * next installment, but as interest recalculation is not implemented, - * it wont make any difference to schedule even though if we made excess - * payment, so excess payments will behave the same as regular payment - * with the excess amount + * According to RBI Excess payment should go to principal portion of next + * installment, but as interest recalculation is not implemented, it wont make + * any difference to schedule even though if we made excess payment, so excess + * payments will behave the same as regular payment with the excess amount */ thirdInstallment = loanSchedule.get(3); validateNumberForEqual("3200", String.valueOf(thirdInstallment.get("totalOutstandingForPeriod"))); @@ -3083,16 +3273,15 @@ public class ClientLoanIntegrationTest { validateNumberForEqual("100.00", String.valueOf(thirdInstallment.get("interestOutstanding"))); /*** - * Make payment with due amount of 3rd installment on 4th installment - * date + * Make payment with due amount of 3rd installment on 4th installment date */ this.loanTransactionHelper.makeRepayment("20 January 2012", Float.valueOf("3200"), loanID); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); /*** - * Verify overdue interests are deducted first and then remaining amount - * for interest portion of due installment + * Verify overdue interests are deducted first and then remaining amount for + * interest portion of due installment */ thirdInstallment = loanSchedule.get(3); HashMap fourthInstallment = loanSchedule.get(4); @@ -3121,22 +3310,27 @@ public class ClientLoanIntegrationTest { final HashMap repayment = loanSchedule.get(i); final ArrayList dueDateAsArray = (ArrayList) repayment.get("dueDate"); - final LocalDate transactionDate = new LocalDate(dueDateAsArray.get(0), dueDateAsArray.get(1), dueDateAsArray.get(2)); + final LocalDate transactionDate = new LocalDate(dueDateAsArray.get(0), dueDateAsArray.get(1), + dueDateAsArray.get(2)); final Float interestPortion = BigDecimal.valueOf(Double.valueOf(repayment.get("interestDue").toString())) .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("interestWaived").toString()))) - .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("interestWrittenOff").toString()))).floatValue(); + .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("interestWrittenOff").toString()))) + .floatValue(); final Float feePortion = BigDecimal.valueOf(Double.valueOf(repayment.get("feeChargesDue").toString())) .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("feeChargesWaived").toString()))) - .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("feeChargesWrittenOff").toString()))).floatValue(); + .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("feeChargesWrittenOff").toString()))) + .floatValue(); - final Float penaltyPortion = BigDecimal.valueOf(Double.valueOf(repayment.get("penaltyChargesDue").toString())) + final Float penaltyPortion = BigDecimal + .valueOf(Double.valueOf(repayment.get("penaltyChargesDue").toString())) .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("penaltyChargesWaived").toString()))) - .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("penaltyChargesWrittenOff").toString()))).floatValue(); + .subtract(BigDecimal.valueOf(Double.valueOf(repayment.get("penaltyChargesWrittenOff").toString()))) + .floatValue(); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(transactionDate, interestPortion, feePortion, penaltyPortion, - loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(transactionDate, interestPortion, feePortion, + penaltyPortion, loanID); } } @@ -3153,20 +3347,21 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, - LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, null); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, null, - LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, null, LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "0.0", "0.0"); @@ -3175,12 +3370,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3261,20 +3456,21 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, - LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, preCloseInterestStrategy, null, - null, null); + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, + preCloseInterestStrategy, null, null, null); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, null, - LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, null, LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -9, true, "2482.76", "46.15", "0.0", "0.0"); @@ -3283,12 +3479,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3340,24 +3536,25 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, - LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, null); List charges = new ArrayList<>(); - Integer installmentCharge = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "10", false)); + Integer installmentCharge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST, "10", false)); addCharges(charges, installmentCharge, "10", null); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, null, - LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, null, LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "4.62", "0.0"); @@ -3366,12 +3563,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "1.16", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3439,20 +3636,23 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails( - LoanProductTestBuilder.RBI_INDIA_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST, + LoanProductTestBuilder.RBI_INDIA_STRATEGY, + LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "1", LOAN_DISBURSEMENT_DATE, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_WEEKLY, "1", LOAN_DISBURSEMENT_DATE, - LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, dayOfWeek, null, dayOfWeek); + LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, dayOfWeek, null, + dayOfWeek); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "0.0", "0.0"); @@ -3462,12 +3662,12 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3481,7 +3681,8 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - loanSchedule = this.loanTransactionHelper.getLoanFutureRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + loanSchedule = this.loanTransactionHelper.getLoanFutureRepaymentSchedule(this.requestSpec, this.responseSpec, + loanID); expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, 0, false, "4965.3", "92.52", "0.0", "0.0"); @@ -3562,8 +3763,8 @@ public class ClientLoanIntegrationTest { List charges = new ArrayList<>(2); Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); - Integer principalPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "2", false)); + Integer principalPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "2", false)); addCharges(charges, flat, "100", LOAN_FLAT_CHARGE_DATE); addCharges(charges, principalPercentage, "2", LOAN_INTEREST_CHARGE_DATE); @@ -3571,21 +3772,23 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails( - LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE, + LoanProductTestBuilder.DEFAULT_STRATEGY, + LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE, LoanProductTestBuilder.RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_WEEKLY, "1", REST_START_DATE, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_WEEKLY, "1", LOAN_DISBURSEMENT_DATE, - LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, compoundingDayOfMonth, compoundingDayOfWeek, - restDayOfMonth, restDayOfWeek); + LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, compoundingDayOfMonth, + compoundingDayOfWeek, restDayOfMonth, restDayOfWeek); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "100.0", "0.0"); @@ -3594,12 +3797,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3695,8 +3898,8 @@ public class ClientLoanIntegrationTest { List charges = new ArrayList<>(2); Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "100", false)); - Integer principalPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, - ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "2", false)); + Integer principalPercentage = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper + .getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT, "2", false)); addCharges(charges, flat, "100", LOAN_FLAT_CHARGE_DATE); addCharges(charges, principalPercentage, "2", LOAN_INTEREST_CHARGE_DATE); @@ -3704,20 +3907,22 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails( - LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE, + LoanProductTestBuilder.DEFAULT_STRATEGY, + LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE, LoanProductTestBuilder.RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_WEEKLY, "1", REST_START_DATE, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, null, null, preCloseInterestStrategy, null, - null, null, restDateOfMonth, restDateOfWeek); + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, null, null, + preCloseInterestStrategy, null, null, null, restDateOfMonth, restDateOfWeek); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, charges); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -9, true, "2482.76", "46.15", "100.0", "0.0"); @@ -3726,12 +3931,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3796,23 +4001,25 @@ public class ClientLoanIntegrationTest { ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final String recalculationCompoundingFrequencyInterval = null; final String recalculationCompoundingFrequencyDate = null; - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE, LoanProductTestBuilder.RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "1", REST_START_DATE, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, recalculationCompoundingFrequencyInterval, - recalculationCompoundingFrequencyDate, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, + recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate, + LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, overdueFeeChargeId.toString(), false, null, null, null, null); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, null); - + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, null); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -2, false, "2482.76", "46.15", "0.0", "0.0"); @@ -3821,12 +4028,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3901,42 +4108,43 @@ public class ClientLoanIntegrationTest { final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); Calendar todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); - System.out.println("Disbursal Date Calendar " + todaysDate.getTime()); + LOG.info("Disbursal Date Calendar {}" , todaysDate.getTime()); todaysDate.add(Calendar.DAY_OF_MONTH, -14); final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime()); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); Account[] accounts = { assetAccount, incomeAccount, expenseAccount, overpaymentAccount }; - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, - LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, accounts, null, null); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, null, - LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, null, LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); - System.out.println("Date during repayment schedule" + todaysDate.getTime()); + LOG.info("Date during repayment schedule {}" , todaysDate.getTime()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "0.0", "0.0"); addRepaymentValues(expectedvalues, todaysDate, 1, false, "2494.22", "34.69", "0.0", "0.0"); addRepaymentValues(expectedvalues, todaysDate, 1, false, "2505.73", "23.18", "0.0", "0.0"); addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -3950,15 +4158,19 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(10000.0f, JournalEntry.TransactionType.CREDIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(10000.0f, JournalEntry.TransactionType.CREDIT), new JournalEntry(10000.0f, JournalEntry.TransactionType.DEBIT), }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, LOAN_DISBURSEMENT_DATE, assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, LOAN_DISBURSEMENT_DATE, + assetAccountInitialEntry); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); String runOndate = dateFormat.format(todaysDate.getTime()); - System.out.println("runOndate : " + runOndate); + LOG.info("runOndate : {}" , runOndate); this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), 46.15f, 0f, 0f, loanID); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 46.15f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), + 46.15f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 46.15f, 0f, 0f, + loanID); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); todaysDate.add(Calendar.DAY_OF_MONTH, -7); @@ -3976,8 +4188,10 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), 46.15f, 0f, 0f, loanID); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 34.69f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), + 46.15f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 34.69f, 0f, 0f, + loanID); HashMap prepayDetail = this.loanTransactionHelper.getPrepayAmount(this.requestSpec, this.responseSpec, loanID); String prepayAmount = String.valueOf(prepayDetail.get("amount")); @@ -3987,8 +4201,10 @@ public class ClientLoanIntegrationTest { loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), 46.15f, 0f, 0f, loanID); - this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 34.69f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant().minusDays(7), + 46.15f, 0f, 0f, loanID); + this.loanTransactionHelper.checkAccrualTransactionForRepayment(Utils.getLocalDateOfTenant(), 34.69f, 0f, 0f, + loanID); } @@ -4006,21 +4222,25 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final Integer loanProductID = createLoanProductWithInterestRecalculationAndCompoundingDetails( - LoanProductTestBuilder.RBI_INDIA_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST, + LoanProductTestBuilder.RBI_INDIA_STRATEGY, + LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST, LoanProductTestBuilder.RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "1", LOAN_DISBURSEMENT_DATE, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "1", LOAN_DISBURSEMENT_DATE, - LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, getDayOfMonth(todaysDate), - getDayOfWeek(todaysDate), getDayOfMonth(todaysDate), getDayOfWeek(todaysDate)); + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "1", + LOAN_DISBURSEMENT_DATE, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, + getDayOfMonth(todaysDate), getDayOfWeek(todaysDate), getDayOfMonth(todaysDate), + getDayOfWeek(todaysDate)); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, + new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "0.0", "0.0"); @@ -4030,12 +4250,12 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -4080,7 +4300,7 @@ public class ClientLoanIntegrationTest { dateFormat.setTimeZone(Utils.getTimeZoneOfTenant()); Calendar todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); - System.out.println("----timeeeeeeeeeeeeee------>" + dateFormat.format(todaysDate.getTime())); + LOG.info("----timeeeeeeeeeeeeee------> {}" , dateFormat.format(todaysDate.getTime())); todaysDate.add(Calendar.DAY_OF_MONTH, -14); final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime()); @@ -4088,22 +4308,26 @@ public class ClientLoanIntegrationTest { ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); final String recalculationCompoundingFrequencyInterval = null; final String recalculationCompoundingFrequencyDate = null; - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.RBI_INDIA_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_INTEREST, LoanProductTestBuilder.RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS, LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_DAILY, "1", LOAN_DISBURSEMENT_DATE, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, recalculationCompoundingFrequencyInterval, - recalculationCompoundingFrequencyDate, LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, - true, null, null, getDayOfMonth(todaysDate), getDayOfWeek(todaysDate)); + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, + recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate, + LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, null, null, true, null, null, + getDayOfMonth(todaysDate), getDayOfWeek(todaysDate)); - final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE, - LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, new ArrayList(0)); + final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, + LOAN_DISBURSEMENT_DATE, LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.RBI_INDIA_STRATEGY, + new ArrayList(0)); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); addRepaymentValues(expectedvalues, todaysDate, -1, false, "2482.76", "46.15", "0.0", "0.0"); @@ -4113,12 +4337,12 @@ public class ClientLoanIntegrationTest { verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -4178,19 +4402,22 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.DEFAULT_STRATEGY, - LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, + final Integer loanProductID = createLoanProductWithInterestRecalculation( + LoanProductTestBuilder.DEFAULT_STRATEGY, LoanProductTestBuilder.RECALCULATION_COMPOUNDING_METHOD_NONE, LoanProductTestBuilder.RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN, - LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, preCloseStrategy, null, null, null); + LoanProductTestBuilder.RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD, "0", null, + preCloseStrategy, null, null, null); final Integer loanID = applyForLoanApplicationForInterestRecalculationWithMoratorium(clientID, loanProductID, - LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0), "1", null); + LOAN_DISBURSEMENT_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, new ArrayList(0), "1", + null); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); List> expectedvalues = new ArrayList<>(); todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); todaysDate.add(Calendar.DAY_OF_MONTH, -1); @@ -4200,12 +4427,12 @@ public class ClientLoanIntegrationTest { addRepaymentValues(expectedvalues, todaysDate, 1, false, "2517.29", "11.62", "0.0", "0.0"); verifyLoanRepaymentSchedule(loanSchedule, expectedvalues); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -4230,15 +4457,16 @@ public class ClientLoanIntegrationTest { LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap); } - private void addRepaymentValues(List> expectedvalues, Calendar todaysDate, int addPeriod, boolean isAddDays, - String principalDue, String interestDue, String feeChargesDue, String penaltyChargesDue) { + private void addRepaymentValues(List> expectedvalues, Calendar todaysDate, int addPeriod, + boolean isAddDays, String principalDue, String interestDue, String feeChargesDue, + String penaltyChargesDue) { Map values = new HashMap<>(3); if (isAddDays) { values.put("dueDate", getDateAsArray(todaysDate, addPeriod)); } else { values.put("dueDate", getDateAsArray(todaysDate, addPeriod * 7)); } - System.out.println("Updated date " + values.get("dueDate")); + LOG.info("Updated date {}" , values.get("dueDate")); values.put("principalDue", principalDue); values.put("interestDue", interestDue); values.put("feeChargesDue", feeChargesDue); @@ -4259,8 +4487,9 @@ public class ClientLoanIntegrationTest { private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, final String interestRecalculationCompoundingMethod, final String rescheduleStrategyMethod, final String recalculationRestFrequencyType, final String recalculationRestFrequencyInterval, - final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts, - final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { + final String recalculationRestFrequencyDate, final String preCloseInterestCalculationStrategy, + final Account[] accounts, final Integer recalculationRestFrequencyOnDayType, + final Integer recalculationRestFrequencyDayOfWeekType) { final String recalculationCompoundingFrequencyType = null; final String recalculationCompoundingFrequencyInterval = null; final String recalculationCompoundingFrequencyDate = null; @@ -4268,10 +4497,11 @@ public class ClientLoanIntegrationTest { final Integer recalculationCompoundingFrequencyDayOfWeekType = null; return createLoanProductWithInterestRecalculation(repaymentStrategy, interestRecalculationCompoundingMethod, rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval, - recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, - recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, - recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, - recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType); + recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, + recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate, + preCloseInterestCalculationStrategy, accounts, null, false, recalculationCompoundingFrequencyOnDayType, + recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType, + recalculationRestFrequencyDayOfWeekType); } private Integer createLoanProductWithInterestRecalculationAndCompoundingDetails(final String repaymentStrategy, @@ -4280,14 +4510,16 @@ public class ClientLoanIntegrationTest { final String recalculationRestFrequencyDate, final String recalculationCompoundingFrequencyType, final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts, - final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, + final Integer recalculationCompoundingFrequencyOnDayType, + final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { return createLoanProductWithInterestRecalculation(repaymentStrategy, interestRecalculationCompoundingMethod, rescheduleStrategyMethod, recalculationRestFrequencyType, recalculationRestFrequencyInterval, - recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, - recalculationCompoundingFrequencyDate, preCloseInterestCalculationStrategy, accounts, null, false, - recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType, - recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType); + recalculationRestFrequencyDate, recalculationCompoundingFrequencyType, + recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate, + preCloseInterestCalculationStrategy, accounts, null, false, recalculationCompoundingFrequencyOnDayType, + recalculationCompoundingFrequencyDayOfWeekType, recalculationRestFrequencyOnDayType, + recalculationRestFrequencyDayOfWeekType); } private Integer createLoanProductWithInterestRecalculation(final String repaymentStrategy, @@ -4297,24 +4529,19 @@ public class ClientLoanIntegrationTest { final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate, final String preCloseInterestCalculationStrategy, final Account[] accounts, final String chargeId, boolean isArrearsBasedOnOriginalSchedule, final Integer recalculationCompoundingFrequencyOnDayType, - final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, - final Integer recalculationRestFrequencyDayOfWeekType) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); - LoanProductTestBuilder builder = new LoanProductTestBuilder() - .withPrincipal("10000000.00") - .withNumberOfRepayments("24") - .withRepaymentAfterEvery("1") - .withRepaymentTypeAsWeek() - .withinterestRatePerPeriod("2") - .withInterestRateFrequencyTypeAsMonths() - .withRepaymentStrategy(repaymentStrategy) - .withAmortizationTypeAsEqualPrincipalPayment() - .withInterestCalculationPeriodTypeAsRepaymentPeriod(true) - .withInterestTypeAsDecliningBalance() + final Integer recalculationCompoundingFrequencyDayOfWeekType, + final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000000.00") + .withNumberOfRepayments("24").withRepaymentAfterEvery("1").withRepaymentTypeAsWeek() + .withinterestRatePerPeriod("2").withInterestRateFrequencyTypeAsMonths() + .withRepaymentStrategy(repaymentStrategy).withAmortizationTypeAsEqualPrincipalPayment() + .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).withInterestTypeAsDecliningBalance() .withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod, preCloseInterestCalculationStrategy) - .withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, recalculationRestFrequencyInterval, - recalculationRestFrequencyOnDayType, recalculationRestFrequencyDayOfWeekType) + .withInterestRecalculationRestFrequencyDetails(recalculationRestFrequencyType, + recalculationRestFrequencyInterval, recalculationRestFrequencyOnDayType, + recalculationRestFrequencyDayOfWeekType) .withInterestRecalculationCompoundingFrequencyDetails(recalculationCompoundingFrequencyType, recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyOnDayType, recalculationCompoundingFrequencyDayOfWeekType); @@ -4322,7 +4549,8 @@ public class ClientLoanIntegrationTest { builder = builder.withAccountingRulePeriodicAccrual(accounts); } - if (isArrearsBasedOnOriginalSchedule) builder = builder.withArrearsConfiguration(); + if (isArrearsBasedOnOriginalSchedule) + builder = builder.withArrearsConfiguration(); final String loanProductJSON = builder.build(chargeId); return this.loanTransactionHelper.getLoanProductId(loanProductJSON); @@ -4330,27 +4558,28 @@ public class ClientLoanIntegrationTest { private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, final String disbursementDate, final String repaymentStrategy, final List charges) { - return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, repaymentStrategy, charges, null, - null); + return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, + repaymentStrategy, charges, null, null); } - private Integer applyForLoanApplicationForInterestRecalculationWithMoratorium(final Integer clientID, final Integer loanProductID, - final String disbursementDate, final String repaymentStrategy, final List charges, - final String graceOnInterestPayment, final String graceOnPrincipalPayment) { - return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, repaymentStrategy, charges, - graceOnInterestPayment, graceOnPrincipalPayment); + private Integer applyForLoanApplicationForInterestRecalculationWithMoratorium(final Integer clientID, + final Integer loanProductID, final String disbursementDate, final String repaymentStrategy, + final List charges, final String graceOnInterestPayment, final String graceOnPrincipalPayment) { + return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, + repaymentStrategy, charges, graceOnInterestPayment, graceOnPrincipalPayment); } private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, - final String disbursementDate, final String compoundingStartDate, final String repaymentStrategy, final List charges) { - return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, repaymentStrategy, charges, null, - null); + final String disbursementDate, final String compoundingStartDate, final String repaymentStrategy, + final List charges) { + return applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, disbursementDate, + repaymentStrategy, charges, null, null); } private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, final String disbursementDate, final String repaymentStrategy, final List charges, final String graceOnInterestPayment, final String graceOnPrincipalPayment) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000.00") // .withLoanTermFrequency("4") // @@ -4372,24 +4601,32 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } - private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule, List> expectedvalues) { + private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule, + List> expectedvalues) { int index = 1; verifyLoanRepaymentSchedule(loanSchedule, expectedvalues, index); } - private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule, List> expectedvalues, int index) { - System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); + private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule, + List> expectedvalues, int index) { + LOG.info( + "--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------"); for (Map values : expectedvalues) { - assertEquals("Checking for Due Date for installment " + index, values.get("dueDate"), loanSchedule.get(index).get("dueDate")); + assertEquals("Checking for Due Date for installment " + index, values.get("dueDate"), + loanSchedule.get(index).get("dueDate")); validateNumberForEqualWithMsg("Checking for Principal Due for installment " + index, - String.valueOf(values.get("principalDue")), String.valueOf(loanSchedule.get(index).get("principalDue"))); - validateNumberForEqualWithMsg("Checking for Interest Due for installment " + index, String.valueOf(values.get("interestDue")), + String.valueOf(values.get("principalDue")), + String.valueOf(loanSchedule.get(index).get("principalDue"))); + validateNumberForEqualWithMsg("Checking for Interest Due for installment " + index, + String.valueOf(values.get("interestDue")), String.valueOf(loanSchedule.get(index).get("interestDue"))); validateNumberForEqualWithMsg("Checking for Fee charge Due for installment " + index, - String.valueOf(values.get("feeChargesDue")), String.valueOf(loanSchedule.get(index).get("feeChargesDue"))); + String.valueOf(values.get("feeChargesDue")), + String.valueOf(loanSchedule.get(index).get("feeChargesDue"))); validateNumberForEqualWithMsg("Checking for Penalty charge Due for installment " + index, - String.valueOf(values.get("penaltyChargesDue")), String.valueOf(loanSchedule.get(index).get("penaltyChargesDue"))); + String.valueOf(values.get("penaltyChargesDue")), + String.valueOf(loanSchedule.get(index).get("penaltyChargesDue"))); index++; } } @@ -4420,8 +4657,8 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, CASH_BASED, assetAccount, - incomeAccount, expenseAccount, overpaymentAccount); + final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, CASH_BASED, + assetAccount, incomeAccount, expenseAccount, overpaymentAccount); Assert.assertNotNull(loanProductID); /*** @@ -4437,26 +4674,29 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); addCharges(charges, flatInstallmentFee, "50", null); - final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, savingsId, - principal, LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); + final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, + savingsId, principal, LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, + assetAccountInitialEntry); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap firstInstallment = loanSchedule.get(1); validateNumberForEqual("2290", String.valueOf(firstInstallment.get("totalOutstandingForPeriod"))); @@ -4478,10 +4718,12 @@ public class ClientLoanIntegrationTest { final String twoMonthsfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(twoMonthsfromNow, Float.valueOf("2290"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, new JournalEntry(Float.valueOf("2290"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, twoMonthsfromNow, new JournalEntry(Float.valueOf("50"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, + new JournalEntry(Float.valueOf("2290"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, twoMonthsfromNow, + new JournalEntry(Float.valueOf("50"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4495,10 +4737,12 @@ public class ClientLoanIntegrationTest { final String oneMonthfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(oneMonthfromNow, Float.valueOf("4580"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, new JournalEntry(Float.valueOf("4580"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("4000"), JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, oneMonthfromNow, new JournalEntry(Float.valueOf("100"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("480"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, + new JournalEntry(Float.valueOf("4580"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("4000"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, oneMonthfromNow, + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("480"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4516,8 +4760,9 @@ public class ClientLoanIntegrationTest { final String now = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRefundByCash(now, Float.valueOf("20"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4533,11 +4778,12 @@ public class ClientLoanIntegrationTest { // refund 2000 means paid: principal 0, interest 220, fees 50, penalty 0 this.loanTransactionHelper.makeRefundByCash(now, Float.valueOf("2000"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("2000"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4575,9 +4821,9 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, ACCRUAL_UPFRONT, assetAccount, - incomeAccount, expenseAccount, overpaymentAccount);// , - // LoanProductTestBuilder.EQUAL_INSTALLMENTS, + final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, + ACCRUAL_UPFRONT, assetAccount, incomeAccount, expenseAccount, overpaymentAccount);// , + // LoanProductTestBuilder.EQUAL_INSTALLMENTS, // LoanProductTestBuilder.FLAT_BALANCE); Assert.assertNotNull(loanProductID); @@ -4594,28 +4840,31 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); addCharges(charges, flatInstallmentFee, "50", null); - final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, savingsId, - principal, LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); + final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, + savingsId, principal, LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("1440"), JournalEntry.TransactionType.DEBIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("1440"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("300.00"), JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, + assetAccountInitialEntry); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap firstInstallment = loanSchedule.get(1); validateNumberForEqual("2290", String.valueOf(firstInstallment.get("totalOutstandingForPeriod"))); @@ -4637,8 +4886,9 @@ public class ClientLoanIntegrationTest { final String twoMonthsfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(twoMonthsfromNow, Float.valueOf("2290"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, new JournalEntry(Float.valueOf("2290"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2290"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, + new JournalEntry(Float.valueOf("2290"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2290"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4652,8 +4902,9 @@ public class ClientLoanIntegrationTest { final String oneMonthfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(oneMonthfromNow, Float.valueOf("4580"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, new JournalEntry(Float.valueOf("4580"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("4580"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, + new JournalEntry(Float.valueOf("4580"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("4580"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4671,8 +4922,9 @@ public class ClientLoanIntegrationTest { final String now = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRefundByCash(now, Float.valueOf("20"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4688,11 +4940,12 @@ public class ClientLoanIntegrationTest { // refund 2000 means paid: principal 0, interest 220, fees 50, penalty 0 this.loanTransactionHelper.makeRefundByCash(now, Float.valueOf("2000"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("2000"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4720,17 +4973,20 @@ public class ClientLoanIntegrationTest { final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID); - final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE); + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, + MINIMUM_OPENING_BALANCE); Assert.assertNotNull(savingsProductID); - final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); + final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, + ACCOUNT_TYPE_INDIVIDUAL); Assert.assertNotNull(savingsProductID); HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId, ACCOUNT_TYPE_INDIVIDUAL); Assert.assertTrue(modifications.containsKey("submittedOnDate")); - HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId); + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, + savingsId); SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); @@ -4748,8 +5004,8 @@ public class ClientLoanIntegrationTest { final Account expenseAccount = this.accountHelper.createExpenseAccount(); final Account overpaymentAccount = this.accountHelper.createLiabilityAccount(); - final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, CASH_BASED, assetAccount, - incomeAccount, expenseAccount, overpaymentAccount); + final Integer loanProductID = createLoanProduct("0", "0", LoanProductTestBuilder.DEFAULT_STRATEGY, CASH_BASED, + assetAccount, incomeAccount, expenseAccount, overpaymentAccount); Assert.assertNotNull(loanProductID); /*** @@ -4765,26 +5021,29 @@ public class ClientLoanIntegrationTest { ChargesHelper.getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, "50", false)); addCharges(charges, flatInstallmentFee, "50", null); - final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, null, principal, - LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); + final Integer loanID = applyForLoanApplicationWithPaymentStrategyAndPastMonth(clientID, loanProductID, charges, + null, principal, LoanApplicationTestBuilder.DEFAULT_STRATEGY, -4); Assert.assertNotNull(loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("12000.00"), JournalEntry.TransactionType.DEBIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, fourMonthsfromNow, + assetAccountInitialEntry); - ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, + this.responseSpec, loanID); HashMap firstInstallment = loanSchedule.get(1); validateNumberForEqual("2290", String.valueOf(firstInstallment.get("totalOutstandingForPeriod"))); @@ -4806,10 +5065,12 @@ public class ClientLoanIntegrationTest { final String twoMonthsfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(twoMonthsfromNow, Float.valueOf("2290"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, new JournalEntry(Float.valueOf("2290"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, twoMonthsfromNow, new JournalEntry(Float.valueOf("50"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, twoMonthsfromNow, + new JournalEntry(Float.valueOf("2290"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, twoMonthsfromNow, + new JournalEntry(Float.valueOf("50"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("240"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4823,10 +5084,12 @@ public class ClientLoanIntegrationTest { final String oneMonthfromNow = Utils.convertDateToURLFormat(fourMonthsfromNowCalendar); this.loanTransactionHelper.makeRepayment(oneMonthfromNow, Float.valueOf("4580"), loanID); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, new JournalEntry(Float.valueOf("4580"), - JournalEntry.TransactionType.DEBIT), new JournalEntry(Float.valueOf("4000"), JournalEntry.TransactionType.CREDIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, oneMonthfromNow, new JournalEntry(Float.valueOf("100"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("480"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, oneMonthfromNow, + new JournalEntry(Float.valueOf("4580"), JournalEntry.TransactionType.DEBIT), + new JournalEntry(Float.valueOf("4000"), JournalEntry.TransactionType.CREDIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, oneMonthfromNow, + new JournalEntry(Float.valueOf("100"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("480"), JournalEntry.TransactionType.CREDIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4848,8 +5111,8 @@ public class ClientLoanIntegrationTest { final String FROM_LOAN_ACCOUNT_TYPE = "1"; final String TO_SAVINGS_ACCOUNT_TYPE = "2"; - this.accountTransferHelper.refundLoanByTransfer(now, clientID, loanID, clientID, savingsId, FROM_LOAN_ACCOUNT_TYPE, - TO_SAVINGS_ACCOUNT_TYPE, TRANSFER_AMOUNT.toString()); + this.accountTransferHelper.refundLoanByTransfer(now, clientID, loanID, clientID, savingsId, + FROM_LOAN_ACCOUNT_TYPE, TO_SAVINGS_ACCOUNT_TYPE, TRANSFER_AMOUNT.toString()); Float toSavingsBalance = Float.valueOf(MINIMUM_OPENING_BALANCE); @@ -4861,8 +5124,9 @@ public class ClientLoanIntegrationTest { assertEquals("Verifying From Savings Account Balance after Account Transfer", toSavingsBalance, toSavingsSummaryAfter.get("accountBalance")); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4880,8 +5144,8 @@ public class ClientLoanIntegrationTest { TRANSFER_AMOUNT = 2000f; - this.accountTransferHelper.refundLoanByTransfer(now, clientID, loanID, clientID, savingsId, FROM_LOAN_ACCOUNT_TYPE, - TO_SAVINGS_ACCOUNT_TYPE, TRANSFER_AMOUNT.toString()); + this.accountTransferHelper.refundLoanByTransfer(now, clientID, loanID, clientID, savingsId, + FROM_LOAN_ACCOUNT_TYPE, TO_SAVINGS_ACCOUNT_TYPE, TRANSFER_AMOUNT.toString()); toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); @@ -4891,11 +5155,12 @@ public class ClientLoanIntegrationTest { assertEquals("Verifying From Savings Account Balance after Account Transfer", toSavingsBalance, toSavingsSummaryAfter.get("accountBalance")); - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, new JournalEntry(Float.valueOf("2000"), - JournalEntry.TransactionType.CREDIT), new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, now, + new JournalEntry(Float.valueOf("2000"), JournalEntry.TransactionType.CREDIT), + new JournalEntry(Float.valueOf("1980"), JournalEntry.TransactionType.DEBIT)); - this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, new JournalEntry(Float.valueOf("20"), - JournalEntry.TransactionType.DEBIT)); + this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, now, + new JournalEntry(Float.valueOf("20"), JournalEntry.TransactionType.DEBIT)); loanSchedule.clear(); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); @@ -4907,13 +5172,13 @@ public class ClientLoanIntegrationTest { } - private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String minOpenningBalance) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + private Integer createSavingsProduct(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String minOpenningBalance) { + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); final String savingsProductJSON = savingsProductHelper - // + // .withInterestCompoundingPeriodTypeAsDaily() // .withInterestPostingPeriodTypeAsMonthly() @@ -4928,10 +5193,12 @@ public class ClientLoanIntegrationTest { public void testLoanProductConfiguration() { final String proposedAmount = "5000"; JsonObject loanProductConfigurationAsTrue = new JsonObject(); - loanProductConfigurationAsTrue = this.createLoanProductConfigurationDetail(loanProductConfigurationAsTrue, true); + loanProductConfigurationAsTrue = this.createLoanProductConfigurationDetail(loanProductConfigurationAsTrue, + true); JsonObject loanProductConfigurationAsFalse = new JsonObject(); - loanProductConfigurationAsFalse = this.createLoanProductConfigurationDetail(loanProductConfigurationAsFalse, false); + loanProductConfigurationAsFalse = this.createLoanProductConfigurationDetail(loanProductConfigurationAsFalse, + false); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012"); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() @@ -4939,23 +5206,25 @@ public class ClientLoanIntegrationTest { .withRepaymentStrategy(LoanProductTestBuilder.DEFAULT_STRATEGY).withInterestTypeAsDecliningBalance() .withInterestCalculationPeriodTypeAsDays().withInArrearsTolerance("10").withMoratorium("2", "3") .withLoanProductConfiguration(loanProductConfigurationAsTrue).build(null)); - System.out.println("-----------------------LOAN PRODUCT CREATED WITH ATTRIBUTE CONFIGURATION AS TRUE--------------------------" - + loanProductID); + LOG.info( + "-----------------------LOAN PRODUCT CREATED WITH ATTRIBUTE CONFIGURATION AS TRUE-------------------------- {}" + , loanProductID); Integer loanID = applyForLoanApplicationWithProductConfigurationAsTrue(clientID, loanProductID, proposedAmount); - System.out.println("------------------------LOAN CREATED WITH ID------------------------------" + loanID); + LOG.info("------------------------LOAN CREATED WITH ID------------------------------{}" , loanID); - loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().withAmortizationTypeAsEqualInstallments() - .withRepaymentTypeAsMonth().withRepaymentAfterEvery("1").withRepaymentStrategy(LoanProductTestBuilder.DEFAULT_STRATEGY) - .withInterestTypeAsDecliningBalance().withInterestCalculationPeriodTypeAsDays().withInArrearsTolerance("10") - .withMoratorium("2", "3").withLoanProductConfiguration(loanProductConfigurationAsFalse).build(null)); - System.out.println("-------------------LOAN PRODUCT CREATED WITH ATTRIBUTE CONFIGURATION AS FALSE----------------------" - + loanProductID); + loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() + .withAmortizationTypeAsEqualInstallments().withRepaymentTypeAsMonth().withRepaymentAfterEvery("1") + .withRepaymentStrategy(LoanProductTestBuilder.DEFAULT_STRATEGY).withInterestTypeAsDecliningBalance() + .withInterestCalculationPeriodTypeAsDays().withInArrearsTolerance("10").withMoratorium("2", "3") + .withLoanProductConfiguration(loanProductConfigurationAsFalse).build(null)); + LOG.info("-------------------LOAN PRODUCT CREATED WITH ATTRIBUTE CONFIGURATION AS FALSE---------------------- {}" + , loanProductID); /* * Try to override attribute values in loan account when attribute * configurations are set to false at product level */ loanID = applyForLoanApplicationWithProductConfigurationAsFalse(clientID, loanProductID, proposedAmount); - System.out.println("--------------------------LOAN CREATED WITH ID-------------------------" + loanID); + LOG.info("--------------------------LOAN CREATED WITH ID------------------------- {}" , loanID); this.validateIfValuesAreNotOverridden(loanID, loanProductID); } @@ -4985,20 +5254,20 @@ public class ClientLoanIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("----------------------------------- APPROVE LOAN -----------------------------------------"); + LOG.info("----------------------------------- APPROVE LOAN -----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("----------------------------------- DISBURSE LOAN ----------------------------------------"); + LOG.info("----------------------------------- DISBURSE LOAN ----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10,000.00"); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}", loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - System.out.println("---------------------------------- Make repayment 1 --------------------------------------"); + LOG.info("---------------------------------- Make repayment 1 --------------------------------------"); this.loanTransactionHelper.makeRepayment("20 October 2011", Float.valueOf("2676.24"), loanID); - System.out.println("---------------------------------- FORECLOSE LOAN ----------------------------------------"); + LOG.info("---------------------------------- FORECLOSE LOAN ----------------------------------------"); this.loanTransactionHelper.forecloseLoan("08 November 2011", loanID); // retrieving the loan status @@ -5013,11 +5282,12 @@ public class ClientLoanIntegrationTest { } private void validateIfValuesAreNotOverridden(Integer loanID, Integer loanProductID) { - String loanProductDetails = this.loanTransactionHelper.getLoanProductDetails(this.requestSpec, this.responseSpec, loanProductID); + String loanProductDetails = this.loanTransactionHelper.getLoanProductDetails(this.requestSpec, + this.responseSpec, loanProductID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); - List comparisonAttributes = Arrays.asList("amortizationType", "interestType", "transactionProcessingStrategyId", - "interestCalculationPeriodType", "repaymentFrequencyType", "graceOnPrincipalPayment", "graceOnInterestPayment", - "inArrearsTolerance", "graceOnArrearsAgeing"); + List comparisonAttributes = Arrays.asList("amortizationType", "interestType", + "transactionProcessingStrategyId", "interestCalculationPeriodType", "repaymentFrequencyType", + "graceOnPrincipalPayment", "graceOnInterestPayment", "inArrearsTolerance", "graceOnArrearsAgeing"); for (String comparisonAttribute : comparisonAttributes) { Object val1 = JsonPath.from(loanProductDetails).get(comparisonAttribute); @@ -5038,9 +5308,9 @@ public class ClientLoanIntegrationTest { return loanProductConfiguration; } - private Integer applyForLoanApplicationWithProductConfigurationAsTrue(final Integer clientID, final Integer loanProductID, - String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplicationWithProductConfigurationAsTrue(final Integer clientID, + final Integer loanProductID, String principal) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withRepaymentEveryAfter("1") // @@ -5056,9 +5326,9 @@ public class ClientLoanIntegrationTest { return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } - private Integer applyForLoanApplicationWithProductConfigurationAsFalse(final Integer clientID, final Integer loanProductID, - String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + private Integer applyForLoanApplicationWithProductConfigurationAsFalse(final Integer clientID, + final Integer loanProductID, String principal) { + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java index e48f8645d..24f79435f 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java @@ -56,13 +56,15 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Client Savings Integration Test for checking Savings Application. */ @SuppressWarnings({ "rawtypes"}) public class ClientSavingsIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(ClientSavingsIntegrationTest.class); public static final String DEPOSIT_AMOUNT = "2000"; public static final String WITHDRAW_AMOUNT = "1000"; public static final String WITHDRAW_AMOUNT_ADJUSTED = "500"; @@ -970,8 +972,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); transactionDate.set(Calendar.DAY_OF_MONTH, 3); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); @@ -1007,8 +1008,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked-------"); + LOG.info("-----Post Interest As on Successfully Worked-------"); //DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); Calendar transactionCalendarDateFormat = Calendar.getInstance(); @@ -1047,8 +1047,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } DateFormat lastTransactionDateFormat = new SimpleDateFormat( "dd MMMM yyyy", Locale.US); @@ -1091,8 +1090,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } transactionDate.set(Calendar.DAY_OF_MONTH, 1); @@ -1128,8 +1126,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } @@ -1313,8 +1310,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); transactionDate.set(Calendar.DAY_OF_MONTH, 3); TRANSACTION_DATE = dateFormat.format(transactionDate.getTime()); @@ -1350,8 +1346,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked-------"); + LOG.info("-----Post Interest As on Successfully Worked-------"); //DateFormat transactionFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); Calendar transactionCalendarDateFormat = Calendar.getInstance(); @@ -1390,8 +1385,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } DateFormat lastTransactionDateFormat = new SimpleDateFormat( "dd MMMM yyyy", Locale.US); @@ -1434,8 +1428,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } transactionDate.set(Calendar.DAY_OF_MONTH, 1); @@ -1471,8 +1464,7 @@ public class ClientSavingsIntegrationTest { decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out - .println("-----Post Interest As on Successfully Worked----------"); + LOG.info("-----Post Interest As on Successfully Worked----------"); } @SuppressWarnings("unchecked") @@ -1619,7 +1611,7 @@ public class ClientSavingsIntegrationTest { interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); //actualInterestPosted = Float.valueOf(decimalFormat.format(accountDetailsPostInterestPosted)); assertEquals("Verifying interest posted", interestPosted, accountDetailsPostInterestPosted); - System.out.println("------Post Interest As On After doing a post interest Successfully worked--------"); + LOG.info("------Post Interest As On After doing a post interest Successfully worked--------"); todaysDate = Calendar.getInstance(); final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime()); @@ -1706,7 +1698,7 @@ public class ClientSavingsIntegrationTest { final String POSTED_TRANSACTION_DATE = dateFormat.format(postedDate.getTime()); Calendar postedLastDate = Calendar.getInstance(); int countOfDate=postedDate.getActualMaximum(Calendar.DAY_OF_MONTH); - System.out.println("count Of Date---> "+countOfDate); + LOG.info("count Of Date---> {}",countOfDate); postedLastDate.set(Calendar.DAY_OF_MONTH,countOfDate); final String POSTED_LAST_TRANSACTION_DATE = dateFormat.format(postedLastDate.getTime()); @@ -1786,7 +1778,7 @@ public class ClientSavingsIntegrationTest { interestPosted = Float.valueOf(decimalFormat.format(interestPosted)); actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted)); assertEquals("Verifying interest posted", interestPosted, actualInterestPosted); - System.out.println("------Post Interest As On Successful Worked--------"); + LOG.info("------Post Interest As On Successful Worked--------"); this.savingsAccountHelper.postInterestAsOnSavings(savingsId, POSTED_LAST_TRANSACTION_DATE); HashMap accountLastDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); @@ -1806,7 +1798,7 @@ public class ClientSavingsIntegrationTest { interestLastPosted = Float.valueOf(decimalLastFormat.format(interestLastPosted)); actualInterestPosted = Float.valueOf(decimalFormat.format(actualInterestPosted)); assertEquals("Verifying interest posted", interestLastPosted, actualInterestPosted); - System.out.println("------Post Interest As On Successful Worked--------"); + LOG.info("------Post Interest As On Successful Worked--------"); } @@ -2070,7 +2062,7 @@ public class ClientSavingsIntegrationTest { private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance, String enforceMinRequiredBalance, final boolean allowOverdraft, final String taxGroupId, boolean withDormancy) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); if (allowOverdraft) { final String overDraftLimit = "2000.0"; @@ -2104,7 +2096,7 @@ public class ClientSavingsIntegrationTest { /* * private void verifySavingsInterest(final Object savingsInterest) { - * System.out.println( + * LOG.info( * "--------------------VERIFYING THE BALANCE, INTEREST --------------------------" * ); * 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 12863bbdf..f7892bafb 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 @@ -21,41 +21,49 @@ package org.apache.fineract.integrationtests; import static org.junit.Assert.assertEquals; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; 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); } public static void verifyClientClosed(final HashMap clientStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------"); assertEquals((int) clientStatusHashMap.get("id"), 600); - System.out.println("Client Status:" + clientStatusHashMap + "\n"); + LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientPending(final HashMap clientStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------"); assertEquals((int) clientStatusHashMap.get("id"), 100); - System.out.println("Client Status:" + clientStatusHashMap + "\n"); + LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientRejected(final HashMap clientStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------"); assertEquals((int) clientStatusHashMap.get("id"), 700); - System.out.println("Client Status:" + clientStatusHashMap + "\n"); + LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientActiavted(final HashMap clientStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------"); assertEquals((int) clientStatusHashMap.get("id"), 300); - System.out.println("Client Status:" + clientStatusHashMap + "\n"); + LOG.info("Client Status: {} \n", clientStatusHashMap); } public static void verifyClientWithdrawn(final HashMap clientStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------"); assertEquals((int) clientStatusHashMap.get("id"), 800); - System.out.println("Client Status:" + clientStatusHashMap + "\n"); + LOG.info("Client Status: {} \n", clientStatusHashMap); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ConcurrencyIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ConcurrencyIntegrationTest.java index 3c646d4c2..ec12ffe2b 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ConcurrencyIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ConcurrencyIntegrationTest.java @@ -37,9 +37,11 @@ import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConcurrencyIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(ConcurrencyIntegrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -73,7 +75,7 @@ public class ConcurrencyIntegrationTest { date.set(2011, 9, 20); Float repaymentAmount = 100.0f; for (int i = 0; i < 10; i++) { - System.out.println("Starting concurrent transaction number " + i); + LOG.info("Starting concurrent transaction number {}" , i); date.add(Calendar.DAY_OF_MONTH, 1); repaymentAmount = repaymentAmount + 100; Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date); @@ -85,12 +87,12 @@ public class ConcurrencyIntegrationTest { while (!executor.isTerminated()) { } - System.out.println("\nFinished all threads"); + LOG.info("\nFinished all threads"); } private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() // .withPrincipal("12,000.00") // .withNumberOfRepayments("4") // @@ -111,7 +113,7 @@ public class ConcurrencyIntegrationTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // @@ -150,13 +152,12 @@ public class ConcurrencyIntegrationTest { try { this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId); } catch (Exception e) { - System.out.println("Found an exception" + e.getMessage()); - System.out.println("Details of failed concurrent transaction (date, amount, loanId) are " + repaymentDate + "," - + repaymentAmount + "," + loanId); + LOG.info("Found an exception {}" , e.getMessage()); + LOG.info("Details of failed concurrent transaction (date, amount, loanId) are {},{},{}" , repaymentDate, repaymentAmount , loanId); throw (e); } - System.out.println("Details of passed concurrent transaction, details (date, amount, loanId) are " + repaymentDate + "," - + repaymentAmount + "," + loanId); + LOG.info("Details of passed concurrent transaction, details (date, amount, loanId) are {},{},{}" , repaymentDate + , repaymentAmount , loanId); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java index 63bbe6325..6753b4b85 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/DisbursalAndRepaymentScheduleTest.java @@ -53,321 +53,362 @@ import org.junit.Test; @Ignore public class DisbursalAndRepaymentScheduleTest { - private ResponseSpecification responseSpec; - private ResponseSpecification responseSpecForStatusCode403; - private ResponseSpecification generalResponseSpec; - private RequestSpecification requestSpec; - private LoanTransactionHelper loanTransactionHelper; - private LoanRescheduleRequestHelper loanRescheduleRequestHelper; - private Integer loanRescheduleRequestId; - private Integer clientId; - private Integer groupId; - private Integer groupCalendarId; - private Integer loanProductId; - private Integer loanId; - private final String loanPrincipalAmount = "100000.00"; - private final String numberOfRepayments = "12"; - private final String interestRatePerPeriod = "18"; + private ResponseSpecification responseSpec; + private ResponseSpecification responseSpecForStatusCode403; + private ResponseSpecification generalResponseSpec; + private RequestSpecification requestSpec; + private LoanTransactionHelper loanTransactionHelper; + private LoanRescheduleRequestHelper loanRescheduleRequestHelper; + private Integer loanRescheduleRequestId; + private Integer clientId; + private Integer groupId; + private Integer groupCalendarId; + private Integer loanProductId; + private Integer loanId; + private final String loanPrincipalAmount = "100000.00"; + private final String numberOfRepayments = "12"; + private final String interestRatePerPeriod = "18"; - private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy"); + private final SimpleDateFormat dateFormatterStandard = new SimpleDateFormat("dd MMMM yyyy"); - @Before - public void setup() { - Utils.initializeRESTAssured(); - } - - @Test - public void testRescheduleJLGLoanSynk() { - System.out.println("---------------------------------STARTING RESCHEDULE JLG LOAN TEST ------------------------------------------"); - - Calendar meetingCalendar = Calendar.getInstance(); - meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); - meetingCalendar.setTime(new java.util.Date()); - - int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); - // making sure that the meeting calendar is set for the coming monday. - if (today >= Calendar.MONDAY) { - meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7)); - } else { - meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today)); + @Before + public void setup() { + Utils.initializeRESTAssured(); } - Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); + @Test + public void testRescheduleJLGLoanSynk() { + // system.out.println("---------------------------------STARTING RESCHEDULE JLG + // LOAN TEST ------------------------------------------"); - meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); + Calendar meetingCalendar = Calendar.getInstance(); + meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); + meetingCalendar.setTime(new java.util.Date()); - final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); + int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); + // making sure that the meeting calendar is set for the coming monday. + if (today >= Calendar.MONDAY) { + meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7)); + } else { + meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today)); + } - final String disbursalDate = groupMeetingDate; // first meeting date - // after group creation + Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); - final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date()); + meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); - final String loanType = "jlg"; - final String rescheduleInterestRate = "28.0"; - groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); - final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime()); - // The date - // from - // which we - // start the - // new group - // meeting - // occasion, - // this is a - // tuesday. - groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2); - final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime()); + final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); - this.requestSpec.header("Fineract-Platform-TenantId", "default"); - this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.generalResponseSpec = new ResponseSpecBuilder().build(); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + final String disbursalDate = groupMeetingDate; // first meeting date + // after group creation - this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); - System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------"); - // create all required entities - this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); + final String rescheduleSubmittedDate = this.dateFormatterStandard.format(new java.util.Date()); - final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") - .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2") - .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() - .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate) - .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin() - .withCalendarID(this.groupCalendarId.toString()) - .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null); + final String loanType = "jlg"; + final String rescheduleInterestRate = "28.0"; + groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); + final String groupMeetingNewStartDate = this.dateFormatterStandard + .format(groupMeetingChangeCalendar.getTime()); + // The date + // from + // which we + // start the + // new group + // meeting + // occasion, + // this is a + // tuesday. + groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2); + final String rescheduleDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime()); - this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); + this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + this.requestSpec.header("Authorization", + "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.requestSpec.header("Fineract-Platform-TenantId", "default"); + this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + this.generalResponseSpec = new ResponseSpecBuilder().build(); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - // Test for loan account is created - Assert.assertNotNull(this.loanId); - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); + // system.out.println("---------------------------------CREATING ENTITIES AND + // JLG LOAN ------------------------------------------"); + // create all required entities + this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) + .withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12") + .withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths() + .withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() + .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks() + .withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate) + .withLoanType(loanType).withSyncDisbursementWithMeetin() + .withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(), + this.groupId.toString(), this.loanProductId.toString(), null); - // Test for loan account is created, can be approved - this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); - loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); - // Test for loan account approved can be disbursed - this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); - loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + // Test for loan account is created + Assert.assertNotNull(this.loanId); + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + this.loanId); - System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); - CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(), - groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates - // will be the tuesday - // after the - // coming - // monday + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - ArrayList loanRepaymnetSchedule = this.loanTransactionHelper - .getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); + // Test for loan account is created, can be approved + this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); + loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); - Calendar dueDateCalendar = Calendar.getInstance(); - dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY); - dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, - (Integer) dueDateLoanSchedule.get(2)); - assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY", 3, dueDateCalendar.get(Calendar.DAY_OF_WEEK)); + // Test for loan account approved can be disbursed + this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); + loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); + // system.out.println("---------------------------------CHANGING GROUP MEETING + // DATE ------------------------------------------"); + CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, + this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New + // meeting + // dates + // will be + // the + // tuesday + // after the + // coming + // monday - String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2") - .updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate) - .updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString()); + ArrayList loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, + generalResponseSpec, this.loanId); - this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON); - this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); + ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); + Calendar dueDateCalendar = Calendar.getInstance(); + dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY); + dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, + (Integer) dueDateLoanSchedule.get(2)); + assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY", 3, + dueDateCalendar.get(Calendar.DAY_OF_WEEK)); - loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); - dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); - dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, - (Integer) dueDateLoanSchedule.get(2)); - assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT", 3, - dueDateCalendar.get(Calendar.DAY_OF_WEEK)); + // system.out.println("---------------------------------CREATING LOAN RESCHEDULE + // REQUEST------------------------------------------"); - System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); + String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2") + .updateGraceOnPrincipal("2").updateNewInterestRate(rescheduleInterestRate) + .updateRescheduleFromDate(rescheduleDate).updateSubmittedOnDate(rescheduleSubmittedDate) + .build(this.loanId.toString()); - System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------"); + this.loanRescheduleRequestId = this.loanRescheduleRequestHelper + .createLoanRescheduleRequest(requestJSON); + this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); - requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) - .getApproveLoanRescheduleRequestJSON(); - this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); + loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, + generalResponseSpec, this.loanId); + dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); + dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, + (Integer) dueDateLoanSchedule.get(2)); + assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT", + 3, dueDateCalendar.get(Calendar.DAY_OF_WEEK)); - final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); - assertTrue((Boolean) response.get("approved")); + // system.out.println("Successfully created loan reschedule request (ID: " + + // this.loanRescheduleRequestId + ")"); - loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId); + // system.out.println("-----------------------------APPROVING LOAN RESCHEDULE + // REQUEST--------------------------"); - dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); - dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, - (Integer) dueDateLoanSchedule.get(2)); - assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE", 3, - dueDateCalendar.get(Calendar.DAY_OF_WEEK)); - System.out.println("Successfully changed group meeting date (CAELNDAR ID: " + this.groupCalendarId - + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + ")"); + requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate) + .getApproveLoanRescheduleRequestJSON(); + this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, + requestJSON); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403); - } + final HashMap response = (HashMap) this.loanRescheduleRequestHelper + .getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); + assertTrue((Boolean) response.get("approved")); - @Test - public void testChangeGroupMeetingMaturedOnDate() { - System.out - .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE DATE EXPECTED MATURED CHANGE------------------------------------------"); + loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, + generalResponseSpec, this.loanId); - Calendar meetingCalendar = Calendar.getInstance(); - meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); - meetingCalendar.setTime(new java.util.Date()); + dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate"); + dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1, + (Integer) dueDateLoanSchedule.get(2)); + assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE", + 3, dueDateCalendar.get(Calendar.DAY_OF_WEEK)); + // system.out.println("Successfully changed group meeting date (CAELNDAR ID: " + + // this.groupCalendarId + // + ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + + // ")"); - int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); - // making sure that the meeting calendar is set for the coming monday. - if (today >= Calendar.MONDAY) { - meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7)); - } else { - meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today)); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, + this.responseSpecForStatusCode403); } - Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); + @Test + public void testChangeGroupMeetingMaturedOnDate() { + // system.out + // .println("---------------------------------STARTING GROUP LOAN MEETING CHANGE + // DATE EXPECTED MATURED CHANGE------------------------------------------"); - meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); + Calendar meetingCalendar = Calendar.getInstance(); + meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY); + meetingCalendar.setTime(new java.util.Date()); - final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); + int today = meetingCalendar.get(Calendar.DAY_OF_WEEK); + // making sure that the meeting calendar is set for the coming monday. + if (today >= Calendar.MONDAY) { + meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7)); + } else { + meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today)); + } - final String disbursalDate = groupMeetingDate; // first meeting date - // after group creation + Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone(); - final String loanType = "jlg"; - groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); - final String groupMeetingNewStartDate = this.dateFormatterStandard.format(groupMeetingChangeCalendar.getTime()); - // The date - // from - // which we - // start the - // new group - // meeting - // occasion, - // this is a - // tuesday. + meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); - this.requestSpec.header("Fineract-Platform-TenantId", "default"); - this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.generalResponseSpec = new ResponseSpecBuilder().build(); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + final String groupMeetingDate = this.dateFormatterStandard.format(meetingCalendar.getTime()); - this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); - System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------"); - // create all required entities - this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); + final String disbursalDate = groupMeetingDate; // first meeting date + // after group creation - final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24") - .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2") - .withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() - .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate) - .withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin() - .withCalendarID(this.groupCalendarId.toString()) - .build(this.clientId.toString(), this.groupId.toString(), this.loanProductId.toString(), null); + final String loanType = "jlg"; + groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1); + final String groupMeetingNewStartDate = this.dateFormatterStandard + .format(groupMeetingChangeCalendar.getTime()); + // The date + // from + // which we + // start the + // new group + // meeting + // occasion, + // this is a + // tuesday. - this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); + this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + this.requestSpec.header("Authorization", + "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.requestSpec.header("Fineract-Platform-TenantId", "default"); + this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + this.generalResponseSpec = new ResponseSpecBuilder().build(); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - // Test for loan account is created - Assert.assertNotNull(this.loanId); - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec); + // system.out.println("---------------------------------CREATING ENTITIES AND + // JLG LOAN ------------------------------------------"); + // create all required entities + this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount) + .withLoanTermFrequency("24").withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12") + .withRepaymentEveryAfter("2").withRepaymentFrequencyTypeAsMonths() + .withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays() + .withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks() + .withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate) + .withLoanType(loanType).withSyncDisbursementWithMeetin() + .withCalendarID(this.groupCalendarId.toString()).build(this.clientId.toString(), + this.groupId.toString(), this.loanProductId.toString(), null); - // Test for loan account is created, can be approved - this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); - loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); - // Test for loan account approved can be disbursed - this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); - loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + // Test for loan account is created + Assert.assertNotNull(this.loanId); + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + this.loanId); - System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); - CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(), - groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates - // will be the tuesday - // after the - // coming - // monday + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - Calendar expectedMaturityCalendar = Calendar.getInstance(); - expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY); - ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, - this.loanId, "timeline")).get("expectedMaturityDate")); + // Test for loan account is created, can be approved + this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId); + loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1, - (Integer) expectedMaturityDate.get(2)); + // Test for loan account approved can be disbursed + this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId); + loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3, - expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK)); + // system.out.println("---------------------------------CHANGING GROUP MEETING + // DATE ------------------------------------------"); + CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, + this.groupCalendarId.toString(), groupMeetingNewStartDate, "2", "2", "2"); // New + // meeting + // dates + // will be + // the + // tuesday + // after the + // coming + // monday - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403); - } + Calendar expectedMaturityCalendar = Calendar.getInstance(); + expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY); + ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper + .getLoanDetail(requestSpec, generalResponseSpec, this.loanId, "timeline")) + .get("expectedMaturityDate")); - /** - * entities for jlg loan - **/ - private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) { - this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly - // , interval=2: - // Every two weeks , - // repeatsOnDay=1:Monday - // groupActivationDate is decided by the current date - this.createClientEntity(); - this.associateClientToGroup(this.groupId, this.clientId); - this.createLoanProductEntity(); + expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), + (Integer) expectedMaturityDate.get(1) - 1, (Integer) expectedMaturityDate.get(2)); - } + assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3, + expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK)); - /* - * Associate client to the group - */ + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, + this.responseSpecForStatusCode403); + } - private void associateClientToGroup(final Integer groupId, final Integer clientId) { - GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString()); - GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId); - } + /** + * entities for jlg loan + **/ + private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) { + this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly + // , interval=2: + // Every two weeks , + // repeatsOnDay=1:Monday + // groupActivationDate is decided by the current date + this.createClientEntity(); + this.associateClientToGroup(this.groupId, this.clientId); + this.createLoanProductEntity(); - private void createGroupEntityWithCalendar(final String frequency, final String interval, final String repeatsOnDay, - final String groupActivationDate) { - this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate); - GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId); + } - final String startDate = groupActivationDate; + /* + * Associate client to the group + */ - this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate, - frequency, interval, repeatsOnDay)); - } + private void associateClientToGroup(final Integer groupId, final Integer clientId) { + GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), + clientId.toString()); + GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId); + } - /** - * create a new client - **/ - private void createClientEntity() { - this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); - ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId); - } + private void createGroupEntityWithCalendar(final String frequency, final String interval, + final String repeatsOnDay, final String groupActivationDate) { + this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate); + GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId); - /** - * create a new loan product - **/ - private void createLoanProductEntity() { - final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount) - .withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod) - .withInterestRateFrequencyTypeAsYear().build(null); - this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); - } + final String startDate = groupActivationDate; - public void setGroupCalendarId(Integer groupCalendarId) { - this.groupCalendarId = groupCalendarId; - } + this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, + this.responseSpec, this.groupId, startDate, frequency, interval, repeatsOnDay)); + } + + /** + * create a new client + **/ + private void createClientEntity() { + this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); + ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId); + } + + /** + * create a new loan product + **/ + private void createLoanProductEntity() { + final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount) + .withNumberOfRepayments(numberOfRepayments) + .withinterestRatePerPeriod(interestRatePerPeriod).withInterestRateFrequencyTypeAsYear() + .build(null); + this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); + } + + public void setGroupCalendarId(Integer groupCalendarId) { + this.groupCalendarId = groupCalendarId; + } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ExternalServicesConfigurationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ExternalServicesConfigurationTest.java index a44789321..8b69c6f28 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ExternalServicesConfigurationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ExternalServicesConfigurationTest.java @@ -30,10 +30,12 @@ import org.apache.fineract.integrationtests.common.Utils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked", "static-access" }) public class ExternalServicesConfigurationTest { - + private final static Logger LOG = LoggerFactory.getLogger(ExternalServicesConfigurationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private ExternalServicesConfigurationHelper externalServicesConfigurationHelper; @@ -67,7 +69,7 @@ public class ExternalServicesConfigurationTest { value = "testnull"; } String newValue = "test"; - System.out.println(name + ":" + value); + LOG.info( "{} : {}",name, value); HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, responseSpec, "S3", name, newValue); Assert.assertNotNull(arrayListValue.get("value")); @@ -95,7 +97,7 @@ public class ExternalServicesConfigurationTest { value = "testnull"; } String newValue = "test"; - System.out.println(name + ":" + value); + LOG.info("{} : {}",name,value); HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec, responseSpec, "SMTP", name, newValue); Assert.assertNotNull(arrayListValue.get("value")); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java index 83e79f61d..bf3cbe757 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/FixedDepositTest.java @@ -63,10 +63,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" }) public class FixedDepositTest { - + private final static Logger LOG = LoggerFactory.getLogger(FixedDepositTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private FixedDepositProductHelper fixedDepositProductHelper; @@ -1224,7 +1226,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.getActualMaximum(Calendar.DATE); @@ -1236,7 +1238,7 @@ public class FixedDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); } @@ -1298,7 +1300,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.getActualMaximum(Calendar.DATE); @@ -1309,7 +1311,7 @@ public class FixedDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); } @@ -1376,7 +1378,7 @@ public class FixedDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.add(Calendar.MONTH, -1); @@ -1387,12 +1389,12 @@ public class FixedDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth; todaysDate.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(todaysDate.getTime())); + LOG.info("{}",monthDayFormat.format(todaysDate.getTime())); interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE); @@ -1484,7 +1486,7 @@ public class FixedDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}", perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.add(Calendar.MONTH, -1); @@ -1495,12 +1497,12 @@ public class FixedDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth; todaysDate.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(todaysDate.getTime())); + LOG.info("{}",monthDayFormat.format(todaysDate.getTime())); interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE); @@ -1597,7 +1599,7 @@ public class FixedDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.add(Calendar.MONTH, -1); @@ -1608,12 +1610,12 @@ public class FixedDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth; todaysDate.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(todaysDate.getTime())); + LOG.info("{}",monthDayFormat.format(todaysDate.getTime())); interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE); @@ -1713,7 +1715,7 @@ public class FixedDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.add(Calendar.MONTH, -1); @@ -1724,12 +1726,12 @@ public class FixedDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth; todaysDate.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(todaysDate.getTime())); + LOG.info("{}",monthDayFormat.format(todaysDate.getTime())); interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); this.fixedDepositAccountHelper.calculatePrematureAmountForFixedDeposit(fixedDepositAccountId, CLOSED_ON_DATE); @@ -1812,7 +1814,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.getActualMaximum(Calendar.DATE); @@ -1824,7 +1826,7 @@ public class FixedDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); } @@ -1853,7 +1855,7 @@ public class FixedDepositTest { dateFormat.format(todaysDate.getTime()); monthDayFormat.format(todaysDate.getTime()); - System.out.println("Submitted Date:" + SUBMITTED_ON_DATE); + LOG.info("Submitted Date: {}" , SUBMITTED_ON_DATE); Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); Assert.assertNotNull(clientId); @@ -1889,7 +1891,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; todaysDate.getActualMaximum(Calendar.DATE); @@ -1899,7 +1901,7 @@ public class FixedDepositTest { principal = new BigDecimal(principal).setScale(0, RoundingMode.FLOOR).floatValue(); maturityAmount = new BigDecimal(maturityAmount).setScale(0, RoundingMode.FLOOR).floatValue(); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount); } @@ -1925,7 +1927,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -1971,7 +1973,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2009,7 +2011,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2055,7 +2057,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2094,7 +2096,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2137,7 +2139,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2176,7 +2178,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2219,7 +2221,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" ,perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2258,7 +2260,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2301,7 +2303,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2339,7 +2341,7 @@ public class FixedDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2382,7 +2384,7 @@ public class FixedDepositTest { Float interestRate = this.fixedDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod, @@ -2400,7 +2402,7 @@ public class FixedDepositTest { private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -2415,7 +2417,7 @@ public class FixedDepositTest { private Integer createFixedDepositProductWithWithHoldTax(final String validFrom, final String validTo, final String taxGroupId, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -2430,7 +2432,7 @@ public class FixedDepositTest { private Integer createFixedDepositProduct(final String validFrom, final String validTo, final String accountingRule, final String chartToBePicked, Account... accounts) { - System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { fixedDepositProductHelper = fixedDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -2461,7 +2463,7 @@ public class FixedDepositTest { private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, final String penalInterestType) { - System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate).build(clientID, productID, penalInterestType); return this.fixedDepositAccountHelper @@ -2470,7 +2472,7 @@ public class FixedDepositTest { private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String submittedOnDate, final String penalInterestType, final String depositAmount, final String depositPeriod) { - System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate).withDepositPeriod(depositPeriod).withDepositAmount(depositAmount) @@ -2481,7 +2483,7 @@ public class FixedDepositTest { private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String minOpenningBalance, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); if (accountingRule.equals(CASH_BASED)) { 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 368b3c40a..57cd2af45 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 @@ -39,10 +39,12 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unused", "unchecked" }) public class FlexibleSavingsInterestPostingIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(FlexibleSavingsInterestPostingIntegrationTest.class); public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; private ResponseSpecification responseSpec; @@ -84,7 +86,7 @@ public class FlexibleSavingsInterestPostingIntegrationTest { ArrayList> transactions = (ArrayList>) accountDetails.get("transactions"); HashMap interestPostingTransaction = transactions.get(transactions.size() - 2); for (Entry entry : interestPostingTransaction.entrySet()) - System.out.println(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 diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java index e99dd804a..2a3d0a631 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/GroupTest.java @@ -37,13 +37,15 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Group Test for checking Group: Creation, Activation, Client Association, * Updating & Deletion */ public class GroupTest { - + private final static Logger LOG = LoggerFactory.getLogger(GroupTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -107,11 +109,11 @@ public class GroupTest { // create staff Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); - System.out.println("--------------creating first staff with id-------------" + createStaffId1); + LOG.info("--------------creating first staff with id------------- {}" , createStaffId1); Assert.assertNotNull(createStaffId1); Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec); - System.out.println("--------------creating second staff with id-------------" + createStaffId2); + LOG.info("--------------creating second staff with id------------- {}" , createStaffId2); Assert.assertNotNull(createStaffId2); // assign staff "createStaffId1" to group @@ -155,7 +157,7 @@ public class GroupTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/HookIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/HookIntegrationTest.java index f1e301f87..0e214a79c 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/HookIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/HookIntegrationTest.java @@ -36,9 +36,11 @@ import org.apache.http.conn.HttpHostConnectException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HookIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(HookIntegrationTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; @@ -77,7 +79,7 @@ public class HookIntegrationTest { final Integer notificationOfficeId = JsonPath.with(json).get("officeId"); Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID, notificationOfficeId); - System.out.println("Notification Office Id - " + notificationOfficeId); + LOG.info("Notification Office Id - {}" , notificationOfficeId); i = 6; } catch (Exception e) { TimeUnit.SECONDS.sleep(3); @@ -102,13 +104,13 @@ public class HookIntegrationTest { Long hookId = this.hookHelper.createHook(payloadURL).longValue(); Assert.assertNotNull(hookId); this.hookHelper.verifyHookCreatedOnServer(hookId); - System.out.println("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK-------------------------"+hookId); + LOG.info("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK------------------------- {}",hookId); this.hookHelper.updateHook(updateURL, hookId); this.hookHelper.verifyUpdateHook(updateURL, hookId); - System.out.println("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK-------------------------"+hookId); + LOG.info("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK------------------------- {}",hookId); this.hookHelper.deleteHook(hookId); this.hookHelper.verifyDeleteHook(hookId); - System.out.println("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK-------------------------"+hookId); + LOG.info("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK------------------------- {}",hookId); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationApprovalTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationApprovalTest.java index 044d73ba6..81d4fae6d 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationApprovalTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationApprovalTest.java @@ -37,10 +37,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class LoanApplicationApprovalTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationApprovalTest.class); private ResponseSpecification responseSpec; private ResponseSpecification responseSpecForStatusCode403; private ResponseSpecification responseSpecForStatusCode400; @@ -128,14 +130,14 @@ public class LoanApplicationApprovalTest { createTranches.add(createTrancheDetail("23 March 2014", "4000")); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" + , clientID); final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .build(null)); - System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" - + loanProductID); + LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" + , loanProductID); this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches); this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches); @@ -153,19 +155,18 @@ public class LoanApplicationApprovalTest { approveTranches.add(createTrancheDetail("23 March 2014", "1000")); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); - System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" - + loanID); + LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" + , loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanID, approveTranches); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out - .println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------"); + LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------"); } @@ -200,13 +201,13 @@ public class LoanApplicationApprovalTest { approveTranche4.add(createTrancheDetail("24 March 2014", "100")); final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); - System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" - + loanID); + LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" + , loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400); /* Tranches with same expected disbursement date */ @@ -256,7 +257,7 @@ public class LoanApplicationApprovalTest { public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationUndoLastTrancheTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationUndoLastTrancheTest.java index 04b4d24eb..a2ccea450 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationUndoLastTrancheTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanApplicationUndoLastTrancheTest.java @@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class LoanApplicationUndoLastTrancheTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanApplicationUndoLastTrancheTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -65,15 +67,15 @@ public class LoanApplicationUndoLastTrancheTest { // CREATE CLIENT final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" + , clientID); // CREATE LOAN MULTIDISBURSAL PRODUCT final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .build(null)); - System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" - + loanProductID); + LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" + , loanProductID); // CREATE TRANCHES List createTranches = new ArrayList<>(); @@ -87,14 +89,14 @@ public class LoanApplicationUndoLastTrancheTest { // APPLY FOR LOAN WITH TRANCHES final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); - System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" - + loanID); + LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" + , loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); // VALIDATE THE LOAN STATUS LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanID, approveTranches); @@ -109,11 +111,11 @@ public class LoanApplicationUndoLastTrancheTest { // VALIDATE THE LOAN IS ACTIVE STATUS LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - System.out.println("-------------Make repayment 1-----------"); + LOG.info("-------------Make repayment 1-----------"); this.loanTransactionHelper.makeRepayment("01 April 2014", Float.valueOf("420"), loanID); - System.out.println("-------------Make repayment 2-----------"); + LOG.info("-------------Make repayment 2-----------"); this.loanTransactionHelper.makeRepayment("01 May 2014", Float.valueOf("412"), loanID); - System.out.println("-------------Make repayment 3-----------"); + LOG.info("-------------Make repayment 3-----------"); this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID); // DISBURSE A SECOND TRANCHE this.loanTransactionHelper.disburseLoan("23 June 2014", loanID); @@ -129,7 +131,7 @@ public class LoanApplicationUndoLastTrancheTest { public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursalDateValidationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursalDateValidationTest.java index 64b9ee4ec..abc9640ea 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursalDateValidationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanDisbursalDateValidationTest.java @@ -35,10 +35,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class LoanDisbursalDateValidationTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursalDateValidationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -63,25 +65,25 @@ public class LoanDisbursalDateValidationTest { // CREATE CLIENT final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" + , clientID); // CREATE LOAN PRODUCT final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() .withSyncExpectedWithDisbursementDate(true).build(null)); - System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" - + loanProductID); + LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" + , loanProductID); // APPLY FOR LOAN final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount); - System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" - + loanID); + LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" + , loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); // VALIDATE THE LOAN STATUS LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(approveDate, loanID); // VALIDATE THE LOAN IS APPROVED 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 c5b936bd4..35be2ff3f 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 @@ -39,10 +39,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class LoanDisbursementDetailsIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanDisbursementDetailsIntegrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -73,21 +75,20 @@ public class LoanDisbursementDetailsIntegrationTest { createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 Sep 2015", "5000")); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------{}" + , clientID); final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() .withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true) .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null)); - System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" - + loanProductID); + LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" + , loanProductID); final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, installmentAmount); - System.out - .println("-----------------------------------LOAN CREATED WITH EMI LOANID-------------------------------------------------" - + loanIDWithEmi); + LOG.info("-----------------------------------LOAN CREATED WITH EMI LOANID------------------------------------------------- {}" + , loanIDWithEmi); HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanIDWithEmi, "repaymentSchedule"); @@ -100,13 +101,12 @@ public class LoanDisbursementDetailsIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithEmi); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanIDWithEmi, createTranches); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out - .println("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------"); + LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------"); final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches, withoutInstallmentAmount); @@ -117,9 +117,8 @@ public class LoanDisbursementDetailsIntegrationTest { ArrayList periods1 = (ArrayList) repaymentScheduleWithEmi.get("periods"); assertEquals(periods1.size(), 15); - System.out - .println("-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------" - + loanIDWithoutEmi); + LOG.info("-----------------------------------LOAN CREATED WITHOUT EMI LOANID------------------------------------------------- {}" + , loanIDWithoutEmi); /* To be uncommented once issue MIFOSX-2006 is closed. */ // this.validateRepaymentScheduleWithoutEMI(periods1); @@ -127,13 +126,12 @@ public class LoanDisbursementDetailsIntegrationTest { HashMap loanStatusMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanIDWithoutEmi); LoanStatusChecker.verifyLoanIsPending(loanStatusMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount("01 June 2015", "01 June 2015", "10000", loanIDWithoutEmi, createTranches); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out - .println("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------"); + LOG.info("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------"); } @@ -209,7 +207,7 @@ public class LoanDisbursementDetailsIntegrationTest { assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate()); assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding()); - System.out.println(period.get("totalOriginalDueForPeriod").toString()); + LOG.info("{}",period.get("totalOriginalDueForPeriod").toString()); assertEquals(Float.valueOf(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule .getTotalOriginalDueForPeriod().floatValue(), 0.0f); @@ -342,7 +340,7 @@ public class LoanDisbursementDetailsIntegrationTest { private Integer applyForLoanApplicationWithEmiAmount(final Integer clientID, final Integer loanProductID, final String proposedAmount, List tranches, final String installmentAmount) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(proposedAmount) @@ -373,29 +371,28 @@ public class LoanDisbursementDetailsIntegrationTest { createTranches.add(this.loanTransactionHelper.createTrancheDetail(id, "01 March 2014", "1000")); final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" + , clientID); final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder() .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true) .build(null)); - System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------" - + loanProductID); + LOG.info("----------------------------------LOAN PRODUCT CREATED WITH ID------------------------------------------- {}" + , loanProductID); this.loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches); - System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------" - + loanID); + LOG.info("-----------------------------------LOAN CREATED WITH LOANID------------------------------------------------- {}" + , loanID); HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanID, createTranches); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out - .println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------"); + LOG.info("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------"); ArrayList disbursementDetails = (ArrayList) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanID, "disbursementDetails"); this.disbursementId = (Integer) disbursementDetails.get(0).get("id"); @@ -474,7 +471,7 @@ public class LoanDisbursementDetailsIntegrationTest { private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRepaymentRescheduleAtDisbursementTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRepaymentRescheduleAtDisbursementTest.java index bef3864ff..eec0b7a22 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRepaymentRescheduleAtDisbursementTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanRepaymentRescheduleAtDisbursementTest.java @@ -40,10 +40,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanStatusChecker; import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class LoanRepaymentRescheduleAtDisbursementTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanRepaymentRescheduleAtDisbursementTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -73,8 +75,8 @@ public class LoanRepaymentRescheduleAtDisbursementTest { // CREATE CLIENT final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014"); - System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------" - + clientID); + LOG.info("---------------------------------CLIENT CREATED WITH ID--------------------------------------------------- {}" + , clientID); // CREATE LOAN MULTIDISBURSAL PRODUCT WITH INTEREST RECALCULATION final Integer loanProductID = createLoanProductWithInterestRecalculation(LoanProductTestBuilder.RBI_INDIA_STRATEGY, @@ -102,7 +104,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest { // VALIDATE THE LOAN STATUS LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanID, approveTranches); @@ -167,7 +169,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest { boolean isArrearsBasedOnOriginalSchedule, final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() .withPrincipal("10000.00") .withNumberOfRepayments("12") @@ -207,7 +209,7 @@ public class LoanRepaymentRescheduleAtDisbursementTest { private Integer applyForLoanApplicationForInterestRecalculation(final Integer clientID, final Integer loanProductID, final String disbursementDate, final String repaymentStrategy, final List charges, final String graceOnInterestPayment, final String graceOnPrincipalPayment, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000.00") // .withLoanTermFrequency("24") // 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 03376dc47..60a76be10 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 @@ -36,12 +36,15 @@ import org.apache.fineract.integrationtests.common.loans.LoanRescheduleRequestTe import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Test the creation, approval and rejection of a loan reschedule request **/ @SuppressWarnings({ "rawtypes" }) public class LoanRescheduleRequestTest { + private final static Logger LOG = LoggerFactory.getLogger(LoanRescheduleRequestTest.class); private ResponseSpecification responseSpec; private ResponseSpecification generalResponseSpec; private RequestSpecification requestSpec; @@ -93,7 +96,7 @@ public class LoanRescheduleRequestTest { * create a new loan product **/ private void createLoanProductEntity() { - System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); + LOG.info("---------------------------------CREATING LOAN PRODUCT------------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() .withPrincipal(loanPrincipalAmount) @@ -103,14 +106,14 @@ public class LoanRescheduleRequestTest { .build(null); this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON); - System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")"); + LOG.info("Successfully created loan product (ID:{}) " , this.loanProductId); } /** * submit a new loan application, approve and disburse the loan **/ private void createLoanEntity() { - System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------"); + LOG.info("---------------------------------NEW LOAN APPLICATION------------------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() .withPrincipal(loanPrincipalAmount) @@ -131,7 +134,7 @@ public class LoanRescheduleRequestTest { this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON); - System.out.println("Sucessfully created loan (ID: " + this.loanId + ")"); + LOG.info("Sucessfully created loan (ID: {} )" , this.loanId); this.approveLoanApplication(); this.disburseLoan(); @@ -144,7 +147,7 @@ public class LoanRescheduleRequestTest { if(this.loanId != null) { this.loanTransactionHelper.approveLoan(this.dateString, this.loanId); - System.out.println("Successfully approved loan (ID: " + this.loanId + ")"); + LOG.info("Successfully approved loan (ID: {} )" , this.loanId); } } @@ -155,7 +158,7 @@ public class LoanRescheduleRequestTest { if(this.loanId != null) { this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId); - System.out.println("Successfully disbursed loan (ID: " + this.loanId + ")"); + LOG.info("Successfully disbursed loan (ID: {} )" , this.loanId); } } @@ -163,14 +166,14 @@ public class LoanRescheduleRequestTest { * create new loan reschedule request **/ private void createLoanRescheduleRequest() { - System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); + LOG.info("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------"); final String requestJSON = new LoanRescheduleRequestTestBuilder().build(this.loanId.toString()); this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON); this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId); - System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); + LOG.info("Successfully created loan reschedule request (ID: {} )" , this.loanRescheduleRequestId); } @Test @@ -182,7 +185,7 @@ public class LoanRescheduleRequestTest { public void testRejectLoanRescheduleRequest() { this.createLoanRescheduleRequest(); - System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------"); + LOG.info("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------"); final String requestJSON = new LoanRescheduleRequestTestBuilder().getRejectLoanRescheduleRequestJSON(); this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); @@ -190,14 +193,14 @@ public class LoanRescheduleRequestTest { final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum"); assertTrue((Boolean)response.get("rejected")); - System.out.println("Successfully rejected loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); + LOG.info("Successfully rejected loan reschedule request (ID: {} )" , this.loanRescheduleRequestId); } @Test public void testApproveLoanRescheduleRequest() { this.createLoanRescheduleRequest(); - System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------"); + LOG.info("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------"); final String requestJSON = new LoanRescheduleRequestTestBuilder().getApproveLoanRescheduleRequestJSON(); this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON); @@ -212,6 +215,6 @@ public class LoanRescheduleRequestTest { 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()); - System.out.println("Successfully approved loan reschedule request (ID: " + this.loanRescheduleRequestId + ")"); + LOG.info("Successfully approved loan reschedule request (ID: {})" , this.loanRescheduleRequestId); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java index 44a1701b0..2ed745ca7 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanReschedulingWithinCenterTest.java @@ -52,9 +52,11 @@ import org.apache.fineract.integrationtests.common.organisation.StaffHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LoanReschedulingWithinCenterTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanReschedulingWithinCenterTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; private LoanTransactionHelper loanTransactionHelper; @@ -133,7 +135,7 @@ public class LoanReschedulingWithinCenterTest { loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); + LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); todaysdate.add(Calendar.DAY_OF_MONTH, 14); String oldMeetingDate = dateFormat.format(todaysdate.getTime()); @@ -181,7 +183,7 @@ public class LoanReschedulingWithinCenterTest { Integer calendarId = CalendarHelper.createMeetingForGroup(this.requestSpec, this.responseSpec, centerId, startDate, frequency, interval, repeatsOnDay.toString()); - System.out.println("calendarId " + calendarId); + LOG.info("calendarId {}" , calendarId); return calendarId; } @@ -253,7 +255,7 @@ public class LoanReschedulingWithinCenterTest { // VALIDATE THE LOAN STATUS LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount, loanID, approveTranches); @@ -265,7 +267,7 @@ public class LoanReschedulingWithinCenterTest { this.loanTransactionHelper.disburseLoan(disbursementDate, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); + LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); Calendar todaysdate = Calendar.getInstance(Utils.getTimeZoneOfTenant()); todaysdate.add(Calendar.DAY_OF_MONTH, 14); String oldMeetingDate = dateFormat.format(todaysdate.getTime()); @@ -312,7 +314,7 @@ public class LoanReschedulingWithinCenterTest { final Integer recalculationCompoundingFrequencyOnDayType, final Integer recalculationCompoundingFrequencyDayOfWeekType, final Integer recalculationRestFrequencyOnDayType, final Integer recalculationRestFrequencyDayOfWeekType) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() .withPrincipal("10000.00") .withNumberOfRepayments("12") @@ -359,7 +361,7 @@ public class LoanReschedulingWithinCenterTest { final Integer loanProductID, final String disbursementDate, final String restStartDate, final String compoundingStartDate, final String repaymentStrategy, final List charges, final String graceOnInterestPayment, final String graceOnPrincipalPayment, List tranches) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000.00") // .withLoanTermFrequency("24") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanWithWaiveInterestAndWriteOffIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanWithWaiveInterestAndWriteOffIntegrationTest.java index dd9447751..c5aacb81b 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanWithWaiveInterestAndWriteOffIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/LoanWithWaiveInterestAndWriteOffIntegrationTest.java @@ -33,6 +33,8 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Client Loan Integration Test for checking Loan Disbursement with Waive @@ -40,7 +42,7 @@ import org.junit.Test; */ @SuppressWarnings({ "rawtypes" }) public class LoanWithWaiveInterestAndWriteOffIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(LoanWithWaiveInterestAndWriteOffIntegrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -74,7 +76,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -83,14 +85,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------RE-APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------RE-APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("1 October 2010", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); // DISBURSE loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}" , loanStatusHashMap.toString()); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // PERFORM REPAYMENTS AND CHECK LOAN STATUS @@ -103,7 +105,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { // DIBURSE AGAIN loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}" , loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // MAKE REPAYMENTS @@ -142,14 +144,14 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); // DISBURSE loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID); - System.out.println("DISBURSE " + loanStatusHashMap); + LOG.info("DISBURSE {}" , loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); // MAKE REPAYMENTS @@ -179,7 +181,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { } private Integer createLoanProduct() { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth() .withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth() .withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths() @@ -189,7 +191,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(this.PRINCIPAL) .withLoanTermFrequency(this.LOAN_TERM_FREQUENCY).withLoanTermFrequencyAsMonths() .withNumberOfRepayments(this.NUMBER_OF_REPAYMENTS).withRepaymentEveryAfter(this.REPAYMENT_PERIOD) diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/NotificationApiTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/NotificationApiTest.java index 7b1d604a3..e4925d0a1 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/NotificationApiTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/NotificationApiTest.java @@ -29,9 +29,11 @@ import org.apache.fineract.integrationtests.common.Utils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NotificationApiTest { - + private final static Logger LOG = LoggerFactory.getLogger(NotificationApiTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -48,7 +50,7 @@ public class NotificationApiTest { public void testNotificationRetrieval() { HashMap response = (HashMap) NotificationHelper.getNotifications(this.requestSpec, this.responseSpec, ""); - System.out.println("Response : " + response.toString()); + LOG.info("Response : {}" , response.toString()); Assert.assertNotNull(response); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/PasswordPreferencesIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/PasswordPreferencesIntegrationTest.java index a4705a45c..f670693e1 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/PasswordPreferencesIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/PasswordPreferencesIntegrationTest.java @@ -32,10 +32,12 @@ import org.apache.fineract.integrationtests.common.PasswordPreferencesHelper; import org.apache.fineract.integrationtests.common.Utils; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class PasswordPreferencesIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(PasswordPreferencesIntegrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private ResponseSpecification generalResponseSpec; @@ -60,7 +62,7 @@ public class PasswordPreferencesIntegrationTest { private void validateIfThePasswordIsUpdated(String validationPolicyId){ Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec); assertEquals(validationPolicyId, id.toString()); - System.out.println("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------"); + LOG.info("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java index 55b789063..6ae8df598 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/RecurringDepositTest.java @@ -62,10 +62,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes", "unchecked", "static-access" }) public class RecurringDepositTest { - + private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private RecurringDepositProductHelper recurringDepositProductHelper; @@ -1420,7 +1422,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); @@ -1432,7 +1434,7 @@ public class RecurringDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); } @@ -1505,7 +1507,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); @@ -1517,7 +1519,7 @@ public class RecurringDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); } @@ -1588,7 +1590,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US)); @@ -1601,7 +1603,7 @@ public class RecurringDepositTest { principal += interestToBePosted; Float expectedBalanceAfter = Float.valueOf(decimalFormat.format(principal)); - System.out.println(expectedBalanceAfter); + LOG.info("{}",expectedBalanceAfter.toString()); Integer transactionIdForPostInterest = this.recurringDepositAccountHelper .postInterestForRecurringDeposit(recurringDepositAccountId); @@ -1696,7 +1698,7 @@ public class RecurringDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Calendar calendar = Calendar.getInstance(); @@ -1707,7 +1709,7 @@ public class RecurringDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth + depositAmount; calendar.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(calendar.getTime())); + LOG.info("{}",monthDayFormat.format(calendar.getTime())); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, @@ -1716,9 +1718,9 @@ public class RecurringDepositTest { currentDate = currentDate - 1; interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( recurringDepositAccountId, CLOSED_ON_DATE); @@ -1828,7 +1830,7 @@ public class RecurringDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Calendar calendar = Calendar.getInstance(); @@ -1839,7 +1841,7 @@ public class RecurringDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth + depositAmount; calendar.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(calendar.getTime())); + LOG.info("{}",monthDayFormat.format(calendar.getTime())); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, @@ -1848,9 +1850,9 @@ public class RecurringDepositTest { currentDate = currentDate - 1; interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( recurringDepositAccountId, CLOSED_ON_DATE); @@ -1967,7 +1969,7 @@ public class RecurringDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Calendar calendar = Calendar.getInstance(); @@ -1979,7 +1981,7 @@ public class RecurringDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth + depositAmount; calendar.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(calendar.getTime())); + LOG.info("{}",monthDayFormat.format(calendar.getTime())); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); Integer transactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, @@ -1988,9 +1990,9 @@ public class RecurringDepositTest { currentDate = currentDate - 1; interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( recurringDepositAccountId, CLOSED_ON_DATE); @@ -2112,7 +2114,7 @@ public class RecurringDepositTest { interestRate -= preClosurePenalInterestRate; double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Calendar calendar = Calendar.getInstance(); @@ -2124,7 +2126,7 @@ public class RecurringDepositTest { Float interestPerMonth = (float) (interestPerDay * principal * daysInMonth); principal += interestPerMonth + depositAmount; calendar.add(Calendar.DATE, daysInMonth); - System.out.println(monthDayFormat.format(calendar.getTime())); + LOG.info("{}",monthDayFormat.format(calendar.getTime())); EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(calendar.getTime()); Integer newTransactionIdForDeposit = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, @@ -2133,9 +2135,9 @@ public class RecurringDepositTest { currentDate = currentDate - 1; interestPerMonth = (float) (interestPerDay * principal * currentDate); - System.out.println("IPM = " + interestPerMonth); + LOG.info("IPM = {}" , interestPerMonth); principal += interestPerMonth; - System.out.println("principal = " + principal); + LOG.info("principal = {}" , principal); HashMap recurringDepositPrematureData = this.recurringDepositAccountHelper.calculatePrematureAmountForRecurringDeposit( recurringDepositAccountId, CLOSED_ON_DATE); @@ -2227,7 +2229,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); @@ -2239,7 +2241,7 @@ public class RecurringDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); } @@ -2312,7 +2314,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); @@ -2324,7 +2326,7 @@ public class RecurringDepositTest { decimalFormat.applyPattern("."); principal = Float.valueOf(decimalFormat.format(principal)); maturityAmount = Float.valueOf(decimalFormat.format(maturityAmount)); - System.out.println(principal); + LOG.info("{}",principal.toString()); Assert.assertEquals("Verifying Maturity amount for Recurring Deposit Account", principal, maturityAmount); } @@ -2355,7 +2357,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2403,7 +2405,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {}" , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -2446,7 +2448,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2494,7 +2496,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {} " , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -2536,7 +2538,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2585,7 +2587,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {} " , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -2627,7 +2629,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2676,7 +2678,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {} " , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -2719,7 +2721,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2767,7 +2769,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {} " , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -2810,7 +2812,7 @@ public class RecurringDepositTest { Integer daysLeft = daysInMonth - currentDate; todaysDate.add(Calendar.DATE, (daysLeft + 1)); daysInMonth = todaysDate.getActualMaximum(Calendar.DATE); - System.out.println(dateFormat.format(todaysDate.getTime())); + LOG.info("{}",dateFormat.format(todaysDate.getTime())); final String VALID_FROM = dateFormat.format(todaysDate.getTime()); final String VALID_TO = null; @@ -2858,7 +2860,7 @@ public class RecurringDepositTest { Float interestRate = this.recurringDepositAccountHelper.getInterestRate(interestRateChartData, depositPeriod); double interestRateInFraction = (interestRate / 100); double perDay = (double) 1 / (daysInYear); - System.out.println("per day = " + perDay); + LOG.info("per day = {} " , perDay); double interestPerDay = interestRateInFraction * perDay; principal = this.recurringDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, recurringDepositAmount, @@ -3040,7 +3042,7 @@ public class RecurringDepositTest { private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -3053,7 +3055,7 @@ public class RecurringDepositTest { private Integer createRecurringDepositProductWithWithHoldTax(final String validFrom, final String validTo,final String taxGroupId, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -3068,7 +3070,7 @@ public class RecurringDepositTest { private Integer createRecurringDepositProduct(final String validFrom, final String validTo, final String accountingRule, final String chartToBePicked, Account... accounts) { - System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------"); RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec); if (accountingRule.equals(CASH_BASED)) { recurringDepositProductHelper = recurringDepositProductHelper.withAccountingRuleAsCashBased(accounts); @@ -3098,7 +3100,7 @@ public class RecurringDepositTest { private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate) { - System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) .build(clientID, productID, penalInterestType); @@ -3109,7 +3111,7 @@ public class RecurringDepositTest { private Integer applyForRecurringDepositApplication(final String clientID, final String productID, final String validFrom, final String validTo, final String submittedOnDate, final String penalInterestType, final String expectedFirstDepositOnDate, final String depositAmount, final String depositPeriod) { - System.out.println("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); + LOG.info("--------------------------------APPLYING FOR RECURRING DEPOSIT ACCOUNT --------------------------------"); final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) .withSubmittedOnDate(submittedOnDate).withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) .withDepositPeriod(depositPeriod).withMandatoryDepositAmount(depositAmount).build(clientID, productID, penalInterestType); @@ -3119,7 +3121,7 @@ public class RecurringDepositTest { private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String minOpenningBalance, final String accountingRule, Account... accounts) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); if (accountingRule.equals(CASH_BASED)) { savingsProductHelper = savingsProductHelper.withAccountingRuleAsCashBased(accounts); 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 ba745b21c..46697fb82 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 @@ -34,9 +34,11 @@ import org.apache.fineract.integrationtests.useradministration.users.UserHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RolesTest { - + private final static Logger LOG = LoggerFactory.getLogger(RolesTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; @@ -52,11 +54,11 @@ public class RolesTest { @Test public void testCreateRolesStatus() { - System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); + LOG.info("---------------------------------CREATING A ROLE---------------------------------------------"); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); Assert.assertNotNull(roleId); - System.out.println("--------------------------------- Getting ROLE -------------------------------"); + LOG.info("--------------------------------- Getting ROLE -------------------------------"); HashMap role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); @@ -66,15 +68,15 @@ public class RolesTest { @Test public void testDisableRolesStatus() { - System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); + LOG.info("---------------------------------CREATING A ROLE---------------------------------------------"); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); Assert.assertNotNull(roleId); - System.out.println("--------------------------------- Getting ROLE -------------------------------"); + LOG.info("--------------------------------- Getting ROLE -------------------------------"); HashMap role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - System.out.println("--------------------------------- DISABLING ROLE -------------------------------"); + LOG.info("--------------------------------- DISABLING ROLE -------------------------------"); final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId); assertEquals(disableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); @@ -87,22 +89,22 @@ public class RolesTest { @Test public void testEnableRolesStatus() { - System.out.println("---------------------------------CREATING A ROLE---------------------------------------------"); + LOG.info("---------------------------------CREATING A ROLE---------------------------------------------"); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); Assert.assertNotNull(roleId); - System.out.println("--------------------------------- Getting ROLE -------------------------------"); + LOG.info("--------------------------------- Getting ROLE -------------------------------"); HashMap role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - System.out.println("--------------------------------- DISABLING ROLE -------------------------------"); + LOG.info("--------------------------------- DISABLING ROLE -------------------------------"); final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId); assertEquals(disableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); assertEquals((Boolean) role.get("disabled"), true); - System.out.println("--------------------------------- ENABLING ROLE -------------------------------"); + LOG.info("--------------------------------- ENABLING ROLE -------------------------------"); final Integer enableRoleId = RolesHelper.enableRole(this.requestSpec, this.responseSpec, roleId); assertEquals(enableRoleId, roleId); role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); @@ -115,15 +117,15 @@ public class RolesTest { @Test public void testDeleteRoleStatus() { - System.out.println("-------------------------------- CREATING A ROLE---------------------------------------------"); + LOG.info("-------------------------------- CREATING A ROLE---------------------------------------------"); final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec); Assert.assertNotNull(roleId); - System.out.println("--------------------------------- Getting ROLE -------------------------------"); + LOG.info("--------------------------------- Getting ROLE -------------------------------"); HashMap role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId); assertEquals((Integer) role.get("id"), roleId); - System.out.println("--------------------------------- DELETE ROLE -------------------------------"); + LOG.info("--------------------------------- DELETE ROLE -------------------------------"); final Integer deleteRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId); assertEquals(deleteRoleId, roleId); } 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 d00e03a68..fd49a7124 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 @@ -51,10 +51,13 @@ public class SchedulerJobsTest { @Test // FINERACT-926 public void testDateFormat() { - // must start scheduler and make job active to have nextRunTime (which is a java.util.Date) + // must start scheduler and make job active to have nextRunTime (which is a + // java.util.Date) schedulerJobHelper.updateSchedulerStatus(true); schedulerJobHelper.updateSchedulerJob(1, "true"); - String nextRunTimeText = await().until(() -> (String)schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"), nextRunTime -> nextRunTime != null); + String nextRunTimeText = await().until( + () -> (String) schedulerJobHelper.getSchedulerJobById(1).get("nextRunTime"), + nextRunTime -> nextRunTime != null); DateTimeFormatter.ISO_INSTANT.parse(nextRunTimeText); } @@ -77,7 +80,8 @@ public class SchedulerJobsTest { @Test public void testFlippingJobsActiveStatus() throws InterruptedException { - // Stop the Scheduler while we test flapping jobs' active on/off, to avoid side effects + // Stop the Scheduler while we test flapping jobs' active on/off, to avoid side + // effects schedulerJobHelper.updateSchedulerStatus(false); // For each retrieved scheduled job (by ID)... @@ -119,13 +123,13 @@ public class SchedulerJobsTest { Thread.sleep(500); schedulerJob = schedulerJobHelper.getSchedulerJobById(jobId); assertNotNull(schedulerJob); - System.out.println("Job " + jobId +" is Still Running"); } @SuppressWarnings({ "unchecked", "rawtypes" }) List jobHistoryData = schedulerJobHelper.getSchedulerJobHistory(jobId); // Verifying the Status of the Recently executed Scheduler Job - assertFalse("Job History is empty :( Was it too slow? Failures in background job?", jobHistoryData.isEmpty()); + assertFalse("Job History is empty :( Was it too slow? Failures in background job?", + jobHistoryData.isEmpty()); assertEquals("Verifying Last Scheduler Job Status", "success", jobHistoryData.get(jobHistoryData.size() - 1).get("status")); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java index 0ece685ed..21976f4e5 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java @@ -69,936 +69,1024 @@ import org.junit.Test; @SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access", "cast" }) public class SchedulerJobsTestResults { - private static final String FROM_ACCOUNT_TYPE_LOAN = "1"; - private static final String FROM_ACCOUNT_TYPE_SAVINGS = "2"; - private static final String TO_ACCOUNT_TYPE_LOAN = "1"; - private static final String TO_ACCOUNT_TYPE_SAVINGS = "2"; - private final String DATE_OF_JOINING = "01 January 2011"; - - private final String TRANSACTION_DATE = "01 March 2013"; - public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; - public static final String MINIMUM_OPENING_BALANCE = "1000"; - - Float SP_BALANCE = Float.valueOf(MINIMUM_OPENING_BALANCE); - - private static ResponseSpecification responseSpec; - private static RequestSpecification requestSpec; - private ResponseSpecification responseSpecForSchedulerJob; - private SchedulerJobHelper schedulerJobHelper; - private SavingsAccountHelper savingsAccountHelper; - private LoanTransactionHelper loanTransactionHelper; - private HolidayHelper holidayHelper; - private GlobalConfigurationHelper globalConfigurationHelper; - private AccountHelper accountHelper; - private JournalEntryHelper journalEntryHelper; - private StandingInstructionsHelper standingInstructionsHelper; - - @Before - public void setup() { - Utils.initializeRESTAssured(); - this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); - this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); - this.requestSpec.header("Fineract-Platform-TenantId", "default"); - this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); - this.responseSpecForSchedulerJob = new ResponseSpecBuilder().expectStatusCode(202).build(); - this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); - this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec); - } - - @After - public void tearDown() { - GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); - } - - @Test - @Ignore // TODO FINERACT-924 - public void testApplyAnnualFeeForSavingsJobOutcome() 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 annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, - ChargesHelper.getSavingsAnnualFeeJSON()); - Assert.assertNotNull(annualFeeChargeId); - - this.savingsAccountHelper.addChargesForSavings(savingsId, annualFeeChargeId, true); - ArrayList 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); - - String JobName = "Apply Annual Fee For Savings"; - - this.schedulerJobHelper.executeJob(JobName); - final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId); - - Float chargeAmount = (Float) chargeData.get("amount"); - - final HashMap savingsDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); - final HashMap annualFeeDetails = (HashMap) savingsDetails.get("annualFee"); - ArrayList annualFeeDueDateAsArrayList = (ArrayList) annualFeeDetails.get("dueDate"); - LocalDate nextDueDateForAnnualFee = LocalDate.of(annualFeeDueDateAsArrayList.get(0), annualFeeDueDateAsArrayList.get(1), annualFeeDueDateAsArrayList.get(2)); - LocalDate todaysDate = LocalDate.now(ZoneId.of("Asia/Kolkata")); - - Assert.assertTrue("Verifying that all due Annual Fees have been paid ", - nextDueDateForAnnualFee.isAfter(todaysDate)); - - } - - @Test - @Ignore - public void testInterestPostingForSavingsJobOutcome() 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); - - savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); - SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - - savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); - SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - - final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); - - String JobName = "Post Interest For Savings"; - - this.schedulerJobHelper.executeJob(JobName); - final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); - - Assert.assertNotSame("Verifying the Balance after running Post Interest for Savings Job", summaryBefore.get("accountBalance"), - summaryAfter.get("accountBalance")); - - } - - @Test - @Ignore // TODO FINERACT-857 - public void testTransferFeeForLoansFromSavingsJobOutcome() throws InterruptedException { - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(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); - - savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); - SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - - savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); - SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), savingsId.toString()); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, - ChargesHelper.getLoanSpecifiedDueDateWithAccountTransferJSON()); - Assert.assertNotNull(specifiedDueDateChargeId); - - this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString(), "12 March 2013", "100")); - ArrayList chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); - Assert.assertEquals(1, chargesPendingState.size()); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); - - String JobName = "Transfer Fee For Loans From Savings"; - this.schedulerJobHelper.executeJob(JobName); - final 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 Transfer Fee for Loans from Savings", balance, - (Float) summaryAfter.get("accountBalance")); - - } - - @Test - @Ignore // TODO FINERACT-923 - public void testApplyHolidaysToLoansJobOutcome() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - this.holidayHelper = new HolidayHelper(this.requestSpec, this.responseSpec); - this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - Integer holidayId = this.holidayHelper.createHolidays(this.requestSpec, this.responseSpec); - Assert.assertNotNull(holidayId); - - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - // Retrieving All Global Configuration details - final ArrayList globalConfig = this.globalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec, - this.responseSpec); - Assert.assertNotNull(globalConfig); - - // Updating Value for reschedule-repayments-on-holidays Global - // Configuration - Integer configId = (Integer) globalConfig.get(3).get("id"); - Assert.assertNotNull(configId); - - HashMap configData = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec, - configId.toString()); - Assert.assertNotNull(configData); - - Boolean enabled = (Boolean) globalConfig.get(3).get("enabled"); - - if (enabled == false) { - enabled = true; - configId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec, - configId.toString(), enabled); - } - final ArrayList repaymentScheduleDataBeforeJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); - - holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, holidayId.toString()); - Assert.assertNotNull(holidayId); - - String JobName = "Apply Holidays To Loans"; - - this.schedulerJobHelper.executeJob(JobName); - final ArrayList repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); - - HashMap holidayData = this.holidayHelper.getHolidayById(this.requestSpec, this.responseSpec, holidayId.toString()); - ArrayList repaymentsRescheduledDate = (ArrayList) holidayData.get("repaymentsRescheduledTo"); - - ArrayList rescheduleDateAfter = (ArrayList) repaymentScheduleDataAfterJob.get(2).get("fromDate"); - - Assert.assertEquals("Verifying Repayment Rescheduled Date after Running Apply Holidays to Loans Scheduler Job", - repaymentsRescheduledDate, repaymentsRescheduledDate); - - } - - @Test - @Ignore // TODO FINERACT-857 - 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, true); - ArrayList 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); - - HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); - - String JobName = "Pay Due Savings Charges"; - - this.schedulerJobHelper.executeJob(JobName); - 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")); - } - - @Test - @Ignore // TODO FINERACT-857 - public void testUpdateAccountingRunningBalancesJobOutcome() throws InterruptedException { - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - - final Account assetAccount = this.accountHelper.createAssetAccount(); - final Account incomeAccount = this.accountHelper.createIncomeAccount(); - final Account expenseAccount = this.accountHelper.createExpenseAccount(); - final Account liabilityAccount = this.accountHelper.createLiabilityAccount(); - - final Integer accountID = assetAccount.getAccountID(); - - final Integer savingsProductID = createSavingsProduct(MINIMUM_OPENING_BALANCE, assetAccount, incomeAccount, expenseAccount, - liabilityAccount); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING); - final Integer savingsID = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); - - HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsID); - SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); - - savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsID); - SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - - savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsID); - SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - - // Checking initial Account entries. - final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) }; - final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) }; - this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, assetAccountInitialEntry); - this.journalEntryHelper - .checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, liablilityAccountInitialEntry); - - String JobName = "Update Accounting Running Balances"; - - this.schedulerJobHelper.executeJob(JobName); - final HashMap runningBalanceAfter = this.accountHelper.getAccountingWithRunningBalanceById(accountID.toString()); - - final Integer INT_BALANCE = Integer.valueOf(MINIMUM_OPENING_BALANCE); - - Assert.assertEquals("Verifying Account Running Balance after running Update Accounting Running Balances Scheduler Job", - INT_BALANCE, runningBalanceAfter.get("organizationRunningBalance")); - - } - - @Test - @Ignore // TODO FINERACT-857 - public void testUpdateLoanArrearsAgingJobOutcome() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - String JobName = "Update Loan Arrears Ageing"; - - this.schedulerJobHelper.executeJob(JobName); - HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); - - Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") + (Float) loanSummaryData.get("interestOverdue"); - - Assert.assertEquals("Verifying Arrears Aging after Running Update Loan Arrears Aging Scheduler Job", totalLoanArrearsAging, - loanSummaryData.get("totalOverdue")); - - } - - @Test - @Ignore // TODO FINERACT-857 - public void testUpdateLoanPaidInAdvanceJobOutcome() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - - Calendar todayDate = Calendar.getInstance(); - final String currentDate = dateFormat.format(todayDate.getTime()); - - todayDate.add(Calendar.MONTH, -1); - final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime()); - - todayDate = Calendar.getInstance(); - todayDate.add(Calendar.DATE, -5); - final String LOAN_FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime()); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - ArrayList loanScheduleBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); - - Float totalDueForCurrentPeriod = (Float) loanScheduleBefore.get(1).get("totalDueForPeriod"); - - this.loanTransactionHelper.makeRepayment(LOAN_FIRST_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID); - - HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); - - String JobName = "Update Loan Paid In Advance"; - this.schedulerJobHelper.executeJob(JobName); - // Retrieving Loan Repayment Schedule after the successful - // completion of - // Update Loan Paid in Advance Scheduler Job - ArrayList loanScheduleAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, - loanID); - - loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); - - Float totalPaidInAdvance = (Float) loanScheduleAfter.get(1).get("totalPaidInAdvanceForPeriod"); - - Assert.assertEquals("Verifying Loan Repayment in Advance after Running Update Loan Paid in Advance Scheduler Job", - totalDueForCurrentPeriod, totalPaidInAdvance); - - } - - // Invalid test case as it won't affect summary (Loan summary is properly - // updated before running this job) - @Ignore - @Test - public void testUpdateLoanSummaryJobOutcome() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - - Calendar todaysDate = Calendar.getInstance(); - final String currentDate = dateFormat.format(todaysDate.getTime()); - - todaysDate.add(Calendar.MONTH, -1); - final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime()); - - todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.DATE, -5); - final String LOAN_FIRST_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime()); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - Integer disburseChargeId = ChargesHelper - .createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getLoanDisbursementJSON()); - Assert.assertNotNull(disburseChargeId); - - this.loanTransactionHelper.addChargesForLoan(loanID, - LoanTransactionHelper.getDisbursementChargesForLoanAsJSON(disburseChargeId.toString())); - ArrayList chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); - Assert.assertEquals(1, chargesPendingState.size()); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); - - String JobName = "Update loan Summary"; - this.schedulerJobHelper.executeJob(JobName); - Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment") - /* - (Float) loanSummaryBefore.get("feeChargesPaid")*/; - HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); - Assert.assertEquals("Verifying Loan Summary after Running Update Loan Summary Scheduler Job", expectedSummaryAfterJob, - (Float) loanSummaryAfter.get("totalExpectedRepayment")); - - } - - @Test - @Ignore // TODO FINERACT-857 - public void testExecuteStandingInstructionsJobOutcome() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.standingInstructionsHelper = new StandingInstructionsHelper(this.requestSpec, this.responseSpec); - - DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US); - - Calendar todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.WEEK_OF_YEAR, -1); - final String VALID_FROM = dateFormat.format(todaysDate.getTime()); - - final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime()); - - todaysDate.add(Calendar.YEAR, 1); - final String VALID_TO = dateFormat.format(todaysDate.getTime()); - - 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 fromSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, - ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); - Assert.assertNotNull(savingsProductID); - - HashMap fromSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, fromSavingsId); - SavingsStatusChecker.verifySavingsIsPending(fromSavingsStatusHashMap); - - fromSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(fromSavingsId); - SavingsStatusChecker.verifySavingsIsApproved(fromSavingsStatusHashMap); - - fromSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(fromSavingsId); - SavingsStatusChecker.verifySavingsIsActive(fromSavingsStatusHashMap); - - final Integer toSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, - ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); - Assert.assertNotNull(savingsProductID); - - HashMap toSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, toSavingsId); - SavingsStatusChecker.verifySavingsIsPending(toSavingsStatusHashMap); - - toSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(toSavingsId); - SavingsStatusChecker.verifySavingsIsApproved(toSavingsStatusHashMap); - - toSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(toSavingsId); - SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap); - - HashMap fromSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(fromSavingsId); - Float fromSavingsBalanceBefore = (Float) fromSavingsSummaryBefore.get("accountBalance"); - - HashMap toSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(toSavingsId); - Float toSavingsBalanceBefore = (Float) toSavingsSummaryBefore.get("accountBalance"); - - Integer standingInstructionId = this.standingInstructionsHelper.createStandingInstruction(clientID.toString(), - fromSavingsId.toString(), toSavingsId.toString(), FROM_ACCOUNT_TYPE_SAVINGS, TO_ACCOUNT_TYPE_SAVINGS, VALID_FROM, VALID_TO, - MONTH_DAY); - Assert.assertNotNull(standingInstructionId); - - String JobName = "Execute Standing Instruction"; - this.schedulerJobHelper.executeJob(JobName); - HashMap fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsId); - Float fromSavingsBalanceAfter = (Float) fromSavingsSummaryAfter.get("accountBalance"); - - HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsId); - Float toSavingsBalanceAfter = (Float) toSavingsSummaryAfter.get("accountBalance"); - - final HashMap standingInstructionData = this.standingInstructionsHelper - .getStandingInstructionById(standingInstructionId.toString()); - Float expectedFromSavingsBalance = fromSavingsBalanceBefore - (Float) standingInstructionData.get("amount"); - Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount"); - - Assert.assertEquals("Verifying From Savings Balance after Successful completion of Scheduler Job", expectedFromSavingsBalance, - fromSavingsBalanceAfter); - Assert.assertEquals("Verifying To Savings Balance after Successful completion of Scheduler Job", expectedToSavingsBalance, - toSavingsBalanceAfter); - Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue(); - Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue(); - List standinInstructionHistoryData = this.standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId, - fromAccountType, clientID, transferType); - Assert.assertEquals("Verifying the no of stainding instruction transactions logged for the client", 1, - standinInstructionHistoryData.size()); - HashMap loggedTransaction = standinInstructionHistoryData.get(0); - - Assert.assertEquals("Verifying transferred amount and logged transaction amounts", (Float) standingInstructionData.get("amount"), - (Float) loggedTransaction.get("amount")); - - } - - @Test - @Ignore - public void testApplyPenaltyForOverdueLoansJobOutcome() throws InterruptedException { - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - Integer overdueFeeChargeId = ChargesHelper - .createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getLoanOverdueFeeJSON()); - Assert.assertNotNull(overdueFeeChargeId); - - final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString()); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - ArrayList repaymentScheduleDataBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); - - String JobName = "Apply penalty to overdue loans"; - this.schedulerJobHelper.executeJob(JobName); - - final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId); - - Float chargeAmount = (Float) chargeData.get("amount"); - - ArrayList repaymentScheduleDataAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); - - Assert.assertEquals("Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job", - chargeAmount, (Float) repaymentScheduleDataAfter.get(1).get("penaltyChargesDue")); - - loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - - } - - @Test - @Ignore // TODO FINERACT-857 - public void testAvoidUnncessaryPenaltyWhenAmountZeroForOverdueLoansJobOutcome() throws InterruptedException { - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); - - Integer overdueFeeChargeId = ChargesHelper - .createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getLoanOverdueFeeJSONWithCalculattionTypePercentage("0.000001")); - Assert.assertNotNull(overdueFeeChargeId); - - final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString()); - Assert.assertNotNull(loanProductID); - - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); - - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); - - ArrayList repaymentScheduleDataBefore = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); - - String JobName = "Apply penalty to overdue loans"; - Integer jobId = 12; - - this.schedulerJobHelper.executeJob(JobName); - - Map schedulerJob = this.schedulerJobHelper.getSchedulerJobById(jobId); - - Assert.assertNotNull(schedulerJob); - while ((Boolean) schedulerJob.get("currentlyRunning") == true) { - Thread.sleep(15000); - schedulerJob = this.schedulerJobHelper.getSchedulerJobById(jobId); - Assert.assertNotNull(schedulerJob); + private static final String FROM_ACCOUNT_TYPE_LOAN = "1"; + private static final String FROM_ACCOUNT_TYPE_SAVINGS = "2"; + private static final String TO_ACCOUNT_TYPE_LOAN = "1"; + private static final String TO_ACCOUNT_TYPE_SAVINGS = "2"; + private final String DATE_OF_JOINING = "01 January 2011"; + + private final String TRANSACTION_DATE = "01 March 2013"; + public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL"; + public static final String MINIMUM_OPENING_BALANCE = "1000"; + + Float SP_BALANCE = Float.valueOf(MINIMUM_OPENING_BALANCE); + + private static ResponseSpecification responseSpec; + private static RequestSpecification requestSpec; + private ResponseSpecification responseSpecForSchedulerJob; + private SchedulerJobHelper schedulerJobHelper; + private SavingsAccountHelper savingsAccountHelper; + private LoanTransactionHelper loanTransactionHelper; + private HolidayHelper holidayHelper; + private GlobalConfigurationHelper globalConfigurationHelper; + private AccountHelper accountHelper; + private JournalEntryHelper journalEntryHelper; + private StandingInstructionsHelper standingInstructionsHelper; + + @Before + public void setup() { + Utils.initializeRESTAssured(); + this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); + this.requestSpec.header("Authorization", + "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); + this.requestSpec.header("Fineract-Platform-TenantId", "default"); + this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); + this.responseSpecForSchedulerJob = new ResponseSpecBuilder().expectStatusCode(202).build(); + this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); + this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec); } - final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId); + @After + public void tearDown() { + GlobalConfigurationHelper.resetAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + GlobalConfigurationHelper.verifyAllDefaultGlobalConfigurations(this.requestSpec, this.responseSpec); + } - ArrayList repaymentScheduleDataAfter = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, - this.responseSpec, loanID); + @Test + @Ignore // TODO FINERACT-924 + public void testApplyAnnualFeeForSavingsJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - Assert.assertEquals("Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job", - 0, repaymentScheduleDataAfter.get(1).get("penaltyChargesDue")); + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); - final ArrayList loanCharges = this.loanTransactionHelper.getLoanCharges(this.requestSpec, - this.responseSpec, loanID); + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, + ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); + Assert.assertNotNull(savingsProductID); - Assert.assertNull("Verifying that charge isn't created when the amount is 0", loanCharges); + final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsProductID); - loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, savingsId); + SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); - } + final Integer annualFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, + ChargesHelper.getSavingsAnnualFeeJSON()); + Assert.assertNotNull(annualFeeChargeId); - @Test - @Ignore // TODO FINERACT-857 - public void testUpdateOverdueDaysForNPA() throws InterruptedException { - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + this.savingsAccountHelper.addChargesForSavings(savingsId, annualFeeChargeId, true); + ArrayList chargesPendingState = this.savingsAccountHelper.getSavingsCharges(savingsId); + Assert.assertEquals(1, chargesPendingState.size()); - final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientID); + savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - final Integer loanProductID = createLoanProduct(null); - Assert.assertNotNull(loanProductID); + savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); - Assert.assertNotNull(loanID); + String JobName = "Apply Annual Fee For Savings"; - HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); - LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + this.schedulerJobHelper.executeJob(JobName); + final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, + annualFeeChargeId); - loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + Float chargeAmount = (Float) chargeData.get("amount"); - loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID); - LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + final HashMap savingsDetails = this.savingsAccountHelper.getSavingsDetails(savingsId); + final HashMap annualFeeDetails = (HashMap) savingsDetails.get("annualFee"); + ArrayList annualFeeDueDateAsArrayList = (ArrayList) annualFeeDetails.get("dueDate"); + LocalDate nextDueDateForAnnualFee = LocalDate.of(annualFeeDueDateAsArrayList.get(0), + annualFeeDueDateAsArrayList.get(1), annualFeeDueDateAsArrayList.get(2)); + LocalDate todaysDate = LocalDate.now(ZoneId.of("Asia/Kolkata")); - final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA"); - Assert.assertFalse(isNPABefore); - // Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId"); - String JobName = "Update Non Performing Assets"; - this.schedulerJobHelper.executeJob(JobName); - final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA"); - Assert.assertTrue(isNPAAfter); - } + Assert.assertTrue("Verifying that all due Annual Fees have been paid ", + nextDueDateForAnnualFee.isAfter(todaysDate)); - @Test - @Ignore // TODO FINERACT-857 - public void testInterestTransferForSavings() throws InterruptedException { - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); - this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - //FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec,this.responseSpec); - //AccountHelper accountHelper = new AccountHelper(this.requestSpec, this.responseSpec); - FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec); + } - DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); - //DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US); + @Test + @Ignore + public void testInterestPostingForSavingsJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); - Calendar todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.MONTH, -3); - final String VALID_FROM = dateFormat.format(todaysDate.getTime()); - todaysDate.add(Calendar.YEAR, 10); - final String VALID_TO = dateFormat.format(todaysDate.getTime()); + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); - todaysDate = Calendar.getInstance(); - todaysDate.add(Calendar.MONTH, -2); - final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); - final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime()); - final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); - todaysDate.add(Calendar.MONTH, 1); - final String WHOLE_TERM = "1"; + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, + ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); + Assert.assertNotNull(savingsProductID); - Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); - Assert.assertNotNull(clientId); - Float balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + Float.valueOf(FixedDepositAccountHelper.depositAmount); - final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, String.valueOf(balance)); - Assert.assertNotNull(savingsProductID); + final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsProductID); - final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, savingsProductID, - ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); - Assert.assertNotNull(savingsId); + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, savingsId); + SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); - HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId); - SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); + savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); - SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); + savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); - SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - HashMap summary = savingsAccountHelper.getSavingsSummary(savingsId); - assertEquals("Verifying opening Balance", balance, summary.get("accountBalance")); + final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); - Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO); - Assert.assertNotNull(fixedDepositProductId); + String JobName = "Post Interest For Savings"; - Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), fixedDepositProductId.toString(), VALID_FROM, - VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, savingsId.toString(), true, fixedDepositAccountHelper); - Assert.assertNotNull(fixedDepositAccountId); + this.schedulerJobHelper.executeJob(JobName); + final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId); - HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker.getStatusOfFixedDepositAccount(this.requestSpec, - this.responseSpec, fixedDepositAccountId.toString()); - FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap); + Assert.assertNotSame("Verifying the Balance after running Post Interest for Savings Job", + summaryBefore.get("accountBalance"), summaryAfter.get("accountBalance")); - fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, APPROVED_ON_DATE); - FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap); + } - fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, ACTIVATION_DATE); - FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); - summary = savingsAccountHelper.getSavingsSummary(savingsId); - balance = Float.valueOf(MINIMUM_OPENING_BALANCE); - assertEquals("Verifying Balance", balance, summary.get("accountBalance")); + @Test + @Ignore // TODO FINERACT-857 + public void testTransferFeeForLoansFromSavingsJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); - fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId); + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); - HashMap fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); - Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") - Float.valueOf(FixedDepositAccountHelper.depositAmount); + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, + ClientSavingsIntegrationTest.MINIMUM_OPENING_BALANCE); + Assert.assertNotNull(savingsProductID); - String JobName = "Transfer Interest To Savings"; - this.schedulerJobHelper.executeJob(JobName); - fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); - assertEquals("Verifying opening Balance", Float.valueOf(FixedDepositAccountHelper.depositAmount), - fixedDepositSummary.get("accountBalance")); + final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsProductID); - summary = savingsAccountHelper.getSavingsSummary(savingsId); - balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + interestPosted; - validateNumberForEqualExcludePrecission(String.valueOf(balance), String.valueOf(summary.get("accountBalance"))); - } + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, savingsId); + SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); - private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String minOpenningBalance) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); - SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); - final String savingsProductJSON = savingsProductHelper // - .withInterestCompoundingPeriodTypeAsDaily() // - .withInterestPostingPeriodTypeAsMonthly() // - .withInterestCalculationPeriodTypeAsDailyBalance() // - .withMinimumOpenningBalance(minOpenningBalance).build(); - return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); - } + savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); - private static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); - final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() // - .withInterestPostingPeriodTypeAsQuarterly() // - .withInterestCalculationPeriodTypeAsDailyBalance() // - .withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsCashBased(accounts).build(); - return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); - } + savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); - private Integer createLoanProduct(final String chargeId) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); - final String loanProductJSON = new LoanProductTestBuilder() // - .withPrincipal("15,000.00") // - .withNumberOfRepayments("4") // - .withRepaymentAfterEvery("1") // - .withRepaymentTypeAsMonth() // - .withinterestRatePerPeriod("1") // - .withInterestRateFrequencyTypeAsMonths() // - .withAmortizationTypeAsEqualInstallments() // - .withInterestTypeAsDecliningBalance() // - .build(chargeId); - return this.loanTransactionHelper.getLoanProductId(loanProductJSON); - } + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); - private Integer applyForLoanApplication(final String clientID, final String loanProductID, final String savingsID) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); - final String loanApplicationJSON = new LoanApplicationTestBuilder() // - .withPrincipal("15,000.00") // - .withLoanTermFrequency("4") // - .withLoanTermFrequencyAsMonths() // - .withNumberOfRepayments("4") // - .withRepaymentEveryAfter("1") // - .withRepaymentFrequencyTypeAsMonths() // - .withInterestRatePerPeriod("2") // - .withAmortizationTypeAsEqualInstallments() // - .withInterestTypeAsDecliningBalance() // - .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // - .withExpectedDisbursementDate("10 January 2013") // - .withSubmittedOnDate("10 January 2013") // - .build(clientID, loanProductID, savingsID); - return this.loanTransactionHelper.getLoanId(loanApplicationJSON); - } + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), + savingsId.toString()); + Assert.assertNotNull(loanID); - private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) { - System.out.println("------------------------------CREATING NEW FIXED DEPOSIT PRODUCT ---------------------------------------"); - FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, this.responseSpec); - final String fixedDepositProductJSON = fixedDepositProductHelper // - // .withAccountingRuleAsCashBased(accounts) - .withPeriodRangeChart()// - .build(validFrom, validTo); - return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, responseSpec); - } + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); - private Integer applyForFixedDepositApplication(final String clientID, final String productID, final String validFrom, - final String validTo, final String submittedOnDate, final String penalInterestType, String savingsId, - final boolean transferInterest, final FixedDepositAccountHelper fixedDepositAccountHelper) { - System.out.println("--------------------------------APPLYING FOR FIXED DEPOSIT ACCOUNT --------------------------------"); - final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) - // - .withSubmittedOnDate(submittedOnDate).withSavings(savingsId).transferInterest(true) - .withLockinPeriodFrequency("1", FixedDepositAccountHelper.DAYS) - .build(clientID, productID, penalInterestType); - return fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, this.requestSpec, this.responseSpec); - } + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); - private void validateNumberForEqualExcludePrecission(String val, String val2) { - DecimalFormat twoDForm = new DecimalFormat("#", new DecimalFormatSymbols(Locale.US)); - Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))).compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); - } + Integer specifiedDueDateChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, + ChargesHelper.getLoanSpecifiedDueDateWithAccountTransferJSON()); + Assert.assertNotNull(specifiedDueDateChargeId); + + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON( + specifiedDueDateChargeId.toString(), "12 March 2013", "100")); + ArrayList chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); + Assert.assertEquals(1, chargesPendingState.size()); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); + + String JobName = "Transfer Fee For Loans From Savings"; + this.schedulerJobHelper.executeJob(JobName); + final 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 Transfer Fee for Loans from Savings", balance, + (Float) summaryAfter.get("accountBalance")); + + } + + @Test + @Ignore // TODO FINERACT-923 + public void testApplyHolidaysToLoansJobOutcome() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + this.holidayHelper = new HolidayHelper(this.requestSpec, this.responseSpec); + this.globalConfigurationHelper = new GlobalConfigurationHelper(this.requestSpec, this.responseSpec); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + Integer holidayId = this.holidayHelper.createHolidays(this.requestSpec, this.responseSpec); + Assert.assertNotNull(holidayId); + + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + // Retrieving All Global Configuration details + final ArrayList globalConfig = this.globalConfigurationHelper + .getAllGlobalConfigurations(this.requestSpec, this.responseSpec); + Assert.assertNotNull(globalConfig); + + // Updating Value for reschedule-repayments-on-holidays Global + // Configuration + Integer configId = (Integer) globalConfig.get(3).get("id"); + Assert.assertNotNull(configId); + + HashMap configData = this.globalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, + this.responseSpec, configId.toString()); + Assert.assertNotNull(configData); + + Boolean enabled = (Boolean) globalConfig.get(3).get("enabled"); + + if (enabled == false) { + enabled = true; + configId = this.globalConfigurationHelper.updateEnabledFlagForGlobalConfiguration( + this.requestSpec, this.responseSpec, configId.toString(), enabled); + } + final ArrayList repaymentScheduleDataBeforeJob = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + holidayId = this.holidayHelper.activateHolidays(this.requestSpec, this.responseSpec, + holidayId.toString()); + Assert.assertNotNull(holidayId); + + String JobName = "Apply Holidays To Loans"; + + this.schedulerJobHelper.executeJob(JobName); + final ArrayList repaymentScheduleDataAfterJob = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + HashMap holidayData = this.holidayHelper.getHolidayById(this.requestSpec, this.responseSpec, + holidayId.toString()); + ArrayList repaymentsRescheduledDate = (ArrayList) holidayData + .get("repaymentsRescheduledTo"); + + ArrayList rescheduleDateAfter = (ArrayList) repaymentScheduleDataAfterJob.get(2) + .get("fromDate"); + + Assert.assertEquals( + "Verifying Repayment Rescheduled Date after Running Apply Holidays to Loans Scheduler Job", + repaymentsRescheduledDate, repaymentsRescheduledDate); + + } + + @Test + @Ignore // TODO FINERACT-857 + 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, true); + ArrayList 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); + + HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); + + String JobName = "Pay Due Savings Charges"; + + this.schedulerJobHelper.executeJob(JobName); + 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")); + } + + @Test + @Ignore // TODO FINERACT-857 + public void testUpdateAccountingRunningBalancesJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + + final Account assetAccount = this.accountHelper.createAssetAccount(); + final Account incomeAccount = this.accountHelper.createIncomeAccount(); + final Account expenseAccount = this.accountHelper.createExpenseAccount(); + final Account liabilityAccount = this.accountHelper.createLiabilityAccount(); + + final Integer accountID = assetAccount.getAccountID(); + + final Integer savingsProductID = createSavingsProduct(MINIMUM_OPENING_BALANCE, assetAccount, + incomeAccount, expenseAccount, liabilityAccount); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, + this.DATE_OF_JOINING); + final Integer savingsID = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ACCOUNT_TYPE_INDIVIDUAL); + + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, savingsID); + SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); + + savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsID); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); + + savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsID); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); + + // Checking initial Account entries. + final JournalEntry[] assetAccountInitialEntry = { + new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.DEBIT) }; + final JournalEntry[] liablilityAccountInitialEntry = { + new JournalEntry(this.SP_BALANCE, JournalEntry.TransactionType.CREDIT) }; + this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.TRANSACTION_DATE, + assetAccountInitialEntry); + this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, this.TRANSACTION_DATE, + liablilityAccountInitialEntry); + + String JobName = "Update Accounting Running Balances"; + + this.schedulerJobHelper.executeJob(JobName); + final HashMap runningBalanceAfter = this.accountHelper + .getAccountingWithRunningBalanceById(accountID.toString()); + + final Integer INT_BALANCE = Integer.valueOf(MINIMUM_OPENING_BALANCE); + + Assert.assertEquals( + "Verifying Account Running Balance after running Update Accounting Running Balances Scheduler Job", + INT_BALANCE, runningBalanceAfter.get("organizationRunningBalance")); + + } + + @Test + @Ignore // TODO FINERACT-857 + public void testUpdateLoanArrearsAgingJobOutcome() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + String JobName = "Update Loan Arrears Ageing"; + + this.schedulerJobHelper.executeJob(JobName); + HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, + loanID); + + Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") + + (Float) loanSummaryData.get("interestOverdue"); + + Assert.assertEquals("Verifying Arrears Aging after Running Update Loan Arrears Aging Scheduler Job", + totalLoanArrearsAging, loanSummaryData.get("totalOverdue")); + + } + + @Test + @Ignore // TODO FINERACT-857 + public void testUpdateLoanPaidInAdvanceJobOutcome() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); + + Calendar todayDate = Calendar.getInstance(); + final String currentDate = dateFormat.format(todayDate.getTime()); + + todayDate.add(Calendar.MONTH, -1); + final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime()); + + todayDate = Calendar.getInstance(); + todayDate.add(Calendar.DATE, -5); + final String LOAN_FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime()); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + ArrayList loanScheduleBefore = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + Float totalDueForCurrentPeriod = (Float) loanScheduleBefore.get(1).get("totalDueForPeriod"); + + this.loanTransactionHelper.makeRepayment(LOAN_FIRST_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID); + + HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, + loanID); + + String JobName = "Update Loan Paid In Advance"; + this.schedulerJobHelper.executeJob(JobName); + // Retrieving Loan Repayment Schedule after the successful + // completion of + // Update Loan Paid in Advance Scheduler Job + ArrayList loanScheduleAfter = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID); + + Float totalPaidInAdvance = (Float) loanScheduleAfter.get(1).get("totalPaidInAdvanceForPeriod"); + + Assert.assertEquals( + "Verifying Loan Repayment in Advance after Running Update Loan Paid in Advance Scheduler Job", + totalDueForCurrentPeriod, totalPaidInAdvance); + + } + + // Invalid test case as it won't affect summary (Loan summary is properly + // updated before running this job) + @Ignore + @Test + public void testUpdateLoanSummaryJobOutcome() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); + + Calendar todaysDate = Calendar.getInstance(); + final String currentDate = dateFormat.format(todaysDate.getTime()); + + todaysDate.add(Calendar.MONTH, -1); + final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime()); + + todaysDate = Calendar.getInstance(); + todaysDate.add(Calendar.DATE, -5); + final String LOAN_FIRST_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime()); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + Integer disburseChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, + ChargesHelper.getLoanDisbursementJSON()); + Assert.assertNotNull(disburseChargeId); + + this.loanTransactionHelper.addChargesForLoan(loanID, + LoanTransactionHelper.getDisbursementChargesForLoanAsJSON(disburseChargeId.toString())); + ArrayList chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID); + Assert.assertEquals(1, chargesPendingState.size()); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, + this.responseSpec, loanID); + + String JobName = "Update loan Summary"; + this.schedulerJobHelper.executeJob(JobName); + Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment") + /* - (Float) loanSummaryBefore.get("feeChargesPaid") */; + HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, + this.responseSpec, loanID); + Assert.assertEquals("Verifying Loan Summary after Running Update Loan Summary Scheduler Job", + expectedSummaryAfterJob, (Float) loanSummaryAfter.get("totalExpectedRepayment")); + + } + + @Test + @Ignore // TODO FINERACT-857 + public void testExecuteStandingInstructionsJobOutcome() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.standingInstructionsHelper = new StandingInstructionsHelper(this.requestSpec, this.responseSpec); + + DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); + DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US); + + Calendar todaysDate = Calendar.getInstance(); + todaysDate.add(Calendar.WEEK_OF_YEAR, -1); + final String VALID_FROM = dateFormat.format(todaysDate.getTime()); + + final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime()); + + todaysDate.add(Calendar.YEAR, 1); + final String VALID_TO = dateFormat.format(todaysDate.getTime()); + + 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 fromSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsProductID); + + HashMap fromSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, fromSavingsId); + SavingsStatusChecker.verifySavingsIsPending(fromSavingsStatusHashMap); + + fromSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(fromSavingsId); + SavingsStatusChecker.verifySavingsIsApproved(fromSavingsStatusHashMap); + + fromSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(fromSavingsId); + SavingsStatusChecker.verifySavingsIsActive(fromSavingsStatusHashMap); + + final Integer toSavingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsProductID); + + HashMap toSavingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, toSavingsId); + SavingsStatusChecker.verifySavingsIsPending(toSavingsStatusHashMap); + + toSavingsStatusHashMap = this.savingsAccountHelper.approveSavings(toSavingsId); + SavingsStatusChecker.verifySavingsIsApproved(toSavingsStatusHashMap); + + toSavingsStatusHashMap = this.savingsAccountHelper.activateSavings(toSavingsId); + SavingsStatusChecker.verifySavingsIsActive(toSavingsStatusHashMap); + + HashMap fromSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(fromSavingsId); + Float fromSavingsBalanceBefore = (Float) fromSavingsSummaryBefore.get("accountBalance"); + + HashMap toSavingsSummaryBefore = this.savingsAccountHelper.getSavingsSummary(toSavingsId); + Float toSavingsBalanceBefore = (Float) toSavingsSummaryBefore.get("accountBalance"); + + Integer standingInstructionId = this.standingInstructionsHelper.createStandingInstruction( + clientID.toString(), fromSavingsId.toString(), toSavingsId.toString(), + FROM_ACCOUNT_TYPE_SAVINGS, TO_ACCOUNT_TYPE_SAVINGS, VALID_FROM, VALID_TO, MONTH_DAY); + Assert.assertNotNull(standingInstructionId); + + String JobName = "Execute Standing Instruction"; + this.schedulerJobHelper.executeJob(JobName); + HashMap fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsId); + Float fromSavingsBalanceAfter = (Float) fromSavingsSummaryAfter.get("accountBalance"); + + HashMap toSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(toSavingsId); + Float toSavingsBalanceAfter = (Float) toSavingsSummaryAfter.get("accountBalance"); + + final HashMap standingInstructionData = this.standingInstructionsHelper + .getStandingInstructionById(standingInstructionId.toString()); + Float expectedFromSavingsBalance = fromSavingsBalanceBefore + - (Float) standingInstructionData.get("amount"); + Float expectedToSavingsBalance = toSavingsBalanceBefore + (Float) standingInstructionData.get("amount"); + + Assert.assertEquals("Verifying From Savings Balance after Successful completion of Scheduler Job", + expectedFromSavingsBalance, fromSavingsBalanceAfter); + Assert.assertEquals("Verifying To Savings Balance after Successful completion of Scheduler Job", + expectedToSavingsBalance, toSavingsBalanceAfter); + Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue(); + Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue(); + List standinInstructionHistoryData = this.standingInstructionsHelper + .getStandingInstructionHistory(fromSavingsId, fromAccountType, clientID, transferType); + Assert.assertEquals("Verifying the no of stainding instruction transactions logged for the client", 1, + standinInstructionHistoryData.size()); + HashMap loggedTransaction = standinInstructionHistoryData.get(0); + + Assert.assertEquals("Verifying transferred amount and logged transaction amounts", + (Float) standingInstructionData.get("amount"), (Float) loggedTransaction.get("amount")); + + } + + @Test + @Ignore + public void testApplyPenaltyForOverdueLoansJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + Integer overdueFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, + ChargesHelper.getLoanOverdueFeeJSON()); + Assert.assertNotNull(overdueFeeChargeId); + + final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString()); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper + .disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + ArrayList repaymentScheduleDataBefore = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + String JobName = "Apply penalty to overdue loans"; + this.schedulerJobHelper.executeJob(JobName); + + final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, + overdueFeeChargeId); + + Float chargeAmount = (Float) chargeData.get("amount"); + + ArrayList repaymentScheduleDataAfter = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + Assert.assertEquals( + "Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job", + chargeAmount, (Float) repaymentScheduleDataAfter.get(1).get("penaltyChargesDue")); + + loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); + + } + + @Test + @Ignore // TODO FINERACT-857 + public void testAvoidUnncessaryPenaltyWhenAmountZeroForOverdueLoansJobOutcome() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + Integer overdueFeeChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, + ChargesHelper.getLoanOverdueFeeJSONWithCalculattionTypePercentage("0.000001")); + Assert.assertNotNull(overdueFeeChargeId); + + final Integer loanProductID = createLoanProduct(overdueFeeChargeId.toString()); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper + .disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + ArrayList repaymentScheduleDataBefore = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + String JobName = "Apply penalty to overdue loans"; + Integer jobId = 12; + + this.schedulerJobHelper.executeJob(JobName); + + Map schedulerJob = this.schedulerJobHelper.getSchedulerJobById(jobId); + + Assert.assertNotNull(schedulerJob); + while ((Boolean) schedulerJob.get("currentlyRunning") == true) { + Thread.sleep(15000); + schedulerJob = this.schedulerJobHelper.getSchedulerJobById(jobId); + Assert.assertNotNull(schedulerJob); + } + + final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, + overdueFeeChargeId); + + ArrayList repaymentScheduleDataAfter = this.loanTransactionHelper + .getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); + + Assert.assertEquals( + "Verifying From Penalty Charges due fot first Repayment after Successful completion of Scheduler Job", + 0, repaymentScheduleDataAfter.get(1).get("penaltyChargesDue")); + + final ArrayList loanCharges = this.loanTransactionHelper.getLoanCharges(this.requestSpec, + this.responseSpec, loanID); + + Assert.assertNull("Verifying that charge isn't created when the amount is 0", loanCharges); + + loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); + + } + + @Test + @Ignore // TODO FINERACT-857 + public void testUpdateOverdueDaysForNPA() throws InterruptedException { + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec); + + final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientID); + + final Integer loanProductID = createLoanProduct(null); + Assert.assertNotNull(loanProductID); + + final Integer loanID = applyForLoanApplication(clientID.toString(), loanProductID.toString(), null); + Assert.assertNotNull(loanID); + + HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, + loanID); + LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); + + loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, + loanID); + LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); + + final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, + responseSpec, loanID, "isNPA"); + Assert.assertFalse(isNPABefore); + // Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId"); + String JobName = "Update Non Performing Assets"; + this.schedulerJobHelper.executeJob(JobName); + final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, + loanID, "isNPA"); + Assert.assertTrue(isNPAAfter); + } + + @Test + @Ignore // TODO FINERACT-857 + public void testInterestTransferForSavings() throws InterruptedException { + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); + this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec); + // FixedDepositProductHelper fixedDepositProductHelper = new + // FixedDepositProductHelper(this.requestSpec,this.responseSpec); + // AccountHelper accountHelper = new AccountHelper(this.requestSpec, + // this.responseSpec); + FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, + this.responseSpec); + + DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); + // DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US); + + Calendar todaysDate = Calendar.getInstance(); + todaysDate.add(Calendar.MONTH, -3); + final String VALID_FROM = dateFormat.format(todaysDate.getTime()); + todaysDate.add(Calendar.YEAR, 10); + final String VALID_TO = dateFormat.format(todaysDate.getTime()); + + todaysDate = Calendar.getInstance(); + todaysDate.add(Calendar.MONTH, -2); + final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); + final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime()); + final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime()); + todaysDate.add(Calendar.MONTH, 1); + final String WHOLE_TERM = "1"; + + Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec); + Assert.assertNotNull(clientId); + Float balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + + Float.valueOf(FixedDepositAccountHelper.depositAmount); + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, + String.valueOf(balance)); + Assert.assertNotNull(savingsProductID); + + final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientId, + savingsProductID, ClientSavingsIntegrationTest.ACCOUNT_TYPE_INDIVIDUAL); + Assert.assertNotNull(savingsId); + + HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, + this.responseSpec, savingsId); + SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap); + + savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId); + SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap); + + savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId); + SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap); + HashMap summary = savingsAccountHelper.getSavingsSummary(savingsId); + assertEquals("Verifying opening Balance", balance, summary.get("accountBalance")); + + Integer fixedDepositProductId = createFixedDepositProduct(VALID_FROM, VALID_TO); + Assert.assertNotNull(fixedDepositProductId); + + Integer fixedDepositAccountId = applyForFixedDepositApplication(clientId.toString(), + fixedDepositProductId.toString(), VALID_FROM, VALID_TO, SUBMITTED_ON_DATE, WHOLE_TERM, + savingsId.toString(), true, fixedDepositAccountHelper); + Assert.assertNotNull(fixedDepositAccountId); + + HashMap fixedDepositAccountStatusHashMap = FixedDepositAccountStatusChecker + .getStatusOfFixedDepositAccount(this.requestSpec, this.responseSpec, + fixedDepositAccountId.toString()); + FixedDepositAccountStatusChecker.verifyFixedDepositIsPending(fixedDepositAccountStatusHashMap); + + fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.approveFixedDeposit(fixedDepositAccountId, + APPROVED_ON_DATE); + FixedDepositAccountStatusChecker.verifyFixedDepositIsApproved(fixedDepositAccountStatusHashMap); + + fixedDepositAccountStatusHashMap = fixedDepositAccountHelper.activateFixedDeposit(fixedDepositAccountId, + ACTIVATION_DATE); + FixedDepositAccountStatusChecker.verifyFixedDepositIsActive(fixedDepositAccountStatusHashMap); + summary = savingsAccountHelper.getSavingsSummary(savingsId); + balance = Float.valueOf(MINIMUM_OPENING_BALANCE); + assertEquals("Verifying Balance", balance, summary.get("accountBalance")); + + fixedDepositAccountHelper.postInterestForFixedDeposit(fixedDepositAccountId); + + HashMap fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); + Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") + - Float.valueOf(FixedDepositAccountHelper.depositAmount); + + String JobName = "Transfer Interest To Savings"; + this.schedulerJobHelper.executeJob(JobName); + fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId); + assertEquals("Verifying opening Balance", Float.valueOf(FixedDepositAccountHelper.depositAmount), + fixedDepositSummary.get("accountBalance")); + + summary = savingsAccountHelper.getSavingsSummary(savingsId); + balance = Float.valueOf(MINIMUM_OPENING_BALANCE) + interestPosted; + validateNumberForEqualExcludePrecission(String.valueOf(balance), + String.valueOf(summary.get("accountBalance"))); + } + + private Integer createSavingsProduct(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String minOpenningBalance) { + // system.out.println("------------------------------CREATING NEW SAVINGS + // PRODUCT ---------------------------------------"); + SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); + final String savingsProductJSON = savingsProductHelper // + .withInterestCompoundingPeriodTypeAsDaily() // + .withInterestPostingPeriodTypeAsMonthly() // + .withInterestCalculationPeriodTypeAsDailyBalance() // + .withMinimumOpenningBalance(minOpenningBalance).build(); + return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); + } + + private static Integer createSavingsProduct(final String minOpenningBalance, final Account... accounts) { + // system.out.println("------------------------------CREATING NEW SAVINGS + // PRODUCT ---------------------------------------"); + final String savingsProductJSON = new SavingsProductHelper().withInterestCompoundingPeriodTypeAsDaily() // + .withInterestPostingPeriodTypeAsQuarterly() // + .withInterestCalculationPeriodTypeAsDailyBalance() // + .withMinimumOpenningBalance(minOpenningBalance).withAccountingRuleAsCashBased(accounts) + .build(); + return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec); + } + + private Integer createLoanProduct(final String chargeId) { + // system.out.println("------------------------------CREATING NEW LOAN PRODUCT + // ---------------------------------------"); + final String loanProductJSON = new LoanProductTestBuilder() // + .withPrincipal("15,000.00") // + .withNumberOfRepayments("4") // + .withRepaymentAfterEvery("1") // + .withRepaymentTypeAsMonth() // + .withinterestRatePerPeriod("1") // + .withInterestRateFrequencyTypeAsMonths() // + .withAmortizationTypeAsEqualInstallments() // + .withInterestTypeAsDecliningBalance() // + .build(chargeId); + return this.loanTransactionHelper.getLoanProductId(loanProductJSON); + } + + private Integer applyForLoanApplication(final String clientID, final String loanProductID, + final String savingsID) { + // system.out.println("--------------------------------APPLYING FOR LOAN + // APPLICATION--------------------------------"); + final String loanApplicationJSON = new LoanApplicationTestBuilder() // + .withPrincipal("15,000.00") // + .withLoanTermFrequency("4") // + .withLoanTermFrequencyAsMonths() // + .withNumberOfRepayments("4") // + .withRepaymentEveryAfter("1") // + .withRepaymentFrequencyTypeAsMonths() // + .withInterestRatePerPeriod("2") // + .withAmortizationTypeAsEqualInstallments() // + .withInterestTypeAsDecliningBalance() // + .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // + .withExpectedDisbursementDate("10 January 2013") // + .withSubmittedOnDate("10 January 2013") // + .build(clientID, loanProductID, savingsID); + return this.loanTransactionHelper.getLoanId(loanApplicationJSON); + } + + private Integer createFixedDepositProduct(final String validFrom, final String validTo, Account... accounts) { + // system.out.println("------------------------------CREATING NEW FIXED DEPOSIT + // PRODUCT ---------------------------------------"); + FixedDepositProductHelper fixedDepositProductHelper = new FixedDepositProductHelper(this.requestSpec, + this.responseSpec); + final String fixedDepositProductJSON = fixedDepositProductHelper // + // .withAccountingRuleAsCashBased(accounts) + .withPeriodRangeChart()// + .build(validFrom, validTo); + return FixedDepositProductHelper.createFixedDepositProduct(fixedDepositProductJSON, requestSpec, + responseSpec); + } + + private Integer applyForFixedDepositApplication(final String clientID, final String productID, + final String validFrom, final String validTo, final String submittedOnDate, + final String penalInterestType, String savingsId, final boolean transferInterest, + final FixedDepositAccountHelper fixedDepositAccountHelper) { + // system.out.println("--------------------------------APPLYING FOR FIXED + // DEPOSIT ACCOUNT --------------------------------"); + final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, + this.responseSpec) + // + .withSubmittedOnDate(submittedOnDate).withSavings(savingsId) + .transferInterest(true) + .withLockinPeriodFrequency("1", FixedDepositAccountHelper.DAYS) + .build(clientID, productID, penalInterestType); + return fixedDepositAccountHelper.applyFixedDepositApplication(fixedDepositApplicationJSON, + this.requestSpec, this.responseSpec); + } + + private void validateNumberForEqualExcludePrecission(String val, String val2) { + DecimalFormat twoDForm = new DecimalFormat("#", new DecimalFormatSymbols(Locale.US)); + Assert.assertTrue(Float.valueOf(twoDForm.format(Float.valueOf(val))) + .compareTo(Float.valueOf(twoDForm.format(Float.valueOf(val2)))) == 0); + } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java index 7eaf0aaff..035dce87d 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SkipRepaymentOnMonthFirstTest.java @@ -40,10 +40,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "static-access", "rawtypes", "unchecked", "deprecation" }) public class SkipRepaymentOnMonthFirstTest { - + private final static Logger LOG = LoggerFactory.getLogger(SkipRepaymentOnMonthFirstTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private GlobalConfigurationHelper globalConfigurationHelper; @@ -102,10 +104,10 @@ public class SkipRepaymentOnMonthFirstTest { final String interval = "1"; //Every One Moth Integer calendarID = calendarHelper.createMeetingForGroup(requestSpec, responseSpec, groupID, startDate, frequency, interval, null); - System.out.println("caladerId --------------------" + calendarID); + LOG.info("caladerId -------------------- {}" , calendarID); final Integer loanProductID = createLoanProduct(); final Integer loanID = applyForLoanApplication(groupID, loanProductID, calendarID, clientID); - System.out.println("loanID----" + loanID); + LOG.info("loanID---- {}" , loanID); final ArrayList loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); verifyLoanRepaymentSchedule(loanSchedule); @@ -113,7 +115,7 @@ public class SkipRepaymentOnMonthFirstTest { } private Integer createLoanProduct() { - System.out.println( + LOG.info( "------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("12,000.00") // @@ -130,7 +132,7 @@ public class SkipRepaymentOnMonthFirstTest { private Integer applyForLoanApplication(final Integer groupID, final Integer loanProductID, Integer calendarID, Integer clientID) { - System.out.println( + LOG.info( "--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("12,000.00") // @@ -147,27 +149,27 @@ public class SkipRepaymentOnMonthFirstTest { .withCalendarID(calendarID.toString()) // .withSubmittedOnDate("01 October 2011") // .withLoanType("jlg").build(clientID.toString(), groupID.toString(), loanProductID.toString(), null); - System.out.println(loanApplicationJSON); + LOG.info(loanApplicationJSON); return this.loanTransactionHelper.getLoanId(loanApplicationJSON); } private void verifyLoanRepaymentSchedule(final ArrayList loanSchedule) { - System.out.println("--------------------VERIFYING THE REPAYMENT DATE--------------------------"); + LOG.info("--------------------VERIFYING THE REPAYMENT DATE--------------------------"); assertEquals("Checking for Repayment Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 15)), loanSchedule.get(1).get("dueDate")); - System.out.println("Repayment Date for 1st Month--" + loanSchedule.get(1).get("dueDate")); + LOG.info("Repayment Date for 1st Month-- {}" , loanSchedule.get(1).get("dueDate")); assertEquals("Checking for Repayment Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 15)), loanSchedule.get(2).get("dueDate")); - System.out.println("Repayment Date for 2nd Month--" + loanSchedule.get(2).get("dueDate")); + LOG.info("Repayment Date for 2nd Month-- {}" , loanSchedule.get(2).get("dueDate")); assertEquals("Checking for Repayment Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 15)), loanSchedule.get(3).get("dueDate")); - System.out.println("Repayment Date for 3rd Month--" + loanSchedule.get(3).get("dueDate")); + LOG.info("Repayment Date for 3rd Month-- {}" , loanSchedule.get(3).get("dueDate")); assertEquals("Checking for Repayment Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 15)), loanSchedule.get(4).get("dueDate")); - System.out.println("Repayment Date for 4th Month--" + loanSchedule.get(4).get("dueDate")); + LOG.info("Repayment Date for 4th Month-- {}" , loanSchedule.get(4).get("dueDate")); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/UserAdministrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/UserAdministrationTest.java index 202156eb2..cf11db90a 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/UserAdministrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/UserAdministrationTest.java @@ -36,10 +36,11 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UserAdministrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(UserAdministrationTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private List transientUsers = new ArrayList<>(); @@ -79,8 +80,8 @@ public class UserAdministrationTest { final List errors = (List) UserHelper.createUser(this.requestSpec, expectStatusCode(403), roleId, staffId, "alphabet", "errors"); Map reason = (Map) errors.get(0); - System.out.println("Reason: " + reason.get("defaultUserMessage")); - System.out.println("Code: " + reason.get("userMessageGlobalisationCode")); + LOG.info("Reason: {}" , reason.get("defaultUserMessage")); + LOG.info("Code: {}" , reason.get("userMessageGlobalisationCode")); Assert.assertEquals("User with username alphabet already exists.", reason.get("defaultUserMessage")); Assert.assertEquals("error.msg.user.duplicate.username", reason.get("userMessageGlobalisationCode")); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/XBRLIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/XBRLIntegrationTest.java index d10e5357a..d515df0d1 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/XBRLIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/XBRLIntegrationTest.java @@ -31,10 +31,12 @@ import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.xbrl.XBRLIntegrationTestHelper; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class XBRLIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(XBRLIntegrationTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; @@ -57,7 +59,7 @@ public class XBRLIntegrationTest { } private void verifyTaxonomyList(final ArrayList taxonomyList) { - System.out.println("--------------------VERIFYING TAXONOMY LIST--------------------------"); + LOG.info("--------------------VERIFYING TAXONOMY LIST--------------------------"); assertEquals("Checking for the 1st taxonomy", "AdministrativeExpense", taxonomyList.get(0).get("name")); } 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 8c7859ac4..3e9cf171a 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 @@ -28,6 +28,8 @@ import java.util.Map; import org.apache.fineract.batch.domain.BatchRequest; import org.apache.fineract.batch.domain.BatchResponse; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Helper class for {@link org.apache.fineract.integrationtests.BatchApiTest}. It @@ -39,7 +41,7 @@ import org.junit.Assert; * @see org.apache.fineract.integrationtests.BatchApiTest */ public class BatchHelper { - + private final static Logger LOG = LoggerFactory.getLogger(BatchHelper.class); private static final String BATCH_API_URL = "/fineract-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER; private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true"; @@ -422,7 +424,7 @@ public class BatchHelper { */ public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String externalId) { - System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); + 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); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CalendarHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CalendarHelper.java index 5cf60b8b3..f1e02a189 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CalendarHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CalendarHelper.java @@ -25,9 +25,11 @@ import com.google.gson.Gson; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CalendarHelper { - + private final static Logger LOG = LoggerFactory.getLogger(CalendarHelper.class); private static final String BASE_URL = "/fineract-provider/api/v1/"; private static final String PARENT_ENTITY_NAME = "groups/"; private static final String ENITY_NAME = "/calendars"; @@ -37,11 +39,11 @@ public class CalendarHelper { public static Integer createMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) { - System.out.println("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); + LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; - System.out.println(CALENDAR_RESOURCE_URL); + LOG.info("{}",CALENDAR_RESOURCE_URL); return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); @@ -51,11 +53,11 @@ public class CalendarHelper { final Integer groupId, String calendarID, final String startDate, final String frequency, final String interval, final String repeatsOnDay) { - System.out.println("---------------------------------UPDATING A MEETING CALENDAR FOR THE GROUP------------------------------"); + LOG.info("---------------------------------UPDATING A MEETING CALENDAR FOR THE GROUP------------------------------"); final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID; - System.out.println(CALENDAR_RESOURCE_URL); + LOG.info("{}",CALENDAR_RESOURCE_URL); // TODO: check that resource id indeed exists in calendar update put. return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); @@ -74,13 +76,13 @@ public class CalendarHelper { map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4)); map.put("typeId", "1"); map.put("startDate", startDate); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public static void verifyCalendarCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedGroupId, final Integer generatedCalendarId) { - System.out.println("------------------------------CHECK CALENDAR DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK CALENDAR DETAILS------------------------------------\n"); final String CLIENT_URL = "/fineract-provider/api/v1/groups/" + generatedGroupId + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "collectionMeetingCalendar"); @@ -91,11 +93,11 @@ public class CalendarHelper { public static Integer createMeetingForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) { - System.out.println("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); + LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; - System.out.println(CALENDAR_RESOURCE_URL); + LOG.info("{}",CALENDAR_RESOURCE_URL); return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate), "resourceId"); @@ -104,12 +106,12 @@ public class CalendarHelper { public static Integer updateMeetingCalendarForCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer centerId, String calendarID, String oldDate, String startDate) { - System.out.println("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------"); + LOG.info("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------"); final String CALENDAR_RESOURCE_URL = BASE_URL + Center_Entity + centerId + ENITY_NAME + "/" + calendarID + "?" + Utils.TENANT_IDENTIFIER; - System.out.println(CALENDAR_RESOURCE_URL); + LOG.info("{}",CALENDAR_RESOURCE_URL); return Utils.performServerPut(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarMeetingAsJSON(oldDate, startDate), "resourceId"); @@ -123,7 +125,7 @@ public class CalendarHelper { map.put("newMeetingDate", startDate); map.put("presentMeetingDate", oldDate); map.put("reschedulebasedOnMeetingDates", "true"); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java index f5c4f3c66..1933e5fa1 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterDomain.java @@ -22,9 +22,11 @@ import com.google.gson.Gson; import java.util.ArrayList; import java.util.HashMap; import org.apache.fineract.infrastructure.core.service.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class CenterDomain implements Comparable { - + private final static Logger LOG = LoggerFactory.getLogger(CenterDomain.class); public static class Builder { private Integer id; @@ -147,7 +149,7 @@ public class CenterDomain implements Comparable { } if (externalId != null) map.put("externalId", externalId); if (groupMembers != null) map.put("groupMembers", groupMembers); - System.out.println(map); + LOG.info("{}",map.toString()); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterHelper.java index 0dd25861f..e1490c3e2 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CenterHelper.java @@ -27,10 +27,12 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class CenterHelper { - + private final static Logger LOG = LoggerFactory.getLogger(CenterHelper.class); private static final String CENTERS_URL = "/fineract-provider/api/v1/centers"; public static final String CREATED_DATE = "29 December 2014"; @@ -38,7 +40,7 @@ public class CenterHelper { public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING CENTER AT " + id + "-------------------------"); + LOG.info("------------------------ RETRIEVING CENTER AT {}-------------------------",id); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, ""); final String jsonData = new Gson().toJson(get); return new Gson().fromJson(jsonData, new TypeToken() {}.getType()); @@ -47,7 +49,7 @@ public class CenterHelper { public static ArrayList paginatedListCenters(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_CENTER = CENTERS_URL + "?paged=true&limit=-1&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING CENTERS-------------------------"); + LOG.info("------------------------ RETRIEVING CENTERS-------------------------"); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, "pageItems"); final String jsonData = new Gson().toJson(get); return new Gson().fromJson(jsonData, new TypeToken>() {}.getType()); @@ -55,7 +57,7 @@ public class CenterHelper { public static ArrayList listCenters(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_CENTER = CENTERS_URL + "?limit=-1&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING CENTERS-------------------------"); + LOG.info("------------------------ RETRIEVING CENTERS-------------------------"); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, ""); final String jsonData = new Gson().toJson(get); return new Gson().fromJson(jsonData, new TypeToken>() {}.getType()); @@ -101,14 +103,14 @@ public class CenterHelper { hm.put("activationDate", activationDate); } - System.out.println("------------------------CREATING CENTER-------------------------"); + LOG.info("------------------------CREATING CENTER-------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, new Gson().toJson(hm), "resourceId"); } public static HashMap updateCenter(final int id, HashMap request, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE CENTER AT " + id + "---------------------------------------------"); + LOG.info("---------------------------------UPDATE CENTER AT {}---------------------------------------------",id); HashMap hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CENTER_URL, new Gson().toJson(request), "changes"); return hash; @@ -119,10 +121,10 @@ public class CenterHelper { final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER; HashMap groupMemberHashMap = new HashMap(); groupMemberHashMap.put("groupMembers", groupMembers); - System.out.println("---------------------------------ASSOCIATING GROUPS AT " + id + "--------------------------------------------"); + LOG.info("---------------------------------ASSOCIATING GROUPS AT {}--------------------------------------------",id); HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL, new Gson().toJson(groupMemberHashMap), "changes"); - System.out.println(hash); + LOG.info("{}",hash.toString()); ArrayList arr = (ArrayList) hash.get("groupMembers"); int[] ret = new int[arr.size()]; for (int i = 0; i < ret.length; i++) { @@ -133,38 +135,38 @@ public class CenterHelper { public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------DELETING CENTER AT " + id + "--------------------------------------------"); + LOG.info("---------------------------------DELETING CENTER AT {}--------------------------------------------",id); Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, ""); } public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, @SuppressWarnings("unused") final boolean active) { - System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); + LOG.info("---------------------------------CREATING A CENTER---------------------------------------------"); return createCenter(requestSpec, responseSpec, "CREATED_DATE"); } public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String activationDate) { - System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); + LOG.info("---------------------------------CREATING A CENTER---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, activationDate), "groupId"); } public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); + LOG.info("---------------------------------CREATING A CENTER---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, CenterHelper.CREATED_DATE), "groupId"); } public static int createCenterWithStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer staffId) { - System.out.println("---------------------------------CREATING A CENTER---------------------------------------------"); + LOG.info("---------------------------------CREATING A CENTER---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterWithStaffAsJSON(true, CenterHelper.CREATED_DATE, staffId), "groupId"); } public static void verifyCenterCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedCenterID) { - System.out.println("------------------------------CHECK CENTER DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK CENTER DETAILS------------------------------------\n"); final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER; final Integer responseCenterID = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "id"); assertEquals("ERROR IN CREATING THE CENTER", generatedCenterID, responseCenterID); @@ -172,7 +174,7 @@ public class CenterHelper { public static void verifyCenterActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedCenterID, final boolean generatedCenterStatus) { - System.out.println("------------------------------CHECK CENTER STATUS------------------------------------\n"); + LOG.info("------------------------------CHECK CENTER STATUS------------------------------------\n"); final String CENTER_URL = "/fineract-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER; final Boolean responseCenterStatus = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "active"); assertEquals("ERROR IN ACTIVATING THE CENTER", generatedCenterStatus, responseCenterStatus); @@ -181,7 +183,7 @@ public class CenterHelper { public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String centerId) { final String CENTER_ASSOCIATE_URL = "/fineract-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------ACTIVATE A CENTER---------------------------------------------"); + LOG.info("---------------------------------ACTIVATE A CENTER---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId"); } @@ -226,14 +228,14 @@ public class CenterHelper { public static String assignStaffAsJSON(final Long staffId) { final HashMap map = new HashMap<>(); map.put("staffId", staffId); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public static String unassignStaffAsJSON(final Long staffId) { final HashMap map = new HashMap<>(); map.put("staffId", staffId); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -245,9 +247,9 @@ public class CenterHelper { map.put("activationDate", activationDate); } else { map.put("activationDate", "CREATED_DATE"); - System.out.println("defaulting to fixed date: CREATED_DATE"); + LOG.info("defaulting to fixed date: CREATED_DATE"); } - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -259,7 +261,7 @@ public class CenterHelper { final String groupId, final Long staffId) { final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff"; - System.out.println("---------------------------------Assign Staff---------------------------------------------"); + LOG.info("---------------------------------Assign Staff---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes"); } @@ -267,7 +269,7 @@ public class CenterHelper { final String groupId, final Long staffId) { final String GROUP_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=unassignStaff"; - System.out.println("---------------------------------Unassign Staff---------------------------------------------"); + LOG.info("---------------------------------Unassign Staff---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, unassignStaffAsJSON(staffId), "changes"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientHelper.java index 357005d0c..a255a6082 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ClientHelper.java @@ -36,9 +36,11 @@ import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType; import org.apache.fineract.integrationtests.common.system.CodeHelper; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ClientHelper { - + private final static Logger LOG = LoggerFactory.getLogger(ClientHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -67,7 +69,8 @@ public class ClientHelper { this.responseSpec = responseSpec; } - public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static Integer createClient(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { return createClient(requestSpec, responseSpec, "04 March 2011"); } @@ -78,100 +81,110 @@ public class ClientHelper { public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String activationDate, final String officeId) { - System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(activationDate, officeId), - "clientId"); + LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, + getTestClientAsJSON(activationDate, officeId), "clientId"); } - - - public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static Integer createClientPending(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { return createClientPending(requestSpec, responseSpec, "04 March 2014"); } - public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String submittedOnDate) { + public static Integer createClientPending(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String submittedOnDate) { return createClientPending(requestSpec, responseSpec, submittedOnDate, "1"); } - public static Integer createClientPending(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String submittedOnDate, final String officeId) { - System.out.println("---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId), - "clientId"); + public static Integer createClientPending(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String submittedOnDate, final String officeId) { + LOG.info( + "---------------------------------CREATING A CLIENT IN PENDING---------------------------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, + getTestClientAsJSONPending(submittedOnDate, officeId), "clientId"); } public Object createClientPendingWithError(final String jsonAttributeToGetBack) { - System.out.println("---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------"); + LOG.info( + "---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------"); return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack); } public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String registeredTableName) { - System.out.println("-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------"); + LOG.info( + "-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId"); } - public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static Integer createClientAsPerson(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { return createClientAsPerson(requestSpec, responseSpec, "04 March 2011"); } - public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String activationDate) { + public static Integer createClientAsPerson(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String activationDate) { return createClientAsPerson(requestSpec, responseSpec, activationDate, "1"); } - public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String activationDate, final String officeId) { + public static Integer createClientAsPerson(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String activationDate, final String officeId) { - System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestPersonClientAsJSON(activationDate, officeId), - "clientId"); + LOG.info( + "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, + getTestPersonClientAsJSON(activationDate, officeId), "clientId"); } - public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static Integer createClientAsEntity(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { return createClientAsEntity(requestSpec, responseSpec, "04 March 2011"); } - public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String activationDate) { + public static Integer createClientAsEntity(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String activationDate) { return createClientAsEntity(requestSpec, responseSpec, activationDate, "1"); } - public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String activationDate, final String officeId) { + public static Integer createClientAsEntity(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String activationDate, final String officeId) { - Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution").get("id"); - Integer soleProprietorCodeValueId = (Integer) CodeHelper.retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id"); + Integer constitutionCodeId = (Integer) CodeHelper.getCodeByName(requestSpec, responseSpec, "Constitution") + .get("id"); + Integer soleProprietorCodeValueId = (Integer) CodeHelper + .retrieveOrCreateCodeValue(constitutionCodeId, requestSpec, responseSpec).get("id"); - System.out.println("---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), - "clientId"); + LOG.info( + "---------------------------------CREATING A CLIENT NON PERSON(ORGANISATION)---------------------------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, + getTestEntityClientAsJSON(activationDate, officeId, soleProprietorCodeValueId), "clientId"); } - public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer clientType, String jsonAttributeToGetBack) { + public static Integer createClientForAccountPreference(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) { final String activationDate = "04 March 2011"; final String officeId = "1"; - System.out.println( + LOG.info( "---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, - getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), jsonAttributeToGetBack); + getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), + jsonAttributeToGetBack); } - public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId, final String staffId) { - final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER - + "&command=assignStaff"; + public static Object assignStaffToClient(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId, final String staffId) { + final String CLIENT_ASSIGN_STAFF_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + + Utils.TENANT_IDENTIFIER + "&command=assignStaff"; - System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes"); + LOG.info("---------------------------------CREATING A CLIENT---------------------------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, + assignStaffToClientAsJson(staffId), "changes"); } - public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId) { + public static Integer getClientsStaffId(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId) { return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId"); } @@ -185,7 +198,7 @@ public class ClientHelper { map.put("locale", "en"); map.put("active", "true"); map.put("activationDate", dateOfJoining); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } @@ -199,7 +212,7 @@ public class ClientHelper { map.put("locale", "en"); map.put("active", "false"); map.put("submittedOnDate", submittedOnDate); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } @@ -214,7 +227,7 @@ public class ClientHelper { map.put("active", "false"); map.put("submittedOnDate", "04 March 2014"); String requestJson = getTestDatatableAsJson(map, registeredTableName); - System.out.println("map : " + requestJson); + LOG.info("map : {}", requestJson); return requestJson; } @@ -246,11 +259,12 @@ public class ClientHelper { map.put("activationDate", dateOfJoining); map.put("legalFormId", 1); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } - public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId, final Integer soleProprietorCodeValueId) { + public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId, + final Integer soleProprietorCodeValueId) { final HashMap map = new HashMap<>(); map.put("officeId", officeId); map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5)); @@ -265,11 +279,12 @@ public class ClientHelper { clientNonPersonMap.put("constitutionId", soleProprietorCodeValueId); map.put("clientNonPersonDetails", clientNonPersonMap); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } - public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) { + public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, + final String clientType) { final HashMap map = new HashMap<>(); map.put("officeId", officeId); map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5)); @@ -280,37 +295,38 @@ public class ClientHelper { map.put("active", "true"); map.put("activationDate", dateOfJoining); map.put("clientTypeId", clientType); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } public static String assignStaffToClientAsJson(final String staffId) { final HashMap map = new HashMap<>(); map.put("staffId", staffId); - System.out.println("map : " + map); + LOG.info("map : {}", map); return new Gson().toJson(map); } - public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer generatedClientID) { - System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); - final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; + public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer generatedClientID) { + LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); + final String CLIENT_URL = "/fineract-provider/api/v1/clients/" + generatedClientID + "?" + + Utils.TENANT_IDENTIFIER; final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id"); assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID); } - public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId, - final String jsonReturn) { + public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final String clientId, final String jsonReturn) { final String GET_CLIENT_URL = "/fineract-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------GET A CLIENT---------------------------------------------"); + LOG.info("---------------------------------GET A CLIENT---------------------------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn); } /* Client status is a map.So adding SuppressWarnings */ @SuppressWarnings("unchecked") - public static HashMap getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId) { + public static HashMap getClientStatus(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId) { return (HashMap) getClient(requestSpec, responseSpec, clientId, "status"); } @@ -327,7 +343,8 @@ public class ClientHelper { Integer clientClosureCodeId = (Integer) code.get("id"); /* Retrieve/Create Code Values for the Code "ClientClosureReason" */ - HashMap codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec); + HashMap codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, + this.responseSpec); Integer closureReasonId = (Integer) codeValue.get("id"); map.put("closureReasonId", closureReasonId.toString()); @@ -336,7 +353,7 @@ public class ClientHelper { map.put("closureDate", CREATED_DATE_PLUS_ONE); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -347,7 +364,7 @@ public class ClientHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("reactivationDate", CREATED_DATE_PLUS_ONE); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -358,7 +375,7 @@ public class ClientHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("reopenedDate", date); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -369,7 +386,7 @@ public class ClientHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("reopenedDate", date); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -391,7 +408,7 @@ public class ClientHelper { map.put("rejectionDate", CREATED_DATE_PLUS_ONE); map.put("rejectionReasonId", rejectionReasonId.toString()); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -402,12 +419,10 @@ public class ClientHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("activationDate", date); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } - - private String getWithdrawClientAsJSON() { final HashMap map = new HashMap<>(); /* Retrieve Code id for the Code "ClientWithdrawReason" */ @@ -416,8 +431,8 @@ public class ClientHelper { Integer clientWithdrawReasonCodeId = (Integer) code.get("id"); /* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */ - HashMap codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec, - this.responseSpec); + HashMap codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, + this.requestSpec, this.responseSpec); Integer withdrawalReasonId = (Integer) codeValue.get("id"); map.put("locale", CommonConstants.locale); @@ -425,7 +440,7 @@ public class ClientHelper { map.put("withdrawalDate", CREATED_DATE_PLUS_ONE); map.put("withdrawalReasonId", withdrawalReasonId.toString()); String clientJson = new Gson().toJson(map); - System.out.println(clientJson); + LOG.info(clientJson); return clientJson; } @@ -448,7 +463,7 @@ public class ClientHelper { map.put("transactionDate", date); map.put("amount", amount); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -458,33 +473,38 @@ public class ClientHelper { map.put("amount", amount); map.put("clientChargeId", clientChargeId); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } public HashMap closeClient(final Integer clientId) { - System.out.println("--------------------------------- CLOSE CLIENT -------------------------------"); - return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId); + LOG.info("--------------------------------- CLOSE CLIENT -------------------------------"); + return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), + clientId); } public HashMap reactivateClient(final Integer clientId) { - System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------"); - return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId); + LOG.info("--------------------------------- REACTIVATE CLIENT -------------------------------"); + return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), + getReactivateClientAsJSON(), clientId); } public HashMap rejectClient(final Integer clientId) { - System.out.println("--------------------------------- REJECT CLIENT -------------------------------"); - return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId); + LOG.info("--------------------------------- REJECT CLIENT -------------------------------"); + return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), + clientId); } public HashMap activateClient(final Integer clientId) { - System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); - return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId); + LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); + return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), + getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), clientId); } public HashMap withdrawClient(final Integer clientId) { - System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------"); - return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId); + LOG.info("--------------------------------- WITHDRAWN CLIENT -------------------------------"); + return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), + getWithdrawClientAsJSON(), clientId); } private String createClientOperationURL(final String command, final Integer clientId) { @@ -492,41 +512,42 @@ public class ClientHelper { } public HashMap undoReject(final Integer clientId) { - System.out.println("--------------------------------- UNDO REJECT CLIENT -------------------------------"); + LOG.info("--------------------------------- UNDO REJECT CLIENT -------------------------------"); return performClientActions(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), getUndoRejectClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); } public HashMap undoWithdrawn(final Integer clientId) { - System.out.println("--------------------------------- UNDO WITHDRAWN CLIENT -------------------------------"); + LOG.info("--------------------------------- UNDO WITHDRAWN CLIENT -------------------------------"); return performClientActions(createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId), getUndoWithdrawnClientAsJSON(CREATED_DATE_PLUS_TWO), clientId); } - public ArrayList> undoRejectedclient(final Integer clientId, final String jsonAttributeToGetBack, - final String rejectedDate) { - System.out.println("----------------------------------UNDO REJECT CLIENT ----------------------------------"); + public ArrayList> undoRejectedclient(final Integer clientId, + final String jsonAttributeToGetBack, final String rejectedDate) { + LOG.info("----------------------------------UNDO REJECT CLIENT ----------------------------------"); return performClientActionsWithValidationErrors(createClientOperationURL(UNDOREJECT_CLIENT_COMMAND, clientId), getUndoRejectClientAsJSON(rejectedDate), jsonAttributeToGetBack); } - public ArrayList> undoWithdrawclient(final Integer clientId, final String jsonAttributeToGetBack, - final String rejectedDate) { - System.out.println("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------"); + public ArrayList> undoWithdrawclient(final Integer clientId, + final String jsonAttributeToGetBack, final String rejectedDate) { + LOG.info("----------------------------------UNDO WITHDRAW CLIENT ----------------------------------"); return performClientActionsWithValidationErrors( createClientOperationURL(UNDOWITHDRAWN_CLIENT_COMMAND, clientId), getUndoWithdrawnClientAsJSON(rejectedDate), jsonAttributeToGetBack); } - public ArrayList> activateClient(final Integer clientId, final String jsonAttributeToGetBack) { - System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); + public ArrayList> activateClient(final Integer clientId, + final String jsonAttributeToGetBack) { + LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); return performClientActionsWithValidationErrors(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(CREATED_DATE_PLUS_ONE), jsonAttributeToGetBack); } public HashMap activateClientWithDiffDateOption(final Integer clientId, final String activationDate) { - System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------"); + LOG.info("--------------------------------- ACTIVATE CLIENT -------------------------------"); return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(activationDate), clientId); } @@ -537,88 +558,97 @@ public class ClientHelper { jsonAttributeToGetBack); } - private HashMap performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) { - Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS); - HashMap response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId)); + private HashMap performClientActions(final String postURLForClient, final String jsonToBeSent, + final Integer clientId) { + Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, + CommonConstants.RESPONSE_STATUS); + HashMap response = ClientHelper.getClientStatus(requestSpec, responseSpec, + String.valueOf(clientId)); return response; } - public static Integer addChargesForClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer clientId, final String request) { - System.out.println("--------------------------------- ADD CHARGES FOR Client --------------------------------"); - final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + Utils.TENANT_IDENTIFIER; + public static Integer addChargesForClient(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer clientId, final String request) { + LOG.info("--------------------------------- ADD CHARGES FOR Client --------------------------------"); + final String ADD_CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges?" + + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); return (Integer) response.get("resourceId"); } - public static String payChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer clientId, final Integer clientChargeId, final String json) { - System.out.println("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=paycharge&" - + Utils.TENANT_IDENTIFIER; + public static String payChargesForClients(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, + final String json) { + LOG.info("--------------------------------- PAY CHARGES FOR CLIENT --------------------------------"); + final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + + "?command=paycharge&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); return response.get("transactionId") != null ? response.get("transactionId").toString() : null; } - public static String waiveChargesForClients(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer clientId, final Integer clientChargeId, final String json) { - System.out.println("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?command=waive&" - + Utils.TENANT_IDENTIFIER; + public static String waiveChargesForClients(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer clientId, final Integer clientChargeId, + final String json) { + LOG.info("--------------------------------- WAIVE CHARGES FOR CLIENT --------------------------------"); + final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + + "?command=waive&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); return response.get("transactionId").toString(); } - public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId, String clientChargeId) { - System.out.println("---------------------------------UNDO TRANSACTION---------------------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + "?command=undo&" - + Utils.TENANT_IDENTIFIER; + public static Integer revertClientChargeTransaction(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId, String clientChargeId) { + LOG.info("---------------------------------UNDO TRANSACTION---------------------------------------------"); + final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + clientChargeId + + "?command=undo&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, "", ""); return (Integer) response.get("resourceId"); } - public static Object getClientCharge(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId, final String clientChargeId) { - System.out.println("---------------------------------GET CLIENT CHARGE---------------------------------------------"); + public static Object getClientCharge(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId, final String clientChargeId) { + LOG.info("---------------------------------GET CLIENT CHARGE---------------------------------------------"); final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/charges/" + clientChargeId + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "amountOutstanding"); } - public static Boolean getClientTransactions(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String clientId, final String transactionId) { - System.out.println("---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + "?" - + Utils.TENANT_IDENTIFIER; + public static Boolean getClientTransactions(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String clientId, final String transactionId) { + LOG.info( + "---------------------------------GET CLIENT CHARGE TRANSACTIONS---------------------------------------------"); + final String CHARGES_URL = "/fineract-provider/api/v1/clients/" + clientId + "/transactions/" + transactionId + + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL, "reversed"); } public Workbook getClientEntityWorkbook(GlobalEntityType clientsEntity, String dateFormat) throws IOException { - requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel"); - byte [] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,CLIENT_URL+"/downloadtemplate"+"?"+ - Utils.TENANT_IDENTIFIER+"&legalFormType="+clientsEntity+"&dateFormat="+dateFormat); - InputStream inputStream= new ByteArrayInputStream(byteArray); - Workbook workbook=new HSSFWorkbook(inputStream); + requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); + byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, CLIENT_URL + "/downloadtemplate" + + "?" + Utils.TENANT_IDENTIFIER + "&legalFormType=" + clientsEntity + "&dateFormat=" + dateFormat); + InputStream inputStream = new ByteArrayInputStream(byteArray); + Workbook workbook = new HSSFWorkbook(inputStream); return workbook; } - public String getOutputTemplateLocation(final String importDocumentId){ - requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN); - return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" - +Utils.TENANT_IDENTIFIER,importDocumentId); + public String getOutputTemplateLocation(final String importDocumentId) { + requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); + return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec, + "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, + importDocumentId); } - public String importClientEntityTemplate(File file){ - String locale="en"; - String dateFormat="dd MMMM yyyy"; - String legalFormType=GlobalEntityType.CLIENTS_ENTTTY.toString(); + public String importClientEntityTemplate(File file) { + String locale = "en"; + String dateFormat = "dd MMMM yyyy"; + String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString(); requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); - return Utils.performServerTemplatePost(requestSpec,responseSpec,CLIENT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER, - legalFormType,file,locale,dateFormat); + return Utils.performServerTemplatePost(requestSpec, responseSpec, + CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, + dateFormat); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CurrenciesHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CurrenciesHelper.java index efed531e5..08820beee 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CurrenciesHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/CurrenciesHelper.java @@ -24,16 +24,18 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes", "unchecked" }) public class CurrenciesHelper { - + private final static Logger LOG = LoggerFactory.getLogger(CurrenciesHelper.class); private static final String CURRENCIES_URL = "/fineract-provider/api/v1/currencies"; public static ArrayList getAllCurrencies(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_ALL_CURRENCIES_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING ALL CURRENCIES -------------------------"); + LOG.info("------------------------ RETRIEVING ALL CURRENCIES -------------------------"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_CURRENCIES_URL, ""); ArrayList selectedCurrencyOptions = (ArrayList) response.get("selectedCurrencyOptions"); ArrayList currencyOptions = (ArrayList) response.get("currencyOptions"); @@ -45,7 +47,7 @@ public class CurrenciesHelper { public static ArrayList getSelectedCurrencies(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_ALL_SELECTED_CURRENCIES_URL = CURRENCIES_URL + "?fields=selectedCurrencyOptions" + "&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING ALL SELECTED CURRENCIES -------------------------"); + LOG.info("------------------------ RETRIEVING ALL SELECTED CURRENCIES -------------------------"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_SELECTED_CURRENCIES_URL, ""); final String jsonData = new Gson().toJson(response.get("selectedCurrencyOptions")); return new Gson().fromJson(jsonData, new TypeToken>() {}.getType()); @@ -63,7 +65,7 @@ public class CurrenciesHelper { public static ArrayList updateSelectedCurrencies(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final ArrayList currencies) { final String CURRENCIES_UPDATE_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE SELECTED CURRENCIES LIST---------------------------------------------"); + LOG.info("---------------------------------UPDATE SELECTED CURRENCIES LIST---------------------------------------------"); HashMap hash = Utils.performServerPut(requestSpec, responseSpec, CURRENCIES_UPDATE_URL, currenciesToJSON(currencies), "changes"); return (ArrayList) hash.get("currencies"); } @@ -71,7 +73,7 @@ public class CurrenciesHelper { private static String currenciesToJSON(final ArrayList currencies) { HashMap map = new HashMap<>(); map.put("currencies", currencies); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ExternalServicesConfigurationHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ExternalServicesConfigurationHelper.java index 8d2701fe9..946033407 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ExternalServicesConfigurationHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ExternalServicesConfigurationHelper.java @@ -29,24 +29,28 @@ public class ExternalServicesConfigurationHelper { private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; - public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { this.requestSpec = requestSpec; this.responseSpec = responseSpec; } - public static ArrayList getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec, - final ResponseSpecification responseSpec, final String serviceName) { - final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?" - + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); + public static ArrayList getExternalServicesConfigurationByServiceName( + final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final String serviceName) { + final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/fineract-provider/api/v1/externalservice/" + + serviceName + "?" + Utils.TENANT_IDENTIFIER; + // system.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION + // BY ID -------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, ""); } public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) { - final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + "?" - + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); + final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/externalservice/" + serviceName + + "?" + Utils.TENANT_IDENTIFIER; + // system.out.println("---------------------------------UPDATE VALUE FOR GLOBAL + // CONFIG---------------------------------------------"); HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL, updateExternalServicesConfigUpdateValueAsJSON(name, value), ""); @@ -56,7 +60,7 @@ public class ExternalServicesConfigurationHelper { public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) { final HashMap map = new HashMap<>(); map.put(name, value); - System.out.println("map : " + map); + // system.out.println("map : " + map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java index f116aad86..e0c754040 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/GlobalConfigurationHelper.java @@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class GlobalConfigurationHelper { - + private final static Logger LOG = LoggerFactory.getLogger(GlobalConfigurationHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -38,7 +40,7 @@ public class GlobalConfigurationHelper { public static ArrayList getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_ALL_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); + LOG.info("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------"); final HashMap> response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, ""); return (ArrayList) response.get("globalConfiguration"); } @@ -46,7 +48,7 @@ public class GlobalConfigurationHelper { public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String configId) { final String GET_GLOBAL_CONFIG_BY_ID_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); + LOG.info("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, ""); } @@ -338,7 +340,7 @@ public class GlobalConfigurationHelper { public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String configId, final String value) { final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); + LOG.info("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------"); return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateValueAsJSON(value), "resourceId"); } @@ -346,8 +348,7 @@ public class GlobalConfigurationHelper { public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String configId, final Boolean enabled) { final String GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - System.out - .println("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------"); + LOG.info("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------"); return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateEnabledFlagAsJSON(enabled), "resourceId"); } @@ -355,7 +356,7 @@ public class GlobalConfigurationHelper { public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------"); + LOG.info("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------"); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, GET_IS_CACHE_GLOBAL_CONFIG_URL, ""); return response; } @@ -363,7 +364,7 @@ public class GlobalConfigurationHelper { public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String cacheType) { final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/fineract-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------"); + LOG.info("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------"); return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL, updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes"); } @@ -371,7 +372,7 @@ public class GlobalConfigurationHelper { public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) { final String UPDATE_URL = "/fineract-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); + LOG.info("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------"); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL, updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack); } @@ -379,7 +380,7 @@ public class GlobalConfigurationHelper { public static String updateGlobalConfigUpdateValueAsJSON(final String value) { final HashMap map = new HashMap<>(); map.put("value", value); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -389,21 +390,21 @@ public class GlobalConfigurationHelper { map.put("value", value); } map.put("enabled", enabled); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) { final HashMap map = new HashMap(); map.put("enabled", enabled); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) { final HashMap map = new HashMap<>(); map.put("cacheType", cacheType); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HolidayHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HolidayHelper.java index 491c5cf18..65beb2bc7 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HolidayHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HolidayHelper.java @@ -24,10 +24,12 @@ import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class HolidayHelper { - + private final static Logger LOG = LoggerFactory.getLogger(HolidayHelper.class); private static final String HOLIDAYS_URL = "/fineract-provider/api/v1/holidays"; private static final String CREATE_HOLIDAY_URL = HOLIDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; @@ -57,14 +59,14 @@ public class HolidayHelper { map.put("repaymentsRescheduledTo", "08 April 2013"); map.put("reschedulingType", 2); String HolidayCreateJson = new Gson().toJson(map); - System.out.println(HolidayCreateJson); + LOG.info("{}",HolidayCreateJson); return HolidayCreateJson; } public static String getActivateHolidayDataAsJSON() { final HashMap map = new HashMap<>(); String activateHoliday = new Gson().toJson(map); - System.out.println(activateHoliday); + LOG.info("{}",activateHoliday); return activateHoliday; } @@ -80,7 +82,7 @@ public class HolidayHelper { public static HashMap getHolidayById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) { final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING HOLIDAY BY ID -------------------------"); + LOG.info("------------------------ RETRIEVING HOLIDAY BY ID -------------------------"); final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_HOLIDAY_BY_ID_URL, ""); return response; } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HookHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HookHelper.java index 89cbbc585..ac1d34d4a 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HookHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/HookHelper.java @@ -26,9 +26,11 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HookHelper { - + private final static Logger LOG = LoggerFactory.getLogger(HookHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -40,7 +42,7 @@ public class HookHelper { } public Integer createHook(final String payloadURL) { - System.out.println("---------------------------------CREATING A HOOK---------------------------------------------"); + LOG.info("---------------------------------CREATING A HOOK---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId"); } @@ -60,31 +62,31 @@ public class HookHelper { createOfficeEvent.put("entityName", "OFFICE"); events.add(createOfficeEvent); map.put("events", events); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public Integer updateHook(final String payloadURL, final Long hookId) { - System.out.println("---------------------------------UPDATING HOOK---------------------------------------------"); + LOG.info("---------------------------------UPDATING HOOK---------------------------------------------"); final String UPDATE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId"); } public Integer deleteHook(final Long hookId) { - System.out.println("---------------------------------DELETING HOOK---------------------------------------------"); + LOG.info("---------------------------------DELETING HOOK---------------------------------------------"); final String DELETE_HOOK_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId"); } public void verifyHookCreatedOnServer(final Long hookId) { - System.out.println("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n"); final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; final Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id"); assertEquals(hookId.toString(), responseHookId.toString()); } public void verifyUpdateHook(final String updateURL, final Long hookId) { - System.out.println("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n"); final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; ArrayList> map = Utils.>>performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config"); HashMap hash = (HashMap) map.get(1); @@ -92,7 +94,7 @@ public class HookHelper { } public void verifyDeleteHook(final Long hookId) { - System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n"); final String GET_URL = "/fineract-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER; ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build(); ArrayList> array = Utils.>>performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors"); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ImageHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ImageHelper.java index 6fc205852..42d523c07 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ImageHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ImageHelper.java @@ -21,29 +21,31 @@ package org.apache.fineract.integrationtests.common; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import org.apache.http.HttpHeaders; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ImageHelper { - + private final static Logger LOG = LoggerFactory.getLogger(ImageHelper.class); private static final String STAFF_IMAGE_URL = "/fineract-provider/api/v1/staff/"; private static final String IMAGES_URI = "/images"; public static Integer createImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { - System.out.println("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------"); + LOG.info("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------"); String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId"); } public static Integer updateImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { - System.out.println("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------"); + LOG.info("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------"); String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId"); } public static String getStaffImageAsText(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { - System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); + LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; requestSpec.header(HttpHeaders.ACCEPT, "text/plain"); return Utils.performGetTextResponse(requestSpec, responseSpec, URL); @@ -51,14 +53,14 @@ public class ImageHelper { public static byte[] getStaffImageAsBinary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { - System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); + LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream"); return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL); } public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) { - System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); + LOG.info("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------"); String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/NotificationHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/NotificationHelper.java index e9ff3cf29..f5793304f 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/NotificationHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/NotificationHelper.java @@ -20,9 +20,11 @@ package org.apache.fineract.integrationtests.common; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NotificationHelper { - + private final static Logger LOG = LoggerFactory.getLogger(NotificationHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -36,7 +38,7 @@ public class NotificationHelper { public static Object getNotifications(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String jsonReturn) { final String GET_NOTIFICATIONS_URL = NOTIFICATION_API_URL; - System.out.println("-----------------------------GET NOTIFICATIONS-----------------------------------"); + LOG.info("-----------------------------GET NOTIFICATIONS-----------------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_NOTIFICATIONS_URL, ""); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/OfficeHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/OfficeHelper.java index 0707f486b..cf25c675a 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/OfficeHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/OfficeHelper.java @@ -31,9 +31,11 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class OfficeHelper { - + private final static Logger LOG = LoggerFactory.getLogger(OfficeHelper.class); private static final String OFFICE_URL = "/fineract-provider/api/v1/offices"; private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -67,7 +69,7 @@ public class OfficeHelper { map.put("locale", "en"); map.put("openingDate", openingDate); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER, @@ -81,7 +83,7 @@ public class OfficeHelper { map.put("dateFormat", "dd MMMM yyyy"); map.put("locale", "en"); map.put("openingDate", openingDate); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PasswordPreferencesHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PasswordPreferencesHelper.java index 002ab097e..472dac43e 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PasswordPreferencesHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PasswordPreferencesHelper.java @@ -27,18 +27,20 @@ public class PasswordPreferencesHelper { private static final String PASSWORD_PREFERENCES_URL = "/fineract-provider/api/v1/passwordpreferences"; - public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - String validationPolicyId) { + public static Object updatePasswordPreferences(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, String validationPolicyId) { final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE PASSWORD PREFERENCE---------------------------------------------"); - return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesAsJson(validationPolicyId), ""); + // system.out.println("---------------------------------UPDATE PASSWORD + // PREFERENCE---------------------------------------------"); + return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, + updatePreferencesAsJson(validationPolicyId), ""); } public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) { final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out - .println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------"); + //system.out + //.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------"); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId), jsonAttributeToGetback); } @@ -55,14 +57,17 @@ public class PasswordPreferencesHelper { return new Gson().toJson(map); } - - public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id"); + public static int getActivePasswordPreference(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { + return Utils.performServerGet(requestSpec, responseSpec, + PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id"); } - public static HashMap getAllPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static HashMap getAllPreferences(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { - return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, ""); + return Utils.performServerGet(requestSpec, responseSpec, + PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, ""); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java index 014fdd7f7..d59d8f1fc 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java @@ -29,58 +29,72 @@ import java.util.HashMap; @SuppressWarnings({ "rawtypes", "unchecked" }) public class PaymentTypeHelper { - private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" + Utils.TENANT_IDENTIFIER; + private static final String CREATE_PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes?" + + Utils.TENANT_IDENTIFIER; private static final String PAYMENTTYPE_URL = "/fineract-provider/api/v1/paymenttypes"; - public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String name, final String description, final Boolean isCashPayment, final Integer position) { - System.out.println("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------"); + public static Integer createPaymentType(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String name, final String description, + final Boolean isCashPayment, final Integer position) { + // system.out.println("---------------------------------CREATING A PAYMENT + // TYPE---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL, getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId"); } - public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment, - final Integer position) { + public static String getJsonToCreatePaymentType(final String name, final String description, + final Boolean isCashPayment, final Integer position) { HashMap hm = new HashMap(); hm.put("name", name); - if (description != null) hm.put("description", description); + if (description != null) + hm.put("description", description); hm.put("isCashPayment", isCashPayment); - if (position != null) hm.put("position", position); + if (position != null) + hm.put("position", position); - System.out.println("------------------------CREATING PAYMENT TYPE-------------------------" + hm); + // system.out.println("------------------------CREATING PAYMENT + // TYPE-------------------------" + hm); return new Gson().toJson(hm); } - public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer generatedPaymentTypeID) { - System.out.println("------------------------------CHECK PAYMENT DETAILS------------------------------------\n"); - final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER; - final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id"); + public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer generatedPaymentTypeID) { + // system.out.println("------------------------------CHECK PAYMENT + // DETAILS------------------------------------\n"); + final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + + Utils.TENANT_IDENTIFIER; + final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, + "id"); assertEquals("ERROR IN CREATING THE PAYMENT TYPE", generatedPaymentTypeID, responsePaymentTypeID); } public static PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec, final Integer paymentTypeId) { final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + paymentTypeId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------GET PAYMENT TYPE---------------------------------------------"); + // system.out.println("---------------------------------GET PAYMENT + // TYPE---------------------------------------------"); Object get = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""); final String jsonData = new Gson().toJson(get); - return new Gson().fromJson(jsonData, new TypeToken() {}.getType()); + return new Gson().fromJson(jsonData, new TypeToken() { + }.getType()); } - public static HashMap updatePaymentType(final int id, HashMap request, final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { + public static HashMap updatePaymentType(final int id, HashMap request, + final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE PAYMENT TYPE " + id + "---------------------------------------------"); + // system.out.println("---------------------------------UPDATE PAYMENT TYPE " + + // id + "---------------------------------------------"); HashMap hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL, new Gson().toJson(request), "changes"); return hash; } - public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------DELETING PAYMENT TYPE " + id + "--------------------------------------------"); + // system.out.println("---------------------------------DELETING PAYMENT TYPE " + // + id + "--------------------------------------------"); return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java index 8d8bf359a..d30dc0021 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/ProvisioningIntegrationTest.java @@ -44,10 +44,12 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class ProvisioningIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(ProvisioningIntegrationTest.class); private static final String NONE = "1"; private final static int LOANPRODUCTS_SIZE = 10; @@ -84,7 +86,7 @@ public class ProvisioningIntegrationTest { loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); loans.add(loanID); @@ -181,7 +183,7 @@ public class ProvisioningIntegrationTest { } private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder() // .withPrincipal("1,00,000.00") // .withNumberOfRepayments("4") // @@ -203,7 +205,7 @@ public class ProvisioningIntegrationTest { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, List charges, final String savingsId, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // 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 560f932d0..027b15a5f 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 @@ -31,10 +31,12 @@ import java.util.Map; import java.util.function.ToIntFunction; import java.util.stream.Collectors; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class SchedulerJobHelper { - + private final static Logger LOG = LoggerFactory.getLogger(SchedulerJobHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification response200Spec; private final ResponseSpecification response202Spec; @@ -53,7 +55,7 @@ public class SchedulerJobHelper { private List getAllSchedulerJobs() { final String GET_ALL_SCHEDULER_JOBS_URL = "/fineract-provider/api/v1/jobs?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING ALL SCHEDULER JOBS -------------------------"); + LOG.info("------------------------ RETRIEVING ALL SCHEDULER JOBS -------------------------"); final ArrayList response = Utils.performServerGet(requestSpec, response200Spec, GET_ALL_SCHEDULER_JOBS_URL, ""); return response; } @@ -65,16 +67,16 @@ public class SchedulerJobHelper { public Map getSchedulerJobById(int jobId) { final String GET_SCHEDULER_JOB_BY_ID_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------"); + LOG.info("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------"); final Map response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_JOB_BY_ID_URL, ""); - System.out.println(response); + LOG.info("{}",response.toString()); assertNotNull(response); return response; } public Boolean getSchedulerStatus() { final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING SCHEDULER STATUS -------------------------"); + LOG.info("------------------------ RETRIEVING SCHEDULER STATUS -------------------------"); final Map response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, ""); return (Boolean) response.get("active"); } @@ -82,13 +84,13 @@ public class SchedulerJobHelper { public void updateSchedulerStatus(final boolean on) { String command = on ? "start" : "stop"; final String UPDATE_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/scheduler?command=" + command + "&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ UPDATING SCHEDULER STATUS -------------------------"); + LOG.info("------------------------ UPDATING SCHEDULER STATUS -------------------------"); Utils.performServerPost(requestSpec, response202Spec, UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null); } public Map updateSchedulerJob(int jobId, final String active) { final String UPDATE_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ UPDATING SCHEDULER JOB -------------------------"); + LOG.info("------------------------ UPDATING SCHEDULER JOB -------------------------"); final Map response = Utils.performServerPut(requestSpec, response200Spec, UPDATE_SCHEDULER_JOB_URL, updateSchedulerJobAsJSON(active), "changes"); return response; @@ -97,13 +99,13 @@ public class SchedulerJobHelper { private static String updateSchedulerJobAsJSON(final String active) { final Map map = new HashMap<>(); map.put("active", active); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public List getSchedulerJobHistory(int jobId) { final String GET_SCHEDULER_STATUS_URL = "/fineract-provider/api/v1/jobs/" + jobId + "/runhistory?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING SCHEDULER JOB HISTORY -------------------------"); + LOG.info("------------------------ RETRIEVING SCHEDULER JOB HISTORY -------------------------"); final Map response = Utils.performServerGet(requestSpec, response200Spec, GET_SCHEDULER_STATUS_URL, ""); return (ArrayList) response.get("pageItems"); } @@ -111,14 +113,14 @@ public class SchedulerJobHelper { public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) { final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build(); final String RUN_SCHEDULER_JOB_URL = "/fineract-provider/api/v1/jobs/" + jobId + "?command=executeJob&" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RUN SCHEDULER JOB -------------------------"); + LOG.info("------------------------ RUN SCHEDULER JOB -------------------------"); Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null); } private static String runSchedulerJobAsJSON() { final Map map = new HashMap<>(); String runSchedulerJob = new Gson().toJson(map); - System.out.println(runSchedulerJob); + LOG.info(runSchedulerJob); return runSchedulerJob; } @@ -142,7 +144,7 @@ public class SchedulerJobHelper { Thread.sleep(15000); schedulerJob = getSchedulerJobById(jobId); Assert.assertNotNull(schedulerJob); - System.out.println("Job is Still Running"); + LOG.info("Job is Still Running"); } List jobHistoryData = getSchedulerJobHistory(jobId); @@ -150,10 +152,10 @@ public class SchedulerJobHelper { Assert.assertFalse("Job History is empty :( Was it too slow? Failures in background job?", jobHistoryData.isEmpty()); // print error associated with recent job failure (if any) - System.out.println("Job run error message (printed only if the job fails: " - + jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage")); - System.out.println("Job failure error log (printed only if the job fails: " - + jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog")); + LOG.info("Job run error message (printed only if the job fails: {}" + , jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage")); + LOG.info("Job failure error log (printed only if the job fails: {}" + , jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog")); // Verifying the Status of the Recently executed Scheduler Job Assert.assertEquals("Verifying Last Scheduler Job Status", "success", diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java index e072ccad4..aea18e46b 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/StandingInstructionsHelper.java @@ -23,10 +23,12 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({"unused", "rawtypes", "unchecked" }) public class StandingInstructionsHelper { - + private final static Logger LOG = LoggerFactory.getLogger(StandingInstructionsHelper.class); private static final String STANDING_INSTRUCTIONS_URL = "/fineract-provider/api/v1/standinginstructions"; private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/fineract-provider/api/v1/standinginstructionrunhistory"; private static final String LOCALE = "en_GB"; @@ -88,13 +90,13 @@ public class StandingInstructionsHelper { map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS); map.put("recurrenceOnMonthDay", monthDay); String savingsApplicationJSON = new Gson().toJson(map); - System.out.println(savingsApplicationJSON); + LOG.info("{}",savingsApplicationJSON); return savingsApplicationJSON; } public Integer createStandingInstruction(final String clientId, final String fromAccountId, final String toAccountId, final String fromAccountType, final String toAccountType, final String validFrom, final String validTo, final String monthDay) { - System.out.println("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------"); + LOG.info("-------------------------------- CREATE STANDING INSTRUCTIONS --------------------------------"); final String standingInstructionAsJSON = new StandingInstructionsHelper(this.requestSpec, this.responseSpec) // .build(clientId.toString(), fromAccountId.toString(), toAccountId.toString(), fromAccountType, toAccountType, validFrom, validTo, monthDay); @@ -104,7 +106,7 @@ public class StandingInstructionsHelper { public HashMap getStandingInstructionById(final String standingInstructionId) { - System.out.println("----------------------------- RETRIEVING STANDING INSTRUCTION BY ID---------------------------"); + LOG.info("----------------------------- RETRIEVING STANDING INSTRUCTION BY ID---------------------------"); final String GET_STANDING_INSTRUCTION_BY_ID_URL = STANDING_INSTRUCTIONS_URL + "/" + standingInstructionId + "?" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, ""); @@ -115,7 +117,7 @@ public class StandingInstructionsHelper { final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER + "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId + "&transferType=" + transferType; - System.out.println("STANDING_INSTRUCTIONS_HISTORY_URL="+STANDING_INSTRUCTIONS_HISTORY_URL); + LOG.info("STANDING_INSTRUCTIONS_HISTORY_URL= {}",STANDING_INSTRUCTIONS_HISTORY_URL); final List response = (List) Utils.performServerGet(this.requestSpec, this.responseSpec, STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems"); return response; diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SurveyHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SurveyHelper.java index 22ce565cf..2904f757f 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SurveyHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/SurveyHelper.java @@ -24,9 +24,11 @@ import com.google.gson.Gson; import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SurveyHelper { - + private final static Logger LOG = LoggerFactory.getLogger(SurveyHelper.class); private static final String FULFIL_SURVEY_URL = "/fineract-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER; public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { @@ -35,7 +37,7 @@ public class SurveyHelper { public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String activationDate) { - System.out.println("---------------------------------FULFIL PPI ---------------------------------------------"); + LOG.info("---------------------------------FULFIL PPI ---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec,FULFIL_SURVEY_URL, getTestPPIAsJSON(), "clientId"); } @@ -57,13 +59,13 @@ public class SurveyHelper { map.put("ppi_towels_cd_q9_towels", "134"); map.put("ppi_fryingpans_cd_q10_fryingpans", "138"); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedClientID) { - System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); + LOG.info("------------------------------CHECK CLIENT DETAILS------------------------------------\n"); final String SURVEY_URL = "/fineract-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER; final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id"); assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxComponentHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxComponentHelper.java index 43cf953f7..5e87d522d 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxComponentHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxComponentHelper.java @@ -23,14 +23,16 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.accounting.Account; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TaxComponentHelper { - + private final static Logger LOG = LoggerFactory.getLogger(TaxComponentHelper.class); private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/component?" + Utils.TENANT_IDENTIFIER; public static Integer createTaxComponent(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String percentage, final Integer liabilityAccountId) { - System.out.println("---------------------------------CREATING A TAX COMPONENT---------------------------------------------"); + LOG.info("---------------------------------CREATING A TAX COMPONENT---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxComponentAsJSON(percentage, liabilityAccountId), "resourceId"); } @@ -41,7 +43,7 @@ public class TaxComponentHelper { map.put("creditAccountType", Account.AccountType.LIABILITY.toString()); map.put("creditAcountId", String.valueOf(creditAccountId)); } - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxGroupHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxGroupHelper.java index 86e12ef73..02adfbd19 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxGroupHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/TaxGroupHelper.java @@ -25,14 +25,16 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TaxGroupHelper { - + private final static Logger LOG = LoggerFactory.getLogger(TaxGroupHelper.class); private static final String CREATE_TAX_COMPONENT_URL = "/fineract-provider/api/v1/taxes/group?" + Utils.TENANT_IDENTIFIER; public static Integer createTaxGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Collection taxComponentIds) { - System.out.println("---------------------------------CREATING A TAX GROUP---------------------------------------------"); + LOG.info("---------------------------------CREATING A TAX GROUP---------------------------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_TAX_COMPONENT_URL, getTaxGroupAsJSON(taxComponentIds), "resourceId"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java index 733df4d5c..b7dd1c177 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java @@ -61,7 +61,7 @@ public class Utils { public static final String TENANT_TIME_ZONE = "Asia/Kolkata"; private static final String HEALTH_URL = "/fineract-provider/actuator/health"; - private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER; + private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?" + TENANT_IDENTIFIER; public static void initializeRESTAssured() { RestAssured.baseURI = "https://localhost"; @@ -83,11 +83,13 @@ public class Utils { logger.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL); return; } else { - logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++); + logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, + healthHttpStatus, attempt++); sleep(3); } } catch (Exception e) { - logger.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++); + logger.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), + attempt++); lastException = e; sleep(3); } @@ -97,7 +99,8 @@ public class Utils { logger.error("{} still not reachable, giving up", HEALTH_URL, lastException); throw new AssertionError(HEALTH_URL + " not reachable", lastException); } else { - logger.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, response.prettyPrint()); + logger.error("{} still has not returned HTTP 200, giving up (last) body: {}", HEALTH_URL, + response.prettyPrint()); fail(HEALTH_URL + " returned " + response.prettyPrint()); } } @@ -115,10 +118,10 @@ public class Utils { awaitSpringBootActuatorHealthyUp(); try { logger.info("Logging in, for integration test..."); - System.out.println("-----------------------------------LOGIN-----------------------------------------"); + // system.out.println("-----------------------------------LOGIN-----------------------------------------"); String json = RestAssured.given().contentType(ContentType.JSON) - .body("{\"username\":\"mifos\", \"password\":\"password\"}") - .expect().log().ifError().when().post(LOGIN_URL).asString(); + .body("{\"username\":\"mifos\", \"password\":\"password\"}").expect().log().ifError().when() + .post(LOGIN_URL).asString(); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); String key = JsonPath.with(json).get("base64EncodedAuthenticationKey"); assertThat("Failed to obtain key: " + json, StringUtils.isBlank(key), is(false)); @@ -133,49 +136,59 @@ public class Utils { } } - public static T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String getURL, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); - if (jsonAttributeToGetBack == null) { return (T) json; } - return (T) from(json).get(jsonAttributeToGetBack); - } - - public static String performGetTextResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String getURL){ - return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); - } - - public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String getURL){ - return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asByteArray(); - } - - public static T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL) + public static T performServerGet(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String getURL, final String jsonAttributeToGetBack) { + final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL) .andReturn().asString(); - if (jsonAttributeToGetBack == null) { return (T) json; } + if (jsonAttributeToGetBack == null) { + return (T) json; + } return (T) from(json).get(jsonAttributeToGetBack); } - public static T performServerPut(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String putURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().put(putURL) - .andReturn().asString(); - return (T) from(json).get(jsonAttributeToGetBack); - } - - public static T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String deleteURL, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().delete(deleteURL).andReturn() + public static String performGetTextResponse(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String getURL) { + return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn() .asString(); + } + + public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String getURL) { + return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn() + .asByteArray(); + } + + public static T performServerPost(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String postURL, final String jsonBodyToSend, + final String jsonAttributeToGetBack) { + final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError() + .when().post(postURL).andReturn().asString(); + if (jsonAttributeToGetBack == null) { + return (T) json; + } return (T) from(json).get(jsonAttributeToGetBack); } - public static T performServerDelete(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String deleteURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) { - final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when() + public static T performServerPut(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String putURL, final String jsonBodyToSend, + final String jsonAttributeToGetBack) { + final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError() + .when().put(putURL).andReturn().asString(); + return (T) from(json).get(jsonAttributeToGetBack); + } + + public static T performServerDelete(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String deleteURL, final String jsonAttributeToGetBack) { + final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when() .delete(deleteURL).andReturn().asString(); + return (T) from(json).get(jsonAttributeToGetBack); + } + + public static T performServerDelete(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String deleteURL, final String jsonBodyToSend, + final String jsonAttributeToGetBack) { + final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError() + .when().delete(deleteURL).andReturn().asString(); return (T) (jsonAttributeToGetBack == null ? json : from(json).get(jsonAttributeToGetBack)); } @@ -208,11 +221,12 @@ public class Utils { public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) { return randomStringGenerator(prefix, lenOfRandomSuffix); } - public static Long randomNumberGenerator(final int expectedLength){ - final String source="1234567890"; - final int lengthofSource=source.length(); - final Random random=new Random(); - StringBuilder stringBuilder=new StringBuilder(expectedLength); + + public static Long randomNumberGenerator(final int expectedLength) { + final String source = "1234567890"; + final int lengthofSource = source.length(); + final Random random = new Random(); + StringBuilder stringBuilder = new StringBuilder(expectedLength); for (int i = 0; i < expectedLength; i++) { stringBuilder.append(source.charAt(random.nextInt(lengthofSource))); } @@ -238,28 +252,20 @@ public class Utils { return TimeZone.getTimeZone(TENANT_TIME_ZONE); } - public static String performServerTemplatePost(final RequestSpecification requestSpec,final ResponseSpecification responseSpec, - final String postURL,final String legalFormType,final File file,final String locale,final String dateFormat) { + public static String performServerTemplatePost(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String postURL, final String legalFormType, final File file, + final String locale, final String dateFormat) { - final String importDocumentId=given().spec(requestSpec) - .queryParam("legalFormType",legalFormType) - .multiPart("file",file) - .formParam("locale",locale) - .formParam("dateFormat",dateFormat) - .expect().spec(responseSpec). - log().ifError().when().post(postURL) - .andReturn().asString(); + final String importDocumentId = given().spec(requestSpec).queryParam("legalFormType", legalFormType) + .multiPart("file", file).formParam("locale", locale).formParam("dateFormat", dateFormat).expect() + .spec(responseSpec).log().ifError().when().post(postURL).andReturn().asString(); return importDocumentId; } - public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec,final ResponseSpecification responseSpec, - final String getURL,final String importDocumentId){ - final String templateLocation=given().spec(requestSpec). - queryParam("importDocumentId",importDocumentId) - .expect().spec(responseSpec) - .log().ifError().when().get(getURL) - .andReturn().asString(); - return templateLocation.substring(1,templateLocation.length()-1); + public static String performServerOutputTemplateLocationGet(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String getURL, final String importDocumentId) { + final String templateLocation = given().spec(requestSpec).queryParam("importDocumentId", importDocumentId) + .expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString(); + return templateLocation.substring(1, templateLocation.length() - 1); } } - diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/WorkingDaysHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/WorkingDaysHelper.java index ee595b69e..9529a78a3 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/WorkingDaysHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/WorkingDaysHelper.java @@ -23,22 +23,23 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import java.util.Random; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class WorkingDaysHelper { - + private final static Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class); private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays"; public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("---------------------------------UPDATE WORKINGDAY---------------------------------------------"); + LOG.info("---------------------------------UPDATE WORKINGDAY---------------------------------------------"); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), ""); } public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, String jsonAttributeToGetback) { final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER; - System.out - .println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------"); + LOG.info("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------"); return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(), jsonAttributeToGetback); } @@ -49,7 +50,7 @@ public class WorkingDaysHelper { map.put("locale", "en"); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("extendTermForDailyRepayments", false); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -59,7 +60,7 @@ public class WorkingDaysHelper { map.put("locale", "en"); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("extendTermForDailyRepayments", false); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java index e22677155..90a749dae 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java @@ -26,10 +26,12 @@ import java.util.HashMap; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.portfolio.charge.domain.ChargeTimeType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "rawtypes", "unchecked" }) public class ChargesHelper { - + private final static Logger LOG = LoggerFactory.getLogger(ChargesHelper.class); private static final String CHARGES_URL = "/fineract-provider/api/v1/charges"; private static final String CREATE_CHARGES_URL = CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER; @@ -48,9 +50,9 @@ public class ChargesHelper { private static final Integer CHARGE_OVERDUE_INSTALLMENT_FEE = 9; private static final Integer CHARGE_OVERDRAFT_FEE = 10; private static final Integer WEEKLY_FEE = 11; - private static final Integer SHAREACCOUNT_ACTIVATION = 13 ; - private static final Integer SHARE_PURCHASE = 14 ; - private static final Integer SHARE_REDEEM = 15 ; + private static final Integer SHAREACCOUNT_ACTIVATION = 13; + private static final Integer SHARE_PURCHASE = 14; + private static final Integer SHARE_REDEEM = 15; private static final Integer CHARGE_SAVINGS_NO_ACTIVITY_FEE = 16; @@ -81,7 +83,7 @@ public class ChargesHelper { map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("feeInterval", 2); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -101,7 +103,7 @@ public class ChargesHelper { final HashMap map = populateDefaultsForSavings(amount.toString(), currencyCode); map.put("chargeTimeType", timeType.getValue()); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -110,7 +112,7 @@ public class ChargesHelper { map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("chargeTimeType", CHARGE_ANNUAL_FEE); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -120,7 +122,7 @@ public class ChargesHelper { map.put("chargeTimeType", CHARGE_MONTHLY_FEE); map.put("feeInterval", 2); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -129,7 +131,7 @@ public class ChargesHelper { map.put("chargeTimeType", WEEKLY_FEE); map.put("feeInterval", 1); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -137,7 +139,7 @@ public class ChargesHelper { final HashMap map = populateDefaultsForSavings(); map.put("chargeTimeType", CHARGE_OVERDRAFT_FEE); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -166,31 +168,37 @@ public class ChargesHelper { return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); } - public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, final String amount) { - return getLoanDisbursementJSON(chargeCalculationType, amount, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); + public static String getLoanDisbursementAccountTransferJSON(final Integer chargeCalculationType, + final String amount) { + return getLoanDisbursementJSON(chargeCalculationType, amount, + ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); } - public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, final Integer paymentmode) { + public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount, + final Integer paymentmode) { final HashMap map = populateDefaultsForLoan(); map.put("chargeTimeType", CHARGE_DISBURSEMENT_FEE); map.put("chargePaymentMode", paymentmode); map.put("amount", amount); map.put("chargeCalculationType", chargeCalculationType); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } public static String getLoanSpecifiedDueDateJSON() { - return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty); + return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, + ChargesHelper.penalty); } - public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { - return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); + public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, + boolean penalty) { + return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, + ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); } - public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, final boolean penalty, - final Integer paymentMode) { + public static String getLoanSpecifiedDueDateJSON(final Integer chargeCalculationType, final String amount, + final boolean penalty, final Integer paymentMode) { final HashMap map = populateDefaultsForLoan(); map.put("chargeTimeType", CHARGE_SPECIFIED_DUE_DATE); map.put("chargePaymentMode", paymentMode); @@ -199,26 +207,29 @@ public class ChargesHelper { map.put("chargeCalculationType", chargeCalculationType); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } - public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, final String amount, - boolean penalty) { - return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); - } - - public static String getLoanSpecifiedDueDateWithAccountTransferJSON() { - return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty, + public static String getLoanSpecifiedDueDateWithAccountTransferJSON(final Integer chargeCalculationType, + final String amount, boolean penalty) { + return getLoanSpecifiedDueDateJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); } - public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { - return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); + public static String getLoanSpecifiedDueDateWithAccountTransferJSON() { + return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, + ChargesHelper.penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); } - public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, final boolean penalty, - final Integer paymentMode) { + public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, + boolean penalty) { + return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, + ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); + } + + public static String getLoanInstallmentJSON(final Integer chargeCalculationType, final String amount, + final boolean penalty, final Integer paymentMode) { final HashMap map = populateDefaultsForLoan(); map.put("chargeTimeType", CHARGE_INSTALLMENT_FEE); map.put("chargePaymentMode", paymentMode); @@ -227,36 +238,39 @@ public class ChargesHelper { map.put("chargeCalculationType", chargeCalculationType); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } - public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, final String amount, boolean penalty) { - return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); + public static String getLoanInstallmentWithAccountTransferJSON(final Integer chargeCalculationType, + final String amount, boolean penalty) { + return getLoanInstallmentJSON(chargeCalculationType, amount, penalty, + ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); } public static String getLoanInstallmentFeeJSON() { - return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, ChargesHelper.penalty); + return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, + ChargesHelper.penalty); } public static String getShareAccountActivationChargeJson() { - HashMap map = populateDefaultsShareActivationCharge() ; + HashMap map = populateDefaultsShareActivationCharge(); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } public static String getShareAccountPurchaseChargeJson() { - HashMap map = populateDefaultsSharePurchaseFlatCharge() ; + HashMap map = populateDefaultsSharePurchaseFlatCharge(); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } public static String getShareAccountRedeemChargeJson() { - HashMap map = populateDefaultsShareRedeemFlatCharge() ; + HashMap map = populateDefaultsShareRedeemFlatCharge(); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -269,7 +283,7 @@ public class ChargesHelper { map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeInterval", 2); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -281,7 +295,7 @@ public class ChargesHelper { map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST); String chargesCreateJson = new Gson().toJson(map); - System.out.println(chargesCreateJson); + LOG.info("{}", chargesCreateJson); return chargesCreateJson; } @@ -304,7 +318,7 @@ public class ChargesHelper { map.put("amount", ChargesHelper.amount); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); - map.put("chargeTimeType",ChargesHelper.CHARGE_SPECIFIED_DUE_DATE); + map.put("chargeTimeType", ChargesHelper.CHARGE_SPECIFIED_DUE_DATE); map.put("currencyCode", ChargesHelper.currencyCode); map.put("locale", CommonConstants.locale); map.put("monthDayFormat", ChargesHelper.monthDayFormat); @@ -318,7 +332,7 @@ public class ChargesHelper { map.put("amount", ChargesHelper.amount); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); - map.put("chargeTimeType",ChargesHelper.SHAREACCOUNT_ACTIVATION); + map.put("chargeTimeType", ChargesHelper.SHAREACCOUNT_ACTIVATION); map.put("currencyCode", ChargesHelper.currencyCode); map.put("locale", CommonConstants.locale); map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8)); @@ -331,7 +345,7 @@ public class ChargesHelper { map.put("amount", ChargesHelper.amount); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); - map.put("chargeTimeType",ChargesHelper.SHARE_PURCHASE); + map.put("chargeTimeType", ChargesHelper.SHARE_PURCHASE); map.put("currencyCode", ChargesHelper.currencyCode); map.put("locale", CommonConstants.locale); map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8)); @@ -344,43 +358,47 @@ public class ChargesHelper { map.put("amount", ChargesHelper.amount); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); - map.put("chargeTimeType",ChargesHelper.SHARE_REDEEM); + map.put("chargeTimeType", ChargesHelper.SHARE_REDEEM); map.put("currencyCode", ChargesHelper.currencyCode); map.put("locale", CommonConstants.locale); map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8)); return map; } - public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String request) { + public static Integer createCharges(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String request) { return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request, "resourceId"); } - public static ArrayList getCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, ""); + public static ArrayList getCharges(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { + return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, + CHARGES_URL + "?" + Utils.TENANT_IDENTIFIER, ""); } - public static HashMap getChargeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer chargeId) { - return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, ""); + public static HashMap getChargeById(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer chargeId) { + return Utils.performServerGet(requestSpec, responseSpec, + CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, ""); } - public static HashMap getChargeChanges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer chargeId) { - return Utils.performServerGet(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, - CommonConstants.RESPONSE_CHANGES); + public static HashMap getChargeChanges(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer chargeId) { + return Utils.performServerGet(requestSpec, responseSpec, + CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_CHANGES); } - public static HashMap updateCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer chargeId, final String request) { - return Utils.performServerPut(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request, + public static HashMap updateCharges(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer chargeId, final String request) { + return Utils.performServerPut(requestSpec, responseSpec, + CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, request, CommonConstants.RESPONSE_CHANGES); } public static Integer deleteCharge(final ResponseSpecification responseSpec, final RequestSpecification requestSpec, final Integer chargeId) { - return Utils.performServerDelete(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, - CommonConstants.RESPONSE_RESOURCE_ID); + return Utils.performServerDelete(requestSpec, responseSpec, + CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, CommonConstants.RESPONSE_RESOURCE_ID); } public static String getModifyChargeJSON() { @@ -388,7 +406,7 @@ public class ChargesHelper { map.put("locale", CommonConstants.locale); map.put("amount", "200.0"); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -397,7 +415,7 @@ public class ChargesHelper { map.put("locale", CommonConstants.locale); map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -407,7 +425,7 @@ public class ChargesHelper { map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -417,7 +435,7 @@ public class ChargesHelper { map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -427,7 +445,7 @@ public class ChargesHelper { map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST); map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -437,7 +455,7 @@ public class ChargesHelper { map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS); map.put("feeInterval", 2); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -447,7 +465,7 @@ public class ChargesHelper { map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS); map.put("feeInterval", 2); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -457,7 +475,7 @@ public class ChargesHelper { map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS); map.put("feeInterval", 2); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -467,19 +485,21 @@ public class ChargesHelper { map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS); map.put("feeInterval", 2); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } public static String getChargeSpecifiedDueDateJSON() { final HashMap map = populateDefaultsClientCharge(); String chargesCreateJson = new Gson().toJson(map); - System.out.println("chargesCreateJson:"+chargesCreateJson); + LOG.info("chargesCreateJson: {}", chargesCreateJson); return chargesCreateJson; } - public static String applyCharge(RequestSpecification requestSpec,ResponseSpecification responseSpec, String chargeId,String json) { - return Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json,"status"); + public static String applyCharge(RequestSpecification requestSpec, ResponseSpecification responseSpec, + String chargeId, String json) { + return Utils.performServerPost(requestSpec, responseSpec, + CHARGES_URL + "/" + chargeId + "?" + Utils.TENANT_IDENTIFIER, json, "status"); } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java index 22b5a7688..ded5afbd8 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountHelper.java @@ -26,10 +26,12 @@ import java.util.Calendar; import java.util.HashMap; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class FixedDepositAccountHelper { - + private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -39,7 +41,8 @@ public class FixedDepositAccountHelper { } private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; - private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER; + private static final String APPLY_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "?" + + Utils.TENANT_IDENTIFIER; private static final String APPROVE_FIXED_DEPOSIT_COMMAND = "approve"; private static final String UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND = "undoapproval"; private static final String REJECT_FIXED_DEPOSIT_COMMAND = "reject"; @@ -126,21 +129,22 @@ public class FixedDepositAccountHelper { map.put("transferInterestToSavings", transferInterest); String fixedDepositAccountJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountJson); + LOG.info("{}", fixedDepositAccountJson); return fixedDepositAccountJson; } - public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, final RequestSpecification requestSpec, - final ResponseSpecification responseSpec) { - System.out.println("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, fixedDepositAccountAsJson, - CommonConstants.RESPONSE_RESOURCE_ID); + public static Integer applyFixedDepositApplication(final String fixedDepositAccountAsJson, + final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + LOG.info("--------------------- APPLYING FOR FIXED DEPOSIT ACCOUNT ------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, APPLY_FIXED_DEPOSIT_ACCOUNT_URL, + fixedDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID); } - public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer accountID) { - final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------"); + public static HashMap getFixedDepositAccountById(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer accountID) { + final String GET_FIXED_DEPOSIT_BY_ID_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + + Utils.TENANT_IDENTIFIER; + LOG.info("------------------------ RETRIEVING FIXED DEPOSIT ACCOUNT BY ID -------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_FIXED_DEPOSIT_BY_ID_URL, ""); } @@ -173,8 +177,8 @@ public class FixedDepositAccountHelper { return annualInterestRate; } - public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, Integer depositPeriod, - double interestPerDay, Integer compoundingInterval, Integer postingInterval) { + public static Float getPrincipalAfterCompoundingInterest(Calendar currentDate, Float principal, + Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) { Float totalInterest = 0.0f; Float interestEarned = 0.0f; @@ -194,7 +198,7 @@ public class FixedDepositAccountHelper { principal += totalInterest; } totalInterest = 0.0f; - System.out.println(principal); + LOG.info("{}", principal.toString()); } currentDate.add(Calendar.MONTH, 1); @@ -203,21 +207,23 @@ public class FixedDepositAccountHelper { return principal; } - public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, final String validFrom, - final String validTo, final String penalInterestType, final String submittedOnDate) { + public HashMap updateFixedDepositAccount(final String clientID, final String productID, final String accountID, + final String validFrom, final String validTo, final String penalInterestType, + final String submittedOnDate) { final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate) // .build(clientID, productID, penalInterestType); - return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" - + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, + fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); } - public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, final String accountID, - final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear, - final String penalInterestType, final String interestCalculationType, final String interestCompoundingPeriodType, - final String interestPostingPeriodType) { + public HashMap updateInterestCalculationConfigForFixedDeposit(final String clientID, final String productID, + final String accountID, final String submittedOnDate, final String validFrom, final String validTo, + final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType, + final String interestCompoundingPeriodType, final String interestPostingPeriodType) { final String fixedDepositApplicationJSON = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec) // .withSubmittedOnDate(submittedOnDate) // @@ -227,75 +233,91 @@ public class FixedDepositAccountHelper { .withInterestPostingPeriodType(interestPostingPeriodType) // .build(clientID, productID, penalInterestType); - return Utils.performServerPut(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" - + Utils.TENANT_IDENTIFIER, fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + FIXED_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, + fixedDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); } public HashMap approveFixedDeposit(final Integer fixedDepositAccountID, final String approvedOnDate) { - System.out.println("--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------"); - return performFixedDepositApplicationActions(createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), + LOG.info( + "--------------------------------- APPROVING FIXED DEPOSIT APPLICATION ------------------------------------"); + return performFixedDepositApplicationActions( + createFixedDepositOperationURL(APPROVE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), getApproveFixedDepositAccountAsJSON(approvedOnDate)); } public HashMap undoApproval(final Integer fixedDepositAccountID) { - System.out.println("--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------"); + LOG.info( + "--------------------------------- UNDO APPROVING FIXED DEPOSIT APPLICATION -------------------------------"); final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; return performFixedDepositApplicationActions( - createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), undoBodyJson); + createFixedDepositOperationURL(UNDO_APPROVAL_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), + undoBodyJson); } public HashMap rejectApplication(final Integer fixedDepositAccountID, final String rejectedOnDate) { - System.out.println("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------"); - return performFixedDepositApplicationActions(createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), + LOG.info("--------------------------------- REJECT FIXED DEPOSIT APPLICATION -------------------------------"); + return performFixedDepositApplicationActions( + createFixedDepositOperationURL(REJECT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), getRejectedFixedDepositAsJSON(rejectedOnDate)); } public HashMap withdrawApplication(final Integer fixedDepositAccountID, final String withdrawApplicationOnDate) { - System.out.println("--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------"); + LOG.info( + "--------------------------------- Withdraw FIXED DEPOSIT APPLICATION -------------------------------"); return performFixedDepositApplicationActions( createFixedDepositOperationURL(WITHDRAWN_BY_CLIENT_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), getWithdrawnFixedDepositAccountAsJSON(withdrawApplicationOnDate)); } public HashMap activateFixedDeposit(final Integer fixedDepositAccountID, final String activationDate) { - System.out.println("---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------"); - return performFixedDepositApplicationActions(createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), + LOG.info( + "---------------------------------- ACTIVATING FIXED DEPOSIT APPLICATION ----------------------------------"); + return performFixedDepositApplicationActions( + createFixedDepositOperationURL(ACTIVATE_FIXED_DEPOSIT_COMMAND, fixedDepositAccountID), getActivatedFixedDepositAccountAsJSON(activationDate)); } - public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, final String jsonAttributeToGetBack) { - System.out.println("---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------"); - return Utils.performServerDelete(this.requestSpec, this.responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" - + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack); + public Object deleteFixedDepositApplication(final Integer fixedDepositAccountID, + final String jsonAttributeToGetBack) { + LOG.info( + "---------------------------------- DELETE FIXED DEPOSIT APPLICATION ----------------------------------"); + return Utils.performServerDelete(this.requestSpec, this.responseSpec, + FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, + jsonAttributeToGetBack); } public Integer calculateInterestForFixedDeposit(final Integer fixedDepositAccountId) { - System.out.println("--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------"); + LOG.info( + "--------------------------------- CALCULATING INTEREST FOR FIXED DEPOSIT --------------------------------"); return (Integer) performFixedDepositActions( createFixedDepositCalculateInterestURL(CALCULATE_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); } public Integer postInterestForFixedDeposit(final Integer fixedDepositAccountId) { - System.out.println("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------"); + LOG.info("--------------------------------- POST INTEREST FOR FIXED DEPOSIT --------------------------------"); return (Integer) performFixedDepositActions( createFixedDepositCalculateInterestURL(POST_INTEREST_FIXED_DEPOSIT_COMMAND, fixedDepositAccountId), getCalculatedInterestForFixedDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); } - public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate) { - System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------"); + public HashMap calculatePrematureAmountForFixedDeposit(final Integer fixedDepositAccountId, + final String closedOnDate) { + LOG.info("--------------------- CALCULATING PREMATURE AMOUNT FOR FIXED DEPOSIT ----------------------------"); return (HashMap) performFixedDepositActions( createFixedDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, fixedDepositAccountId), getCalculatedPrematureAmountForFixedDepositAccountAsJSON(closedOnDate), ""); } - public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, final String closureType, - final Integer toSavingsId, final String jsonAttributeToGetBack) { - System.out.println("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------"); - return performFixedDepositActions(createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId), - getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack); + public Object prematureCloseForFixedDeposit(final Integer fixedDepositAccountId, final String closedOnDate, + final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) { + LOG.info("--------------------- PREMATURE CLOSE FOR FIXED DEPOSIT ----------------------------"); + return performFixedDepositActions( + createFixedDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, fixedDepositAccountId), + getPrematureCloseForFixedDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), + jsonAttributeToGetBack); } private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) { @@ -305,7 +327,7 @@ public class FixedDepositAccountHelper { map.put("approvedOnDate", approvedOnDate); map.put("note", "Approval NOTE"); String fixedDepositAccountApproveJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountApproveJson); + LOG.info(fixedDepositAccountApproveJson); return fixedDepositAccountApproveJson; } @@ -316,7 +338,7 @@ public class FixedDepositAccountHelper { map.put("rejectedOnDate", rejectedOnDate); map.put("note", "Rejected NOTE"); String fixedDepositAccountJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountJson); + LOG.info("{}", fixedDepositAccountJson); return fixedDepositAccountJson; } @@ -327,7 +349,7 @@ public class FixedDepositAccountHelper { map.put("withdrawnOnDate", withdrawnApplicationOnDate); map.put("note", "Withdraw NOTE"); String fixedDepositAccountJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountJson); + LOG.info("{}", fixedDepositAccountJson); return fixedDepositAccountJson; } @@ -337,14 +359,14 @@ public class FixedDepositAccountHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("activatedOnDate", activationDate); String fixedDepositAccountActivateJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountActivateJson); + LOG.info("{}", fixedDepositAccountActivateJson); return fixedDepositAccountActivateJson; } private String getCalculatedInterestForFixedDepositApplicationAsJSON() { final HashMap map = new HashMap<>(); String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountCalculatedInterestJson); + LOG.info(fixedDepositAccountCalculatedInterestJson); return fixedDepositAccountCalculatedInterestJson; } @@ -354,7 +376,7 @@ public class FixedDepositAccountHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("closedOnDate", closedOnDate); String fixedDepositAccountPrematureClosureJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountPrematureClosureJson); + LOG.info(fixedDepositAccountPrematureClosureJson); return fixedDepositAccountPrematureClosureJson; } @@ -370,23 +392,26 @@ public class FixedDepositAccountHelper { map.put("transferDescription", "Transferring To Savings Account"); } String fixedDepositAccountPrematureCloseJson = new Gson().toJson(map); - System.out.println(fixedDepositAccountPrematureCloseJson); + LOG.info(fixedDepositAccountPrematureCloseJson); return fixedDepositAccountPrematureCloseJson; } private String createFixedDepositOperationURL(final String command, final Integer fixedDepositAccountID) { - return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } private Object performFixedDepositActions(final String postURLForFixedDeposit, final String jsonToBeSent, final String jsonAttributeToGetBack) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, jsonAttributeToGetBack); + return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDeposit, jsonToBeSent, + jsonAttributeToGetBack); } - private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, final String jsonToBeSent) { + private HashMap performFixedDepositApplicationActions(final String postURLForFixedDepositAction, + final String jsonToBeSent) { HashMap status = null; - final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForFixedDepositAction, jsonToBeSent, - CommonConstants.RESPONSE_CHANGES); + final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, + postURLForFixedDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES); if (response != null) { status = (HashMap) response.get("status"); } @@ -394,13 +419,15 @@ public class FixedDepositAccountHelper { } private String createFixedDepositCalculateInterestURL(final String command, final Integer fixedDepositAccountID) { - return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + return FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } - public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------"); - final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_ACCOUNT_URL + "?" - + Utils.TENANT_IDENTIFIER, ""); + public static ArrayList retrieveAllFixedDepositAccounts(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { + LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT ACCOUNTS ---------------------"); + final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, + FIXED_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER, ""); return response; } @@ -439,7 +466,8 @@ public class FixedDepositAccountHelper { return this; } - public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType, final String lockinPeriodFrequency) { + public FixedDepositAccountHelper withLockinPeriodFrequency(final String lockingPeriodFrequencyType, + final String lockinPeriodFrequency) { this.lockingPeriodFrequencyType = lockingPeriodFrequencyType; this.lockinPeriodFrequency = lockinPeriodFrequency; return this; @@ -456,7 +484,9 @@ public class FixedDepositAccountHelper { } private String getDepositAmount() { - if (this.newDepositAmount == null) { return depositAmount; } + if (this.newDepositAmount == null) { + return depositAmount; + } return this.newDepositAmount; } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountStatusChecker.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountStatusChecker.java index 0bccf3708..724a07bfa 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountStatusChecker.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositAccountStatusChecker.java @@ -25,71 +25,78 @@ import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class FixedDepositAccountStatusChecker { - + private final static Logger LOG = LoggerFactory.getLogger(FixedDepositAccountStatusChecker.class); private static final String FIXED_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/fixeddepositaccounts"; public static void verifyFixedDepositIsApproved(final HashMap fixedDepositStatusHashMap) { - System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------"); + LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS APPROVED --------------------"); assertTrue("Error in Approving Fixed deposit application", getStatus(fixedDepositStatusHashMap, "approved")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositIsPending(final HashMap fixedDepositStatusHashMap) { - System.out.println("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------"); - assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE", getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("-------------------- VERIFYING FIXED DEPOSIT APPLICATION IS PENDING --------------------"); + assertTrue("FIXED DEPOSIT ACCOUNT IS NOT IN PENDING STATE", + getStatus(fixedDepositStatusHashMap, "submittedAndPendingApproval")); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositIsActive(final HashMap fixedDepositStatusHashMap) { - System.out.println("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------"); + LOG.info("----------------- VERIFYING FIXED DEPOSIT APPLICATION IS ACTIVE -----------------"); assertTrue("ERROR IN ACTIVATING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "active")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositIsRejected(final HashMap fixedDepositStatusHashMap) { - System.out.println("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------"); - assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "rejected")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("-------------- VERIFYING FIXED DEPOSIT APPLICATION IS REJECTED ----------------"); + assertTrue("ERROR IN REJECTING THE FIXED DEPOSIT APPLICATION", + getStatus(fixedDepositStatusHashMap, "rejected")); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositIsWithdrawn(final HashMap fixedDepositStatusHashMap) { - System.out.println("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------"); - assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("---------------- VERIFYING FIXED DEPOSIT APPLICATION IS WITHDRAWN ----------------"); + assertTrue("ERROR IN WITHDRAW THE FIXED DEPOSIT APPLICATION", + getStatus(fixedDepositStatusHashMap, "withdrawnByApplicant")); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositAccountIsClosed(final HashMap fixedDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); + LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); assertTrue("ERROR IN CLOSING THE FIXED DEPOSIT APPLICATION", getStatus(fixedDepositStatusHashMap, "closed")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositAccountIsNotActive(final HashMap fixedDepositStatusHashMap) { - System.out.println("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------"); + LOG.info("------------------ VERIFYING FIXED DEPOSIT APPLICATION IS INACTIVE --------------------"); Assert.assertFalse(getStatus(fixedDepositStatusHashMap, "active")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } - public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final String fixedDepositAccountID) { - final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + "?" - + Utils.TENANT_IDENTIFIER; + public static HashMap getStatusOfFixedDepositAccount(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final String fixedDepositAccountID) { + final String GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL = FIXED_DEPOSIT_ACCOUNT_URL + "/" + fixedDepositAccountID + + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, GET_STATUS_OF_FIXED_DEPOSIT_ACCOUNT_URL, "status"); } public static void verifyFixedDepositAccountIsPrematureClosed(HashMap fixedDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); - assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "prematureClosed")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS CLOSED ---------------------"); + assertTrue("ERROR IN PREMATURELY CLOSING THE FIXED DEPOSIT ACCOUNT", + getStatus(fixedDepositStatusHashMap, "prematureClosed")); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } public static void verifyFixedDepositAccountIsMatured(HashMap fixedDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); - assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT", getStatus(fixedDepositStatusHashMap, "matured")); - System.out.println(fixedDepositStatusHashMap); + LOG.info("--------------------- VERIFYING FIXED DEPOSIT APPLICATION IS MATURED ---------------------"); + assertTrue("ERROR IN MATURITY JOB OF THE FIXED DEPOSIT ACCOUNT", + getStatus(fixedDepositStatusHashMap, "matured")); + LOG.info("{}", fixedDepositStatusHashMap.toString()); } private static boolean getStatus(final HashMap fixedDepositStatusMap, final String fixedDepositStatusString) { diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java index 3ef1462b4..61687b444 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/fixeddeposit/FixedDepositProductHelper.java @@ -28,10 +28,12 @@ import java.util.Map; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class FixedDepositProductHelper { - + private final static Logger LOG = LoggerFactory.getLogger(FixedDepositProductHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -147,7 +149,7 @@ public class FixedDepositProductHelper { } String FixedDepositProductCreateJson = new Gson().toJson(map); - System.out.println(FixedDepositProductCreateJson); + LOG.info("{}",FixedDepositProductCreateJson); return FixedDepositProductCreateJson; } @@ -421,13 +423,13 @@ public class FixedDepositProductHelper { public static Integer createFixedDepositProduct(final String fixedDepositProductCreateJson, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("--------------------- CREATING FIXED DEPOSIT PRODUCT ------------------------"); + LOG.info("--------------------- CREATING FIXED DEPOSIT PRODUCT ------------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_FIXED_DEPOSIT_PRODUCT_URL, fixedDepositProductCreateJson, CommonConstants.RESPONSE_RESOURCE_ID); } public static ArrayList retrieveAllFixedDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------"); + LOG.info("-------------------- RETRIEVING ALL FIXED DEPOSIT PRODUCTS ---------------------"); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, FIXED_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER, ""); return response; @@ -435,7 +437,7 @@ public class FixedDepositProductHelper { public static HashMap retrieveFixedDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String productId) { - System.out.println("------------------------ RETRIEVING FIXED DEPOSIT PRODUCT BY ID ------------------------"); + LOG.info("------------------------ RETRIEVING FIXED DEPOSIT PRODUCT BY ID ------------------------"); final String GET_FD_PRODUCT_BY_ID_URL = FIXED_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_FD_PRODUCT_BY_ID_URL, ""); return response; @@ -443,7 +445,7 @@ public class FixedDepositProductHelper { public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer productId) { - System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); + LOG.info("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId, "chartSlabs"); return response; diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java index d1316627a..c839d556d 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java @@ -49,9 +49,10 @@ public class LoanTransactionHelper { private final ResponseSpecification responseSpec; private final static Logger LOG = LoggerFactory.getLogger(LoanTransactionHelper.class); - private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" + Utils.TENANT_IDENTIFIER; + private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" + + Utils.TENANT_IDENTIFIER; private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER; - private static final String LOAN_ACCOUNT_URL="/fineract-provider/api/v1/loans"; + private static final String LOAN_ACCOUNT_URL = "/fineract-provider/api/v1/loans"; private static final String APPROVE_LOAN_COMMAND = "approve"; private static final String UNDO_APPROVAL_LOAN_COMMAND = "undoApproval"; private static final String DISBURSE_LOAN_COMMAND = "disburse"; @@ -75,25 +76,29 @@ public class LoanTransactionHelper { } public Integer getLoanProductId(final String loanProductJSON) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId"); + return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, + "resourceId"); } public Integer getLoanId(final String loanApplicationJSON) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId"); + return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, + "loanId"); } - public HashMap getGlimId(final String loanApplicationJSON) { + public HashMap getGlimId(final String loanApplicationJSON) { return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, ""); } public Object getGlimLoanId(final String glimId) { - final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + Utils.TENANT_IDENTIFIER; + final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/glimAccount/" + glimId + "?" + + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "childLoanId"); } public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute); + return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, + responseAttribute); } public Integer getLoanOfficerId(final String loanId) { @@ -102,66 +107,74 @@ public class LoanTransactionHelper { } public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute); + return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, + responseAttribute); } public Integer updateLoan(final Integer id, final String loanApplicationJSON) { - return Utils.performServerPut(this.requestSpec, this.responseSpec, "/fineract-provider/api/v1/loans/" + id + "?" - + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId"); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + "/fineract-provider/api/v1/loans/" + id + "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId"); } - public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer loanID) { - final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + Utils.TENANT_IDENTIFIER; + public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer loanID) { + final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); return (ArrayList) response.get("periods"); } public ArrayList getLoanCharges(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { - final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" + Utils.TENANT_IDENTIFIER; - return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges"); + final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=charges&" + + Utils.TENANT_IDENTIFIER; + return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, URL, "charges"); } - public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer loanID) { - final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule,futureSchedule&" - + Utils.TENANT_IDENTIFIER; + public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer loanID) { + final String URL = "/fineract-provider/api/v1/loans/" + loanID + + "?associations=repaymentSchedule,futureSchedule&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule"); return (ArrayList) response.get("futurePeriods"); } - public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { + public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer loanID) { final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary"); return response; } - public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID, - final String param) { + public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer loanID, final String param) { final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, URL, param); } - public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { + public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer loanID) { final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, URL, null); } public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanProductId, final String jsonAttributeToGetBack) { - final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER; + final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack); } - public String getLoanProductDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer loanProductId) { - final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER; + public String getLoanProductDetails(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer loanProductId) { + final String URL = "/fineract-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, URL, null); } public ArrayList getLoanCharges(final Integer loanId) { - final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; + final String GET_LOAN_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, ""); } @@ -179,13 +192,17 @@ public class LoanTransactionHelper { getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches)); } - public List> approveLoanForTranches(final String approvalDate, final String expectedDisbursementDate, - final String approvalAmount, final Integer loanID, List tranches, final String responseAttribute) { - return (List>) performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), - getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), responseAttribute); + public List> approveLoanForTranches(final String approvalDate, + final String expectedDisbursementDate, final String approvalAmount, final Integer loanID, + List tranches, final String responseAttribute) { + return (List>) performLoanTransaction( + createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), + getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), + responseAttribute); } - public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID, final String responseAttribute) { + public Object approveLoan(final String approvalDate, final String approvalAmount, final Integer loanID, + final String responseAttribute) { final String approvalURL = createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID); final String approvalJSONData = getApproveLoanAsJSON(approvalDate, null, approvalAmount, null); @@ -199,24 +216,29 @@ public class LoanTransactionHelper { } public HashMap disburseLoan(final String date, final Integer loanID) { - return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null)); + return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), + getDisburseLoanAsJSON(date, null)); } - public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, String adjustRepaymentDate) { - return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanWithRepaymentRescheduleAsJSON(date, - null, adjustRepaymentDate)); + public HashMap disburseLoanWithRepaymentReschedule(final String date, final Integer loanID, + String adjustRepaymentDate) { + return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), + getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate)); } public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) { - return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, disburseAmt)); + return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), + getDisburseLoanAsJSON(date, disburseAmt)); } public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError) { - return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null), responseValidationError); + return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), + getDisburseLoanAsJSON(date, null), responseValidationError); } public HashMap disburseLoanToSavings(final String date, final Integer loanID) { - return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date, null)); + return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), + getDisburseLoanAsJSON(date, null)); } public HashMap undoDisbursal(final Integer loanID) { @@ -231,14 +253,15 @@ public class LoanTransactionHelper { final String undoLastDisburseJson = "{'note' : 'UNDO LAST DISBURSAL'}"; final String url = createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID); LOG.info("IN UNDO LAST DISBURSE LOAN URL : {} ", url); - return performUndoLastLoanDisbursementTransaction(createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID), undoLastDisburseJson); + return performUndoLastLoanDisbursementTransaction( + createLoanOperationURL(UNDO_LAST_DISBURSE_LOAN_COMMAND, loanID), undoLastDisburseJson); } - //glimtesting + + // glimtesting public HashMap approveGlimAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final List> approvalFormData, final Integer glimID) { + final List> approvalFormData, final Integer glimID) { String approvalForm = new LoanApplicationTestBuilder() // - .withApprovalFormData(approvalFormData) - .build(); + .withApprovalFormData(approvalFormData).build(); final String approvalURL = createGlimAccountURL(APPROVE_LOAN_COMMAND, glimID); return performLoanTransaction(approvalURL, approvalForm); @@ -262,8 +285,8 @@ public class LoanTransactionHelper { } public HashMap rejectGlimAccount(final String date, final Integer glimID) { - LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------"); - return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date)); + LOG.info("--------------------------------- REJECT GLIM APPLICATION -------------------------------"); + return performLoanTransaction(createGlimAccountURL(REJECT_LOAN_COMMAND, glimID), getRejectAsJSON(date)); } public void recoverFromGuarantor(final Integer loanID) { @@ -271,16 +294,20 @@ public class LoanTransactionHelper { } public HashMap writeOffLoan(final String date, final Integer loanID) { - return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date)); + return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), + getWriteOffBodyAsJSON(date)); } public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) { - return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived)); + return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), + getWaiveBodyAsJSON(date, amountToBeWaived)); } - public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, final Integer loanID) { + public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, + final Integer loanID) { Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec, - createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId"); + createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), + "resourceId"); return resourceId; } @@ -301,13 +328,16 @@ public class LoanTransactionHelper { public Integer addChargesForLoan(final Integer loanId, final String request) { LOG.info("--------------------------------- ADD CHARGES FOR LOAN --------------------------------"); - final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; + final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, ""); return (Integer) response.get("resourceId"); } - public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request, final ResponseSpecification responseSpecification) { - final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER; + public Object addChargesForAllreadyDisursedLoan(final Integer loanId, final String request, + final ResponseSpecification responseSpecification) { + final String ADD_CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges?" + + Utils.TENANT_IDENTIFIER; return Utils.performServerPost(this.requestSpec, responseSpecification, ADD_CHARGES_URL, request, ""); } @@ -329,16 +359,16 @@ public class LoanTransactionHelper { public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=waive&" - + Utils.TENANT_IDENTIFIER; + final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + + "?command=waive&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); return (Integer) response.get("resourceId"); } public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) { LOG.info("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------"); - final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=pay&" - + Utils.TENANT_IDENTIFIER; + final String CHARGES_URL = "/fineract-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + + "?command=pay&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, ""); return (Integer) response.get("resourceId"); } @@ -356,7 +386,8 @@ public class LoanTransactionHelper { return new Gson().toJson(map); } - private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, final String transactionAmount, final String adjustRepaymentDate) { + private String getDisburseLoanWithRepaymentRescheduleAsJSON(final String actualDisbursementDate, + final String transactionAmount, final String adjustRepaymentDate) { final HashMap map = new HashMap<>(); map.put("locale", "en"); map.put("dateFormat", "dd MMMM yyyy"); @@ -374,8 +405,8 @@ public class LoanTransactionHelper { return getApproveLoanAsJSON(approvalDate, null, null, null); } - private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, final String approvalAmount, - List tranches) { + private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, + final String approvalAmount, List tranches) { final HashMap map = new HashMap<>(); map.put("locale", "en"); map.put("dateFormat", "dd MMMM yyyy"); @@ -426,7 +457,7 @@ public class LoanTransactionHelper { map.put("transactionDate", transactionDate); map.put("note", "Foreclosure Made!!!"); String json = new Gson().toJson(map); - LOG.info(json); + LOG.info("{}", json); return json; } @@ -463,7 +494,8 @@ public class LoanTransactionHelper { return getSpecifiedDueDateChargesForLoanAsJSON(chargeId, "12 January 2013", "100"); } - public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, final String amount) { + public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, + final String amount) { final HashMap map = new HashMap<>(); map.put("locale", "en_GB"); map.put("dateFormat", "dd MMMM yyyy"); @@ -471,7 +503,7 @@ public class LoanTransactionHelper { map.put("dueDate", dueDate); map.put("chargeId", chargeId); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -486,7 +518,7 @@ public class LoanTransactionHelper { map.put("amount", amount); map.put("chargeId", chargeId); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -497,7 +529,7 @@ public class LoanTransactionHelper { map.put("amount", amount); map.put("chargeId", chargeId); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -507,7 +539,7 @@ public class LoanTransactionHelper { map.put("dateFormat", "dd MMMM yyyy"); map.put("amount", amount); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -520,7 +552,7 @@ public class LoanTransactionHelper { map.put("installmentNumber", installmentNumber); } String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -529,7 +561,7 @@ public class LoanTransactionHelper { map.put("locale", "en_GB"); map.put("installmentNumber", installmentNumber); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -559,44 +591,53 @@ public class LoanTransactionHelper { } private String createLoanTransactionURL(final String command, final Integer loanID) { - return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + return "/fineract-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } private String createGlimAccountURL(final String command, final Integer glimID) { - return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + return "/fineract-provider/api/v1/loans/glimAccount/" + glimID + "?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) { - final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, - "changes"); + final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, + jsonToBeSent, "changes"); return (HashMap) response.get("status"); } - private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) { + private Float performUndoLastLoanDisbursementTransaction(final String postURLForLoanTransaction, + final String jsonToBeSent) { - final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, - "changes"); + final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, + jsonToBeSent, "changes"); return (Float) response.get("disbursedAmount"); } - private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) { - return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute); + private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, + final String responseAttribute) { + return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, + responseAttribute); } - private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, ResponseSpecification responseValidationError) { + private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, + ResponseSpecification responseValidationError) { - return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, jsonToBeSent, CommonConstants.RESPONSE_ERROR); - } + return Utils.performServerPost(this.requestSpec, responseValidationError, postURLForLoanTransaction, + jsonToBeSent, CommonConstants.RESPONSE_ERROR); + } public Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date, final String transactionAmount, final String responseAttribute) { - return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), responseAttribute); + return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), + responseAttribute); } private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent, final String responseAttribute) { - final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" + Utils.TENANT_IDENTIFIER; + final String URL = "/fineract-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" + + Utils.TENANT_IDENTIFIER; return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute); } @@ -607,11 +648,12 @@ public class LoanTransactionHelper { map.put("transactionDate", date); map.put("transactionAmount", transactionAmount); String json = new Gson().toJson(map); - LOG.info(json); + LOG.info("{}", json); return json; } - public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) { + public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer loanID) { final String URL = "/fineract-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, ""); @@ -622,17 +664,20 @@ public class LoanTransactionHelper { return "/fineract-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default"; } - public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) { + public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, + final Integer loanID) { LOG.info("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------"); - final ArrayList repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); - assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, repaymentPeriods.get(repaymentNumber) - .get("principalLoanBalanceOutstanding")); + final ArrayList repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, + loanID); + assertEquals("Mismatch in Principal Loan Balance Outstanding ", expectedPrincipalOutstanding, + repaymentPeriods.get(repaymentNumber).get("principalLoanBalanceOutstanding")); } - public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, final Float feePortion, - final Float penaltyPortion, final Integer loanID) { + public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, + final Float feePortion, final Float penaltyPortion, final Integer loanID) { - ArrayList transactions = (ArrayList) getLoanDetail(this.requestSpec, this.responseSpec, loanID, "transactions"); + ArrayList transactions = (ArrayList) getLoanDetail(this.requestSpec, this.responseSpec, + loanID, "transactions"); boolean isTransactionFound = false; for (int i = 0; i < transactions.size(); i++) { HashMap transactionType = (HashMap) transactions.get(i).get("type"); @@ -640,8 +685,8 @@ public class LoanTransactionHelper { if (isAccrualTransaction) { ArrayList accrualEntryDateAsArray = (ArrayList) transactions.get(i).get("date"); - LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1), - accrualEntryDateAsArray.get(2)); + LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), + accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2)); if (transactionDate.equals(accrualEntryDate)) { isTransactionFound = true; @@ -664,10 +709,10 @@ public class LoanTransactionHelper { getRefundByCashBodyAsJSON(date, amountToBeRefunded)); } - public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId, - final Integer fromClientId, final String date, final Float amountToBeRefunded) { - return performLoanTransaction(createLoanRefundTransferURL(), - getRefundByTransferBodyAsJSON(fromAccountId, toClientId, toAccountId, fromClientId, date, amountToBeRefunded)); + public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, + final Integer toAccountId, final Integer fromClientId, final String date, final Float amountToBeRefunded) { + return performLoanTransaction(createLoanRefundTransferURL(), getRefundByTransferBodyAsJSON(fromAccountId, + toClientId, toAccountId, fromClientId, date, amountToBeRefunded)); } private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) { @@ -680,8 +725,9 @@ public class LoanTransactionHelper { return new Gson().toJson(map); } - private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId, - final Integer fromClientId, final String transactionDate, final Float transactionAmount) { + private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, + final Integer toAccountId, final Integer fromClientId, final String transactionDate, + final Float transactionAmount) { final HashMap map = new HashMap<>(); map.put("fromAccountId", fromAccountId.toString()); map.put("fromAccountType", "1"); @@ -701,7 +747,7 @@ public class LoanTransactionHelper { public HashMap createTrancheDetail(final String id, final String date, final String amount) { HashMap detail = new HashMap<>(); - if(id != null){ + if (id != null) { detail.put("id", id); } detail.put("expectedDisbursementDate", date); @@ -710,26 +756,34 @@ public class LoanTransactionHelper { return detail; } - public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount, final String expectedDisbursementDate, - final String updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) { + public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, + final String approvalAmount, final String expectedDisbursementDate, + final String updatedExpectedDisbursementDate, final String updatedPrincipal, + final String jsonAttributeToGetBack) { - return Utils.performServerPut(this.requestSpec, this.responseSpec, createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, - updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, + expectedDisbursementDate, updatedExpectedDisbursementDate, updatedPrincipal), + jsonAttributeToGetBack); } - public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate - , List disbursementData, final String jsonAttributeToGetBack) { + public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, + final String expectedDisbursementDate, List disbursementData, + final String jsonAttributeToGetBack) { return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID), - getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), jsonAttributeToGetBack); + getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), + jsonAttributeToGetBack); } private String createEditDisbursementURL(Integer loanID, Integer disbursementId) { - return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + Utils.TENANT_IDENTIFIER; + return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + + Utils.TENANT_IDENTIFIER; } private String createAddAndDeleteDisbursementURL(Integer loanID) { - return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + Utils.TENANT_IDENTIFIER; + return "/fineract-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + + Utils.TENANT_IDENTIFIER; } public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, @@ -742,12 +796,12 @@ public class LoanTransactionHelper { map.put("updatedExpectedDisbursementDate", updatedExpectedDisbursementDate); map.put("updatedPrincipal", updatedPrincipal); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } - public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate, - final List disbursementData) { + public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, + final String expectedDisbursementDate, final List disbursementData) { final HashMap map = new HashMap<>(); map.put("locale", "en"); map.put("dateFormat", "dd MMMM yyyy"); @@ -755,7 +809,7 @@ public class LoanTransactionHelper { map.put("expectedDisbursementDate", expectedDisbursementDate); map.put("disbursementData", disbursementData); String json = new Gson().toJson(map); - LOG.info("{}",json); + LOG.info("{}", json); return json; } @@ -776,27 +830,29 @@ public class LoanTransactionHelper { } public Workbook getLoanWorkbook(String dateFormat) throws IOException { - requestSpec.header(HttpHeaders.CONTENT_TYPE,"application/vnd.ms-excel"); - byte[] byteArray=Utils.performGetBinaryResponse(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/downloadtemplate"+"?"+ - Utils.TENANT_IDENTIFIER+"&dateFormat="+dateFormat); - InputStream inputStream= new ByteArrayInputStream(byteArray); - Workbook workbook=new HSSFWorkbook(inputStream); + requestSpec.header(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel"); + byte[] byteArray = Utils.performGetBinaryResponse(requestSpec, responseSpec, + LOAN_ACCOUNT_URL + "/downloadtemplate" + "?" + Utils.TENANT_IDENTIFIER + "&dateFormat=" + dateFormat); + InputStream inputStream = new ByteArrayInputStream(byteArray); + Workbook workbook = new HSSFWorkbook(inputStream); return workbook; } public String importLoanTemplate(File file) { - String locale="en"; - String dateFormat="dd MMMM yyyy"; - String legalFormType= null; + String locale = "en"; + String dateFormat = "dd MMMM yyyy"; + String legalFormType = null; requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA); - return Utils.performServerTemplatePost(requestSpec,responseSpec,LOAN_ACCOUNT_URL+"/uploadtemplate"+"?"+Utils.TENANT_IDENTIFIER, - legalFormType,file,locale,dateFormat); + return Utils.performServerTemplatePost(requestSpec, responseSpec, + LOAN_ACCOUNT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER, legalFormType, file, locale, + dateFormat); } - public String getOutputTemplateLocation(final String importDocumentId){ - requestSpec.header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_PLAIN); - return Utils.performServerOutputTemplateLocationGet(requestSpec,responseSpec,"/fineract-provider/api/v1/imports/getOutputTemplateLocation"+"?" - +Utils.TENANT_IDENTIFIER,importDocumentId); + public String getOutputTemplateLocation(final String importDocumentId) { + requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN); + return Utils.performServerOutputTemplateLocationGet(requestSpec, responseSpec, + "/fineract-provider/api/v1/imports/getOutputTemplateLocation" + "?" + Utils.TENANT_IDENTIFIER, + importDocumentId); } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CampaignsHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CampaignsHelper.java index 90d798b22..1118a999f 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CampaignsHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CampaignsHelper.java @@ -33,10 +33,12 @@ import java.util.List; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.report.ReportData; import org.joda.time.LocalDateTime; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.Assert; public class CampaignsHelper { - + private final static Logger LOG = LoggerFactory.getLogger(CampaignsHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -52,51 +54,58 @@ public class CampaignsHelper { } public Integer createCampaign(String reportName, Integer triggerType) { - System.out.println("---------------------------------CREATING A CAMPAIGN---------------------------------------------"); + LOG.info("---------------------------------CREATING A CAMPAIGN---------------------------------------------"); final String CREATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, getCreateCampaignJSON(reportName, triggerType), - "resourceId"); + return Utils.performServerPost(requestSpec, responseSpec, CREATE_SMS_CAMPAIGNS_URL, + getCreateCampaignJSON(reportName, triggerType), "resourceId"); } - public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer generatedCampaignId) { - System.out.println("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n"); - final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; - final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL, "id"); + public void verifyCampaignCreatedOnServer(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer generatedCampaignId) { + LOG.info("------------------------------CHECK CAMPAIGN DETAILS------------------------------------\n"); + final String RETRIEVE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + + Utils.TENANT_IDENTIFIER; + final Integer responseCampaignId = Utils.performServerGet(requestSpec, responseSpec, RETRIEVE_SMS_CAMPAIGNS_URL, + "id"); assertEquals("ERROR IN CREATING THE CAMPAIGN", generatedCampaignId, responseCampaignId); } public Integer updateCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedCampaignId, String reportName, Integer triggerType) { - System.out.println("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n"); - final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; - return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, getUpdateCampaignJSON(reportName, triggerType), - "resourceId"); + LOG.info("------------------------------UPDATE CAMPAIGN DETAILS------------------------------------\n"); + final String UPDATE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + + Utils.TENANT_IDENTIFIER; + return Utils.performServerPut(requestSpec, responseSpec, UPDATE_SMS_CAMPAIGNS_URL, + getUpdateCampaignJSON(reportName, triggerType), "resourceId"); } public Integer deleteCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer generatedCampaignId) { - System.out.println("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n"); - final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + Utils.TENANT_IDENTIFIER; + LOG.info("------------------------------DELETE CAMPAIGN DETAILS------------------------------------\n"); + final String DELETE_SMS_CAMPAIGNS_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?" + + Utils.TENANT_IDENTIFIER; return Utils.performServerDelete(requestSpec, responseSpec, DELETE_SMS_CAMPAIGNS_URL, "resourceId"); } - public Integer performActionsOnCampaign(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer generatedCampaignId, String command) { - System.out.println("------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n"); - final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&" - + Utils.TENANT_IDENTIFIER; + public Integer performActionsOnCampaign(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer generatedCampaignId, String command) { + LOG.info( + "------------------------------PERFORM ACTION ON CAMPAIGN DETAILS------------------------------------\n"); + final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + + "&" + Utils.TENANT_IDENTIFIER; String actionDate = Utils.getLocalDateOfTenant().toString(DATE_FORMAT); - return Utils - .performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate), "resourceId"); + return Utils.performServerPost(requestSpec, responseSpec, SMS_CAMPAIGNS_ACTION_URL, + getJSONForCampaignAction(command, actionDate), "resourceId"); } - public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, String actionDate, String responseJsonAttribute) { - System.out.println("--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n"); - final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + "&" - + Utils.TENANT_IDENTIFIER; - return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL, getJSONForCampaignAction(command, actionDate), - responseJsonAttribute); + public Object performActionsOnCampaignWithFailure(final Integer generatedCampaignId, String command, + String actionDate, String responseJsonAttribute) { + LOG.info( + "--------------------------PERFORM ACTION ON CAMPAIGN DETAILS WITH FAILURE-------------------------------\n"); + final String SMS_CAMPAIGNS_ACTION_URL = SMS_CAMPAIGNS_URL + "/" + generatedCampaignId + "?command=" + command + + "&" + Utils.TENANT_IDENTIFIER; + return Utils.performServerPost(this.requestSpec, this.responseSpec, SMS_CAMPAIGNS_ACTION_URL, + getJSONForCampaignAction(command, actionDate), responseJsonAttribute); } public String getCreateCampaignJSON(String reportName, Integer triggerType) { @@ -122,7 +131,7 @@ public class CampaignsHelper { paramValueMap.put("reportName", reportName); map.put("paramValue", paramValueMap); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -147,7 +156,7 @@ public class CampaignsHelper { paramValueMap.put("reportName", reportName); map.put("paramValue", paramValueMap); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -158,7 +167,7 @@ public class CampaignsHelper { map.put("locale", "en"); map.put("dateFormat", DATE_FORMAT); String json = new Gson().toJson(map); - System.out.println(json); + LOG.info("{}", json); return json; } @@ -167,17 +176,18 @@ public class CampaignsHelper { } private ArrayList getReports(String jsonAttributeToGetBack) { - System.out.println("--------------------------------- GET REPORTS OPTIONS -------------------------------"); + LOG.info("--------------------------------- GET REPORTS OPTIONS -------------------------------"); Assert.notNull(jsonAttributeToGetBack, "jsonAttributeToGetBack may not be null"); final String templateUrl = SMS_CAMPAIGNS_URL + "/template?" + Utils.TENANT_IDENTIFIER; - final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(templateUrl).andReturn() - .asString(); + final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when() + .get(templateUrl).andReturn().asString(); Assert.notNull(json, "json"); ArrayList reportsList = new ArrayList<>(); String reportsString = new Gson().toJson(from(json).get(jsonAttributeToGetBack)); Assert.notNull(reportsString, "reportsString"); final Gson gson = new Gson(); - final Type typeOfHashMap = new TypeToken>() {}.getType(); + final Type typeOfHashMap = new TypeToken>() { + }.getType(); reportsList = gson.fromJson(reportsString, typeOfHashMap); return reportsList; } @@ -187,7 +197,9 @@ public class CampaignsHelper { if (reports != null && !reports.isEmpty()) { for (ReportData reportData : reports) { - if (reportName.equals(reportData.getReportName())) { return reportData.getReportId(); } + if (reportName.equals(reportData.getReportName())) { + return reportData.getReportId(); + } } } Assert.notNull(null, "null"); diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CurrencyHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CurrencyHelper.java index 072fba2c3..38df9a0a2 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CurrencyHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/CurrencyHelper.java @@ -31,10 +31,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.Assert; public class CurrencyHelper { - + private final static Logger LOG = LoggerFactory.getLogger(CurrencyHelper.class); private static final String CURRENCY_URL = "/fineract-provider/api/v1/currencies?" + Utils.TENANT_IDENTIFIER; private static final String CURRENCY_URL_SELECTED = CURRENCY_URL + "&fields=selectedCurrencyOptions"; @@ -59,19 +61,19 @@ public class CurrencyHelper { return getCurrencies(CURRENCY_URL_SELECTED, permittedCurrencyArraySelected); } - private ArrayList getCurrencies(final String getUrl, final List permittedCurrencyArrays) { - System.out.println("--------------------------------- GET CURRENCY OPTIONS -------------------------------"); - final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when() - .get(getUrl).andReturn().asString(); + LOG.info("--------------------------------- GET CURRENCY OPTIONS -------------------------------"); + final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getUrl) + .andReturn().asString(); final Gson gson = new Gson(); Assert.notNull(json, "json"); final ArrayList currencyList = new ArrayList(); - final Type typeOfHashMap = new TypeToken>>() { }.getType(); + final Type typeOfHashMap = new TypeToken>>() { + }.getType(); final Map> responseMap = gson.fromJson(json, typeOfHashMap); - for(Map.Entry> entry : responseMap.entrySet()) { + for (Map.Entry> entry : responseMap.entrySet()) { Assert.isTrue(permittedCurrencyArrays.contains(entry.getKey()), "permittedCurrencyArrays"); - for(Currency currency : entry.getValue()) { + for (Currency currency : entry.getValue()) { currencyList.add(currency); } } @@ -79,13 +81,14 @@ public class CurrencyHelper { } public List updateCurrencies(final List currencies) { - System.out.println("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------"); - final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log().ifError().when() - .put(CURRENCY_URL).andReturn().asString(); + LOG.info("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------"); + final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log() + .ifError().when().put(CURRENCY_URL).andReturn().asString(); final Gson gson = new Gson(); Assert.notNull(json, "json"); - final Type typeOfHashMap = new TypeToken>>>() { }.getType(); - final Map>> responseMap = gson.fromJson(json, typeOfHashMap); + final Type typeOfHashMap = new TypeToken>>>() { + }.getType(); + final Map>> responseMap = gson.fromJson(json, typeOfHashMap); return responseMap.get("changes").get("currencies"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java index 14e4ebd21..daebf48fe 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java @@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class EntityDatatableChecksHelper { - + private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -59,7 +61,7 @@ public class EntityDatatableChecksHelper { map.put("productId", productId); } String requestJsonString = new Gson().toJson(map); - System.out.println("map : " + requestJsonString); + LOG.info("map : {}" , requestJsonString); return requestJsonString; } 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 2b4a4bc65..977f6dbaa 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 @@ -42,6 +42,8 @@ import org.apache.fineract.integrationtests.common.system.DatatableHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Entity Datatable Checks Integration Test for checking Creation, Deletion and @@ -49,7 +51,7 @@ import org.junit.Test; */ public class EntityDatatableChecksIntegrationTest { - + private final static Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksIntegrationTest.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; private EntityDatatableChecksHelper entityDatatableChecksHelper; @@ -407,7 +409,7 @@ public class EntityDatatableChecksIntegrationTest { private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance, String enforceMinRequiredBalance, final boolean allowOverdraft, final String taxGroupId, boolean withDormancy) { - System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------"); SavingsProductHelper savingsProductHelper = new SavingsProductHelper(); if (allowOverdraft) { final String overDraftLimit = "2000.0"; @@ -433,7 +435,7 @@ public class EntityDatatableChecksIntegrationTest { } private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("10000000.00") // .withNumberOfRepayments("24") // @@ -450,7 +452,7 @@ public class EntityDatatableChecksIntegrationTest { private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment, final String registeredTableName) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000000.00") // .withLoanTermFrequency("24") // @@ -471,7 +473,7 @@ public class EntityDatatableChecksIntegrationTest { private Object applyForLoanApplicationWithError(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment, final String responseAttribute) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000000.00") // .withLoanTermFrequency("24") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java index df5da6a30..399c7ac8f 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java @@ -26,9 +26,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class StaffHelper { - + private final static Logger LOG = LoggerFactory.getLogger(StaffHelper.class); private static final String TRANSFER_STAFF_URL = "/fineract-provider/api/v1/groups"; private static final String CREATE_STAFF_URL = "/fineract-provider/api/v1/staff"; @@ -46,7 +48,7 @@ public class StaffHelper { final HashMap map = new HashMap<>(); map.put("staffId", staffToTransferId); map.put("note", note); - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -97,7 +99,7 @@ public class StaffHelper { map.put("locale", "en"); map.put("dateFormat", "dd MMMM yyyy"); map.put("joiningDate", "20 September 2011") ; - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } @@ -119,7 +121,7 @@ public class StaffHelper { if(fieldList.contains("mobileNo")) { map.put("mobileNo", "+123515198"); } - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java index 59cacff87..bdcff1399 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountHelper.java @@ -29,20 +29,24 @@ import java.util.HashMap; import java.util.Locale; import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class RecurringDepositAccountHelper { - + private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositAccountHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; - public RecurringDepositAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { + public RecurringDepositAccountHelper(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec) { this.requestSpec = requestSpec; this.responseSpec = responseSpec; } private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts"; - private static final String APPLY_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER; + private static final String APPLY_RECURRING_DEPOSIT_ACCOUNT_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "?" + + Utils.TENANT_IDENTIFIER; private static final String APPROVE_RECURRING_DEPOSIT_COMMAND = "approve"; private static final String UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND = "undoapproval"; private static final String REJECT_RECURRING_DEPOSIT_COMMAND = "reject"; @@ -140,21 +144,22 @@ public class RecurringDepositAccountHelper { map.put("isCalendarInherited", this.isCalendarInherited); String recurringDepositAccountJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountJson); + LOG.info("{}", recurringDepositAccountJson); return recurringDepositAccountJson; } public static Integer applyRecurringDepositApplication(final String recurringDepositAccountAsJson, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------"); - return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL, recurringDepositAccountAsJson, - CommonConstants.RESPONSE_RESOURCE_ID); + LOG.info("--------------------- APPLYING FOR RECURRING DEPOSIT ACCOUNT ------------------------"); + return Utils.performServerPost(requestSpec, responseSpec, APPLY_RECURRING_DEPOSIT_ACCOUNT_URL, + recurringDepositAccountAsJson, CommonConstants.RESPONSE_RESOURCE_ID); } - public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer accountID) { - final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER; - System.out.println("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------"); + public static HashMap getRecurringDepositAccountById(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer accountID) { + final String GET_RECURRING_DEPOSIT_BY_ID_URL = RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + + Utils.TENANT_IDENTIFIER; + LOG.info("------------------------ RETRIEVING RECURRING DEPOSIT ACCOUNT BY ID -------------------------"); return Utils.performServerGet(requestSpec, responseSpec, GET_RECURRING_DEPOSIT_BY_ID_URL, ""); } @@ -202,7 +207,7 @@ public class RecurringDepositAccountHelper { principal += totalInterest; } totalInterest = 0.0f; - System.out.println(principal); + LOG.info("{}", principal.toString()); } currentDate.add(Calendar.MONTH, 1); @@ -212,7 +217,8 @@ public class RecurringDepositAccountHelper { } public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID, - final String validFrom, final String validTo, final String penalInterestType, final String submittedOnDate) { + final String validFrom, final String validTo, final String penalInterestType, + final String submittedOnDate) { DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US); Calendar todaysDate = Calendar.getInstance(); @@ -220,128 +226,155 @@ public class RecurringDepositAccountHelper { todaysDate.add(Calendar.DATE, -1); final String SUBMITTED_ON_DATE = dateFormat.format(todaysDate.getTime()); final String EXPECTED_FIRST_DEPOSIT_ON_ON_DATE = SUBMITTED_ON_DATE; - final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) - .withSubmittedOnDate(SUBMITTED_ON_DATE).withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE) - .build(clientID, productID, penalInterestType); + final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, + this.responseSpec).withSubmittedOnDate(SUBMITTED_ON_DATE) + .withExpectedFirstDepositOnDate(EXPECTED_FIRST_DEPOSIT_ON_ON_DATE) + .build(clientID, productID, penalInterestType); - return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" - + Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, + recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); } public HashMap updateInterestCalculationConfigForRecurringDeposit(final String clientID, final String productID, final String accountID, final String submittedOnDate, final String validFrom, final String validTo, final String numberOfDaysPerYear, final String penalInterestType, final String interestCalculationType, - final String interestCompoundingPeriodType, final String interestPostingPeriodType, final String expectedFirstDepositOnDate) { + final String interestCompoundingPeriodType, final String interestPostingPeriodType, + final String expectedFirstDepositOnDate) { - final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, this.responseSpec) // - .withSubmittedOnDate(submittedOnDate) // - .withNumberOfDaysPerYear(numberOfDaysPerYear) // - .withInterestCalculationPeriodType(interestCalculationType) // - .withInterestCompoundingPeriodType(interestCompoundingPeriodType) // - .withInterestPostingPeriodType(interestPostingPeriodType) // - .withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) // - .build(clientID, productID, penalInterestType); + final String recurringDepositApplicationJSON = new RecurringDepositAccountHelper(this.requestSpec, + this.responseSpec) // + .withSubmittedOnDate(submittedOnDate) // + .withNumberOfDaysPerYear(numberOfDaysPerYear) // + .withInterestCalculationPeriodType(interestCalculationType) // + .withInterestCompoundingPeriodType(interestCompoundingPeriodType) // + .withInterestPostingPeriodType(interestPostingPeriodType) // + .withExpectedFirstDepositOnDate(expectedFirstDepositOnDate) // + .build(clientID, productID, penalInterestType); - return Utils.performServerPut(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" - + Utils.TENANT_IDENTIFIER, recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); + return Utils.performServerPut(this.requestSpec, this.responseSpec, + RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "?" + Utils.TENANT_IDENTIFIER, + recurringDepositApplicationJSON, CommonConstants.RESPONSE_CHANGES); } - public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate, - final Float transactionAmount) { - System.out.println("--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------"); - return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID - + "/transactions/" + transactionId + "?command=" + MODIFY_TRANSACTION_COMMAND, + public Integer updateTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, + final String transactionDate, final Float transactionAmount) { + LOG.info( + "--------------------------------- UPDATE RECURRING DEPOSIT TRANSACTION ------------------------------------"); + return Utils.performServerPost(this.requestSpec, this.responseSpec, + RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "/transactions/" + transactionId + "?command=" + + MODIFY_TRANSACTION_COMMAND, getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID); } - public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, final String transactionDate, - final Float transactionAmount) { - System.out.println("--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------"); - return Utils.performServerPost(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID - + "/transactions/" + transactionId + "?command=" + UNDO_TRANSACTION_COMMAND, + public Integer undoTransactionForRecurringDeposit(final Integer accountID, final Integer transactionId, + final String transactionDate, final Float transactionAmount) { + LOG.info( + "--------------------------------- UNDO RECURRING DEPOSIT TRANSACTION ------------------------------------"); + return Utils.performServerPost(this.requestSpec, this.responseSpec, + RECURRING_DEPOSIT_ACCOUNT_URL + "/" + accountID + "/transactions/" + transactionId + "?command=" + + UNDO_TRANSACTION_COMMAND, getUpdateTransactionAsJSON(transactionDate, transactionAmount), CommonConstants.RESPONSE_RESOURCE_ID); } public HashMap approveRecurringDeposit(final Integer recurringDepositAccountID, final String approvedOnDate) { - System.out - .println("--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------"); + LOG.info( + "--------------------------------- APPROVING RECURRING DEPOSIT APPLICATION ------------------------------------"); return performRecurringDepositApplicationActions( createRecurringDepositOperationURL(APPROVE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), getApproveRecurringDepositAccountAsJSON(approvedOnDate)); } public HashMap undoApproval(final Integer recurringDepositAccountID) { - System.out - .println("--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------"); + LOG.info( + "--------------------------------- UNDO APPROVING RECURRING DEPOSIT APPLICATION -------------------------------"); final String undoBodyJson = "{'note':'UNDO APPROVAL'}"; return performRecurringDepositApplicationActions( - createRecurringDepositOperationURL(UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), undoBodyJson); + createRecurringDepositOperationURL(UNDO_APPROVAL_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), + undoBodyJson); } public HashMap rejectApplication(final Integer recurringDepositAccountID, final String rejectedOnDate) { - System.out.println("--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------"); + LOG.info( + "--------------------------------- REJECT RECURRING DEPOSIT APPLICATION -------------------------------"); return performRecurringDepositApplicationActions( createRecurringDepositOperationURL(REJECT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), getRejectedRecurringDepositAsJSON(rejectedOnDate)); } - public HashMap withdrawApplication(final Integer recurringDepositAccountID, final String withdrawApplicationOnDate) { - System.out.println("--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------"); + public HashMap withdrawApplication(final Integer recurringDepositAccountID, + final String withdrawApplicationOnDate) { + LOG.info( + "--------------------------------- WITHDRAW RECURRING DEPOSIT APPLICATION -------------------------------"); return performRecurringDepositApplicationActions( - createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), + createRecurringDepositOperationURL(WITHDRAWN_BY_CLIENT_RECURRING_DEPOSIT_COMMAND, + recurringDepositAccountID), getWithdrawnRecurringDepositAccountAsJSON(withdrawApplicationOnDate)); } public HashMap activateRecurringDeposit(final Integer recurringDepositAccountID, final String activationDate) { - System.out - .println("---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------"); + LOG.info( + "---------------------------------- ACTIVATING RECURRING DEPOSIT APPLICATION ----------------------------------"); return performRecurringDepositApplicationActions( createRecurringDepositOperationURL(ACTIVATE_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountID), getActivatedRecurringDepositAccountAsJSON(activationDate)); } - public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID, final String jsonAttributeToGetBack) { - System.out.println("---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------"); - return Utils.performServerDelete(this.requestSpec, this.responseSpec, RECURRING_DEPOSIT_ACCOUNT_URL + "/" - + recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetBack); + public Object deleteRecurringDepositApplication(final Integer recurringDepositAccountID, + final String jsonAttributeToGetBack) { + LOG.info( + "---------------------------------- DELETE RECURRING DEPOSIT APPLICATION ----------------------------------"); + return Utils.performServerDelete(this.requestSpec, this.responseSpec, + RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?" + Utils.TENANT_IDENTIFIER, + jsonAttributeToGetBack); } public Integer calculateInterestForRecurringDeposit(final Integer recurringDepositAccountId) { - System.out.println("--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------"); + LOG.info( + "--------------------------------- CALCULATING INTEREST FOR RECURRING DEPOSIT --------------------------------"); return (Integer) performRecurringDepositActions( - createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), + createRecurringDepositCalculateInterestURL(CALCULATE_INTEREST_RECURRING_DEPOSIT_COMMAND, + recurringDepositAccountId), getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); } public Integer postInterestForRecurringDeposit(final Integer recurringDepositAccountId) { - System.out.println("--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------"); + LOG.info( + "--------------------------------- POST INTEREST FOR RECURRING DEPOSIT --------------------------------"); return (Integer) performRecurringDepositActions( - createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), + createRecurringDepositCalculateInterestURL(POST_INTEREST_RECURRING_DEPOSIT_COMMAND, + recurringDepositAccountId), getCalculatedInterestForRecurringDepositApplicationAsJSON(), CommonConstants.RESPONSE_RESOURCE_ID); } public Integer depositToRecurringDepositAccount(final Integer recurringDepositAccountId, final Float depositAmount, final String depositedOnDate) { - System.out.println("--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------"); + LOG.info( + "--------------------------------- DEPOSIT TO RECURRING DEPOSIT ACCOUNT --------------------------------"); return (Integer) performRecurringDepositActions( createDepositToRecurringDepositURL(DEPOSIT_INTO_RECURRING_DEPOSIT_COMMAND, recurringDepositAccountId), - getDepositToRecurringDepositAccountAsJSON(depositAmount, depositedOnDate), CommonConstants.RESPONSE_RESOURCE_ID); + getDepositToRecurringDepositAccountAsJSON(depositAmount, depositedOnDate), + CommonConstants.RESPONSE_RESOURCE_ID); } - public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate) { - System.out.println("--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------"); + public HashMap calculatePrematureAmountForRecurringDeposit(final Integer recurringDepositAccountId, + final String closedOnDate) { + LOG.info( + "--------------------- CALCULATING PREMATURE AMOUNT FOR RECURRING DEPOSIT ----------------------------"); return (HashMap) performRecurringDepositActions( - createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, recurringDepositAccountId), + createRecurringDepositCalculateInterestURL(CALCULATE_PREMATURE_AMOUNT_COMMAND, + recurringDepositAccountId), getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(closedOnDate), ""); } public Object prematureCloseForRecurringDeposit(final Integer recurringDepositAccountId, final String closedOnDate, final String closureType, final Integer toSavingsId, final String jsonAttributeToGetBack) { - System.out.println("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------"); + LOG.info("--------------------- PREMATURE CLOSE FOR RECURRING DEPOSIT ----------------------------"); return performRecurringDepositActions( createRecurringDepositCalculateInterestURL(PREMATURE_CLOSE_COMMAND, recurringDepositAccountId), - getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), jsonAttributeToGetBack); + getPrematureCloseForRecurringDepositAccountAsJSON(closedOnDate, closureType, toSavingsId), + jsonAttributeToGetBack); } private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) { @@ -351,7 +384,7 @@ public class RecurringDepositAccountHelper { map.put("approvedOnDate", approvedOnDate); map.put("note", "Approval NOTE"); String recurringDepositAccountApproveJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountApproveJson); + LOG.info(recurringDepositAccountApproveJson); return recurringDepositAccountApproveJson; } @@ -362,7 +395,7 @@ public class RecurringDepositAccountHelper { map.put("transactionDate", transactionDate); map.put("transactionAmount", transactionAmount); String updateTransactionJson = new Gson().toJson(map); - System.out.println(updateTransactionJson); + LOG.info(updateTransactionJson); return updateTransactionJson; } @@ -373,7 +406,7 @@ public class RecurringDepositAccountHelper { map.put("rejectedOnDate", rejectedOnDate); map.put("note", "Rejected NOTE"); String recurringDepositAccountJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountJson); + LOG.info("{}", recurringDepositAccountJson); return recurringDepositAccountJson; } @@ -384,7 +417,7 @@ public class RecurringDepositAccountHelper { map.put("withdrawnOnDate", withdrawnApplicationOnDate); map.put("note", "Withdraw NOTE"); String recurringDepositAccountJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountJson); + LOG.info("{}", recurringDepositAccountJson); return recurringDepositAccountJson; } @@ -394,14 +427,14 @@ public class RecurringDepositAccountHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("activatedOnDate", activationDate); String recurringDepositAccountActivateJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountActivateJson); + LOG.info(recurringDepositAccountActivateJson); return recurringDepositAccountActivateJson; } private String getCalculatedInterestForRecurringDepositApplicationAsJSON() { final HashMap map = new HashMap<>(); String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountCalculatedInterestJson); + LOG.info(recurringDepositAccountCalculatedInterestJson); return recurringDepositAccountCalculatedInterestJson; } @@ -411,7 +444,7 @@ public class RecurringDepositAccountHelper { map.put("dateFormat", CommonConstants.dateFormat); map.put("closedOnDate", closedOnDate); String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountPrematureClosureJson); + LOG.info(recurringDepositAccountPrematureClosureJson); return recurringDepositAccountPrematureClosureJson; } @@ -422,12 +455,12 @@ public class RecurringDepositAccountHelper { map.put("transactionAmount", depositAmount); map.put("transactionDate", depositedOnDate); String recurringDepositAccountPrematureClosureJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountPrematureClosureJson); + LOG.info(recurringDepositAccountPrematureClosureJson); return recurringDepositAccountPrematureClosureJson; } - private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, final String closureType, - final Integer toSavingsId) { + private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, + final String closureType, final Integer toSavingsId) { final HashMap map = new HashMap<>(); map.put("locale", CommonConstants.locale); map.put("dateFormat", CommonConstants.dateFormat); @@ -438,12 +471,13 @@ public class RecurringDepositAccountHelper { map.put("transferDescription", "Transferring To Savings Account"); } String recurringDepositAccountPrematureCloseJson = new Gson().toJson(map); - System.out.println(recurringDepositAccountPrematureCloseJson); + LOG.info(recurringDepositAccountPrematureCloseJson); return recurringDepositAccountPrematureCloseJson; } private String createRecurringDepositOperationURL(final String command, final Integer recurringDepositAccountID) { - return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } private Object performRecurringDepositActions(final String postURLForRecurringDeposit, final String jsonToBeSent, @@ -452,23 +486,26 @@ public class RecurringDepositAccountHelper { jsonAttributeToGetBack); } - private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction, final String jsonToBeSent) { + private HashMap performRecurringDepositApplicationActions(final String postURLForRecurringDepositAction, + final String jsonToBeSent) { HashMap status = null; - final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForRecurringDepositAction, - jsonToBeSent, CommonConstants.RESPONSE_CHANGES); + final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, + postURLForRecurringDepositAction, jsonToBeSent, CommonConstants.RESPONSE_CHANGES); if (response != null) { status = (HashMap) response.get("status"); } return status; } - private String createRecurringDepositCalculateInterestURL(final String command, final Integer recurringDepositAccountID) { - return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER; + private String createRecurringDepositCalculateInterestURL(final String command, + final Integer recurringDepositAccountID) { + return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "?command=" + command + "&" + + Utils.TENANT_IDENTIFIER; } private String createDepositToRecurringDepositURL(final String command, final Integer recurringDepositAccountID) { - return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + "&" - + Utils.TENANT_IDENTIFIER; + return RECURRING_DEPOSIT_ACCOUNT_URL + "/" + recurringDepositAccountID + "/transactions" + "?command=" + command + + "&" + Utils.TENANT_IDENTIFIER; } public RecurringDepositAccountHelper withSubmittedOnDate(final String recurringDepositApplicationSubmittedDate) { @@ -476,7 +513,8 @@ public class RecurringDepositAccountHelper { return this; } - public RecurringDepositAccountHelper withExpectedFirstDepositOnDate(final String recurringDepositApplicationExpectedFirstDepositOnDate) { + public RecurringDepositAccountHelper withExpectedFirstDepositOnDate( + final String recurringDepositApplicationExpectedFirstDepositOnDate) { this.expectedFirstDepositOnDate = recurringDepositApplicationExpectedFirstDepositOnDate; return this; } @@ -491,7 +529,8 @@ public class RecurringDepositAccountHelper { return this; } - public RecurringDepositAccountHelper withInterestCompoundingPeriodType(final String interestCompoundingPeriodTypeId) { + public RecurringDepositAccountHelper withInterestCompoundingPeriodType( + final String interestCompoundingPeriodTypeId) { this.interestCompoundingPeriodType = interestCompoundingPeriodTypeId; return this; } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountStatusChecker.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountStatusChecker.java index 0677fb93f..ab6493ee0 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountStatusChecker.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositAccountStatusChecker.java @@ -25,53 +25,55 @@ import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class RecurringDepositAccountStatusChecker { - + private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositAccountStatusChecker.class); private static final String RECURRING_DEPOSIT_ACCOUNT_URL = "/fineract-provider/api/v1/recurringdepositaccounts"; public static void verifyRecurringDepositIsApproved(final HashMap recurringDepositStatusHashMap) { - System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS APPROVED --------------------"); + LOG.info("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS APPROVED --------------------"); assertTrue("Error in Approving Recurring deposit application", getStatus(recurringDepositStatusHashMap, "approved")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositIsPending(final HashMap recurringDepositStatusHashMap) { - System.out.println("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS PENDING --------------------"); + LOG.info("-------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS PENDING --------------------"); assertTrue("RECURRING DEPOSIT ACCOUNT IS NOT IN PENDING STATE", getStatus(recurringDepositStatusHashMap, "submittedAndPendingApproval")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositIsActive(final HashMap recurringDepositStatusHashMap) { - System.out.println("----------------- VERIFYING RECURRING DEPOSIT APPLICATION IS ACTIVE -----------------"); + LOG.info("----------------- VERIFYING RECURRING DEPOSIT APPLICATION IS ACTIVE -----------------"); assertTrue("ERROR IN ACTIVATING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "active")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositIsRejected(final HashMap recurringDepositStatusHashMap) { - System.out.println("-------------- VERIFYING RECURRING DEPOSIT APPLICATION IS REJECTED ----------------"); + LOG.info("-------------- VERIFYING RECURRING DEPOSIT APPLICATION IS REJECTED ----------------"); assertTrue("ERROR IN REJECTING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "rejected")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositIsWithdrawn(final HashMap recurringDepositStatusHashMap) { - System.out.println("---------------- VERIFYING RECURRING DEPOSIT APPLICATION IS WITHDRAWN ----------------"); + LOG.info("---------------- VERIFYING RECURRING DEPOSIT APPLICATION IS WITHDRAWN ----------------"); assertTrue("ERROR IN WITHDRAW THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "withdrawnByApplicant")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositAccountIsClosed(final HashMap recurringDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); + LOG.info("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); assertTrue("ERROR IN CLOSING THE RECURRING DEPOSIT APPLICATION", getStatus(recurringDepositStatusHashMap, "closed")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositAccountIsNotActive(final HashMap recurringDepositStatusHashMap) { - System.out.println("------------------ VERIFYING RECURRING DEPOSIT APPLICATION IS INACTIVE --------------------"); + LOG.info("------------------ VERIFYING RECURRING DEPOSIT APPLICATION IS INACTIVE --------------------"); Assert.assertFalse(getStatus(recurringDepositStatusHashMap, "active")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static HashMap getStatusOfRecurringDepositAccount(final RequestSpecification requestSpec, @@ -82,16 +84,16 @@ public class RecurringDepositAccountStatusChecker { } public static void verifyRecurringDepositAccountIsPrematureClosed(HashMap recurringDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); + LOG.info("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS CLOSED ---------------------"); assertTrue("ERROR IN PREMATURELY CLOSING THE RECURRING DEPOSIT ACCOUNT", getStatus(recurringDepositStatusHashMap, "prematureClosed")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } public static void verifyRecurringDepositAccountIsMatured(HashMap recurringDepositStatusHashMap) { - System.out.println("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS MATURED ---------------------"); + LOG.info("--------------------- VERIFYING RECURRING DEPOSIT APPLICATION IS MATURED ---------------------"); assertTrue("ERROR IN MATURITY JOB OF THE RECURRING DEPOSIT ACCOUNT", getStatus(recurringDepositStatusHashMap, "matured")); - System.out.println(recurringDepositStatusHashMap); + LOG.info("{}",recurringDepositStatusHashMap.toString()); } private static boolean getStatus(final HashMap recurringDepositStatusMap, final String recurringDepositStatusString) { diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositProductHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositProductHelper.java index 512f21ed4..b598c17f7 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositProductHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/recurringdeposit/RecurringDepositProductHelper.java @@ -27,10 +27,12 @@ import java.util.List; import java.util.Map; import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.accounting.Account; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({ "unused", "rawtypes" }) public class RecurringDepositProductHelper { - + private final static Logger LOG = LoggerFactory.getLogger(RecurringDepositProductHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -153,7 +155,7 @@ public class RecurringDepositProductHelper { } String RecurringDepositProductCreateJson = new Gson().toJson(map); - System.out.println(RecurringDepositProductCreateJson); + LOG.info("{}",RecurringDepositProductCreateJson); return RecurringDepositProductCreateJson; } @@ -226,14 +228,14 @@ public class RecurringDepositProductHelper { public static Integer createRecurringDepositProduct(final String recurrungDepositProductCreateJson, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("------------------ CREATING RECURRING DEPOSIT PRODUCT--------------------"); + LOG.info("------------------ CREATING RECURRING DEPOSIT PRODUCT--------------------"); return Utils.performServerPost(requestSpec, responseSpec, CREATE_RECURRING_DEPOSIT_PRODUCT_URL, recurrungDepositProductCreateJson, "resourceId"); } public static ArrayList retrieveAllRecurringDepositProducts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { - System.out.println("----------------- RETRIEVING ALL RECURRING DEPOSIT PRODUCTS---------------------------"); + LOG.info("----------------- RETRIEVING ALL RECURRING DEPOSIT PRODUCTS---------------------------"); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, RECURRING_DEPOSIT_PRODUCT_URL + "?" + Utils.TENANT_IDENTIFIER, ""); return response; @@ -241,7 +243,7 @@ public class RecurringDepositProductHelper { public static HashMap retrieveRecurringDepositProductById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String productId) { - System.out.println("-------------------- RETRIEVING RECURRING DEPOSIT PRODUCT BY ID --------------------------"); + LOG.info("-------------------- RETRIEVING RECURRING DEPOSIT PRODUCT BY ID --------------------------"); final String GET_RD_PRODUCT_BY_ID_URL = RECURRING_DEPOSIT_PRODUCT_URL + "/" + productId + "?" + Utils.TENANT_IDENTIFIER; final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_RD_PRODUCT_BY_ID_URL, ""); return response; @@ -249,7 +251,7 @@ public class RecurringDepositProductHelper { public static ArrayList getInterestRateChartSlabsByProductId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer productId) { - System.out.println("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); + LOG.info("-------------------- RETRIEVE INTEREST CHART BY PRODUCT ID ---------------------"); final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, INTEREST_CHART_URL + "?productId=" + productId, "chartSlabs"); return response; diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/AccountTransferHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/AccountTransferHelper.java index 3fcc9cd48..c2621f966 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/AccountTransferHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/AccountTransferHelper.java @@ -23,9 +23,11 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountTransferHelper { - + private final static Logger LOG = LoggerFactory.getLogger(AccountTransferHelper.class); private static final String ACCOUNT_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers"; private static final String LOAN_REFUND_BY_TRANSFER_URL = "/fineract-provider/api/v1/accounttransfers/refundByTransfer"; private static final String LOCALE = "en_GB"; @@ -45,8 +47,9 @@ public class AccountTransferHelper { this.responseSpec = responseSpec; } - public String build(final String fromAccountId, final String fromClientId, final String toAccountId, final String toClientId, - final String fromAccountType, final String toAccountType, final String transferAmount) { + public String build(final String fromAccountId, final String fromClientId, final String toAccountId, + final String toClientId, final String fromAccountType, final String toAccountType, + final String transferAmount) { final HashMap map = new HashMap<>(); map.put("dateFormat", "dd MMMM yyyy"); @@ -63,7 +66,7 @@ public class AccountTransferHelper { map.put("transferAmount", transferAmount); map.put("transferDescription", this.transferDescription); String savingsApplicationJSON = new Gson().toJson(map); - System.out.println(savingsApplicationJSON); + LOG.info("{}", savingsApplicationJSON); return savingsApplicationJSON; } @@ -73,24 +76,26 @@ public class AccountTransferHelper { } public Integer accountTransfer(final Integer fromClientId, final Integer fromAccountId, final Integer toClientId, - final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) { - System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------"); + final Integer toAccountId, final String fromAccountType, final String toAccountType, + final String transferAmount) { + LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------"); final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) // .withTransferOnDate(ACCOUNT_TRANSFER_DATE) // - .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType, - toAccountType, transferAmount); - return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, - accountTransferJSON, "savingsId"); + .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), + fromAccountType, toAccountType, transferAmount); + return Utils.performServerPost(this.requestSpec, this.responseSpec, + ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, accountTransferJSON, "savingsId"); } - public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, final Integer toClientId, - final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) { - System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------"); + public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, + final Integer toClientId, final Integer toAccountId, final String fromAccountType, + final String toAccountType, final String transferAmount) { + LOG.info("--------------------------------ACCOUNT TRANSFER--------------------------------"); final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) // .withTransferOnDate(date) // - .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType, - toAccountType, transferAmount); - return Utils.performServerPost(this.requestSpec, this.responseSpec, LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, - accountTransferJSON, "savingsId"); + .build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), + fromAccountType, toAccountType, transferAmount); + return Utils.performServerPost(this.requestSpec, this.responseSpec, + LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER, accountTransferJSON, "savingsId"); } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsStatusChecker.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsStatusChecker.java index 6f628142f..56e5d181a 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsStatusChecker.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/savings/SavingsStatusChecker.java @@ -24,117 +24,135 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("rawtypes") public class SavingsStatusChecker { - + private final static Logger LOG = LoggerFactory.getLogger(SavingsStatusChecker.class); private static final String SAVINGS_ACCOUNT_URL = "/fineract-provider/api/v1/savingsaccounts"; public static void verifySavingsIsApproved(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS APPROVED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS APPROVED ------------------------------------"); assertTrue("ERROR IN APPROVING SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "approved")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Status: {} \n", savingsStatusHashMap); } public static void verifySavingsIsPending(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------"); - assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE", getStatus(savingsStatusHashMap, "submittedAndPendingApproval")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS PENDING ------------------------------------"); + assertTrue("SAVINGS ACCOUNT IS NOT IN PENDING STATE", + getStatus(savingsStatusHashMap, "submittedAndPendingApproval")); + LOG.info("Savings Application Status: {} \n", savingsStatusHashMap); } public static void verifySavingsIsActive(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); assertTrue("ERROR IN ACTIVATING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "active")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Status: {} \n", savingsStatusHashMap); } public static void verifySavingsIsRejected(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS REJECTED ------------------------------------"); assertTrue("ERROR IN REJECTING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "rejected")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Status: {} \n", savingsStatusHashMap); } public static void verifySavingsIsWithdrawn(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------"); - assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "withdrawnByApplicant")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS WITHDRAWN ------------------------------------"); + assertTrue("ERROR IN WITHDRAW THE SAVINGS APPLICATION", + getStatus(savingsStatusHashMap, "withdrawnByApplicant")); + LOG.info("Savings Application Status: {}", savingsStatusHashMap); } public static void verifySavingsAccountIsClosed(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS CLOSED ------------------------------------"); assertTrue("ERROR IN CLOSING THE SAVINGS APPLICATION", getStatus(savingsStatusHashMap, "closed")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Status: {}", savingsStatusHashMap); } public static void verifySavingsAccountIsNotActive(final HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS INACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS INACTIVE ------------------------------------"); assertTrue(getStatus(savingsStatusHashMap, "active")); - System.out.println("Savings Application Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Status: {} \n", savingsStatusHashMap); } - public static HashMap getStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer savingsID) { - final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER; + public static HashMap getStatusOfSavings(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer savingsID) { + final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, url, "status"); } - public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, - final Integer savingsID) { - final String url = SAVINGS_ACCOUNT_URL+"/" + savingsID + "?"+Utils.TENANT_IDENTIFIER; + public static HashMap getSubStatusOfSavings(final RequestSpecification requestSpec, + final ResponseSpecification responseSpec, final Integer savingsID) { + final String url = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER; return Utils.performServerGet(requestSpec, responseSpec, url, "subStatus"); } - private static boolean getStatus(final HashMap savingsStatusMap, final String nameOfSavingsStatusString) { + private static boolean getStatus(final HashMap savingsStatusMap, final String nameOfSavingsStatusString) { return (Boolean) savingsStatusMap.get(nameOfSavingsStatusString); } public static void verifySavingsSubStatusInactive(HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "inactive")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusDormant(HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "dormant")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusEscheat(HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "escheat")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusNone(HashMap savingsStatusHashMap) { - System.out.println("\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); + LOG.info( + "\n-------------------------------------- VERIFYING SAVINGS APPLICATION IS ACTIVE ------------------------------------"); assertTrue("UNEXPECTED SAVINGS ACCOUNT SUB STATUS", getStatus(savingsStatusHashMap, "none")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusblock(HashMap savingsStatusHashMap) { - System.out.println( + LOG.info( "\n-------------------------------------- VERIFYING SAVINGS ACCOUNT IS BLOCKED ------------------------------------"); assertTrue("block", getStatus(savingsStatusHashMap, "block")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusIsNone(HashMap savingsStatusHashMap) { - System.out.println("\n------------------------- VERIFYING SAVINGS ACCOUNT IS NOT BLOCKED FOR ANY TYPE OF TRANSACTIONS ---------------------------"); + LOG.info( + "\n------------------------- VERIFYING SAVINGS ACCOUNT IS NOT BLOCKED FOR ANY TYPE OF TRANSACTIONS ---------------------------"); assertTrue("none", getStatus(savingsStatusHashMap, "none")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusIsDebitBlocked(HashMap savingsStatusHashMap) { - System.out.println("\n--------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR DEBIT TRANSACTIONS ---------------------"); + LOG.info( + "\n--------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR DEBIT TRANSACTIONS ---------------------"); assertTrue("status is blockDebit", getStatus(savingsStatusHashMap, "blockDebit")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } public static void verifySavingsSubStatusIsCreditBlocked(HashMap savingsStatusHashMap) { - System.out.println("\n---------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR CREDIT TRANSACTIONS ---------------"); + LOG.info( + "\n---------------------- VERIFYING SAVINGS APPLICATION IS BLOCKED FOR CREDIT TRANSACTIONS ---------------"); assertTrue("blockCredit ", getStatus(savingsStatusHashMap, "blockCredit")); - System.out.println("Savings Application Sub Status:" + savingsStatusHashMap + "\n"); + LOG.info("Savings Application Sub Status: {} ", savingsStatusHashMap.toString()); } } \ No newline at end of file diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java index f924c68e5..016e88b00 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java @@ -23,10 +23,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ShareAccountHelper { - + private final static Logger LOG = LoggerFactory.getLogger(ShareAccountHelper.class); private static final String LOCALE = "en_GB"; private String clientId ; @@ -96,7 +97,7 @@ public class ShareAccountHelper { } String shareAccountCreateJson = new Gson().toJson(map); - System.out.println(shareAccountCreateJson); + LOG.info("{}",shareAccountCreateJson); return shareAccountCreateJson; } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java index 7bd097a00..e2af24830 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountIntegrationTests.java @@ -40,9 +40,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ShareAccountIntegrationTests { - + private final static Logger LOG = LoggerFactory.getLogger(ShareAccountIntegrationTests.class); private RequestSpecification requestSpec; private ResponseSpecification responseSpec; private ShareProductHelper shareProductHelper; @@ -59,21 +61,21 @@ public class ShareAccountIntegrationTests { public void testCreateShareProduct() { // This method will check create share product, get share product, // update share product. - System.out.println("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW SHARE PRODUCT ---------------------------------------"); shareProductHelper = new ShareProductHelper(); final Integer shareProductId = createShareProduct(); Assert.assertNotNull(shareProductId); - System.out.println("------------------------------CREATING SHARE PRODUCT COMPLETE---------------------------------------"); + LOG.info("------------------------------CREATING SHARE PRODUCT COMPLETE---------------------------------------"); - System.out.println("------------------------------RETRIEVING SHARE PRODUCT---------------------------------------"); + LOG.info("------------------------------RETRIEVING SHARE PRODUCT---------------------------------------"); Map shareProductData = ShareProductTransactionHelper .retrieveShareProduct(shareProductId, requestSpec, responseSpec); Assert.assertNotNull(shareProductData); shareProductHelper.verifyShareProduct(shareProductData); - System.out.println("------------------------------RETRIEVING SHARE PRODUCT COMPLETE---------------------------------------"); + LOG.info("------------------------------RETRIEVING SHARE PRODUCT COMPLETE---------------------------------------"); - System.out.println("------------------------------UPDATING SHARE PRODUCT---------------------------------------"); + LOG.info("------------------------------UPDATING SHARE PRODUCT---------------------------------------"); Map shareProductDataForUpdate = new HashMap<>(); @@ -90,7 +92,7 @@ public class ShareAccountIntegrationTests { String updatedSharesIssued = String.valueOf(updatedShareProductData.get("totalSharesIssued")); Assert.assertEquals("2000", updatedTotalShares); Assert.assertEquals("2000", updatedSharesIssued); - System.out.println("------------------------------UPDATING SHARE PRODUCT COMPLETE---------------------------------------"); + LOG.info("------------------------------UPDATING SHARE PRODUCT COMPLETE---------------------------------------"); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareProductHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareProductHelper.java index f6b82e831..34b175a0a 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareProductHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareProductHelper.java @@ -29,11 +29,12 @@ import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.integrationtests.common.Utils; import org.joda.time.LocalDate; import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ShareProductHelper { - - + private final static Logger LOG = LoggerFactory.getLogger(ShareProductHelper.class); private static final String NONE = "1"; private static final String CASH_BASED = "2"; private static final String LOCALE = "en_GB"; @@ -94,7 +95,7 @@ public class ShareProductHelper { } String shareProductCreateJson = new Gson().toJson(map); - System.out.println(shareProductCreateJson); + LOG.info("{}",shareProductCreateJson); return shareProductCreateJson; } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/AccountNumberPreferencesHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/AccountNumberPreferencesHelper.java index bb842ef5a..a817fd2b6 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/AccountNumberPreferencesHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/system/AccountNumberPreferencesHelper.java @@ -23,9 +23,11 @@ import io.restassured.specification.ResponseSpecification; import java.util.ArrayList; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class AccountNumberPreferencesHelper { - + private final static Logger LOG = LoggerFactory.getLogger(AccountNumberPreferencesHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -41,8 +43,7 @@ public class AccountNumberPreferencesHelper { public Object createClientAccountNumberPreference( ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String requestJSON = new AccountNumberPreferencesTestBuilder() .clientBuild(); @@ -56,8 +57,7 @@ public class AccountNumberPreferencesHelper { public Object createLoanAccountNumberPreference( ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String requestJSON = new AccountNumberPreferencesTestBuilder() .loanBuild(); @@ -70,8 +70,7 @@ public class AccountNumberPreferencesHelper { public Object createSavingsAccountNumberPreference( ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String requestJSON = new AccountNumberPreferencesTestBuilder() .savingsBuild(); @@ -85,8 +84,7 @@ public class AccountNumberPreferencesHelper { public Object createGroupsAccountNumberPreference( ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String requestJSON = new AccountNumberPreferencesTestBuilder() .groupsBuild(); @@ -100,8 +98,7 @@ public class AccountNumberPreferencesHelper { public Object createCenterAccountNumberPreference( ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String requestJSON = new AccountNumberPreferencesTestBuilder() .centerBuild(); @@ -146,8 +143,7 @@ public class AccountNumberPreferencesHelper { final Integer accountNumberFormatId, ResponseSpecification responseSpec, String jsonAttributeToGetBack) { - System.out - .println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------"); + LOG.info("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------"); final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/" + accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER; 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 cc018cce9..f44381d2c 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 @@ -27,9 +27,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DatatableHelper { - + private final static Logger LOG = LoggerFactory.getLogger(DatatableHelper.class); private final RequestSpecification requestSpec; private final ResponseSpecification responseSpec; @@ -58,7 +60,7 @@ public class DatatableHelper { public static void verifyDatatableCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String generatedDatatableName) { - System.out.println("------------------------------CHECK DATATABLE DETAILS------------------------------------\n"); + 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); @@ -76,7 +78,7 @@ public class DatatableHelper { addDatatableColumns(datatableColumnsList, "Date of Approval", "Date", false, null); map.put("columns", datatableColumnsList); String requestJsonString = new Gson().toJson(map); - System.out.println("map : " + requestJsonString); + LOG.info("map : {}" , requestJsonString); return requestJsonString; } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTest.java index caefa6d29..dc9df9067 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTest.java @@ -45,9 +45,11 @@ import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GuarantorTest { - + private final static Logger LOG = LoggerFactory.getLogger(GuarantorTest.class); private ResponseSpecification responseSpec; private RequestSpecification requestSpec; private LoanTransactionHelper loanTransactionHelper; @@ -146,7 +148,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_2, null); Assert.assertNotNull(externalGuarantee_2); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -157,14 +159,14 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); - System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0)); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -172,7 +174,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -303,7 +305,7 @@ public class GuarantorTest { Assert.assertNotNull(externalGuarantee_2); verifySavingsOnHoldBalance(externalSavigsId_2, null); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -314,14 +316,14 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds); - System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------UNDO APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID); LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap); verifySavingsOnHoldBalance(selfSavigsId, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_1, Float.valueOf((float)0)); verifySavingsOnHoldBalance(externalSavigsId_2, Float.valueOf((float)0)); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -363,7 +365,7 @@ public class GuarantorTest { } } - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -457,7 +459,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_1, null); Assert.assertNotNull(externalGuarantee_1); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -466,7 +468,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -530,7 +532,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(externalSavigsId_1, null); Assert.assertNotNull(externalGuarantee_1); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -539,7 +541,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -599,7 +601,7 @@ public class GuarantorTest { Assert.assertNotNull(externalGuarantee_1); verifySavingsOnHoldBalance(externalSavigsId_1, null); - System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------"); + LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); @@ -608,7 +610,7 @@ public class GuarantorTest { verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds); verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds); - System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------"); + LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); @@ -660,7 +662,7 @@ public class GuarantorTest { private Integer createLoanProductWithHoldFunds(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor, final String minimumGuaranteeFromOwnFunds) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("4") .withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2") .withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance() @@ -671,7 +673,7 @@ public class GuarantorTest { } private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String disbursementDate) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal("10000.00") // .withLoanTermFrequency("4") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTestBuilder.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTestBuilder.java index f82ea9aee..e1fe97d57 100755 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTestBuilder.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/loanaccount/guarantor/GuarantorTestBuilder.java @@ -21,9 +21,11 @@ package org.apache.fineract.integrationtests.loanaccount.guarantor; import com.google.gson.Gson; import java.util.HashMap; import org.apache.fineract.integrationtests.common.Utils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GuarantorTestBuilder { - + private final static Logger LOG = LoggerFactory.getLogger(GuarantorTestBuilder.class); private static final String GUARANTOR_TYPE_CUSTOMER = "1"; @SuppressWarnings("unused") private static final String GUARANTOR_TYPE_STAFF = "2"; @@ -57,7 +59,7 @@ public class GuarantorTestBuilder { map.put("amount", guaranteeAmount); map.put("savingsId", savingsId); } - System.out.println("map : " + map); + LOG.info("map : {}" , map); return new Gson().toJson(map); } diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java index 1a3b85759..4ab6249ce 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java @@ -30,12 +30,14 @@ import java.util.Map; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({"rawtypes", "unchecked"}) public class VariableInstallmentsDecliningBalanceHelper { - + private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsDecliningBalanceHelper.class); public static String createLoanProductWithoutVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("1,00,000.00") // .withNumberOfRepayments("4") // @@ -51,7 +53,7 @@ public class VariableInstallmentsDecliningBalanceHelper { } public static String createLoanProductWithVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("1,00,000.00") // .withNumberOfRepayments("4") // @@ -69,7 +71,7 @@ public class VariableInstallmentsDecliningBalanceHelper { } public static String createLoanProductWithVaribleConfigwithEqualPrincipal(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("1,00,000.00") // .withNumberOfRepayments("4") // @@ -88,7 +90,7 @@ public class VariableInstallmentsDecliningBalanceHelper { public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List charges, final String savingsId, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // @@ -108,7 +110,7 @@ public class VariableInstallmentsDecliningBalanceHelper { public static String applyForLoanApplicationWithEqualPrincipal(final Integer clientID, final Integer loanProductID, List charges, final String savingsId, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsFlatHelper.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsFlatHelper.java index 95533b126..acedbf37f 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsFlatHelper.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsFlatHelper.java @@ -30,12 +30,14 @@ import java.util.Map; import org.apache.fineract.integrationtests.common.accounting.Account; import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder; import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({"rawtypes", "unchecked"}) public class VariableInstallmentsFlatHelper { - + private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsFlatHelper.class); public static String createLoanProductWithVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) { - System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); + LOG.info("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------"); final String loanProductJSON = new LoanProductTestBuilder() // .withPrincipal("1,00,000.00") // .withNumberOfRepayments("4") // @@ -55,7 +57,7 @@ public class VariableInstallmentsFlatHelper { public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List charges, final String savingsId, String principal) { - System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); + LOG.info("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------"); final String loanApplicationJSON = new LoanApplicationTestBuilder() // .withPrincipal(principal) // .withLoanTermFrequency("4") // diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsIntegrationTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsIntegrationTest.java index 0e4bdd804..bdb9e70b9 100644 --- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsIntegrationTest.java +++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/variableinstallments/VariableInstallmentsIntegrationTest.java @@ -33,11 +33,12 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings({"rawtypes", "unchecked"}) public class VariableInstallmentsIntegrationTest { - - + private final static Logger LOG = LoggerFactory.getLogger(VariableInstallmentsIntegrationTest.class); private static final String NONE = "1"; private RequestSpecification requestSpec; private ResponseSpecification responseSpec; @@ -56,7 +57,7 @@ public class VariableInstallmentsIntegrationTest { public void testVariableLoanProductCreation() { final String json = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithVaribleConfig(false, NONE); final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(json); - System.out.println("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); + LOG.info("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); Map loanProduct = (Map)loanTransactionHelper.getLoanProductDetail(requestSpec, responseSpec, loanProductID, "") ; Assert.assertTrue((Boolean)loanProduct.get("allowVariableInstallments")) ; Assert.assertEquals(Integer.valueOf(5), loanProduct.get("minimumGap")) ; @@ -68,7 +69,7 @@ public class VariableInstallmentsIntegrationTest { public void testLoanProductCreation() { final String josn = VariableInstallmentsDecliningBalanceHelper.createLoanProductWithoutVaribleConfig(false, NONE); Integer loanProductID = this.loanTransactionHelper.getLoanProductId(josn); - System.out.println("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); + LOG.info("------------------------------RETRIEVING CREATED LOAN PRODUCT DETAILS ---------------------------------------"); Map loanProduct = (Map)loanTransactionHelper.getLoanProductDetail(requestSpec, responseSpec, loanProductID, "") ; Assert.assertTrue(!(Boolean)loanProduct.get("allowVariableInstallments")) ; } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/ApplicationExitUtil.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/ApplicationExitUtil.java index d83598d28..5c34994a9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/ApplicationExitUtil.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/ApplicationExitUtil.java @@ -22,10 +22,13 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ConfigurableApplicationContext; -public abstract class ApplicationExitUtil { +public abstract class ApplicationExitUtil { + private final static Logger LOG = LoggerFactory.getLogger(ApplicationExitUtil.class); private ApplicationExitUtil() {} public static void waitForKeyPressToCleanlyExit(ConfigurableApplicationContext ctx) throws IOException { @@ -34,7 +37,7 @@ public abstract class ApplicationExitUtil { // button).. In the case of MariaDB4j that's a problem because then the // mysqld won't be stopped, so: // (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016) - System.out.println("\nHit Enter to quit..."); + LOG.info("\nHit Enter to quit..."); // NOTE: In Eclipse, System.console() is not available.. so: // (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429) BufferedReader d = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/exception/MultiException.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/exception/MultiException.java index 9e8e28a3f..7522365f5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/exception/MultiException.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/exception/MultiException.java @@ -25,6 +25,8 @@ import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Exception with multiple root causes. @@ -41,7 +43,7 @@ import java.util.List; * @author Michael Vorburger.ch */ public class MultiException extends Exception { - + private final static Logger LOG = LoggerFactory.getLogger(MultiException.class); private final List throwables; public MultiException(List problems) { @@ -71,10 +73,10 @@ public class MultiException extends Exception { @Override public void printStackTrace() { - System.err.println(super.getMessage()); + LOG.info("{}", super.getMessage()); int i = 0; for (Throwable e : throwables) { - System.err.print(++i + "."); + LOG.info("{}.",++i); e.printStackTrace(); } } diff --git a/fineract-provider/src/test/java/org/apache/fineract/common/Utils.java b/fineract-provider/src/test/java/org/apache/fineract/common/Utils.java index 9f6fe9026..d9b0004b5 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/common/Utils.java +++ b/fineract-provider/src/test/java/org/apache/fineract/common/Utils.java @@ -30,7 +30,8 @@ import io.restassured.specification.RequestSpecification; import io.restassured.specification.ResponseSpecification; import org.apache.commons.lang3.StringUtils; import org.apache.http.conn.HttpHostConnectException; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -42,7 +43,7 @@ import org.apache.http.conn.HttpHostConnectException; */ @SuppressWarnings("unchecked") public class Utils { - + private final static Logger LOG = LoggerFactory.getLogger(Utils.class); public static final String TENANT_IDENTIFIER = "tenantIdentifier=default"; private static final String LOGIN_URL = "/fineract-provider/api/v1/authentication?username=mifos&password=password&" + TENANT_IDENTIFIER; @@ -56,7 +57,7 @@ public class Utils { public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() { try { - System.out.println("-----------------------------------LOGIN-----------------------------------------"); + LOG.info("-----------------------------------LOGIN-----------------------------------------"); final String json = RestAssured.post(LOGIN_URL).asString(); assertThat("Failed to login into fineract platform", StringUtils.isBlank(json), is(false)); return JsonPath.with(json).get("base64EncodedAuthenticationKey"); diff --git a/fineract-provider/src/test/java/org/apache/fineract/mix/report/service/XBRLBuilderTest.java b/fineract-provider/src/test/java/org/apache/fineract/mix/report/service/XBRLBuilderTest.java index 1fe2011fe..9c7b3e42a 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/mix/report/service/XBRLBuilderTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/mix/report/service/XBRLBuilderTest.java @@ -43,12 +43,14 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @RunWith(MockitoJUnitRunner.class) public class XBRLBuilderTest { - + private final static Logger LOG = LoggerFactory.getLogger(XBRLBuilderTest.class); @Mock private NamespaceReadPlatformServiceImpl readNamespaceService; @@ -58,8 +60,8 @@ public class XBRLBuilderTest { @Before public void setUp() { this.readNamespaceService = Mockito.mock(NamespaceReadPlatformServiceImpl.class); - lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString())).thenReturn( - new NamespaceData(1l, "mockedprefix", "mockedurl")); + lenient().when(this.readNamespaceService.retrieveNamespaceByPrefix(ArgumentMatchers.anyString())) + .thenReturn(new NamespaceData(1l, "mockedprefix", "mockedurl")); } @Test @@ -68,10 +70,12 @@ public class XBRLBuilderTest { final MixTaxonomyData data1 = Mockito.mock(MixTaxonomyData.class); when(data1.getName()).thenReturn("Assets"); map.put(data1, new BigDecimal(10000)); - final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"), "USD"); - System.out.println(result); - NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( - new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))).getElementsByTagName("Assets"); + final String result = this.xbrlBuilder.build(map, Date.valueOf("2005-11-11"), Date.valueOf("2013-07-17"), + "USD"); + LOG.info("{}", result); + NodeList nodes = DocumentBuilderFactory.newInstance().newDocumentBuilder() + .parse(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))) + .getElementsByTagName("Assets"); assertNotNull(nodes); assertNotNull(nodes.item(0)); assertEquals("Assets", nodes.item(0).getNodeName()); diff --git a/fineract-provider/src/test/java/org/apache/fineract/notification/Listener.java b/fineract-provider/src/test/java/org/apache/fineract/notification/Listener.java index 7c9fff7c2..6cdcdb340 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/notification/Listener.java +++ b/fineract-provider/src/test/java/org/apache/fineract/notification/Listener.java @@ -22,13 +22,15 @@ import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.jms.listener.SessionAwareMessageListener; public class Listener implements SessionAwareMessageListener { - + private final static Logger LOG = LoggerFactory.getLogger(Listener.class); @Override public void onMessage(Message message, Session session) throws JMSException { TextMessage msg = (TextMessage) message; - System.out.println("Received: " + msg.getText()); + LOG.info("Received: {}" ,msg.getText()); } } diff --git a/fineract-provider/src/test/java/org/apache/fineract/notification/SenderTest.java b/fineract-provider/src/test/java/org/apache/fineract/notification/SenderTest.java index 6176b9e35..a16985f16 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/notification/SenderTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/notification/SenderTest.java @@ -25,6 +25,8 @@ import javax.jms.Session; import org.apache.fineract.notification.data.NotificationData; import org.junit.Test; import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.MessageCreator; @@ -36,7 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; }) @RunWith(SpringJUnit4ClassRunner.class) public class SenderTest { - + private final static Logger LOG = LoggerFactory.getLogger(SenderTest.class); @Autowired private JmsTemplate jmsTemplate; @@ -68,7 +70,7 @@ public class SenderTest { jmsTemplate.send(mockQueue, new MessageCreator() { @Override public Message createMessage(Session session) throws JMSException { - System.out.println("Message send successfully"); + LOG.info("Message send successfully"); return session.createObjectMessage(notificationData); } });