test_class.declarator: repository
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private LocationRepository repository;
test_class.type: LocationRepository
test_class.var_name: repository
test_class.declarator: optimizer
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private RouteOptimizer optimizer;
test_class.type: RouteOptimizer
test_class.var_name: optimizer
test_class.declarator: distanceMatrix
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DistanceMatrix distanceMatrix;
test_class.type: DistanceMatrix
test_class.var_name: distanceMatrix
test_class.declarator: eventPublisher
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ApplicationEventPublisher eventPublisher;
test_class.type: ApplicationEventPublisher
test_class.var_name: eventPublisher
test_class.declarator: locationService
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private LocationService locationService;
test_class.type: LocationService
test_class.var_name: locationService
test_class.declarator: coordinates = Coordinates.valueOf(0.0, 1.0)
test_class.modifier: private final
test_class.original_string: private final Coordinates coordinates = Coordinates.valueOf(0.0, 1.0);
test_class.type: Coordinates
test_class.var_name: coordinates
test_class.declarator: location = new Location(1, coordinates)
test_class.modifier: private final
test_class.original_string: private final Location location = new Location(1, coordinates);
test_class.type: Location
test_class.var_name: location
test_class.file: optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/service/location/LocationServiceTest.java
test_class.identifier: LocationServiceTest
test_case.body: @Test
      void removing_depot_should_be_successful_when_it_is_the_last_location() {
          when(repository.locations()).thenReturn(Collections.singletonList(location));
          when(repository.find(location.id())).thenReturn(Optional.of(location));
  
          locationService.removeLocation(location.id());
  
          verify(repository).removeLocation(location.id());
          verify(optimizer).removeLocation(location);
          verifyNoInteractions(eventPublisher);
          // TODO remove location from distance matrix
      }
test_case.class_method_signature: LocationServiceTest.removing_depot_should_be_successful_when_it_is_the_last_location()
test_case.full_signature: @Test void removing_depot_should_be_successful_when_it_is_the_last_location()
test_case.identifier: removing_depot_should_be_successful_when_it_is_the_last_location
test_case.invocations: thenReturn when locations singletonList thenReturn when find id of removeLocation id removeLocation verify id removeLocation verify verifyNoInteractions
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void removing_depot_should_be_successful_when_it_is_the_last_location()
focal_class.declarator: logger = LoggerFactory.getLogger(LocationService.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(LocationService.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: repository
focal_class.modifier: private final
focal_class.original_string: private final LocationRepository repository;
focal_class.type: LocationRepository
focal_class.var_name: repository
focal_class.declarator: optimizer
focal_class.modifier: private final
focal_class.original_string: private final RouteOptimizer optimizer;
focal_class.type: RouteOptimizer
focal_class.var_name: optimizer
focal_class.declarator: distanceMatrix
focal_class.modifier: private final
focal_class.original_string: private final DistanceMatrix distanceMatrix;
focal_class.type: DistanceMatrix
focal_class.var_name: distanceMatrix
focal_class.declarator: eventPublisher
focal_class.modifier: private final
focal_class.original_string: private final ApplicationEventPublisher eventPublisher;
focal_class.type: ApplicationEventPublisher
focal_class.var_name: eventPublisher
focal_class.file: optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/service/location/LocationService.java
focal_class.identifier: LocationService
focal_class.class_method_signature: LocationService.LocationService(
              LocationRepository repository,
              RouteOptimizer optimizer,
              DistanceMatrix distanceMatrix,
              ApplicationEventPublisher eventPublisher)
focal_class.full_signature: @Autowired  LocationService(
              LocationRepository repository,
              RouteOptimizer optimizer,
              DistanceMatrix distanceMatrix,
              ApplicationEventPublisher eventPublisher)
focal_class.identifier: LocationService
focal_class.modifiers: @Autowired
focal_class.parameters: (
              LocationRepository repository,
              RouteOptimizer optimizer,
              DistanceMatrix distanceMatrix,
              ApplicationEventPublisher eventPublisher)
focal_class.signature:  LocationService(
              LocationRepository repository,
              RouteOptimizer optimizer,
              DistanceMatrix distanceMatrix,
              ApplicationEventPublisher eventPublisher)
focal_class.class_method_signature: LocationService.createLocation(Coordinates coordinates, String description)
focal_class.full_signature: public synchronized boolean createLocation(Coordinates coordinates, String description)
focal_class.identifier: createLocation
focal_class.modifiers: public synchronized
focal_class.parameters: (Coordinates coordinates, String description)
focal_class.return: boolean
focal_class.signature: boolean createLocation(Coordinates coordinates, String description)
focal_class.class_method_signature: LocationService.addLocation(Location location)
focal_class.full_signature: public synchronized boolean addLocation(Location location)
focal_class.identifier: addLocation
focal_class.modifiers: public synchronized
focal_class.parameters: (Location location)
focal_class.return: boolean
focal_class.signature: boolean addLocation(Location location)
focal_class.class_method_signature: LocationService.submitToPlanner(Location location)
focal_class.full_signature: private boolean submitToPlanner(Location location)
focal_class.identifier: submitToPlanner
focal_class.modifiers: private
focal_class.parameters: (Location location)
focal_class.return: boolean
focal_class.signature: boolean submitToPlanner(Location location)
focal_class.class_method_signature: LocationService.removeLocation(long id)
focal_class.full_signature: public synchronized void removeLocation(long id)
focal_class.identifier: removeLocation
focal_class.modifiers: public synchronized
focal_class.parameters: (long id)
focal_class.return: void
focal_class.signature: void removeLocation(long id)
focal_class.class_method_signature: LocationService.removeAll()
focal_class.full_signature: public synchronized void removeAll()
focal_class.identifier: removeAll
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void removeAll()
focal_method.body: public synchronized void removeLocation(long id) {
          Optional<Location> optionalLocation = repository.find(id);
          if (!optionalLocation.isPresent()) {
              eventPublisher.publishEvent(
                      new ErrorEvent(this, "Location [" + id + "] cannot be removed because it doesn't exist."));
              return;
          }
          Location removedLocation = optionalLocation.get();
          List<Location> locations = repository.locations();
          if (locations.size() > 1) {
              Location depot = locations.stream()
                      .min(comparingLong(Location::id))
                      .orElseThrow(() -> new IllegalStateException(
                              "Impossible. Locations have size (" + locations.size() + ") but the stream is empty."));
              if (removedLocation.equals(depot)) {
                  eventPublisher.publishEvent(
                          new ErrorEvent(this, "You can only remove depot if there are no visits."));
                  return;
              }
          }
  
          optimizer.removeLocation(removedLocation);
          repository.removeLocation(id);
          distanceMatrix.removeLocation(removedLocation);
      }
focal_method.class_method_signature: LocationService.removeLocation(long id)
focal_method.full_signature: public synchronized void removeLocation(long id)
focal_method.identifier: removeLocation
focal_method.invocations: find isPresent publishEvent get locations size orElseThrow min stream comparingLong size equals publishEvent removeLocation removeLocation removeLocation
focal_method.modifiers: public synchronized
focal_method.parameters: (long id)
focal_method.return: void
focal_method.signature: void removeLocation(long id)