Fineract-614:

Updating Global Configurations
Fixing some rebase conflicts
Change to imports on IntegrationTest for CheckStyle
This commit is contained in:
Angel Cajas
2020-03-13 17:15:25 +01:00
committed by Michael Vorburger ⛑️
parent 15a4a7695a
commit 8df44af628
2 changed files with 88 additions and 79 deletions
@@ -23,49 +23,51 @@ import com.jayway.restassured.builder.ResponseSpecBuilder;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.rates.RatesHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
@SuppressWarnings({"rawtypes"})
public class RatesTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@Before
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Before
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization",
"Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void testRatesForLoans() {
@Test
public void testRatesForLoans() {
// Retrieving all Rates
ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec);
Assert.assertNotNull(allRatesData);
// Retrieving all Rates
ArrayList<HashMap> allRatesData = RatesHelper.getRates(this.requestSpec, this.responseSpec);
Assert.assertNotNull(allRatesData);
// Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec,
RatesHelper.getLoanRateJSON());
Assert.assertNotNull(loanRateId);
// Testing Creation and Update of Loan Rate
final Integer loanRateId = RatesHelper.createRates(this.requestSpec, this.responseSpec,
RatesHelper.getLoanRateJSON());
Assert.assertNotNull(loanRateId);
//Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId,
RatesHelper.getModifyRateJSON());
//Update Rate percentage
HashMap changes = RatesHelper.updateRates(this.requestSpec, this.responseSpec, loanRateId,
RatesHelper.getModifyRateJSON());
HashMap rateDataAfterChanges = RatesHelper.getRateById(this.requestSpec, this.responseSpec, loanRateId);
Assert.assertEquals("Verifying Rate after modification", rateDataAfterChanges.get("percentage"), changes.get("percentage"));
HashMap rateDataAfterChanges = RatesHelper
.getRateById(this.requestSpec, this.responseSpec, loanRateId);
Assert.assertEquals("Verifying Rate after modification", rateDataAfterChanges.get("percentage"),
changes.get("percentage"));
}
}
}
@@ -21,71 +21,78 @@ package org.apache.fineract.integrationtests.common.rates;
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;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils;
import java.util.ArrayList;
import java.util.HashMap;
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public class RatesHelper {
private static final String RATES_URL = "/fineract-provider/api/v1/rates";
private static final String CREATE_RATES_URL = RATES_URL + "?" + Utils.TENANT_IDENTIFIER;
private final static String PERCENTAGE = "10";
private final static Integer PRODUCT_APPLY_LOAN = 1;
private final static Boolean ACTIVE = true;
private static final String RATES_URL = "/fineract-provider/api/v1/rates";
private static final String CREATE_RATES_URL = RATES_URL + "?" + Utils.TENANT_IDENTIFIER;
private final static String PERCENTAGE = "10";
private final static Integer PRODUCT_APPLY_LOAN = 1;
private final static Boolean ACTIVE = true;
public static ArrayList<HashMap> getRates(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return (ArrayList) Utils.performServerGet(requestSpec, responseSpec, RATES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static ArrayList<HashMap> getRates(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
return (ArrayList) Utils
.performServerGet(requestSpec, responseSpec, RATES_URL + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static Integer createRates(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String request) {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_RATES_URL, request, "resourceId");
}
public static Integer createRates(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,
final String request) {
return Utils
.performServerPost(requestSpec, responseSpec, CREATE_RATES_URL, request, "resourceId");
}
public static HashMap getRateById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer rateId) {
return Utils.performServerGet(requestSpec, responseSpec, RATES_URL + "/" + rateId + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static HashMap getRateById(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,
final Integer rateId) {
return Utils.performServerGet(requestSpec, responseSpec,
RATES_URL + "/" + rateId + "?" + Utils.TENANT_IDENTIFIER, "");
}
public static HashMap updateRates(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer rateId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec, RATES_URL + "/" + rateId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES);
}
public static HashMap updateRates(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,
final Integer rateId, final String request) {
return Utils.performServerPut(requestSpec, responseSpec,
RATES_URL + "/" + rateId + "?" + Utils.TENANT_IDENTIFIER, request,
CommonConstants.RESPONSE_CHANGES);
}
public static String getLoanRateJSON() {
return getLoanRateJSON(RatesHelper.PRODUCT_APPLY_LOAN, RatesHelper.PERCENTAGE);
}
public static String getLoanRateJSON() {
return getLoanRateJSON(RatesHelper.PRODUCT_APPLY_LOAN, RatesHelper.PERCENTAGE);
}
public static String getLoanRateJSON(final Integer productApply, final String percentage) {
final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("percentage", percentage);
map.put("productApply", productApply);
String crateRateJSON = new Gson().toJson(map);
return crateRateJSON;
}
public static String getLoanRateJSON(final Integer productApply, final String percentage) {
final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("percentage", percentage);
map.put("productApply", productApply);
String crateRateJSON = new Gson().toJson(map);
return crateRateJSON;
}
public static HashMap<String, Object> populateDefaultsForLoan() {
final HashMap<String, Object> map = new HashMap<>();
map.put("active", RatesHelper.ACTIVE);
map.put("percentage", RatesHelper.PERCENTAGE);
map.put("locale", "en");
map.put("productApply", RatesHelper.PRODUCT_APPLY_LOAN);
map.put("name", Utils.randomNameGenerator("Rate_Loans_", 6));
return map;
}
public static HashMap<String, Object> populateDefaultsForLoan() {
final HashMap<String, Object> map = new HashMap<>();
map.put("active", RatesHelper.ACTIVE);
map.put("percentage", RatesHelper.PERCENTAGE);
map.put("locale", "en");
map.put("productApply", RatesHelper.PRODUCT_APPLY_LOAN);
map.put("name", Utils.randomNameGenerator("Rate_Loans_", 6));
return map;
}
public static String getModifyRateJSON() {
final HashMap<String, Object> map = new HashMap<>();
map.put("percentage", "15.0");
map.put("locale", "en");
String json = new Gson().toJson(map);
return json;
}
public static String getModifyRateJSON() {
final HashMap<String, Object> map = new HashMap<>();
map.put("percentage", "15.0");
map.put("locale", "en");
String json = new Gson().toJson(map);
return json;
}
}