This is an automated email from the ASF dual-hosted git repository.
vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 077065c fix generic warnings in StaffTest (re. FINERACT-949)
077065c is described below
commit 077065c1b5dff31d00bf97822f81bdb72b5700d4
Author: Michael Vorburger <[email protected]>
AuthorDate: Fri May 8 19:26:39 2020 +0200
fix generic warnings in StaffTest (re. FINERACT-949)
---
.../fineract/integrationtests/StaffTest.java | 23 ++++++++++---------
.../fineract/integrationtests/common/Utils.java | 26 +++++++++++-----------
.../common/organisation/StaffHelper.java | 19 ++++++++--------
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java
index 134e32f..47df585 100644
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/StaffTest.java
@@ -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"));
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java
index 04fa837..f78c28d 100644
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/Utils.java
@@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("unchecked")
public class Utils {
- private final static Logger logger = LoggerFactory.getLogger(Utils.class);
+ private final static Logger logger = LoggerFactory.getLogger(Utils.class);
public static final String TENANT_PARAM_NAME = "tenantIdentifier";
public static final String DEFAULT_TENANT = "default";
@@ -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);
}
@@ -117,8 +117,8 @@ public class Utils {
logger.info("Logging in, for integration test...");
System.out.println("-----------------------------------LOGIN-----------------------------------------");
String json = RestAssured.given().contentType(ContentType.JSON)
- .body("{\"username\":\"mifos\", \"password\":\"password\"}")
- .expect().log().ifError().when().post(LOGIN_URL).asString();
+ .body("{\"username\":\"mifos\",
\"password\":\"password\"}")
+
.expect().log().ifError().when().post(LOGIN_URL).asString();
assertThat("Failed to login into fineract platform",
StringUtils.isBlank(json), is(false));
String key =
JsonPath.with(json).get("base64EncodedAuthenticationKey");
assertThat("Failed to obtain key: " + json,
StringUtils.isBlank(key), is(false));
@@ -141,12 +141,12 @@ public class Utils {
}
public static String performGetTextResponse(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
- final String getURL){
+ final String getURL){
return
given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
}
public static byte[] performGetBinaryResponse(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
- final String getURL){
+ final String getURL){
return
given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asByteArray();
}
@@ -209,10 +209,10 @@ public class Utils {
return randomStringGenerator(prefix, lenOfRandomSuffix);
}
public static Long randomNumberGenerator(final int expectedLength){
- final String source="1234567890";
- final int lengthofSource=source.length();
- final Random random=new Random();
- StringBuilder stringBuilder=new StringBuilder(expectedLength);
+ final String source="1234567890";
+ final int lengthofSource=source.length();
+ final Random random=new Random();
+ StringBuilder stringBuilder=new StringBuilder(expectedLength);
for (int i = 0; i < expectedLength; i++) {
stringBuilder.append(source.charAt(random.nextInt(lengthofSource)));
}
@@ -239,7 +239,7 @@ public class Utils {
}
public static String performServerTemplatePost(final RequestSpecification
requestSpec,final ResponseSpecification responseSpec,
- final String postURL,final
String legalFormType,final File file,final String locale,final String
dateFormat) {
+ final String postURL,final String legalFormType,final File
file,final String locale,final String dateFormat) {
final String importDocumentId=given().spec(requestSpec)
.queryParam("legalFormType",legalFormType)
@@ -253,7 +253,7 @@ public class Utils {
}
public static String performServerOutputTemplateLocationGet(final
RequestSpecification requestSpec,final ResponseSpecification responseSpec,
- final String
getURL,final String importDocumentId){
+ final String getURL,final String importDocumentId){
final String templateLocation=given().spec(requestSpec).
queryParam("importDocumentId",importDocumentId)
.expect().spec(responseSpec)
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java
index c5fad68..df5da6a 100755
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/organisation/StaffHelper.java
@@ -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,13 +33,11 @@ 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";
public static Integer transferStaffToGroup(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
- final Integer groupId,final
Integer staffToTransfer ,final String note){
+ final Integer groupId,final Integer staffToTransfer ,final String
note){
final String url = TRANSFER_STAFF_URL + "/" + groupId +
"?command=transferStaff&"+ Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, url,
transferStaffToGroupAsJSON(staffToTransfer, note), GROUP_ID);
}
@@ -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,
"");