Search in sources :

Example 6 with Pair

use of com.runwaysdk.Pair in project geoprism-registry by terraframe.

the class AccountServiceControllerTest method createUserWithRoles.

@SuppressWarnings("rawtypes")
private void createUserWithRoles(RestResponse response) {
    Pair pair = (Pair) response.getAttribute("roles");
    JSONArray roleJSONArray = (JSONArray) pair.getFirst();
    Set<String> requiredRolesSet = new HashSet<String>();
    requiredRolesSet.add(RegistryRole.Type.getSRA_RoleName());
    requiredRolesSet.add(RegistryRole.Type.getRA_RoleName(mohOrg.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRM_RoleName(mohOrg.getCode(), healthFacility.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRC_RoleName(mohOrg.getCode(), healthFacility.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getAC_RoleName(mohOrg.getCode(), healthFacility.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRA_RoleName(moiOrg.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), district.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), district.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getAC_RoleName(moiOrg.getCode(), district.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), village.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), village.getCode()));
    requiredRolesSet.add(RegistryRole.Type.getAC_RoleName(moiOrg.getCode(), village.getCode()));
    this.assertReturnedRoles(roleJSONArray, requiredRolesSet, false);
}
Also used : JSONArray(org.json.JSONArray) Pair(com.runwaysdk.Pair) HashSet(java.util.HashSet)

Example 7 with Pair

use of com.runwaysdk.Pair in project geoprism-registry by terraframe.

the class AccountServiceControllerTest method newInstaneWithOrgRoles.

/**
 * Test returning possible roles that can be assigned to a person for a given
 * organization.
 */
@Test
@SuppressWarnings("rawtypes")
public void newInstaneWithOrgRoles() {
    RestResponse response = (RestResponse) controller.newInstance(clientRequest, "[" + moiOrg.getCode() + "]");
    Pair pair = (Pair) response.getAttribute("roles");
    JSONArray roleJSONArray = (JSONArray) pair.getFirst();
    Assert.assertEquals(7, roleJSONArray.length());
    Set<String> rolesFoundSet = new HashSet<String>();
    rolesFoundSet.add(RegistryRole.Type.getRA_RoleName(moiOrg.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), district.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), district.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getAC_RoleName(moiOrg.getCode(), district.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), village.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), village.getCode()));
    rolesFoundSet.add(RegistryRole.Type.getAC_RoleName(moiOrg.getCode(), village.getCode()));
    this.assertReturnedRoles(roleJSONArray, rolesFoundSet, false);
}
Also used : RestResponse(com.runwaysdk.mvc.RestResponse) JSONArray(org.json.JSONArray) Pair(com.runwaysdk.Pair) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Pair (com.runwaysdk.Pair)7 JSONArray (org.json.JSONArray)4 RestResponse (com.runwaysdk.mvc.RestResponse)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 JsonObject (com.google.gson.JsonObject)2 GeoprismUserDTO (net.geoprism.GeoprismUserDTO)2 JSONObject (org.json.JSONObject)2 Test (org.junit.Test)2 JsonArray (com.google.gson.JsonArray)1 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 LocalDate (java.time.LocalDate)1 LinkedList (java.util.LinkedList)1