[Priti/Sailee] Renamed package as common

This commit is contained in:
Priti
2013-04-01 16:47:24 +05:30
parent 419f127cd8
commit f08da673f2
6 changed files with 0 additions and 5623 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,163 +0,0 @@
package org.mifosplatform.integrationtests.testbuilder;
import com.google.gson.Gson;
import java.util.HashMap;
public class LoanApplicationTestBuilder {
private static final String DAYS = "0";
private static final String WEEKS = "1";
private static final String MONTHS = "2";
private static final String YEARS = "3";
private static final String DECLINING_BALANCE = "0";
private static final String FLAT_BALANCE = "1";
private static final String EQUAL_PRINCIPLE_PAYMENTS="0";
private static final String EQUAL_INSTALLMENTS="1";
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD="1";
private static final String MIFOS_STANDARD_STRATEGY ="1";
private String principal = "10,000";
private String clientID="0";
private String loanProductId = "0";
private String loanTermFrequency = "";
private String loanTermFrequencyType=""; //0=Days, 1=Weeks, 2=Months, 3=Years
private String numberOfRepayment = "0";
private String repaymentPeriod = "0";
private String repaymentFrequencyType = ""; //0=Days, 1=Weeks, 2=Months
// 12 % per Year Declining Balance
// interest rate per Interest_frequency interest type
private String interestRate = "2";
private String interestRateFrequencyType="0"; //2=Per month, 3=Per year
private String interestType= ""; //0=Declining Balance, 1=Flat
private String amortizationType =""; //0=Equal principle payments, 1=Equal installments
private String interestCalculationPeriodType =CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
private String transactionProcessingID= MIFOS_STANDARD_STRATEGY;
private String expectedDisbursmentDate="";
private String submittedOndate ="";
public String Build(String clientID, String loanProductId){
this.clientID = clientID;
this.loanProductId = loanProductId;
HashMap<String, String> map = new HashMap<String, String>();
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en_GB");
map.put("clientId", clientID);
map.put("productId",loanProductId);
map.put("principal", principal);
map.put("loanTermFrequency",loanTermFrequency);
map.put("loanTermFrequencyType", "2");
map.put("numberOfRepayments", numberOfRepayment);
map.put("repaymentEvery", repaymentPeriod);
map.put("repaymentFrequencyType", repaymentFrequencyType);
map.put("interestRateFrequencyType", interestRateFrequencyType);
map.put("interestRatePerPeriod", interestRate);
map.put("amortizationType", amortizationType);
map.put("interestType", interestType);
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
map.put("transactionProcessingStrategyId", transactionProcessingID);
map.put("expectedDisbursementDate", expectedDisbursmentDate);
map.put("submittedOnDate", submittedOndate);
return new Gson().toJson(map);
}
public LoanApplicationTestBuilder withPrincipal(String principalAmount){
this.principal = principalAmount;
return this;
}
public LoanApplicationTestBuilder withLoanTermFrequency(String loanToBePayedDuration){
this.loanTermFrequency= loanToBePayedDuration;
return this;
}
public LoanApplicationTestBuilder withLoanTermFrequencyAsDays(){
this.loanTermFrequencyType=DAYS;
return this;
}
public LoanApplicationTestBuilder withLoanTermFrequencyAsMonths(){
this.loanTermFrequencyType=MONTHS;
return this;
}
public LoanApplicationTestBuilder withLoanTermFrequencyAsWeeks(){
this.loanTermFrequencyType=WEEKS;
return this;
}
public LoanApplicationTestBuilder withLoanTermFrequencyAsYears(){
this.loanTermFrequencyType=YEARS;
return this;
}
public LoanApplicationTestBuilder withNumberOfRepayments(String numberOfRepayments){
this.numberOfRepayment= numberOfRepayments;
return this;
}
public LoanApplicationTestBuilder withRepaymentEveryAfter(String repaymentPeriod){
this.repaymentPeriod=repaymentPeriod;
return this;
}
public LoanApplicationTestBuilder withRepaymentFrequencyTypeAsDays(){
this.repaymentFrequencyType = DAYS;
return this;
}
public LoanApplicationTestBuilder withRepaymentFrequencyTypeAsMonths(){
this.repaymentFrequencyType = MONTHS;
return this;
}
public LoanApplicationTestBuilder withRepaymentFrequencyTypeAsWeeks(){
this.repaymentFrequencyType = WEEKS;
return this;
}
public LoanApplicationTestBuilder withInterestRatePerPeriod(String interestRate){
this.interestRate=interestRate;
return this;
}
public LoanApplicationTestBuilder withInterestRateFrequencyTypeAsMonths(){
this.interestRateFrequencyType=MONTHS;
return this;
}
public LoanApplicationTestBuilder withInterestRateFrequencyTypeAsYears(){
this.interestRateFrequencyType=YEARS;
return this;
}
public LoanApplicationTestBuilder withInterestTypeAsFlatBalance(){
this.interestType=FLAT_BALANCE;
return this;
}
public LoanApplicationTestBuilder withInterestTypeAsDecliningBalance(){
this.interestType=DECLINING_BALANCE;
return this;
}
public LoanApplicationTestBuilder withAmortizationTypeAsEqualInstallments(){
this.amortizationType=EQUAL_INSTALLMENTS;
return this;
}
public LoanApplicationTestBuilder withAmortizationTypeAsEqualPrincipalPayments(){
this.amortizationType=EQUAL_PRINCIPLE_PAYMENTS;
return this;
}
public LoanApplicationTestBuilder withInterestCalculationPeriodTypeSameAsRepaymentPeriod(){
this.interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
return this;
}
public LoanApplicationTestBuilder withInterestCalculationPeriodTypeAsDays(){
this.interestCalculationPeriodType=DAYS;
return this;
}
public LoanApplicationTestBuilder withExpectedDisbursementDate(String expectedDisbursementDate){
this.expectedDisbursmentDate=expectedDisbursementDate;
return this;
}
public LoanApplicationTestBuilder withSubmittedOnDate(String loanApplicationSubmittedDate){
this.submittedOndate=loanApplicationSubmittedDate;
return this;
}
}
@@ -1,166 +0,0 @@
package org.mifosplatform.integrationtests.testbuilder;
import com.google.gson.Gson;
import java.util.HashMap;
public class LoanProductTestBuilder {
private static final String LOCALE = "en_GB";
private static final String DIGITS_AFTER_DECIMAL = "2";
private static final String INR = "INR";
private static final String DAYS = "0";
private static final String WEEK = "1";
private static final String MONTHS = "2";
private static final String YEARS = "3";
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD="1";
private static final String EQUAL_PRINCIPLE_PAYMENTS="0";
private static final String EQUAL_INSTALLMENTS="1";
private static final String DECLINING_BALANCE="0";
private static final String FLAT_BALANCE="1";
private static final String MIFOS_STANDARD_STRATEGY ="1";
private static final String HEAVENS_FAMILY_STRATEGY ="2";
private static final String CREO_CORE_STRATEGY ="3";
private static final String RBI_INDIA_STRATEGY ="4";
private static final String NONE ="1";
private static final String CASH_BASED ="2";
private static final String ACCRUAL_BASED ="3";
private String nameOfLoanProduct = Utils.randomNameGenerator("LOAN_PRODUCT_", 6);
private String principal = "10000.00";
private String numberOfRepayments = "0";
private String repaymentFrequency = WEEK;
private String repaymentPeriod = "0";
private String interestRatePerPeriod= "2";
private String interestRateFrequencyType = MONTHS;
private String interestType = FLAT_BALANCE;
private String interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
private String inArrearsTolerance="0";
private String transactionProcessingStrategy=MIFOS_STANDARD_STRATEGY;
private String accountingRule =NONE;
private String currencyCode = INR;
private String amortizationType= EQUAL_INSTALLMENTS;
public String build() {
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", nameOfLoanProduct);
map.put("currencyCode", currencyCode);
map.put("locale", LOCALE);
map.put("digitsAfterDecimal",DIGITS_AFTER_DECIMAL);
map.put("principal", principal);
map.put("numberOfRepayments", numberOfRepayments);
map.put("repaymentEvery",repaymentPeriod );
map.put("repaymentFrequencyType", repaymentFrequency);
map.put("interestRatePerPeriod", interestRatePerPeriod);
map.put("interestRateFrequencyType", interestRateFrequencyType);
map.put("amortizationType",amortizationType);
map.put("interestType", interestType);
map.put("interestCalculationPeriodType", interestCalculationPeriodType);
map.put("inArrearsTolerance", inArrearsTolerance);
map.put("transactionProcessingStrategyId", transactionProcessingStrategy);
map.put("accountingRule", accountingRule);
return new Gson().toJson(map);
}
public LoanProductTestBuilder withLoanName(String loanName){
this.nameOfLoanProduct=loanName;
return this;
}
public LoanProductTestBuilder withPrincipal(String principal){
this.principal = principal;
return this;
}
public LoanProductTestBuilder withNumberOfRepayments(String numberOfRepayment){
this.numberOfRepayments = numberOfRepayment;
return this;
}
public LoanProductTestBuilder withRepaymentTypeAsMonth(){
this.repaymentFrequency = MONTHS;
return this;
}
public LoanProductTestBuilder withRepaymentTypeAsWeek(){
this.repaymentFrequency = WEEK;
return this;
}
public LoanProductTestBuilder withRepaymentTypeAsDays(){
this.repaymentFrequency = DAYS;
return this;
}
public LoanProductTestBuilder withRepaymentAfterEvery(String repaymentAfterEvery){
this.repaymentPeriod=repaymentAfterEvery;
return this;
}
public LoanProductTestBuilder withInterestRateFrequencyTypeAsMonths(){
this.interestRateFrequencyType=MONTHS;
return this;
}
public LoanProductTestBuilder withInterestRateFrequencyTypeAsYear(){
this.interestRateFrequencyType=YEARS;
return this;
}
public LoanProductTestBuilder withinterestRatePerPeriod(String interestRatePerPeriod) {
this.interestRatePerPeriod=interestRatePerPeriod;
return this;
}
public LoanProductTestBuilder withAmortizationTypeAsEqualPrinciplePayment(){
this.amortizationType = EQUAL_PRINCIPLE_PAYMENTS;
return this;
}
public LoanProductTestBuilder withAmortizationTypeAsEqualInstallments(){
this.amortizationType = EQUAL_INSTALLMENTS;
return this;
}
public LoanProductTestBuilder withInterestTypeAsFlat(){
this.interestType=FLAT_BALANCE;
return this;
}
public LoanProductTestBuilder withInterestTypeAsDecliningBalance (){
this.interestType=DECLINING_BALANCE;
return this;
}
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsDays (){
this.interestCalculationPeriodType=DAYS;
return this;
}
public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod (){
this.interestCalculationPeriodType=CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
return this;
}
public LoanProductTestBuilder withInArrearsTolerance (String amountCanBeWaved){
this.inArrearsTolerance = amountCanBeWaved;
return this;
}
public LoanProductTestBuilder withAccountingRuleAsNone (){
this.accountingRule= NONE;
return this;
}
public LoanProductTestBuilder withAccountingRuleAsCashBased (){
this.accountingRule= CASH_BASED;
return this;
}
public LoanProductTestBuilder withAccountingRuleAsAccrualBased (){
this.accountingRule= ACCRUAL_BASED;
return this;
}
}
@@ -1,39 +0,0 @@
package org.mifosplatform.integrationtests.testbuilder;
import junit.framework.Assert;
import java.util.HashMap;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class LoanStatusChecker {
private static boolean getStatus(HashMap loanStatusMap, String nameOfLoanStatusString){
return (Boolean)loanStatusMap.get(nameOfLoanStatusString);
}
public static void verifyLoanIsApproved(HashMap loanStatusHashMap) {
assertFalse(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanStatusIsWaitingForDisbursal(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "waitingForDisbursal"));
}
public static void verifyLoanStatusIsPending(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanStatusIsActive(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "active"));
}
private static void verifyLoanNeedsApproval(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){
Assert.assertTrue(getStatus(loanStatusHashMap, "closed"));
}
}
@@ -1,87 +0,0 @@
package org.mifosplatform.integrationtests.testbuilder;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Random;
public class Utils {
public static String randomStringGenerator(final String prefix, final int len, final String sourceSetString) {
int lengthOfSource = sourceSetString.length();
Random rnd = new Random();
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; i++)
sb.append((sourceSetString).charAt(rnd.nextInt(lengthOfSource)));
return (prefix+(sb.toString()));
}
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
return randomStringGenerator(prefix, lenOfRandomSuffix, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
public static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
return randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
public static String getTestClientAsJSON(String dateOfJoining) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("officeId", "1");
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", Utils.randomIDGenerator("ID_", 7));
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("joinedDate", dateOfJoining);
System.out.println("map : "+map);
return new Gson().toJson(map);
}
public static String getDisburseLoanAsJSON(String actualDisbursementDate){
HashMap<String,String> map = new HashMap<String, String>();
map.put("locale","en");
map.put("dateFormat","dd MMMM yyyy");
map.put("actualDisbursementDate",actualDisbursementDate);
map.put("note", "DISBURSE NOTE");
return new Gson().toJson(map);
}
public static String getApproveLoanAsJSON(String approvalDate){
HashMap<String,String> map = new HashMap<String, String>();
map.put("locale","en");
map.put("dateFormat","dd MMMM yyyy");
map.put("approvedOnDate",approvalDate);
map.put("note", "Approval NOTE");
return new Gson().toJson(map);
}
public static String getRepaymentBodyAsJSON(String transactionDate,Float transactionAmount){
HashMap<String,String> map = new HashMap<String, String>();
map.put("locale","en");
map.put("dateFormat","dd MMMM yyyy");
map.put("transactionDate",transactionDate);
map.put("transactionAmount",transactionAmount.toString());
map.put("note", "Repayment Made!!!");
return new Gson().toJson(map);
}
public static String getWriteOffBodyAsJSON(String transactionDate){
HashMap<String,String> map = new HashMap<String, String>();
map.put("dateFormat","dd MMMM yyyy");
map.put("locale","en");
map.put("note", " LOAN WRITE OFF!!!");
map.put("transactionDate",transactionDate);
return new Gson().toJson(map);
}
public static String getWaiveBodyAsJSON(String transactionDate,String amountToBeWaived){
HashMap<String,String> map = new HashMap<String, String>();
map.put("locale","en");
map.put("dateFormat","dd MMMM yyyy");
map.put("transactionDate",transactionDate);
map.put("transactionAmount",amountToBeWaived);
map.put("note", " Interest Waived!!!");
return new Gson().toJson(map);
}
}