LocationService { public synchronized boolean createLocation(Coordinates coordinates, String description) { Objects.requireNonNull(coordinates); Objects.requireNonNull(description); return submitToPlanner(repository.createLocation(coordinates, description)); } @Autowired  LocationService(
            LocationRepository repository,
            RouteOptimizer optimizer,
            DistanceMatrix distanceMatrix,
            ApplicationEventPublisher eventPublisher); synchronized boolean createLocation(Coordinates coordinates, String description); synchronized boolean addLocation(Location location); synchronized void removeLocation(long id); synchronized void removeAll();  }
@Test void createLocation_should_validate_arguments() { assertThatNullPointerException().isThrownBy(() -> locationService.createLocation(null, "x")); assertThatNullPointerException().isThrownBy(() -> locationService.createLocation(coordinates, null)); }
@Test void createLocation(@Mock DistanceMatrixRow matrixRow) { String description = "new location"; when(repository.createLocation(coordinates, description)).thenReturn(location); when(distanceMatrix.addLocation(any())).thenReturn(matrixRow); assertThat(locationService.createLocation(coordinates, description)).isTrue(); verify(repository).createLocation(coordinates, description); verify(distanceMatrix).addLocation(location); verify(optimizer).addLocation(location, matrixRow); }