use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.
the class AccountServiceControllerTest method newInstanceWithRolesEmptyOrgString.
/**
* Test returning all possible roles that can be assigned to a person by
* passing in an empty string for the organizations.
*/
@Test
public void newInstanceWithRolesEmptyOrgString() {
RestResponse response = (RestResponse) controller.newInstance(clientRequest, "[]");
createUserWithRoles(response);
}
use of com.runwaysdk.mvc.RestResponse in project geoprism-registry by terraframe.
the class AccountServiceControllerTest method createUser.
private JSONObject createUser(String userName, String roleNames) {
RestResponse response = (RestResponse) controller.newInstance(clientRequest, "[" + moiOrg.getCode() + "]");
Pair userPair = (Pair) response.getAttribute("user");
GeoprismUserDTO user = (GeoprismUserDTO) userPair.getFirst();
Pair rolesPair = (Pair) response.getAttribute("roles");
JSONArray roleJSONArray = (JSONArray) rolesPair.getFirst();
JSONObject jsonUser = new JSONObject();
jsonUser.put(GeoprismUserDTO.FIRSTNAME, "Some Firstname");
jsonUser.put(GeoprismUserDTO.LASTNAME, "Some Lastame");
jsonUser.put(GeoprismUserDTO.USERNAME, userName);
jsonUser.put(GeoprismUserDTO.EMAIL, userName);
jsonUser.put(GeoprismUserDTO.PASSWORD, "123456");
response = (RestResponse) controller.apply(clientRequest, jsonUser.toString(), "[" + roleNames + "]");
userPair = (Pair) response.getAttribute("user");
jsonUser = (JSONObject) userPair.getFirst();
return jsonUser;
}
use of com.runwaysdk.mvc.RestResponse 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);
}
Aggregations