@Test public void test_should_return_seva_request_as_is_when_location_id_is_already_present() { final HashMap<String, Object> sevaRequestMap = new HashMap<>(); final HashMap<Object, Object> serviceRequestMap = new HashMap<>(); serviceRequestMap.put("lat", 1.2d); serviceRequestMap.put("lng", 4.5d); final ArrayList<HashMap<String, String>> attributeValues = new ArrayList<>(); final HashMap<String, String> attribEntry = new HashMap<>(); attribEntry.put("key", "systemLocationId"); attribEntry.put("name", "5"); attributeValues.add(attribEntry); serviceRequestMap.put("attribValues", attributeValues); sevaRequestMap.put("serviceRequest", serviceRequestMap); final SevaRequest sevaRequest = new SevaRequest(sevaRequestMap); final SevaRequest actualSevaRequest = locationService.enrich(sevaRequest); assertEquals(sevaRequest, actualSevaRequest); verify(boundaryRepository, never()).findBoundary(any(), any(),any()); verify(crossHierarchyRepository, never()).getCrossHierarchy(any(),any()); }
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);  }