@Test public void test_should_set_location_based_on_cross_hierarchy_id_when_present() { final HashMap<String, Object> sevaRequestMap = new HashMap<>(); final HashMap<Object, Object> serviceRequestMap = new HashMap<>(); serviceRequestMap.put("addressId", "crossHierarchyId"); serviceRequestMap.put("tenantId", "ap.public"); serviceRequestMap.put("isAttribValuesPopulated", false); final ArrayList<HashMap<String, String>> attributeValues = new ArrayList<>(); serviceRequestMap.put("attribValues", attributeValues); sevaRequestMap.put("serviceRequest", serviceRequestMap); final SevaRequest sevaRequest = new SevaRequest(sevaRequestMap); final BoundaryResponse parentBoundaryResponse = new BoundaryResponse(1L, "parent"); final BoundaryResponse childBoundaryResponse = new BoundaryResponse(2L, "child"); final CrossHierarchyResponse hierarchyResponse = new CrossHierarchyResponse(parentBoundaryResponse, childBoundaryResponse); when(crossHierarchyRepository.getCrossHierarchy("crossHierarchyId","ap.public")).thenReturn(hierarchyResponse); final SevaRequest actualSevaRequest = locationService.enrich(sevaRequest); assertEquals("1", actualSevaRequest.getLocationId()); assertEquals("parent", actualSevaRequest.getLocationName()); assertEquals("2", actualSevaRequest.getChildLocationId()); }
public SevaRequest enrich(SevaRequest sevaRequest) { return sevaRequest.isLocationPresent() ? sevaRequest : enrichLocation(sevaRequest); }
LocationService { public SevaRequest enrich(SevaRequest sevaRequest) { return sevaRequest.isLocationPresent() ? sevaRequest : enrichLocation(sevaRequest); } }
LocationService { public SevaRequest enrich(SevaRequest sevaRequest) { return sevaRequest.isLocationPresent() ? sevaRequest : enrichLocation(sevaRequest); } LocationService(BoundaryRepository boundaryRepository,
                           CrossHierarchyRepository crossHierarchyRepository); }
LocationService { public SevaRequest enrich(SevaRequest sevaRequest) { return sevaRequest.isLocationPresent() ? sevaRequest : enrichLocation(sevaRequest); } LocationService(BoundaryRepository boundaryRepository,
                           CrossHierarchyRepository crossHierarchyRepository); SevaRequest enrich(SevaRequest sevaRequest); }
LocationService { public SevaRequest enrich(SevaRequest sevaRequest) { return sevaRequest.isLocationPresent() ? sevaRequest : enrichLocation(sevaRequest); } LocationService(BoundaryRepository boundaryRepository,
                           CrossHierarchyRepository crossHierarchyRepository); SevaRequest enrich(SevaRequest sevaRequest);  }