Unverified Commit deb089e9 authored by reshmi-nair's avatar reshmi-nair Committed by GitHub
Browse files

SB-26289 Org create and update API is failing while updating org location (#917)

Showing with 36 additions and 14 deletions
+36 -14
......@@ -168,6 +168,8 @@ public class OrganisationRequestValidator {
locList =
validator.getValidatedLocationIds(finalLocList, context);
}
}else{
locList = finalLocList;
}
}
List<String> locationIdsList =
......
......@@ -95,19 +95,6 @@ public class OrganisationRequestValidatorTest {
validator.validateOrgLocation(requestMap, new RequestContext());
}
@Test
public void validateOrgLocationWithOrgLocationTest() {
OrganisationRequestValidator validator = new OrganisationRequestValidator();
List codeList = getOrgLocationLists();
Map requestMap = new HashMap<String,Object>();
requestMap.put(JsonKey.ORG_LOCATION,codeList);
try {
validator.validateOrgLocation(requestMap, new RequestContext());
} catch (ProjectCommonException ex) {
Assert.assertNotNull(ex);
Assert.assertEquals(ex.getCode(), ResponseCode.invalidParameterValue.getErrorCode());
}
}
@Test
public void validateChannelInvalidChannelTest(){
......@@ -135,6 +122,27 @@ public class OrganisationRequestValidatorTest {
Assert.assertEquals(ex.getCode(), ResponseCode.errorInactiveOrg.getErrorCode());
}
}
@Test
public void validateOrgLocationWithInvalidOrgLocationTest() {
OrganisationRequestValidator validator = new OrganisationRequestValidator();
List codeList = getInvalidOrgLocationLists();
Map requestMap = new HashMap<String,Object>();
requestMap.put(JsonKey.ORG_LOCATION,codeList);
try {
validator.validateOrgLocation(requestMap, new RequestContext());
} catch (ProjectCommonException ex) {
Assert.assertNotNull(ex);
Assert.assertEquals(ex.getCode(), ResponseCode.invalidParameterValue.getErrorCode());
}
}
@Test
public void validateOrgLocationWithOrgLocationTest() {
OrganisationRequestValidator validator = new OrganisationRequestValidator();
List codeList = getOrgLocationLists();
Map requestMap = new HashMap<String,Object>();
requestMap.put(JsonKey.ORG_LOCATION,codeList);
validator.validateOrgLocation(requestMap, new RequestContext());
}
public static List<String> getLocationIdsLists() {
List<String> locationIds = new ArrayList<>();
locationIds.add("location1");
......@@ -147,7 +155,19 @@ public class OrganisationRequestValidatorTest {
locationCodes.add("code2");
return locationCodes;
}
public static List<Map<String, String>> getInvalidOrgLocationLists() {
List<Map<String, String>> locationCodes = new ArrayList<>();
Map map = new HashMap<String,Object>();
map.put(JsonKey.ID,"location3");
map.put(JsonKey.TYPE,"state");
locationCodes.add(map);
Map map1 = new HashMap<String,Object>();
map1.put(JsonKey.ID,"location5");
map1.put(JsonKey.TYPE,"district");
map1.put(JsonKey.PARENT_ID,"location4");
locationCodes.add(map1);
return locationCodes;
}
public static List<Map<String, String>> getOrgLocationLists() {
List<Map<String, String>> locationCodes = new ArrayList<>();
Map map = new HashMap<String,Object>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment