### Question:
LocationServiceImpl implements LocationService { @Override public Location update(Long id, Location location) { log.info(LogMessage.IN_UPDATE, location); Location updatable = findById(id); updatable.setLat(location.getLat()); updatable.setLng(location.getLng()); updatable.setAddress(location.getAddress()); updatable.setPlace(location.getPlace()); return locationRepo.save(updatable); }  @Override List<Location> findAll(); @Override Location findById(Long id); @Override Location save(Location location); @Override Location update(Long id, Location location); @Override Long deleteById(Long id); @Override Optional<Location> findByLatAndLng(Double lat, Double lng);  }### Answer:
@Test public void updateTest() { Location updated = new Location(); when(locationRepo.findById(anyLong())).thenReturn(Optional.of(updated)); when(locationRepo.save(any())).thenReturn(updated); locationService.update(anyLong(), updated); Location foundEntity = locationService.findById(anyLong()); assertEquals(updated, foundEntity); }
@Test(expected = NotFoundException.class) public void updateGivenIdNullThenThrowException() { locationService.update(null, new Location()); }