test_class.declarator: crudRepository
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private VehicleCrudRepository crudRepository;
test_class.type: VehicleCrudRepository
test_class.var_name: crudRepository
test_class.declarator: repository
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private VehicleRepositoryImpl repository;
test_class.type: VehicleRepositoryImpl
test_class.var_name: repository
test_class.declarator: vehicleEntityCaptor
test_class.modifier: @Captor
      private
test_class.original_string: @Captor
      private ArgumentCaptor<VehicleEntity> vehicleEntityCaptor;
test_class.type: ArgumentCaptor<VehicleEntity>
test_class.var_name: vehicleEntityCaptor
test_class.declarator: testVehicle = VehicleFactory.createVehicle(19, "vehicle name", 1100)
test_class.modifier: private final
test_class.original_string: private final Vehicle testVehicle = VehicleFactory.createVehicle(19, "vehicle name", 1100);
test_class.type: Vehicle
test_class.var_name: testVehicle
test_class.file: optaweb-vehicle-routing-backend/src/test/java/org/optaweb/vehiclerouting/plugin/persistence/VehicleRepositoryImplTest.java
test_class.identifier: VehicleRepositoryImplTest
test_case.body: @Test
      void should_create_vehicle_and_generate_id_and_name() {
          // arrange
          VehicleEntity newEntity = vehicleEntity(testVehicle);
          when(crudRepository.save(vehicleEntityCaptor.capture())).thenReturn(newEntity);
          int savedCapacity = 1;
  
          // act
          Vehicle newVehicle = repository.createVehicle(savedCapacity);
  
          // assert
          // -- the correct values were used to save the entity
          List<VehicleEntity> savedVehicles = vehicleEntityCaptor.getAllValues();
          assertThat(savedVehicles).hasSize(2);
  
          assertThat(savedVehicles.get(0).getName()).isNull();
          assertThat(savedVehicles.get(0).getCapacity()).isEqualTo(savedCapacity);
          assertThat(savedVehicles.get(1).getName()).isEqualTo("Vehicle " + newEntity.getId());
          assertThat(savedVehicles.get(1).getCapacity()).isEqualTo(savedCapacity);
  
          // -- created domain vehicle is equal to the entity returned by repository.save()
          // This may be confusing but that's the contract of Spring Repository API.
          // The entity instance that is being saved is meant to be discarded. The returned instance should be used
          // for further operations as the save() operation may update it (for example generate the ID).
          assertThat(newVehicle.id()).isEqualTo(newEntity.getId());
          assertThat(newVehicle.name()).isEqualTo(newEntity.getName());
          assertThat(newVehicle.capacity()).isEqualTo(newEntity.getCapacity());
      }
test_case.class_method_signature: VehicleRepositoryImplTest.should_create_vehicle_and_generate_id_and_name()
test_case.full_signature: @Test void should_create_vehicle_and_generate_id_and_name()
test_case.identifier: should_create_vehicle_and_generate_id_and_name
test_case.invocations: vehicleEntity thenReturn when save capture createVehicle getAllValues hasSize assertThat isNull assertThat getName get isEqualTo assertThat getCapacity get isEqualTo assertThat getName get getId isEqualTo assertThat getCapacity get isEqualTo assertThat id getId isEqualTo assertThat name getName isEqualTo assertThat capacity getCapacity
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void should_create_vehicle_and_generate_id_and_name()
focal_class.declarator: logger = LoggerFactory.getLogger(VehicleRepositoryImpl.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(VehicleRepositoryImpl.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 VehicleCrudRepository repository;
focal_class.type: VehicleCrudRepository
focal_class.var_name: repository
focal_class.file: optaweb-vehicle-routing-backend/src/main/java/org/optaweb/vehiclerouting/plugin/persistence/VehicleRepositoryImpl.java
focal_class.identifier: VehicleRepositoryImpl
focal_class.interfaces: implements VehicleRepository
focal_class.class_method_signature: VehicleRepositoryImpl.VehicleRepositoryImpl(VehicleCrudRepository repository)
focal_class.full_signature: public  VehicleRepositoryImpl(VehicleCrudRepository repository)
focal_class.identifier: VehicleRepositoryImpl
focal_class.modifiers: public
focal_class.parameters: (VehicleCrudRepository repository)
focal_class.signature:  VehicleRepositoryImpl(VehicleCrudRepository repository)
focal_class.class_method_signature: VehicleRepositoryImpl.createVehicle(int capacity)
focal_class.full_signature: @Override public Vehicle createVehicle(int capacity)
focal_class.identifier: createVehicle
focal_class.modifiers: @Override public
focal_class.parameters: (int capacity)
focal_class.return: Vehicle
focal_class.signature: Vehicle createVehicle(int capacity)
focal_class.class_method_signature: VehicleRepositoryImpl.createVehicle(VehicleData vehicleData)
focal_class.full_signature: @Override public Vehicle createVehicle(VehicleData vehicleData)
focal_class.identifier: createVehicle
focal_class.modifiers: @Override public
focal_class.parameters: (VehicleData vehicleData)
focal_class.return: Vehicle
focal_class.signature: Vehicle createVehicle(VehicleData vehicleData)
focal_class.class_method_signature: VehicleRepositoryImpl.vehicles()
focal_class.full_signature: @Override public List<Vehicle> vehicles()
focal_class.identifier: vehicles
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Vehicle>
focal_class.signature: List<Vehicle> vehicles()
focal_class.class_method_signature: VehicleRepositoryImpl.removeVehicle(long id)
focal_class.full_signature: @Override public Vehicle removeVehicle(long id)
focal_class.identifier: removeVehicle
focal_class.modifiers: @Override public
focal_class.parameters: (long id)
focal_class.return: Vehicle
focal_class.signature: Vehicle removeVehicle(long id)
focal_class.class_method_signature: VehicleRepositoryImpl.removeAll()
focal_class.full_signature: @Override public void removeAll()
focal_class.identifier: removeAll
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void removeAll()
focal_class.class_method_signature: VehicleRepositoryImpl.find(long vehicleId)
focal_class.full_signature: @Override public Optional<Vehicle> find(long vehicleId)
focal_class.identifier: find
focal_class.modifiers: @Override public
focal_class.parameters: (long vehicleId)
focal_class.return: Optional<Vehicle>
focal_class.signature: Optional<Vehicle> find(long vehicleId)
focal_class.class_method_signature: VehicleRepositoryImpl.update(Vehicle vehicle)
focal_class.full_signature: @Override public void update(Vehicle vehicle)
focal_class.identifier: update
focal_class.modifiers: @Override public
focal_class.parameters: (Vehicle vehicle)
focal_class.return: void
focal_class.signature: void update(Vehicle vehicle)
focal_class.class_method_signature: VehicleRepositoryImpl.toDomain(VehicleEntity vehicleEntity)
focal_class.full_signature: private static Vehicle toDomain(VehicleEntity vehicleEntity)
focal_class.identifier: toDomain
focal_class.modifiers: private static
focal_class.parameters: (VehicleEntity vehicleEntity)
focal_class.return: Vehicle
focal_class.signature: Vehicle toDomain(VehicleEntity vehicleEntity)
focal_method.body: @Override
      public Vehicle createVehicle(int capacity) {
          long id = repository.save(new VehicleEntity(0, null, capacity)).getId();
          VehicleEntity vehicleEntity = repository.save(new VehicleEntity(id, "Vehicle " + id, capacity));
          Vehicle vehicle = toDomain(vehicleEntity);
          logger.info("Created vehicle {}.", vehicle);
          return vehicle;
      }
focal_method.class_method_signature: VehicleRepositoryImpl.createVehicle(int capacity)
focal_method.full_signature: @Override public Vehicle createVehicle(int capacity)
focal_method.identifier: createVehicle
focal_method.invocations: getId save save toDomain info
focal_method.modifiers: @Override public
focal_method.parameters: (int capacity)
focal_method.return: Vehicle
focal_method.signature: Vehicle createVehicle(int capacity)