test_class.declarator: scoreDirector
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ScoreDirector<VehicleRoutingSolution> scoreDirector;
test_class.type: ScoreDirector<VehicleRoutingSolution>
test_class.var_name: scoreDirector
test_class.file: optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/planner/change/RemoveVehicleTest.java
test_class.identifier: RemoveVehicleTest
test_case.body: @Test
      void remove_vehicle() {
          PlanningVehicle removedVehicle = PlanningVehicleFactory.testVehicle(1);
          PlanningVehicle otherVehicle = PlanningVehicleFactory.testVehicle(2);
  
          PlanningDepot depot = new PlanningDepot(PlanningLocationFactory.testLocation(1));
  
          PlanningVisit firstVisit = testVisit(1);
          PlanningVisit lastVisit = testVisit(2);
  
          VehicleRoutingSolution solution = SolutionFactory.solutionFromVisits(
                  Arrays.asList(removedVehicle, otherVehicle),
                  depot,
                  Arrays.asList(firstVisit, lastVisit));
  
          when(scoreDirector.getWorkingSolution()).thenReturn(solution);
          when(scoreDirector.lookUpWorkingObject(removedVehicle)).thenReturn(removedVehicle);
  
          // V -> first -> last
          removedVehicle.setNextVisit(firstVisit);
          firstVisit.setPreviousStandstill(removedVehicle);
          firstVisit.setVehicle(removedVehicle);
          firstVisit.setNextVisit(lastVisit);
          lastVisit.setPreviousStandstill(firstVisit);
          lastVisit.setVehicle(removedVehicle);
  
          // do change
          RemoveVehicle removeVehicle = new RemoveVehicle(removedVehicle);
          removeVehicle.doChange(scoreDirector);
  
          assertThat(firstVisit.getPreviousStandstill()).isNull();
          assertThat(lastVisit.getPreviousStandstill()).isNull();
          assertThat(solution.getVehicleList()).containsExactly(otherVehicle);
  
          verify(scoreDirector).beforeVariableChanged(firstVisit, "previousStandstill");
          verify(scoreDirector).afterVariableChanged(firstVisit, "previousStandstill");
          verify(scoreDirector).beforeVariableChanged(lastVisit, "previousStandstill");
          verify(scoreDirector).afterVariableChanged(lastVisit, "previousStandstill");
          verify(scoreDirector).beforeProblemFactRemoved(removedVehicle);
          verify(scoreDirector).afterProblemFactRemoved(removedVehicle);
          verify(scoreDirector).triggerVariableListeners();
      }
test_case.class_method_signature: RemoveVehicleTest.remove_vehicle()
test_case.full_signature: @Test void remove_vehicle()
test_case.identifier: remove_vehicle
test_case.invocations: testVehicle testVehicle testLocation testVisit testVisit solutionFromVisits asList asList thenReturn when getWorkingSolution thenReturn when lookUpWorkingObject setNextVisit setPreviousStandstill setVehicle setNextVisit setPreviousStandstill setVehicle doChange isNull assertThat getPreviousStandstill isNull assertThat getPreviousStandstill containsExactly assertThat getVehicleList beforeVariableChanged verify afterVariableChanged verify beforeVariableChanged verify afterVariableChanged verify beforeProblemFactRemoved verify afterProblemFactRemoved verify triggerVariableListeners verify
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void remove_vehicle()
focal_class.declarator: removedVehicle
focal_class.modifier: private final
focal_class.original_string: private final PlanningVehicle removedVehicle;
focal_class.type: PlanningVehicle
focal_class.var_name: removedVehicle
focal_class.file: optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/planner/change/RemoveVehicle.java
focal_class.identifier: RemoveVehicle
focal_class.interfaces: implements ProblemFactChange<VehicleRoutingSolution>
focal_class.class_method_signature: RemoveVehicle.RemoveVehicle(PlanningVehicle removedVehicle)
focal_class.full_signature: public  RemoveVehicle(PlanningVehicle removedVehicle)
focal_class.identifier: RemoveVehicle
focal_class.modifiers: public
focal_class.parameters: (PlanningVehicle removedVehicle)
focal_class.signature:  RemoveVehicle(PlanningVehicle removedVehicle)
focal_class.class_method_signature: RemoveVehicle.doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_class.full_signature: @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_class.identifier: doChange
focal_class.modifiers: @Override public
focal_class.parameters: (ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_class.return: void
focal_class.signature: void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_method.body: @Override
      public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) {
          VehicleRoutingSolution workingSolution = scoreDirector.getWorkingSolution();
  
          // Look up a working copy of the vehicle
          PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(removedVehicle);
          if (workingVehicle == null) {
              throw new IllegalStateException("Can't look up a working copy of " + removedVehicle);
          }
  
          // Un-initialize all visits of this vehicle
          for (PlanningVisit visit : workingVehicle.getFutureVisits()) {
              scoreDirector.beforeVariableChanged(visit, "previousStandstill");
              visit.setPreviousStandstill(null);
              scoreDirector.afterVariableChanged(visit, "previousStandstill");
          }
  
          // No need to clone the vehicleList because it is a planning entity collection, so it is already
          // planning-cloned.
          // To learn more about problem fact changes, see:
          // https://docs.jboss.org/optaplanner/release/latest/optaplanner-docs/html_single/#problemFactChangeExample
  
          // Remove the vehicle
          scoreDirector.beforeProblemFactRemoved(workingVehicle);
          if (!workingSolution.getVehicleList().remove(workingVehicle)) {
              throw new IllegalStateException(
                      "Working solution's vehicleList "
                              + workingSolution.getVehicleList()
                              + " doesn't contain the workingVehicle ("
                              + workingVehicle
                              + "). This is a bug!");
          }
          scoreDirector.afterProblemFactRemoved(workingVehicle);
  
          scoreDirector.triggerVariableListeners();
      }
focal_method.class_method_signature: RemoveVehicle.doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_method.full_signature: @Override public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_method.identifier: doChange
focal_method.invocations: getWorkingSolution lookUpWorkingObject getFutureVisits beforeVariableChanged setPreviousStandstill afterVariableChanged beforeProblemFactRemoved remove getVehicleList getVehicleList afterProblemFactRemoved triggerVariableListeners
focal_method.modifiers: @Override public
focal_method.parameters: (ScoreDirector<VehicleRoutingSolution> scoreDirector)
focal_method.return: void
focal_method.signature: void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector)