From ed95612b3f437534f24a71b3ebff1021b5ad7c31 Mon Sep 17 00:00:00 2001 From: Priti Date: Sat, 30 Mar 2013 11:07:58 +0530 Subject: [PATCH] common jsonCreator moved to Utils --- .../integrationtests/testbuilder/Utils.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/testbuilder/Utils.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/testbuilder/Utils.java index b665a44df..0bf5c7a46 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/testbuilder/Utils.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/testbuilder/Utils.java @@ -1,5 +1,8 @@ package org.mifosplatform.integrationtests.testbuilder; +import com.google.gson.Gson; + +import java.util.HashMap; import java.util.Random; public class Utils { @@ -20,4 +23,65 @@ public class Utils { public static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) { return randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } + + public static String getTestClientAsJSON(String dateOfJoining) { + HashMap map = new HashMap(); + 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 map = new HashMap(); + 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 map = new HashMap(); + 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 map = new HashMap(); + 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 map = new HashMap(); + 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 map = new HashMap(); + 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); + } + + }