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 io.restassured.specification.ResponseSpecification;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -51,7 +52,7 @@ public class StaffTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaffCreate() {
|
public void testStaffCreate() {
|
||||||
final HashMap response = StaffHelper.createStaffMap(requestSpec, responseSpec);
|
Map<String, Object> response = StaffHelper.createStaffMap(requestSpec, responseSpec);
|
||||||
|
|
||||||
Assert.assertNotNull(response);
|
Assert.assertNotNull(response);
|
||||||
Assert.assertEquals(response.get("officeId"), 1);
|
Assert.assertEquals(response.get("officeId"), 1);
|
||||||
@@ -114,7 +115,7 @@ public class StaffTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaffFetch() {
|
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);
|
||||||
Assert.assertNotNull(response.get("id"));
|
Assert.assertNotNull(response.get("id"));
|
||||||
Assert.assertEquals(response.get("id"), 1);
|
Assert.assertEquals(response.get("id"), 1);
|
||||||
@@ -132,8 +133,8 @@ public class StaffTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaffListStatusActive() {
|
public void testStaffListStatusActive() {
|
||||||
final List<HashMap> responseActive = (List<HashMap>)StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
|
List<Map<String, Object>> responseActive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
|
||||||
for(final HashMap staff : responseActive) {
|
for(final Map<String, Object> staff : responseActive) {
|
||||||
Assert.assertNotNull(staff.get("id"));
|
Assert.assertNotNull(staff.get("id"));
|
||||||
Assert.assertEquals(staff.get("isActive"), true);
|
Assert.assertEquals(staff.get("isActive"), true);
|
||||||
}
|
}
|
||||||
@@ -141,15 +142,14 @@ public class StaffTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaffListStatusInactive() {
|
public void testStaffListStatusInactive() {
|
||||||
final List<HashMap> responseInactive = (List<HashMap>)StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
|
List<Map<String, Object>> responseInactive = StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
|
||||||
|
for(final Map<String, Object> staff : responseInactive) {
|
||||||
for(final HashMap staff : responseInactive) {
|
|
||||||
Assert.assertNotNull(staff.get("id"));
|
Assert.assertNotNull(staff.get("id"));
|
||||||
Assert.assertEquals(staff.get("isActive"), false);
|
Assert.assertEquals(staff.get("isActive"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = ClassCastException.class) // because "xyz" will return an error, not a List
|
||||||
public void testStaffListFetchWrongState() {
|
public void testStaffListFetchWrongState() {
|
||||||
StaffHelper.getStaffListWithState(requestSpec, responseSpecForValidationError, "xyz");
|
StaffHelper.getStaffListWithState(requestSpec, responseSpecForValidationError, "xyz");
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public class StaffTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaffUpdate() {
|
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 firstname = Utils.randomNameGenerator("michael_", 10);
|
||||||
final String lastname = Utils.randomNameGenerator("Doe_", 10);
|
final String lastname = Utils.randomNameGenerator("Doe_", 10);
|
||||||
final String externalId = Utils.randomStringGenerator("EXT", 97);
|
final String externalId = Utils.randomStringGenerator("EXT", 97);
|
||||||
@@ -172,8 +172,9 @@ public class StaffTest {
|
|||||||
map.put("externalId", externalId);
|
map.put("externalId", externalId);
|
||||||
map.put("mobileNo", mobileNo);
|
map.put("mobileNo", mobileNo);
|
||||||
|
|
||||||
final HashMap response = (HashMap) StaffHelper.updateStaff(requestSpec, responseSpec, 1, map);
|
Map<String, Object> response = StaffHelper.updateStaff(requestSpec, responseSpec, 1, map);
|
||||||
final HashMap changes = (HashMap) response.get("changes");
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> changes = (Map<String, Object>) response.get("changes");
|
||||||
|
|
||||||
Assert.assertEquals(1, response.get("resourceId"));
|
Assert.assertEquals(1, response.get("resourceId"));
|
||||||
Assert.assertEquals(firstname, changes.get("firstname"));
|
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);
|
logger.info("{} return HTTP 200, application is now ready for integration testing!", HEALTH_URL);
|
||||||
return;
|
return;
|
||||||
} else {
|
} 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);
|
sleep(3);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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;
|
lastException = e;
|
||||||
sleep(3);
|
sleep(3);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-9
@@ -24,6 +24,7 @@ import io.restassured.specification.ResponseSpecification;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.apache.fineract.integrationtests.common.Utils;
|
import org.apache.fineract.integrationtests.common.Utils;
|
||||||
|
|
||||||
public class StaffHelper {
|
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 CREATE_STAFF_URL = "/fineract-provider/api/v1/staff";
|
||||||
|
|
||||||
private static final String RESOURCE_ID = "resourceId";
|
|
||||||
|
|
||||||
public static final String GROUP_ID = "groupId";
|
public static final String GROUP_ID = "groupId";
|
||||||
|
|
||||||
|
|
||||||
@@ -55,35 +54,35 @@ public class StaffHelper {
|
|||||||
return (Integer) createStaffWithJson(requestSpec, responseSpec, createStaffAsJSON()).get("resourceId");
|
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());
|
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 ResponseSpecification responseSpec, final String json) {
|
||||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
return Utils.performServerPost(requestSpec, responseSpec, url, json, "");
|
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 ResponseSpecification responseSpec, final Integer staffId) {
|
||||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
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;
|
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
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 ResponseSpecification responseSpec, final String status) {
|
||||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER + "&status=" + status;
|
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER + "&status=" + status;
|
||||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object updateStaff(final RequestSpecification requestSpec,
|
public static Map<String, Object> updateStaff(final RequestSpecification requestSpec,
|
||||||
final ResponseSpecification responseSpec, final Integer staffId, final HashMap<String, Object> changes) {
|
final ResponseSpecification responseSpec, final Integer staffId, final Map<String, Object> changes) {
|
||||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
final String json = new Gson().toJson(changes);
|
final String json = new Gson().toJson(changes);
|
||||||
return Utils.performServerPut(requestSpec, responseSpec, url, json, "");
|
return Utils.performServerPut(requestSpec, responseSpec, url, json, "");
|
||||||
|
|||||||
Reference in New Issue
Block a user