MIFOSX-1662 fix for integration test ClientTest and removing warnings
This commit is contained in:
+6
-7
@@ -6,39 +6,38 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ClientStatusChecker {
|
||||
public static void verifyClientIsActive(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientIsActive(final HashMap<String,Object> clientStatusHashMap) {
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 300);
|
||||
}
|
||||
|
||||
|
||||
public static void verifyClientClosed(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientClosed(final HashMap<String,Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 600);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
public static void verifyClientPending(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientPending(final HashMap<String,Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 100);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
public static void verifyClientRejected(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientRejected(final HashMap<String,Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 700);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifyClientActiavted(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientActiavted(final HashMap<String,Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 300);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifyClientWithdrawn(final HashMap clientStatusHashMap) {
|
||||
public static void verifyClientWithdrawn(final HashMap<String,Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 800);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
|
||||
+2
-2
@@ -40,10 +40,10 @@ public class ClientTest {
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
HashMap status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
HashMap<String,Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
ClientStatusChecker.verifyClientIsActive(status);
|
||||
|
||||
HashMap clientStatusHashMap = this.clientHelper.closeClient(clientId);
|
||||
HashMap<String,Object> clientStatusHashMap = this.clientHelper.closeClient(clientId);
|
||||
ClientStatusChecker.verifyClientClosed(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.reactivateClient(clientId);
|
||||
|
||||
+33
-15
@@ -131,8 +131,9 @@ public class ClientHelper {
|
||||
|
||||
}
|
||||
|
||||
/* Client status is a map.So adding SuppressWarnings */
|
||||
@SuppressWarnings("unchecked")
|
||||
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
public static HashMap<String,Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String clientId) {
|
||||
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
|
||||
}
|
||||
@@ -150,10 +151,10 @@ public class ClientHelper {
|
||||
Integer clientClosureCodeId = (Integer) code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientClosureReason" */
|
||||
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec);
|
||||
String closureReasonId = (String) codeValue.get("id");
|
||||
|
||||
map.put("closureReasonId", closureReasonId);
|
||||
HashMap<String,Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId,this.requestSpec,this.responseSpec);
|
||||
Integer closureReasonId = (Integer)codeValue.get("id");
|
||||
|
||||
map.put("closureReasonId", closureReasonId.toString());
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closureDate", CREATED_DATE_PLUS_ONE);
|
||||
@@ -177,10 +178,19 @@ public class ClientHelper {
|
||||
|
||||
private String getRejectClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
/* Retrieve Code id for the Code "ClientRejectReason" */
|
||||
String codeName = "ClientRejectReason";
|
||||
HashMap<String,Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
Integer clientRejectionReasonCodeId = (Integer)code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientRejectReason" */
|
||||
HashMap<String,Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId,this.requestSpec,this.responseSpec);
|
||||
Integer rejectionReasonId = (Integer)codeValue.get("id");
|
||||
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectionDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("rejectionReasonId", "15");
|
||||
map.put("rejectionReasonId", rejectionReasonId.toString());
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
@@ -200,37 +210,46 @@ public class ClientHelper {
|
||||
|
||||
private String getWithdrawClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
/* Retrieve Code id for the Code "ClientWithdrawReason" */
|
||||
String codeName = "ClientWithdrawReason";
|
||||
HashMap<String,Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
Integer clientWithdrawReasonCodeId = (Integer)code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
|
||||
HashMap<String,Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId,this.requestSpec,this.responseSpec);
|
||||
Integer withdrawalReasonId = (Integer)codeValue.get("id");
|
||||
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawalDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("withdrawalReasonId", "17");
|
||||
map.put("withdrawalReasonId", withdrawalReasonId.toString());
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
|
||||
public HashMap closeClient(final Integer clientId) {
|
||||
public HashMap<String,Object> closeClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap reactivateClient(final Integer clientId) {
|
||||
public HashMap<String,Object> reactivateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap rejectClient(final Integer clientId) {
|
||||
public HashMap<String,Object> rejectClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap activateClient(final Integer clientId) {
|
||||
public HashMap<String,Object> activateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap withdrawClient(final Integer clientId) {
|
||||
public HashMap<String,Object> withdrawClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
|
||||
}
|
||||
@@ -239,10 +258,9 @@ public class ClientHelper {
|
||||
return CLIENT_URL + "/" + clientId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private HashMap performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
|
||||
HashMap status = null;
|
||||
private HashMap<String,Object> 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));
|
||||
HashMap<String,Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
+4
-1
@@ -94,13 +94,15 @@ public class CodeHelper {
|
||||
codeValueId = (Integer) CodeHelper.createCodeValue(requestSpec,
|
||||
responseSpec, codeId, codeValue, codeValuePosition,
|
||||
"subResourceId");
|
||||
|
||||
} else {
|
||||
codeValueId = (Integer) codeValuesList.get(0).get("id");
|
||||
return codeValuesList.get(0);
|
||||
}
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
}
|
||||
|
||||
public static ArrayList<HashMap<String, Object>> getAllCodes(
|
||||
@@ -186,6 +188,7 @@ public class CodeHelper {
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
|
||||
}
|
||||
|
||||
public static Object getCodeValueById(
|
||||
|
||||
Reference in New Issue
Block a user