Merge remote-tracking branch 'tw_priti/IT_With_Waive_Interest'

This commit is contained in:
Keith Woodlock
2013-04-02 15:01:30 +01:00
10 changed files with 5604 additions and 2582 deletions
+1
View File
@@ -1,4 +1,5 @@
bin
out/
build
repos
.classpath
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,71 @@
package org.mifosplatform.integrationtests.common;
import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import java.util.HashMap;
import java.util.Random;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.RestAssured.post;
import static com.jayway.restassured.path.json.JsonPath.from;
import junit.framework.Assert;
public class ClientHelper {
private static final String CREATE_CLIENT_URL = "/mifosng-provider/api/v1/clients?tenantIdentifier=default";
public static Integer createClient(RequestSpecification requestSpec, ResponseSpecification responseSpec) {
return createClient(requestSpec,responseSpec,"04 March 2012");
}
public static Integer createClient(RequestSpecification requestSpec, ResponseSpecification responseSpec,String dateOfJoining) {
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSON(dateOfJoining), "clientId");
}
public static String getTestClientAsJSON(String dateOfJoining) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("officeId", "1");
map.put("firstname", randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", randomNameGenerator("Client_LastName_", 4));
map.put("externalId", 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 void verifyClientCreatedOnServer(RequestSpecification requestSpec, ResponseSpecification responseSpec, Integer generatedClientID) {
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
String CLIENT_URL="/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
Assert.assertEquals(generatedClientID,responseClientID);
}
private 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");
}
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
return randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
}
@@ -0,0 +1,157 @@
package org.mifosplatform.integrationtests.common;
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 loanTermFrequency = "";
private String loanTermFrequencyType = "";
private String numberOfRepayment = "0";
private String repaymentPeriod = "0";
private String repaymentFrequencyType = "";
private String interestRate = "2";
private String interestRateFrequencyType = "0";
private String interestType = "";
private String amortizationType = "";
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){
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;
}
}
@@ -0,0 +1,166 @@
package org.mifosplatform.integrationtests.common;
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 = ClientHelper.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(final String loanName){
this.nameOfLoanProduct=loanName;
return this;
}
public LoanProductTestBuilder withPrincipal(final String principal){
this.principal = principal;
return this;
}
public LoanProductTestBuilder withNumberOfRepayments(final 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(final 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(final 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 (final 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;
}
}
@@ -0,0 +1,52 @@
package org.mifosplatform.integrationtests.common;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import junit.framework.Assert;
import java.util.HashMap;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.path.json.JsonPath.from;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class LoanStatusChecker {
public static void verifyLoanIsApproved(HashMap loanStatusHashMap) {
assertFalse(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanIsWaitingForDisbursal(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "waitingForDisbursal"));
}
public static void verifyLoanIsPending(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanIsActive(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "active"));
}
public static void verifyLoanNeedsApproval(HashMap loanStatusHashMap) {
assertTrue(getStatus(loanStatusHashMap, "pendingApproval"));
}
public static void verifyLoanAccountIsClosed(HashMap loanStatusHashMap){
Assert.assertTrue(getStatus(loanStatusHashMap, "closed"));
}
public static HashMap getStatusOfLoan(RequestSpecification requestSpec, ResponseSpecification responseSpec, Integer loanID){
String url = "/mifosng-provider/api/v1/loans/" + loanID + "?tenantIdentifier=default";
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
}
private static boolean getStatus(HashMap loanStatusMap, String nameOfLoanStatusString){
return (Boolean)loanStatusMap.get(nameOfLoanStatusString);
}
}
@@ -0,0 +1,146 @@
package org.mifosplatform.integrationtests.common;
import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
public class LoanTransactionHelper {
private static final String CREATE_LOAN_PRODUCT_URL = "/mifosng-provider/api/v1/loanproducts?tenantIdentifier=default";
private static final String APPLY_LOAN_URL = "/mifosng-provider/api/v1/loans?tenantIdentifier=default";
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";
private static final String WRITE_OFF_LOAN_COMMAND = "writeoff";
private static final String WAIVE_INTEREST_COMMAND = "waiveinterest";
private static final String MAKE_REPAYMENT_COMMAND = "repayment";
public static Integer getLoanProductId(RequestSpecification requestSpec, ResponseSpecification responseSpec, String loanProductJSON) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_LOAN_PRODUCT_URL, loanProductJSON, "resourceId");
}
public static Integer getLoanId(RequestSpecification requestSpec, ResponseSpecification responseSpec, String loanApplicationJSON) {
return Utils.performServerPost(requestSpec, responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
}
public static ArrayList getLoanRepaymentSchedule(RequestSpecification requestSpec, ResponseSpecification responseSpec,final Integer loanID){
String URL = "/mifosng-provider/api/v1/loans/" + loanID +"?associations=repaymentSchedule&tenantIdentifier=default";
HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
return (ArrayList) response.get("periods");
}
public static HashMap approveLoan(RequestSpecification requestSpec, ResponseSpecification responseSpec, String approvalDate, Integer loanID) {
return performLoanTransaction(requestSpec, responseSpec, createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
}
public static HashMap undoApproval(RequestSpecification requestSpec, ResponseSpecification responseSpec, Integer loanID) {
String undoBodyJson = "{'note':'UNDO APPROVAL'}";
return performLoanTransaction(requestSpec, responseSpec, createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson);
}
public static HashMap disburseLoan(RequestSpecification requestSpec, ResponseSpecification responseSpec, String date, Integer loanID) {
return performLoanTransaction(requestSpec, responseSpec, createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date));
}
public static HashMap writeOffLoan(RequestSpecification requestSpec, ResponseSpecification responseSpec, String date, Integer loanID) {
return performLoanTransaction(requestSpec, responseSpec, createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date));
}
public static HashMap waiveInterest(RequestSpecification requestSpec, ResponseSpecification responseSpec, String date,String amountToBeWaived, Integer loanID) {
return performLoanTransaction(requestSpec, responseSpec, createLoanTransactionURL(WAIVE_INTEREST_COMMAND,loanID), getWaiveBodyAsJSON(date, amountToBeWaived));
}
public static HashMap makeRepayment(RequestSpecification requestSpec, ResponseSpecification responseSpec, String date,Float amountToBePaid, Integer loanID) {
return performLoanTransaction(requestSpec, responseSpec, createLoanTransactionURL(MAKE_REPAYMENT_COMMAND,loanID), getRepaymentBodyAsJSON(date,amountToBePaid));
}
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);
}
public static String getLoanCalculationBodyAsJSON(final String productID) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en_GB");
map.put("productId", productID);
map.put("principal", "4,500.00");
map.put("loanTermFrequency", "4");
map.put("loanTermFrequencyType", "2");
map.put("numberOfRepayments", "4");
map.put("repaymentEvery", "1");
map.put("repaymentFrequencyType", "2");
map.put("interestRateFrequencyType", "2");
map.put("interestRatePerPeriod", "2");
map.put("amortizationType", "1");
map.put("interestType", "0");
map.put("interestCalculationPeriodType", "1");
map.put("expectedDisbursementDate", "20 September 2011");
map.put("transactionProcessingStrategyId", "1");
return new Gson().toJson(map);
}
private static String createLoanOperationURL(String command, Integer loanID) {
return "/mifosng-provider/api/v1/loans/" + loanID + "?command=" + command + "&tenantIdentifier=default";
}
private static String createLoanTransactionURL(String command, Integer loanID) {
return "/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command="+command+"&tenantIdentifier=default";
}
private static HashMap performLoanTransaction(RequestSpecification requestSpec, ResponseSpecification responseSpec, String postURLForLoanTransaction, String jsonToBeSent) {
HashMap response = Utils.performServerPost(requestSpec, responseSpec, postURLForLoanTransaction, jsonToBeSent, "changes");
return (HashMap) response.get("status");
}
}
@@ -0,0 +1,41 @@
package org.mifosplatform.integrationtests.common;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.path.json.JsonPath;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.RestAssured.post;
import static com.jayway.restassured.path.json.JsonPath.from;
public class Utils {
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default";
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
System.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.post(LOGIN_URL).asString();
return JsonPath.with(json).get("base64EncodedAuthenticationKey");
}
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String getURL, final String jsonAttributeToGetBack){
String json = given().spec(requestSpec)
.expect().spec(responseSpec).log().ifError()
.when().get(getURL)
.andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack){
String json = given().spec(requestSpec).body(jsonBodyToSend)
.expect().spec(responseSpec).log().ifError()
.when().post(postURL)
.andReturn().asString();
return (T) from(json).get(jsonAttributeToGetBack);
}
}