fix generic warnings in StaffTest (re. FINERACT-949)
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
22224709b6
commit
077065c1b5
+12
-11
@@ -26,6 +26,7 @@ import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
||||
import org.junit.Assert;
|
||||
@@ -51,7 +52,7 @@ public class StaffTest {
|
||||
|
||||
@Test
|
||||
public void testStaffCreate() {
|
||||
final HashMap response = StaffHelper.createStaffMap(requestSpec, responseSpec);
|
||||
Map<String, Object> response = StaffHelper.createStaffMap(requestSpec, responseSpec);
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.get("officeId"), 1);
|
||||
@@ -114,7 +115,7 @@ public class StaffTest {
|
||||
|
||||
@Test
|
||||
public void testStaffFetch() {
|
||||
final HashMap response = StaffHelper.getStaff(requestSpec, responseSpec, 1);
|
||||
Map<String, Object> response = StaffHelper.getStaff(requestSpec, responseSpec, 1);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertNotNull(response.get("id"));
|
||||
Assert.assertEquals(response.get("id"), 1);
|
||||
@@ -132,8 +133,8 @@ public class StaffTest {
|
||||
|
||||
@Test
|
||||
public void testStaffListStatusActive() {
|
||||
final List<HashMap> responseActive = (List<HashMap>)StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
|
||||
for(final HashMap staff : responseActive) {
|
||||
List<Map<String, Object>> responseActive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
|
||||
for(final Map<String, Object> staff : responseActive) {
|
||||
Assert.assertNotNull(staff.get("id"));
|
||||
Assert.assertEquals(staff.get("isActive"), true);
|
||||
}
|
||||
@@ -141,15 +142,14 @@ public class StaffTest {
|
||||
|
||||
@Test
|
||||
public void testStaffListStatusInactive() {
|
||||
final List<HashMap> responseInactive = (List<HashMap>)StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
|
||||
|
||||
for(final HashMap staff : responseInactive) {
|
||||
List<Map<String, Object>> responseInactive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
|
||||
for(final Map<String, Object> staff : responseInactive) {
|
||||
Assert.assertNotNull(staff.get("id"));
|
||||
Assert.assertEquals(staff.get("isActive"), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = ClassCastException.class) // because "xyz" will return an error, not a List
|
||||
public void testStaffListFetchWrongState() {
|
||||
StaffHelper.getStaffListWithState(requestSpec, responseSpecForValidationError, "xyz");
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class StaffTest {
|
||||
|
||||
@Test
|
||||
public void testStaffUpdate() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
final Map<String, Object> map = new HashMap<>();
|
||||
final String firstname = Utils.randomNameGenerator("michael_", 10);
|
||||
final String lastname = Utils.randomNameGenerator("Doe_", 10);
|
||||
final String externalId = Utils.randomStringGenerator("EXT", 97);
|
||||
@@ -172,8 +172,9 @@ public class StaffTest {
|
||||
map.put("externalId", externalId);
|
||||
map.put("mobileNo", mobileNo);
|
||||
|
||||
final HashMap response = (HashMap) StaffHelper.updateStaff(requestSpec, responseSpec, 1, map);
|
||||
final HashMap changes = (HashMap) response.get("changes");
|
||||
Map<String, Object> response = StaffHelper.updateStaff(requestSpec, responseSpec, 1, map);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> changes = (Map<String, Object>) response.get("changes");
|
||||
|
||||
Assert.assertEquals(1, response.get("resourceId"));
|
||||
Assert.assertEquals(firstname, changes.get("firstname"));
|
||||
|
||||
+2
-2
@@ -83,11 +83,11 @@ public class Utils {
|
||||
logger.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
|
||||
return;
|
||||
} else {
|
||||
logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", new Object[] { HEALTH_URL, healthHttpStatus, attempt++ });
|
||||
logger.info("{} returned HTTP {}, going to wait and retry (attempt {})", HEALTH_URL, healthHttpStatus, attempt++);
|
||||
sleep(3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("{} caused {}, going to wait and retry (attempt {})", new Object[] { HEALTH_URL, e.getMessage(), attempt++ });
|
||||
logger.info("{} caused {}, going to wait and retry (attempt {})", HEALTH_URL, e.getMessage(), attempt++);
|
||||
lastException = e;
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
+8
-9
@@ -24,6 +24,7 @@ import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
|
||||
public class StaffHelper {
|
||||
@@ -32,8 +33,6 @@ public class StaffHelper {
|
||||
|
||||
private static final String CREATE_STAFF_URL = "/fineract-provider/api/v1/staff";
|
||||
|
||||
private static final String RESOURCE_ID = "resourceId";
|
||||
|
||||
public static final String GROUP_ID = "groupId";
|
||||
|
||||
|
||||
@@ -55,35 +54,35 @@ public class StaffHelper {
|
||||
return (Integer) createStaffWithJson(requestSpec, responseSpec, createStaffAsJSON()).get("resourceId");
|
||||
}
|
||||
|
||||
public static HashMap createStaffMap(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
public static Map<String, Object> createStaffMap(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createStaffWithJson(requestSpec, responseSpec, createStaffAsJSON());
|
||||
}
|
||||
|
||||
public static HashMap createStaffWithJson(final RequestSpecification requestSpec,
|
||||
public static Map<String, Object> createStaffWithJson(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String json) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, url, json, "");
|
||||
}
|
||||
|
||||
public static HashMap getStaff(final RequestSpecification requestSpec,
|
||||
public static Map<String, Object> getStaff(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer staffId) {
|
||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static List<HashMap> getStaffList(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
public static List<Map<String, Object>> getStaffList(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static Object getStaffListWithState(final RequestSpecification requestSpec,
|
||||
public static List<Map<String, Object>> getStaffListWithState(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String status) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER + "&status=" + status;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static Object updateStaff(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer staffId, final HashMap<String, Object> changes) {
|
||||
public static Map<String, Object> updateStaff(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer staffId, final Map<String, Object> changes) {
|
||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final String json = new Gson().toJson(changes);
|
||||
return Utils.performServerPut(requestSpec, responseSpec, url, json, "");
|
||||
|
||||
Reference in New Issue
Block a user