@Test public void test_should_set_location_based_on_coordinates_when_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); 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 boundaryResponse = new BoundaryResponse(LOCATION_ID, BOUNDARY_NAME); when(boundaryRepository.findBoundary("1.2", "4.5","ap.public")).thenReturn(boundaryResponse); final SevaRequest actualSevaRequest = locationService.enrich(sevaRequest); assertEquals("5", actualSevaRequest.getLocationId()); assertEquals(BOUNDARY_NAME, actualSevaRequest.getLocationName()); }
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);  }