Repository: GreenEV-TQS24-25/backend
Pull request #8: Green 69 vehicle api
Author: login: VioletaR
Created: 2025-05-18T18:34:52Z | Merged: 2025-05-18T18:39:21Z



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added REST API endpoints for managing vehicles, including creating, updating, retrieving, and deleting vehicles for authenticated users.

- **Tests**
  - Introduced comprehensive tests for vehicle management API endpoints and service logic to ensure correct behavior and error handling.

- **Style**
  - Minor formatting improvement in the charging station controller for code readability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/src/main/java/ua/deti/tqs/controllers/ChargingStationController.java b/src/main/java/ua/deti/tqs/controllers/ChargingStationController.java
index b2d0547..cfa440c 100644
--- a/src/main/java/ua/deti/tqs/controllers/ChargingStationController.java
+++ b/src/main/java/ua/deti/tqs/controllers/ChargingStationController.java
@@ -23,6 +23,7 @@
 public class ChargingStationController {
   private static final String PUB_BASE_PATH = "public/charging-stations";
   private static final String PRIV_BASE_PATH = "private/charging-stations";
+
   private final ChargingStationService chargingStationService;
 
   @GetMapping(PUB_BASE_PATH + "/all")
diff --git a/src/main/java/ua/deti/tqs/controllers/VehicleController.java b/src/main/java/ua/deti/tqs/controllers/VehicleController.java
new file mode 100644
index 0000000..de6eb6f
--- /dev/null
+++ b/src/main/java/ua/deti/tqs/controllers/VehicleController.java
@@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(@RequestBody Vehicle vehicle) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Creating new vehicle {}", vehicle);
+
+        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);
+
+        if (newVehicle == null) {
+            log.warn("No vehicle found for the user with id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle created successfully");
+        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
+    }
+
+    @PutMapping()
+    @Operation(summary = "Update a Vehicle", description = "Updates a vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle updated successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> updateVehicle(Vehicle vehicle) {
+        log.info("Updating vehicle {}", vehicle);
+        int userId = getAuthenticatedUser().getId();
+        Vehicle updatedVehicle = vehicleService.updateVehicle(userId, vehicle);
+        if (updatedVehicle == null) {
+            log.warn("No vehicle found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle updated successfully");
+        return new ResponseEntity<>(updatedVehicle, HttpStatus.OK);
+    }
+
+    @DeleteMapping("/{vehicleId}")
+    @Operation(summary = "Delete a Vehicle", description = "Deletes a vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle deleted successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Void> deleteVehicle(@PathVariable("vehicleId") int vehicleId) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Deleting vehicle with id {}", vehicleId);
+
+        if (vehicleService.deleteVehicle(userId, vehicleId)) {
+            log.info("Vehicle deleted successfully");
+            return new ResponseEntity<>(HttpStatus.OK);
+        }
+        log.warn("No vehicle found with id {}", vehicleId);
+        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+    }
+
+}
diff --git a/src/main/java/ua/deti/tqs/repositories/VehicleRepository.java b/src/main/java/ua/deti/tqs/repositories/VehicleRepository.java
new file mode 100644
index 0000000..2f41f48
--- /dev/null
+++ b/src/main/java/ua/deti/tqs/repositories/VehicleRepository.java
@@ -0,0 +1,12 @@
+package ua.deti.tqs.repositories;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import ua.deti.tqs.entities.Vehicle;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface VehicleRepository extends JpaRepository<Vehicle, Integer> {
+    Optional<List<Vehicle>> findAllByUser_Id(int userId);
+
+}
\ No newline at end of file
diff --git a/src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java b/src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java
new file mode 100644
index 0000000..c9bac8f
--- /dev/null
+++ b/src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java
@@ -0,0 +1,118 @@
+package ua.deti.tqs.services;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.repositories.VehicleRepository;
+import ua.deti.tqs.services.interfaces.VehicleService;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@AllArgsConstructor
+public class VehicleServiceImpl implements VehicleService {
+     private final VehicleRepository vehicleRepository;
+    @Override
+    public List<Vehicle> getAllVehiclesByUserId(int userId) {
+        log.debug("Fetching all vehicles with user id {}", userId);
+        List<Vehicle> vehicles = vehicleRepository
+                .findAllByUser_Id(userId)
+                .orElse(null);
+
+        if (vehicles == null) {
+            log.debug("No vehicles found with user id {}", userId);
+            return List.of();
+        }
+
+        log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
+        return vehicles;
+    }
+
+    @Override
+    public Vehicle createVehicle(Vehicle vehicle, int userId) {
+        log.debug("Creating new vehicle {}", vehicle);
+
+        int errorCount = 0;
+        if (vehicle.getBrand() == null || vehicle.getBrand().isEmpty()) {
+            log.debug("Invalid vehicle brand, brand is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getModel() == null || vehicle.getModel().isEmpty()) {
+            log.debug("Invalid vehicle model, model is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getLicensePlate() == null || vehicle.getLicensePlate().isEmpty()) {
+            log.debug("Invalid vehicle license plate, license plate is null or empty");
+            errorCount++;
+        }
+
+        if (errorCount > 0) return null;
+
+
+        Vehicle newVehicle = new Vehicle();
+        newVehicle.setUser(vehicle.getUser());
+        newVehicle.setBrand(vehicle.getBrand());
+        newVehicle.setModel(vehicle.getModel());
+        newVehicle.setLicensePlate(vehicle.getLicensePlate());
+
+        if (vehicle.getConnectorType() != null)
+            newVehicle.setConnectorType(vehicle.getConnectorType());
+
+        log.debug("Saving new vehicle {}", newVehicle);
+        return vehicleRepository.save(newVehicle);
+    }
+
+    @Override
+    public Vehicle updateVehicle(int userId, Vehicle vehicle) {
+        log.debug("Updating vehicle with id {} and user id {}", vehicle.getId(), userId);
+        Vehicle existingVehicle = vehicleRepository.findById(vehicle.getId()).orElse(null);
+
+        if (existingVehicle == null) {
+            log.debug("Vehicle not found");
+            return null;
+        }
+
+        if (existingVehicle.getUser().getId() != userId) {
+            log.debug("Vehicle with id {} does not belong to user with id {}", vehicle.getId(), userId);
+            return null;
+        }
+
+        if (vehicle.getBrand() != null && !vehicle.getBrand().isEmpty()) {
+            existingVehicle.setBrand(vehicle.getBrand());
+        }
+        if (vehicle.getModel() != null && !vehicle.getModel().isEmpty()) {
+            existingVehicle.setModel(vehicle.getModel());
+        }
+        if (vehicle.getLicensePlate() != null && !vehicle.getLicensePlate().isEmpty()) {
+            existingVehicle.setLicensePlate(vehicle.getLicensePlate());
+        }
+        if (vehicle.getConnectorType() != null) {
+            existingVehicle.setConnectorType(vehicle.getConnectorType());
+        }
+
+        log.debug("Saving updated vehicle {}", existingVehicle);
+        return vehicleRepository.save(existingVehicle);
+    }
+
+    @Override
+    public boolean deleteVehicle(int id, int userId) {
+        log.debug("Deleting vehicle with id {} and user id {}", id, userId);
+        Vehicle vehicle = vehicleRepository.findById(id).orElse(null);
+
+        if (vehicle == null) {
+            log.debug("No vehicle found with id {} and user id {}", id, userId);
+            return false;
+        }
+
+        if (vehicle.getUser().getId() != userId) {
+            log.debug("The user with id {}, is not the owner", userId);
+            return false;
+        }
+
+        vehicleRepository.delete(vehicle);
+        log.debug("Deleted vehicle with id {} and user id {}", id, userId);
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java b/src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java
new file mode 100644
index 0000000..3696e83
--- /dev/null
+++ b/src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java
@@ -0,0 +1,15 @@
+package ua.deti.tqs.services.interfaces;
+
+import ua.deti.tqs.entities.Vehicle;
+
+import java.util.List;
+
+public interface VehicleService {
+    List<Vehicle> getAllVehiclesByUserId(int userId);
+
+    Vehicle createVehicle(Vehicle vehicle, int userId);
+
+    Vehicle updateVehicle(int userId, Vehicle vehicle);
+
+    boolean deleteVehicle(int id, int userId);
+}
diff --git a/src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java b/src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java
new file mode 100644
index 0000000..a75bbce
--- /dev/null
+++ b/src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java
@@ -0,0 +1,188 @@
+package ua.deti.tqs.controllers;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.test.web.servlet.MockMvc;
+import ua.deti.tqs.components.AuthTokenFilter;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.services.interfaces.UserService;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+import ua.deti.tqs.utils.SecurityUtils;
+
+@ActiveProfiles("test")
+@WebMvcTest(VehicleController.class)
+@AutoConfigureMockMvc(addFilters = false)
+class VehicleControllerTest {
+
+    @Autowired
+    private MockMvc mockMvc;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @MockitoBean
+    private VehicleService vehicleService;
+
+    @MockitoBean
+    private AuthTokenFilter authTokenFilter;
+
+    @MockitoBean
+    private UserService userService;
+
+    private MockedStatic<SecurityUtils> securityUtils;
+
+    private Vehicle testVehicle;
+    private List<Vehicle> testVehicles;
+    private User testUser;
+
+    @BeforeEach
+    void setUp() {
+        testUser = new User();
+        testUser.setId(1);
+        testUser.setName("Test User");
+        testUser.setEmail("test@example.com");
+        testUser.setPassword("password");
+        testUser.setRole(Role.USER);
+
+        testVehicle = new Vehicle();
+        testVehicle.setId(1);
+        testVehicle.setLicensePlate("AB-12-CD");
+        testVehicle.setBrand("Tesla");
+        testVehicle.setModel("Model 3");
+        testVehicle.setUser(testUser);
+
+        Vehicle testVehicle2 = new Vehicle();
+        testVehicle2.setId(2);
+        testVehicle2.setLicensePlate("EF-34-GH");
+        testVehicle2.setBrand("Nissan");
+        testVehicle2.setModel("Leaf");
+        testVehicle2.setUser(testUser);
+
+        testVehicles = Arrays.asList(testVehicle, testVehicle2);
+
+        securityUtils = mockStatic(SecurityUtils.class);
+        securityUtils.when(SecurityUtils::getAuthenticatedUser).thenReturn(testUser);
+    }
+
+    @AfterEach
+    void tearDown() {
+        securityUtils.close();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnAllVehicles() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(testVehicles);
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$", hasSize(2)))
+                .andExpect(jsonPath("$[0].licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNotFound() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(Collections.emptyList());
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isNotFound());
+    }
+
+    @Test
+    void whenCreateValidVehicle_thenReturnCreatedVehicle() throws Exception {
+        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
+                .thenReturn(testVehicle);
+
+        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(testVehicle)))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenCreateInvalidVehicle_thenReturnBadRequest() throws Exception {
+        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
+                .thenReturn(null);
+
+        Vehicle invalidVehicle = new Vehicle();
+        invalidVehicle.setLicensePlate(""); // Invalid license plate
+
+        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(invalidVehicle)))
+                .andExpect(status().isNotFound());
+    }
+
+    @Test
+    void whenUpdateValidVehicle_thenReturnUpdatedVehicle() throws Exception {
+        when(vehicleService.updateVehicle(eq(testUser.getId()), any(Vehicle.class)))
+                .thenReturn(testVehicle);
+
+        mockMvc.perform(put("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(testVehicle)))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenUpdateInvalidVehicle_thenReturnNotFound() throws Exception {
+        when(vehicleService.updateVehicle(eq(testUser.getId()), any(Vehicle.class)))
+                .thenReturn(null);
+
+        Vehicle invalidVehicle = new Vehicle();
+        invalidVehicle.setLicensePlate(""); // Invalid license plate
+
+        mockMvc.perform(put("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(invalidVehicle)))
+                .andExpect(status().isNotFound());
+    }
+
+    @Test
+    void whenDeleteExistingVehicle_thenReturnOk() throws Exception {
+        int vehicleId = 1;
+        when(vehicleService.deleteVehicle(vehicleId, testUser.getId())).thenReturn(true);
+
+        mockMvc.perform(delete("/" + Constants.API_V1 + "private/vehicles/" + vehicleId)
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk());
+    }
+
+    @Test
+    void whenDeleteNonExistingVehicle_thenReturnNotFound() throws Exception {
+        int vehicleId = 99;
+        when(vehicleService.deleteVehicle(vehicleId, testUser.getId())).thenReturn(false);
+
+        mockMvc.perform(delete("/" + Constants.API_V1 + "private/vehicles/" + vehicleId)
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isNotFound());
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/ua/deti/tqs/services/VehicleServiceTest.java b/src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
new file mode 100644
index 0000000..eafb6bb
--- /dev/null
+++ b/src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
@@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenDeleteVehicle_thenReturnTrue() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isTrue();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidUser_thenReturnFalse() {
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isFalse();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidVehicle_thenReturnFalse() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.empty());
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isFalse();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidUserId_thenReturnFalse() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(vehicle.getId(),2);
+
+        // then
+        assertThat(deleted).isFalse();
+    }
+}


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR implements a new Vehicle API for the "Green 69 vehicle api" project by adding service, controller, repository, and comprehensive test classes.  
- Introduces tests for vehicle operations via VehicleServiceTest and VehicleControllerTest.  
- Implements VehicleService interface and its VehicleServiceImpl while integrating with a JPA repository.  
- Adds a new VehicleController with standard REST endpoints and minor changes in ChargingStationController.

### Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

<details>
<summary>Show a summary per file</summary>

| File | Description |
| ---- | ----------- |
| src/test/java/ua/deti/tqs/services/VehicleServiceTest.java | Added tests for vehicle CRUD operations (naming and method usage inconsistencies noted). |
| src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java | Added tests to exercise REST endpoints for vehicle operations, including cases for valid/invalid vehicles. |
| src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java | Introduces the vehicle service interface with CRUD methods. |
| src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java | Implements vehicle creation, updating, listing, and deletion with basic validation. |
| src/main/java/ua/deti/tqs/repositories/VehicleRepository.java | Provides a repository interface for accessing vehicle data. |
| src/main/java/ua/deti/tqs/controllers/VehicleController.java | Exposes REST endpoints for vehicle operations; note potential improvements in request mapping. |
| src/main/java/ua/deti/tqs/controllers/ChargingStationController.java | Minor update; not directly related to vehicle API changes. |
</details>



<details>
<summary>Comments suppressed due to low confidence (1)</summary>

**src/test/java/ua/deti/tqs/services/VehicleServiceTest.java:32**
* The variable name 'chargingStationService' is misleading in a vehicle API test. Consider renaming it to 'vehicleService' to clearly reflect its purpose.
```
private VehicleServiceImpl chargingStationService;
```
</details>


state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-18T18:35:57Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 23**

<details>
<summary>🧹 Nitpick comments (8)</summary><blockquote>

<details>
<summary>src/main/java/ua/deti/tqs/repositories/VehicleRepository.java (1)</summary><blockquote>

`1-12`: **Consider simplifying the return type for findAllByUser_Id.**

The repository interface is well structured, but consider returning `List<Vehicle>` directly instead of `Optional<List<Vehicle>>`. Spring Data JPA typically returns empty collections rather than Optional-wrapped collections, which simplifies service layer code by eliminating the need to unwrap the Optional.


```diff
-    Optional<List<Vehicle>> findAllByUser_Id(int userId);
+    List<Vehicle> findAllByUser_Id(int userId);
```

</blockquote></details>
<details>
<summary>src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java (2)</summary><blockquote>

`7-15`: **Standardize parameter ordering across methods.**

The parameter ordering is inconsistent. In `createVehicle()`, `userId` is the second parameter, but in `updateVehicle()`, it's the first parameter. Consider standardizing the order for better API consistency and clarity.


```diff
 public interface VehicleService {
     List<Vehicle> getAllVehiclesByUserId(int userId);
 
     Vehicle createVehicle(Vehicle vehicle, int userId);
 
-    Vehicle updateVehicle(int userId, Vehicle vehicle);
+    Vehicle updateVehicle(Vehicle vehicle, int userId);
 
     boolean deleteVehicle(int id, int userId);
 }
```

---

`14-14`: **Enhance method name clarity for deleteVehicle.**

The `deleteVehicle` method returns a boolean, but it's not immediately clear what this boolean represents. Consider a more explicit name like `deleteVehicleIfOwnedByUser` or adding a Javadoc comment to clarify the return value meaning.


```diff
-    boolean deleteVehicle(int id, int userId);
+    /**
+     * Deletes a vehicle if it belongs to the specified user.
+     * @param id The ID of the vehicle to delete
+     * @param userId The ID of the user who must own the vehicle
+     * @return true if the vehicle was found and deleted, false otherwise
+     */
+    boolean deleteVehicle(int id, int userId);
```

</blockquote></details>
<details>
<summary>src/test/java/ua/deti/tqs/services/VehicleServiceTest.java (2)</summary><blockquote>

`183-184`: **Remove unnecessary blank lines.**

For code consistency, remove these consecutive blank lines.


```diff
 vehicle.setLicensePlate(null);
 vehicle.setConnectorType(null);
-

 when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
```

---

`200-201`: **Remove unnecessary blank lines.**

For code consistency, remove these consecutive blank lines.


```diff
 vehicle.setModel("");
 vehicle.setLicensePlate("");
-

 when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
```

</blockquote></details>
<details>
<summary>src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java (1)</summary><blockquote>

`108-115`: **Consider renaming the test method to match the expected status code.**

The test method name `whenGetAllVehiclesByUserId_thenReturnNotFound` correctly reflects the expected outcome, but for consistency, consider naming it to something like `whenGetAllVehiclesByUserIdWithNoVehicles_thenReturnNotFound` to clearly indicate the empty list scenario.

</blockquote></details>
<details>
<summary>src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java (1)</summary><blockquote>

`18-31`: **Simplify the getAllVehiclesByUserId method.**

The method can be simplified by directly returning the result from the repository without the additional null check and empty list creation.

```diff
    public List<Vehicle> getAllVehiclesByUserId(int userId) {
        log.debug("Fetching all vehicles with user id {}", userId);
        List<Vehicle> vehicles = vehicleRepository
                .findAllByUser_Id(userId)
-                .orElse(null);
-
-        if (vehicles == null) {
-            log.debug("No vehicles found with user id {}", userId);
-            return List.of();
-        }
+                .orElse(List.of());

+        if (vehicles.isEmpty()) {
+            log.debug("No vehicles found with user id {}", userId);
+        } else {
+            log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
+        }
-        log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
        return vehicles;
    }
```

</blockquote></details>
<details>
<summary>src/main/java/ua/deti/tqs/controllers/VehicleController.java (1)</summary><blockquote>

`31-43`: **Consider using 204 No Content instead of 404 for empty lists.**

It's a common REST API practice to return a 204 No Content or an empty list with 200 OK when no items are found, rather than a 404 Not Found. This approach is more consistent with REST principles for collection endpoints.

```diff
    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
        int userId = getAuthenticatedUser().getId();
        log.info("Fetching all vehicles with user id {}", userId);

        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);

        if (vehicles.isEmpty()) {
            log.warn("No vehicles found with user id {}", userId);
-            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+            return new ResponseEntity<>(vehicles, HttpStatus.OK);
+            // or return new ResponseEntity<>(HttpStatus.NO_CONTENT);
        }
        log.info("Vehicles retrieved successfully");
        return new ResponseEntity<>(vehicles, HttpStatus.OK);
    }
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**
**Cache: Disabled due to data retention organization setting**
**Knowledge Base: Disabled due to data retention organization setting**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 9ac184e689c4f16b1dde6460018e3758ec8c3b09 and 5beb3c89ab5f9dc036216c92c94aee76bd39dfb2.

</details>

<details>
<summary>📒 Files selected for processing (7)</summary>

* `src/main/java/ua/deti/tqs/controllers/ChargingStationController.java` (1 hunks)
* `src/main/java/ua/deti/tqs/controllers/VehicleController.java` (1 hunks)
* `src/main/java/ua/deti/tqs/repositories/VehicleRepository.java` (1 hunks)
* `src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java` (1 hunks)
* `src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java` (1 hunks)
* `src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java` (1 hunks)
* `src/test/java/ua/deti/tqs/services/VehicleServiceTest.java` (1 hunks)

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>src/main/java/ua/deti/tqs/controllers/ChargingStationController.java (1)</summary>

`26-26`: **LGTM: Formatting change adds clarity.**

This is a simple formatting change that improves code readability by adding a consistent blank line after the constant declarations and before the service field.

</details>
<details>
<summary>src/test/java/ua/deti/tqs/services/VehicleServiceTest.java (1)</summary>

`249-249`: _⚠️ Potential issue_

**Fix parameter order in deleteVehicle call.**

The parameter order seems incorrect here. According to the interface, the first parameter should be the vehicle ID and the second parameter should be the user ID. Currently, it appears to be passing vehicle.getId() as the userId and 2 as the vehicleId.


```diff
-boolean deleted = chargingStationService.deleteVehicle(vehicle.getId(),2);
+boolean deleted = vehicleService.deleteVehicle(2, vehicle.getId());
```



> Likely an incorrect or invalid review comment.

</details>
<details>
<summary>src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java (1)</summary>

`40-96`: **Comprehensive test setup with good use of mocking.**

The test class is well structured with proper setup of mocked dependencies and test data. The use of `MockedStatic` for SecurityUtils is a good approach to simulate the authenticated user context.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-18T18:38:13Z
user: login: andreribeiro87
body: perfeito
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-18T18:39:02Z

Review comments:
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: Copilot
body: List does not have a 'getFirst()' method; use 'get(0)' instead to access the first element.
```suggestion
        assertThat(found.get(0).getId()).isEqualTo(1);
```
created_at: 2025-05-18T18:35:56Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,118 @@
+package ua.deti.tqs.services;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.repositories.VehicleRepository;
+import ua.deti.tqs.services.interfaces.VehicleService;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@AllArgsConstructor
+public class VehicleServiceImpl implements VehicleService {
+     private final VehicleRepository vehicleRepository;
+    @Override
+    public List<Vehicle> getAllVehiclesByUserId(int userId) {
+        log.debug("Fetching all vehicles with user id {}", userId);
+        List<Vehicle> vehicles = vehicleRepository
+                .findAllByUser_Id(userId)
+                .orElse(null);
+
+        if (vehicles == null) {
+            log.debug("No vehicles found with user id {}", userId);
+            return List.of();
+        }
+
+        log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
+        return vehicles;
+    }
+
+    @Override
+    public Vehicle createVehicle(Vehicle vehicle, int userId) {
path: src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java
user: login: Copilot
body: The createVehicle method does not validate if the provided userId is associated with a valid user. If the intended behavior is to return null for an invalid user, add a check to verify the user’s validity before saving the vehicle.
created_at: 2025-05-18T18:35:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
path: src/main/java/ua/deti/tqs/controllers/VehicleController.java
user: login: Copilot
body: Consider annotating the 'vehicle' parameter with @RequestBody to ensure proper JSON deserialization.
```suggestion
    public ResponseEntity<Vehicle> createVehicle(@RequestBody Vehicle vehicle) {
```
created_at: 2025-05-18T18:35:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Creating new vehicle {}", vehicle);
+
+        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);
+
+        if (newVehicle == null) {
path: src/main/java/ua/deti/tqs/controllers/VehicleController.java
user: login: Copilot
body: [nitpick] Returning a 404 status for an invalid vehicle creation may not be semantically accurate; consider using 400 BAD REQUEST to better indicate that the input data is incorrect.
created_at: 2025-05-18T18:35:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenDeleteVehicle_thenReturnTrue() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isTrue();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidUser_thenReturnFalse() {
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 225, the
service field name used to call deleteVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+Vehicle updated = vehicleService.updateVehicle(4, vehicle);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle updated = vehicleService.updateVehicle(4, vehicle);
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 160, the
service field name used to call updateVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 204, the
service field name used to call updateVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid and matches the current
class fields.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 187, the
service field name used to call updateVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid and references the right
service instance.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenDeleteVehicle_thenReturnTrue() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isTrue();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidUser_thenReturnFalse() {
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+
+        // then
+        assertThat(deleted).isFalse();
+    }
+
+    @Test
+    void whenDeleteVehicle_withInvalidVehicle_thenReturnFalse() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.empty());
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 237, the
service field name used to call deleteVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+List<Vehicle> found = vehicleService.getAllVehiclesByUserId(user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        List<Vehicle> found = vehicleService.getAllVehiclesByUserId(user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 72, the
service field name used to call getAllVehiclesByUserId is outdated due to a
previous field name correction. Update the service invocation to use the
corrected service field name to ensure the test calls the right service
instance.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Fix incorrect field name.**

The field is named `chargingStationService` but it's injecting `VehicleServiceImpl`. This appears to be a copy-paste error that should be corrected to avoid confusion.


```diff
 @InjectMocks
-private VehicleServiceImpl chargingStationService;
+private VehicleServiceImpl vehicleService;
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    @InjectMocks
    private VehicleServiceImpl vehicleService;
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at lines 31 to 32,
the field name `chargingStationService` is incorrect for the injected
`VehicleServiceImpl` instance. Rename the field to a more appropriate name such
as `vehicleService` to accurately reflect the type being injected and avoid
confusion.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 120, the
service field name used to call createVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenDeleteVehicle_thenReturnTrue() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-boolean deleted = chargingStationService.deleteVehicle(user.getId(), vehicle.getId());
+boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        boolean deleted = vehicleService.deleteVehicle(user.getId(), vehicle.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 216, the
service field name used to call deleteVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:10Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 134,
update the service invocation from chargingStationService to the correctly named
service field as per the recent field name correction. Replace
chargingStationService with the updated service field name to ensure the method
call matches the corrected field.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 147,
update the service invocation to use the corrected service field name. Replace
the current service field name with the properly renamed one to ensure the
method call matches the updated field.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidData_thenReturnNull() {
+        // given
+        vehicle.setBrand(null);
+        vehicle.setModel(null);
+        vehicle.setLicensePlate(null);
+        vehicle.setConnectorType(null);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenCreateVehicle_withEmptyData_thenReturnNull() {
+        // given
+        vehicle.setBrand("");
+        vehicle.setModel("");
+        vehicle.setLicensePlate("");
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_thenReturnUpdatedVehicle() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+        when(vehicleRepository.save(vehicle)).thenReturn(vehicle);
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+
+        // then
+        assertThat(updated).isNotNull();
+        assertThat(updated.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenUpdateVehicle_withWrongId_thenReturnNull() {
+        // given
+        when(vehicleRepository.findById(vehicle.getId())).thenReturn(Optional.of(vehicle));
+
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(4, vehicle);
+
+        // then
+        assertThat(updated).isNull();
+    }
+
+    @Test
+    void whenUpdateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle updated = chargingStationService.updateVehicle(user.getId(), vehicle);
+Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle updated = vehicleService.updateVehicle(user.getId(), vehicle);
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 169, the
service field name used to call updateVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call matches the current codebase.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 95, the
service field name used to call createVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid and matches the current
class fields.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+List<Vehicle> found = vehicleService.getAllVehiclesByUserId(user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        List<Vehicle> found = vehicleService.getAllVehiclesByUserId(user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 82, the
service field name used to call getAllVehiclesByUserId is outdated due to a
previous field name correction. Update the service invocation to use the
corrected service field name to ensure the test calls the right service
instance.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+List<Vehicle> found = vehicleService.getAllVehiclesByUserId(user.getId());
```

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 58, the
service field name used to call getAllVehiclesByUserId is outdated due to a
previous field name correction. Update the service invocation to use the
corrected service field name to ensure the method call is valid and references
the right service instance.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,254 @@
+package ua.deti.tqs.services;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.test.context.ActiveProfiles;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.repositories.UserRepository;
+import ua.deti.tqs.repositories.VehicleRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+@ActiveProfiles("test")
+@ExtendWith(MockitoExtension.class)
+class VehicleServiceTest {
+    @Mock private VehicleRepository vehicleRepository;
+
+    @Mock private UserRepository userRepository;
+
+    @InjectMocks
+    private VehicleServiceImpl chargingStationService;
+
+    private Vehicle vehicle;
+
+    private User user;
+
+    @BeforeEach
+    void setUp() {
+        user = new User();
+        user.setId(1);
+        user.setRole(Role.OPERATOR);
+
+        vehicle = new Vehicle();
+        vehicle.setId(1);
+        vehicle.setBrand("Brand");
+        vehicle.setModel("Model");
+        vehicle.setLicensePlate("ABC123");
+        vehicle.setUser(user);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnVehicles() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.of(List.of(vehicle)));
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).hasSize(1);
+        assertThat(found.getFirst().getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnEmptyList() {
+        // given
+        when(vehicleRepository.findAllByUser_Id(user.getId())).thenReturn(Optional.empty());
+
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNull() {
+        // when
+        List<Vehicle> found = chargingStationService.getAllVehiclesByUserId(user.getId());
+
+        // then
+        assertThat(found).isNotNull();
+        assertThat(found).isEmpty();
+    }
+
+    @Test
+    void whenCreateVehicle_thenReturnVehicle() {
+        // given
+        when(vehicleRepository.save(any(Vehicle.class))).thenReturn(vehicle);
+
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+
+        // then
+        assertThat(created).isNotNull();
+        assertThat(created.getId()).isEqualTo(1);
+    }
+
+    @Test
+    void whenCreateVehicle_withInvalidUser_thenReturnNull() {
+        // when
+        Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
path: src/test/java/ua/deti/tqs/services/VehicleServiceTest.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Update service invocation to match corrected field name.**

Update this line to use the properly named service field after fixing the field name issue.


```diff
-Vehicle created = chargingStationService.createVehicle(vehicle, user.getId());
+Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
        Vehicle created = vehicleService.createVehicle(vehicle, user.getId());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/services/VehicleServiceTest.java at line 105, the
service field name used to call createVehicle is outdated due to a previous
field name correction. Update the service invocation to use the corrected
service field name to ensure the method call is valid.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,188 @@
+package ua.deti.tqs.controllers;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.test.web.servlet.MockMvc;
+import ua.deti.tqs.components.AuthTokenFilter;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.services.interfaces.UserService;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+import ua.deti.tqs.utils.SecurityUtils;
+
+@ActiveProfiles("test")
+@WebMvcTest(VehicleController.class)
+@AutoConfigureMockMvc(addFilters = false)
+class VehicleControllerTest {
+
+    @Autowired
+    private MockMvc mockMvc;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @MockitoBean
+    private VehicleService vehicleService;
+
+    @MockitoBean
+    private AuthTokenFilter authTokenFilter;
+
+    @MockitoBean
+    private UserService userService;
+
+    private MockedStatic<SecurityUtils> securityUtils;
+
+    private Vehicle testVehicle;
+    private List<Vehicle> testVehicles;
+    private User testUser;
+
+    @BeforeEach
+    void setUp() {
+        testUser = new User();
+        testUser.setId(1);
+        testUser.setName("Test User");
+        testUser.setEmail("test@example.com");
+        testUser.setPassword("password");
+        testUser.setRole(Role.USER);
+
+        testVehicle = new Vehicle();
+        testVehicle.setId(1);
+        testVehicle.setLicensePlate("AB-12-CD");
+        testVehicle.setBrand("Tesla");
+        testVehicle.setModel("Model 3");
+        testVehicle.setUser(testUser);
+
+        Vehicle testVehicle2 = new Vehicle();
+        testVehicle2.setId(2);
+        testVehicle2.setLicensePlate("EF-34-GH");
+        testVehicle2.setBrand("Nissan");
+        testVehicle2.setModel("Leaf");
+        testVehicle2.setUser(testUser);
+
+        testVehicles = Arrays.asList(testVehicle, testVehicle2);
+
+        securityUtils = mockStatic(SecurityUtils.class);
+        securityUtils.when(SecurityUtils::getAuthenticatedUser).thenReturn(testUser);
+    }
+
+    @AfterEach
+    void tearDown() {
+        securityUtils.close();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnAllVehicles() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(testVehicles);
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$", hasSize(2)))
+                .andExpect(jsonPath("$[0].licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNotFound() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(Collections.emptyList());
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isNotFound());
+    }
+
+    @Test
+    void whenCreateValidVehicle_thenReturnCreatedVehicle() throws Exception {
+        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
+                .thenReturn(testVehicle);
+
+        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(testVehicle)))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenCreateInvalidVehicle_thenReturnBadRequest() throws Exception {
+        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
+                .thenReturn(null);
+
+        Vehicle invalidVehicle = new Vehicle();
+        invalidVehicle.setLicensePlate(""); // Invalid license plate
+
+        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(invalidVehicle)))
+                .andExpect(status().isNotFound());
+    }
path: src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Method name doesn't match expected HTTP status.**

The test method name implies a Bad Request (400) response, but the test expects a Not Found (404) status. This creates confusion about the expected behavior.

```diff
-    @Test
-    void whenCreateInvalidVehicle_thenReturnBadRequest() throws Exception {
+    @Test
+    void whenCreateInvalidVehicle_thenReturnNotFound() throws Exception {
```

Alternatively, if the intention is to test for Bad Request:
```diff
-                .andExpect(status().isNotFound());
+                .andExpect(status().isBadRequest());
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    @Test
    void whenCreateInvalidVehicle_thenReturnNotFound() throws Exception {
        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
                .thenReturn(null);

        Vehicle invalidVehicle = new Vehicle();
        invalidVehicle.setLicensePlate(""); // Invalid license plate

        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(objectMapper.writeValueAsString(invalidVehicle)))
                .andExpect(status().isNotFound());
    }
```

```suggestion
        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content(objectMapper.writeValueAsString(invalidVehicle)))
                .andExpect(status().isBadRequest());
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java around lines
129 to 141, the test method name indicates it should expect a Bad Request (400)
status, but the actual test asserts a Not Found (404) status. To fix this,
either rename the test method to reflect the 404 expectation or change the
status assertion to expect 400 to match the method name. Ensure the test method
name and the expected HTTP status are consistent.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:11Z
author_association: NONE
diff_hunk: @@ -0,0 +1,188 @@
+package ua.deti.tqs.controllers;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
+import org.springframework.test.web.servlet.MockMvc;
+import ua.deti.tqs.components.AuthTokenFilter;
+import ua.deti.tqs.entities.User;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.entities.types.Role;
+import ua.deti.tqs.services.interfaces.UserService;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+import ua.deti.tqs.utils.SecurityUtils;
+
+@ActiveProfiles("test")
+@WebMvcTest(VehicleController.class)
+@AutoConfigureMockMvc(addFilters = false)
+class VehicleControllerTest {
+
+    @Autowired
+    private MockMvc mockMvc;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @MockitoBean
+    private VehicleService vehicleService;
+
+    @MockitoBean
+    private AuthTokenFilter authTokenFilter;
+
+    @MockitoBean
+    private UserService userService;
+
+    private MockedStatic<SecurityUtils> securityUtils;
+
+    private Vehicle testVehicle;
+    private List<Vehicle> testVehicles;
+    private User testUser;
+
+    @BeforeEach
+    void setUp() {
+        testUser = new User();
+        testUser.setId(1);
+        testUser.setName("Test User");
+        testUser.setEmail("test@example.com");
+        testUser.setPassword("password");
+        testUser.setRole(Role.USER);
+
+        testVehicle = new Vehicle();
+        testVehicle.setId(1);
+        testVehicle.setLicensePlate("AB-12-CD");
+        testVehicle.setBrand("Tesla");
+        testVehicle.setModel("Model 3");
+        testVehicle.setUser(testUser);
+
+        Vehicle testVehicle2 = new Vehicle();
+        testVehicle2.setId(2);
+        testVehicle2.setLicensePlate("EF-34-GH");
+        testVehicle2.setBrand("Nissan");
+        testVehicle2.setModel("Leaf");
+        testVehicle2.setUser(testUser);
+
+        testVehicles = Arrays.asList(testVehicle, testVehicle2);
+
+        securityUtils = mockStatic(SecurityUtils.class);
+        securityUtils.when(SecurityUtils::getAuthenticatedUser).thenReturn(testUser);
+    }
+
+    @AfterEach
+    void tearDown() {
+        securityUtils.close();
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnAllVehicles() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(testVehicles);
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$", hasSize(2)))
+                .andExpect(jsonPath("$[0].licensePlate", is(testVehicle.getLicensePlate())));
+    }
+
+    @Test
+    void whenGetAllVehiclesByUserId_thenReturnNotFound() throws Exception {
+        when(vehicleService.getAllVehiclesByUserId(testUser.getId())).thenReturn(Collections.emptyList());
+
+        mockMvc.perform(get("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON))
+                .andExpect(status().isNotFound());
+    }
+
+    @Test
+    void whenCreateValidVehicle_thenReturnCreatedVehicle() throws Exception {
+        when(vehicleService.createVehicle(any(Vehicle.class), eq(testUser.getId())))
+                .thenReturn(testVehicle);
+
+        mockMvc.perform(post("/" + Constants.API_V1 + "private/vehicles")
+                        .contentType(MediaType.APPLICATION_JSON)
+                        .content(objectMapper.writeValueAsString(testVehicle)))
+                .andExpect(status().isOk())
+                .andExpect(jsonPath("$.licensePlate", is(testVehicle.getLicensePlate())));
path: src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Missing @RequestBody annotation in controller method.**

Based on this test, it appears that the corresponding controller method should accept a vehicle in the request body, but the `@RequestBody` annotation might be missing in the controller implementation.

---

🏁 Script executed:

```shell
#!/bin/bash
# Check if the controller method has the @RequestBody annotation
rg "@PostMapping.*\)[\s\S]*?createVehicle.*\)" --no-filename
```

Length of output: 62

---

🏁 Script executed:

```shell
#!/bin/bash
# Locate the POST mapping for “private/vehicles” in controller classes
rg -n "\"private/vehicles\"" -g "src/main/java/**/*.java" -A2 -B1

# Check for any @RequestBody annotations in controller source
rg -n "@RequestBody" -g "src/main/java/**/*.java"
```

Length of output: 1529

---



</details>

**Add @RequestBody to VehicleController.createVehicle**  

The POST handler in `VehicleController` is missing the `@RequestBody` annotation, so Spring won’t bind the JSON payload to your `Vehicle` object. Update the method signature in:  
- `src/main/java/ua/deti/tqs/controllers/VehicleController.java`  

Suggested diff:  
```diff
 @PostMapping
-public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+public ResponseEntity<Vehicle> createVehicle(@RequestBody Vehicle vehicle) {
     // existing implementation
 }
```  
This ensures that the JSON sent by your test is deserialized into the `Vehicle` parameter.

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/controllers/VehicleController.java around the
method handling POST requests to "private/vehicles", the method parameter for
the Vehicle object is missing the @RequestBody annotation. Add @RequestBody
before the Vehicle parameter in the createVehicle method signature to ensure
Spring correctly deserializes the incoming JSON payload into the Vehicle object.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE
diff_hunk: @@ -0,0 +1,118 @@
+package ua.deti.tqs.services;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.repositories.VehicleRepository;
+import ua.deti.tqs.services.interfaces.VehicleService;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@AllArgsConstructor
+public class VehicleServiceImpl implements VehicleService {
+     private final VehicleRepository vehicleRepository;
+    @Override
+    public List<Vehicle> getAllVehiclesByUserId(int userId) {
+        log.debug("Fetching all vehicles with user id {}", userId);
+        List<Vehicle> vehicles = vehicleRepository
+                .findAllByUser_Id(userId)
+                .orElse(null);
+
+        if (vehicles == null) {
+            log.debug("No vehicles found with user id {}", userId);
+            return List.of();
+        }
+
+        log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
+        return vehicles;
+    }
+
+    @Override
+    public Vehicle createVehicle(Vehicle vehicle, int userId) {
+        log.debug("Creating new vehicle {}", vehicle);
+
+        int errorCount = 0;
+        if (vehicle.getBrand() == null || vehicle.getBrand().isEmpty()) {
+            log.debug("Invalid vehicle brand, brand is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getModel() == null || vehicle.getModel().isEmpty()) {
+            log.debug("Invalid vehicle model, model is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getLicensePlate() == null || vehicle.getLicensePlate().isEmpty()) {
+            log.debug("Invalid vehicle license plate, license plate is null or empty");
+            errorCount++;
+        }
+
+        if (errorCount > 0) return null;
+
+
+        Vehicle newVehicle = new Vehicle();
+        newVehicle.setUser(vehicle.getUser());
+        newVehicle.setBrand(vehicle.getBrand());
+        newVehicle.setModel(vehicle.getModel());
+        newVehicle.setLicensePlate(vehicle.getLicensePlate());
+
+        if (vehicle.getConnectorType() != null)
+            newVehicle.setConnectorType(vehicle.getConnectorType());
+
+        log.debug("Saving new vehicle {}", newVehicle);
+        return vehicleRepository.save(newVehicle);
+    }
path: src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Security issue: User information is not properly managed.**

The `createVehicle` method accepts a userId parameter but never uses it to set the vehicle's user. Instead, it directly uses the user from the input vehicle object (line 55), which could allow a malicious client to assign the vehicle to a different user than the authenticated one.

```diff
-    public Vehicle createVehicle(Vehicle vehicle, int userId) {
+    public Vehicle createVehicle(Vehicle vehicle, int userId) {
         log.debug("Creating new vehicle {}", vehicle);
 
         int errorCount = 0;
         if (vehicle.getBrand() == null || vehicle.getBrand().isEmpty()) {
             log.debug("Invalid vehicle brand, brand is null or empty");
             errorCount++;
         }
         if (vehicle.getModel() == null || vehicle.getModel().isEmpty()) {
             log.debug("Invalid vehicle model, model is null or empty");
             errorCount++;
         }
         if (vehicle.getLicensePlate() == null || vehicle.getLicensePlate().isEmpty()) {
             log.debug("Invalid vehicle license plate, license plate is null or empty");
             errorCount++;
         }
 
         if (errorCount > 0) return null;
 
 
         Vehicle newVehicle = new Vehicle();
-        newVehicle.setUser(vehicle.getUser());
+        // Get the user by ID from a user repository or service
+        // This assumes you have a userRepository or userService as a dependency
+        User user = userRepository.findById(userId).orElse(null);
+        if (user == null) {
+            log.debug("User not found with id {}", userId);
+            return null;
+        }
+        newVehicle.setUser(user);
```


> Committable suggestion skipped: line range outside the PR's diff.

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java between lines 33
and 65, the createVehicle method accepts a userId parameter but does not use it
to set the vehicle's user, instead relying on the user from the input vehicle
object. To fix this, retrieve the user entity corresponding to the provided
userId from the user repository or service and set this user on the newVehicle
object before saving, ensuring the vehicle is correctly assigned to the
authenticated user and preventing unauthorized user assignment.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE
diff_hunk: @@ -0,0 +1,118 @@
+package ua.deti.tqs.services;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.repositories.VehicleRepository;
+import ua.deti.tqs.services.interfaces.VehicleService;
+
+import java.util.List;
+
+@Slf4j
+@Service
+@AllArgsConstructor
+public class VehicleServiceImpl implements VehicleService {
+     private final VehicleRepository vehicleRepository;
+    @Override
+    public List<Vehicle> getAllVehiclesByUserId(int userId) {
+        log.debug("Fetching all vehicles with user id {}", userId);
+        List<Vehicle> vehicles = vehicleRepository
+                .findAllByUser_Id(userId)
+                .orElse(null);
+
+        if (vehicles == null) {
+            log.debug("No vehicles found with user id {}", userId);
+            return List.of();
+        }
+
+        log.debug("Found {} vehicles with user id {}", vehicles.size(), userId);
+        return vehicles;
+    }
+
+    @Override
+    public Vehicle createVehicle(Vehicle vehicle, int userId) {
+        log.debug("Creating new vehicle {}", vehicle);
+
+        int errorCount = 0;
+        if (vehicle.getBrand() == null || vehicle.getBrand().isEmpty()) {
+            log.debug("Invalid vehicle brand, brand is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getModel() == null || vehicle.getModel().isEmpty()) {
+            log.debug("Invalid vehicle model, model is null or empty");
+            errorCount++;
+        }
+        if (vehicle.getLicensePlate() == null || vehicle.getLicensePlate().isEmpty()) {
+            log.debug("Invalid vehicle license plate, license plate is null or empty");
+            errorCount++;
+        }
+
+        if (errorCount > 0) return null;
+
+
+        Vehicle newVehicle = new Vehicle();
+        newVehicle.setUser(vehicle.getUser());
+        newVehicle.setBrand(vehicle.getBrand());
+        newVehicle.setModel(vehicle.getModel());
+        newVehicle.setLicensePlate(vehicle.getLicensePlate());
+
+        if (vehicle.getConnectorType() != null)
+            newVehicle.setConnectorType(vehicle.getConnectorType());
+
+        log.debug("Saving new vehicle {}", newVehicle);
+        return vehicleRepository.save(newVehicle);
+    }
+
+    @Override
+    public Vehicle updateVehicle(int userId, Vehicle vehicle) {
+        log.debug("Updating vehicle with id {} and user id {}", vehicle.getId(), userId);
+        Vehicle existingVehicle = vehicleRepository.findById(vehicle.getId()).orElse(null);
+
+        if (existingVehicle == null) {
+            log.debug("Vehicle not found");
+            return null;
+        }
+
+        if (existingVehicle.getUser().getId() != userId) {
+            log.debug("Vehicle with id {} does not belong to user with id {}", vehicle.getId(), userId);
+            return null;
+        }
+
+        if (vehicle.getBrand() != null && !vehicle.getBrand().isEmpty()) {
+            existingVehicle.setBrand(vehicle.getBrand());
+        }
+        if (vehicle.getModel() != null && !vehicle.getModel().isEmpty()) {
+            existingVehicle.setModel(vehicle.getModel());
+        }
+        if (vehicle.getLicensePlate() != null && !vehicle.getLicensePlate().isEmpty()) {
+            existingVehicle.setLicensePlate(vehicle.getLicensePlate());
+        }
+        if (vehicle.getConnectorType() != null) {
+            existingVehicle.setConnectorType(vehicle.getConnectorType());
+        }
+
+        log.debug("Saving updated vehicle {}", existingVehicle);
+        return vehicleRepository.save(existingVehicle);
+    }
+
+    @Override
+    public boolean deleteVehicle(int id, int userId) {
+        log.debug("Deleting vehicle with id {} and user id {}", id, userId);
+        Vehicle vehicle = vehicleRepository.findById(id).orElse(null);
+
+        if (vehicle == null) {
+            log.debug("No vehicle found with id {} and user id {}", id, userId);
+            return false;
+        }
+
+        if (vehicle.getUser().getId() != userId) {
+            log.debug("The user with id {}, is not the owner", userId);
+            return false;
+        }
+
+        vehicleRepository.delete(vehicle);
+        log.debug("Deleted vehicle with id {} and user id {}", id, userId);
+        return true;
+    }
path: src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Parameter order mismatch with controller call.**

In the `deleteVehicle` method, the parameters are `id` and `userId`, but the controller calls this method with `userId` and `vehicleId`. This inconsistency can lead to bugs.

```diff
-    public boolean deleteVehicle(int id, int userId) {
+    public boolean deleteVehicle(int vehicleId, int userId) {
-        log.debug("Deleting vehicle with id {} and user id {}", id, userId);
-        Vehicle vehicle = vehicleRepository.findById(id).orElse(null);
+        log.debug("Deleting vehicle with id {} and user id {}", vehicleId, userId);
+        Vehicle vehicle = vehicleRepository.findById(vehicleId).orElse(null);

        if (vehicle == null) {
-            log.debug("No vehicle found with id {} and user id {}", id, userId);
+            log.debug("No vehicle found with id {} and user id {}", vehicleId, userId);
            return false;
        }

        if (vehicle.getUser().getId() != userId) {
            log.debug("The user with id {}, is not the owner", userId);
            return false;
        }

        vehicleRepository.delete(vehicle);
-        log.debug("Deleted vehicle with id {} and user id {}", id, userId);
+        log.debug("Deleted vehicle with id {} and user id {}", vehicleId, userId);
        return true;
    }
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    @Override
    public boolean deleteVehicle(int vehicleId, int userId) {
        log.debug("Deleting vehicle with id {} and user id {}", vehicleId, userId);
        Vehicle vehicle = vehicleRepository.findById(vehicleId).orElse(null);

        if (vehicle == null) {
            log.debug("No vehicle found with id {} and user id {}", vehicleId, userId);
            return false;
        }

        if (vehicle.getUser().getId() != userId) {
            log.debug("The user with id {}, is not the owner", userId);
            return false;
        }

        vehicleRepository.delete(vehicle);
        log.debug("Deleted vehicle with id {} and user id {}", vehicleId, userId);
        return true;
    }
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java around lines 99 to
117, the deleteVehicle method parameters are ordered as (int id, int userId),
but the controller calls it with (userId, vehicleId). To fix this, reorder the
method parameters to (int userId, int id) to match the controller call, and
update all references inside the method accordingly to avoid parameter mismatch
bugs.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE
diff_hunk: @@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Creating new vehicle {}", vehicle);
+
+        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);
+
+        if (newVehicle == null) {
+            log.warn("No vehicle found for the user with id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle created successfully");
+        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
+    }
+
+    @PutMapping()
+    @Operation(summary = "Update a Vehicle", description = "Updates a vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle updated successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> updateVehicle(Vehicle vehicle) {
+        log.info("Updating vehicle {}", vehicle);
+        int userId = getAuthenticatedUser().getId();
+        Vehicle updatedVehicle = vehicleService.updateVehicle(userId, vehicle);
+        if (updatedVehicle == null) {
+            log.warn("No vehicle found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle updated successfully");
+        return new ResponseEntity<>(updatedVehicle, HttpStatus.OK);
+    }
+
+    @DeleteMapping("/{vehicleId}")
+    @Operation(summary = "Delete a Vehicle", description = "Deletes a vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle deleted successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Void> deleteVehicle(@PathVariable("vehicleId") int vehicleId) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Deleting vehicle with id {}", vehicleId);
+
+        if (vehicleService.deleteVehicle(userId, vehicleId)) {
+            log.info("Vehicle deleted successfully");
+            return new ResponseEntity<>(HttpStatus.OK);
+        }
+        log.warn("No vehicle found with id {}", vehicleId);
+        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+    }
path: src/main/java/ua/deti/tqs/controllers/VehicleController.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Parameter order mismatch with service method.**

The controller calls `vehicleService.deleteVehicle(userId, vehicleId)` but the service method signature is `deleteVehicle(int id, int userId)`. This inconsistency can lead to bugs.

```diff
    @DeleteMapping("/{vehicleId}")
    @Operation(summary = "Delete a Vehicle", description = "Deletes a vehicle.")
    @ApiResponse(responseCode = "200", description = "Vehicle deleted successfully")
    @ApiResponse(responseCode = "404", description = "No vehicle found")
    public ResponseEntity<Void> deleteVehicle(@PathVariable("vehicleId") int vehicleId) {
        int userId = getAuthenticatedUser().getId();
        log.info("Deleting vehicle with id {}", vehicleId);

-        if (vehicleService.deleteVehicle(userId, vehicleId)) {
+        if (vehicleService.deleteVehicle(vehicleId, userId)) {
            log.info("Vehicle deleted successfully");
            return new ResponseEntity<>(HttpStatus.OK);
        }
        log.warn("No vehicle found with id {}", vehicleId);
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    @DeleteMapping("/{vehicleId}")
    @Operation(summary = "Delete a Vehicle", description = "Deletes a vehicle.")
    @ApiResponse(responseCode = "200", description = "Vehicle deleted successfully")
    @ApiResponse(responseCode = "404", description = "No vehicle found")
    public ResponseEntity<Void> deleteVehicle(@PathVariable("vehicleId") int vehicleId) {
        int userId = getAuthenticatedUser().getId();
        log.info("Deleting vehicle with id {}", vehicleId);

        if (vehicleService.deleteVehicle(vehicleId, userId)) {
            log.info("Vehicle deleted successfully");
            return new ResponseEntity<>(HttpStatus.OK);
        }
        log.warn("No vehicle found with id {}", vehicleId);
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/controllers/VehicleController.java around lines 79
to 93, the call to vehicleService.deleteVehicle passes parameters in the wrong
order compared to the service method signature. Swap the arguments so that the
vehicle ID is passed first and the user ID second, matching the service method's
parameter order to avoid logic errors.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE
diff_hunk: @@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Creating new vehicle {}", vehicle);
+
+        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);
+
+        if (newVehicle == null) {
+            log.warn("No vehicle found for the user with id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle created successfully");
+        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
+    }
+
+    @PutMapping()
+    @Operation(summary = "Update a Vehicle", description = "Updates a vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle updated successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> updateVehicle(Vehicle vehicle) {
+        log.info("Updating vehicle {}", vehicle);
+        int userId = getAuthenticatedUser().getId();
+        Vehicle updatedVehicle = vehicleService.updateVehicle(userId, vehicle);
+        if (updatedVehicle == null) {
+            log.warn("No vehicle found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle updated successfully");
+        return new ResponseEntity<>(updatedVehicle, HttpStatus.OK);
+    }
path: src/main/java/ua/deti/tqs/controllers/VehicleController.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Missing @RequestBody annotation for PUT endpoint.**

The controller method doesn't use the `@RequestBody` annotation for the `Vehicle` parameter, which is required for Spring to properly deserialize the request body.

```diff
    @PutMapping()
    @Operation(summary = "Update a Vehicle", description = "Updates a vehicle.")
    @ApiResponse(responseCode = "200", description = "Vehicle updated successfully")
    @ApiResponse(responseCode = "404", description = "No vehicle found")
-    public ResponseEntity<Vehicle> updateVehicle(Vehicle vehicle) {
+    public ResponseEntity<Vehicle> updateVehicle(@RequestBody Vehicle vehicle) {
        log.info("Updating vehicle {}", vehicle);
        int userId = getAuthenticatedUser().getId();
        Vehicle updatedVehicle = vehicleService.updateVehicle(userId, vehicle);
        if (updatedVehicle == null) {
            log.warn("No vehicle found with user id {}", userId);
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
        log.info("Vehicle updated successfully");
        return new ResponseEntity<>(updatedVehicle, HttpStatus.OK);
    }
```

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/controllers/VehicleController.java around lines 63
to 77, the updateVehicle method is missing the @RequestBody annotation on the
Vehicle parameter. Add @RequestBody before the Vehicle parameter to ensure
Spring correctly deserializes the incoming JSON request body into a Vehicle
object.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE
diff_hunk: @@ -0,0 +1,95 @@
+package ua.deti.tqs.controllers;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import ua.deti.tqs.entities.Vehicle;
+import ua.deti.tqs.services.interfaces.VehicleService;
+import ua.deti.tqs.utils.Constants;
+
+import java.util.List;
+
+import static ua.deti.tqs.utils.SecurityUtils.getAuthenticatedUser;
+
+@Slf4j
+@RestController
+@RequestMapping(Constants.API_V1 + "private/vehicles")
+@Tag(name = "Vehicle", description = "The Vehicle API")
+@AllArgsConstructor
+public class VehicleController {
+    private final VehicleService vehicleService;
+
+    @GetMapping()
+    @Operation(summary = "Get all Vehicles by User ID", description = "Fetches a list of all vehicles by user id.")
+    @ApiResponse(responseCode = "200", description = "List of vehicles retrieved successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicles found")
+    public ResponseEntity<List<Vehicle>> getAllVehiclesByUserId() {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Fetching all vehicles with user id {}", userId);
+
+        List<Vehicle> vehicles = vehicleService.getAllVehiclesByUserId(userId);
+
+        if (vehicles.isEmpty()) {
+            log.warn("No vehicles found with user id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicles retrieved successfully");
+        return new ResponseEntity<>(vehicles, HttpStatus.OK);
+    }
+
+    @PostMapping()
+    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
+    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
+    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+        int userId = getAuthenticatedUser().getId();
+        log.info("Creating new vehicle {}", vehicle);
+
+        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);
+
+        if (newVehicle == null) {
+            log.warn("No vehicle found for the user with id {}", userId);
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
+        log.info("Vehicle created successfully");
+        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
+    }
path: src/main/java/ua/deti/tqs/controllers/VehicleController.java
user: login: coderabbitai[bot]
body: _⚠️ Potential issue_

**Missing @RequestBody annotation for POST endpoint.**

The controller method doesn't use the `@RequestBody` annotation for the `Vehicle` parameter, which is required for Spring to properly deserialize the request body. Also, the error status is 404 (Not Found) when it should be 400 (Bad Request) for validation errors.

```diff
    @PostMapping()
    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
-    @ApiResponse(responseCode = "404", description = "No vehicle found")
+    @ApiResponse(responseCode = "400", description = "Invalid vehicle data")
-    public ResponseEntity<Vehicle> createVehicle(Vehicle vehicle) {
+    public ResponseEntity<Vehicle> createVehicle(@RequestBody Vehicle vehicle) {
        int userId = getAuthenticatedUser().getId();
        log.info("Creating new vehicle {}", vehicle);

        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);

        if (newVehicle == null) {
-            log.warn("No vehicle found for the user with id {}", userId);
-            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+            log.warn("Invalid vehicle data for user with id {}", userId);
+            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }
        log.info("Vehicle created successfully");
        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
    }
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
    @PostMapping()
    @Operation(summary = "Create a new Vehicle", description = "Creates a new vehicle.")
    @ApiResponse(responseCode = "200", description = "Vehicle created successfully")
    @ApiResponse(responseCode = "400", description = "Invalid vehicle data")
    public ResponseEntity<Vehicle> createVehicle(@RequestBody Vehicle vehicle) {
        int userId = getAuthenticatedUser().getId();
        log.info("Creating new vehicle {}", vehicle);

        Vehicle newVehicle = vehicleService.createVehicle(vehicle, userId);

        if (newVehicle == null) {
            log.warn("Invalid vehicle data for user with id {}", userId);
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }
        log.info("Vehicle created successfully");
        return new ResponseEntity<>(newVehicle, HttpStatus.OK);
    }
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/main/java/ua/deti/tqs/controllers/VehicleController.java lines 45 to 61,
add the @RequestBody annotation to the Vehicle parameter in the createVehicle
method to enable Spring to deserialize the request body correctly. Also, change
the error response status from 404 (Not Found) to 400 (Bad Request) when the
newVehicle is null to properly indicate a validation or bad request error.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-18T18:38:12Z
author_association: NONE

PR comments:
user: login: coderabbitai[bot]
created_at: 2025-05-18T18:34:58Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

This update introduces a full vehicle management feature to the application. It adds REST endpoints, service and repository layers, and comprehensive tests for CRUD operations on vehicles associated with users. Minor formatting changes were also made to an existing controller, but no logic was altered outside the new vehicle functionality.

## Changes

| File(s)                                                                                  | Change Summary                                                                                                                        |
|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| src/main/java/ua/deti/tqs/controllers/ChargingStationController.java                     | Added a blank line after a static final string declaration; no logic changes.                                                        |
| src/main/java/ua/deti/tqs/controllers/VehicleController.java                             | Introduced a new REST controller with endpoints for vehicle CRUD operations, using service and security utilities.                    |
| src/main/java/ua/deti/tqs/repositories/VehicleRepository.java                            | Added a new repository interface extending JpaRepository, with a custom method to find vehicles by user ID.                           |
| src/main/java/ua/deti/tqs/services/VehicleServiceImpl.java                               | Added a service implementation for vehicle CRUD, including validation, ownership checks, and logging.                                 |
| src/main/java/ua/deti/tqs/services/interfaces/VehicleService.java                        | Added a new service interface defining vehicle CRUD methods scoped by user ID.                                                        |
| src/test/java/ua/deti/tqs/controllers/VehicleControllerTest.java                        | Added tests for the vehicle controller, covering all endpoints and response scenarios with mocked dependencies and authenticated user. |
| src/test/java/ua/deti/tqs/services/VehicleServiceTest.java                               | Added comprehensive unit tests for the vehicle service implementation, including all CRUD paths and edge cases.                       |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant VehicleController
    participant SecurityUtils
    participant VehicleService
    participant VehicleRepository
    participant UserRepository

    Client->>VehicleController: GET /api/v1/private/vehicles
    VehicleController->>SecurityUtils: getAuthenticatedUser()
    VehicleController->>VehicleService: getAllVehiclesByUserId(userId)
    VehicleService->>VehicleRepository: findAllByUser_Id(userId)
    VehicleRepository-->>VehicleService: List<Vehicle>
    VehicleService-->>VehicleController: List<Vehicle>
    VehicleController-->>Client: HTTP 200/404 (vehicles)

    Client->>VehicleController: POST /api/v1/private/vehicles (Vehicle)
    VehicleController->>SecurityUtils: getAuthenticatedUser()
    VehicleController->>VehicleService: createVehicle(vehicle, userId)
    VehicleService->>UserRepository: findById(userId)
    UserRepository-->>VehicleService: User
    VehicleService->>VehicleRepository: save(vehicle)
    VehicleRepository-->>VehicleService: Vehicle
    VehicleService-->>VehicleController: Vehicle
    VehicleController-->>Client: HTTP 200/404 (created vehicle)

    Client->>VehicleController: PUT /api/v1/private/vehicles (Vehicle)
    VehicleController->>SecurityUtils: getAuthenticatedUser()
    VehicleController->>VehicleService: updateVehicle(userId, vehicle)
    VehicleService->>VehicleRepository: findById(vehicleId)
    VehicleRepository-->>VehicleService: Vehicle
    VehicleService->>VehicleRepository: save(vehicle)
    VehicleRepository-->>VehicleService: Vehicle
    VehicleService-->>VehicleController: Vehicle
    VehicleController-->>Client: HTTP 200/404 (updated vehicle)

    Client->>VehicleController: DELETE /api/v1/private/vehicles/{vehicleId}
    VehicleController->>SecurityUtils: getAuthenticatedUser()
    VehicleController->>VehicleService: deleteVehicle(vehicleId, userId)
    VehicleService->>VehicleRepository: findById(vehicleId)
    VehicleRepository-->>VehicleService: Vehicle
    VehicleService->>VehicleRepository: delete(vehicle)
    VehicleService-->>VehicleController: success/failure
    VehicleController-->>Client: HTTP 200/404
```

## Poem

> A new fleet hops into view,  
> With CRUD for cars—oh what to do!  
> Controllers, services, tests galore,  
> Now users manage vehicles and more.  
> The repo’s ready, the endpoints shine,  
> This bunny’s code is simply divine!  
> 🚗🐇

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**
**Cache: Disabled due to data retention organization setting**
**Knowledge Base: Disabled due to data retention organization setting**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 5beb3c89ab5f9dc036216c92c94aee76bd39dfb2 and a801cc7cc37202c7b265af59ca0c092f092ad690.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `src/main/java/ua/deti/tqs/controllers/VehicleController.java` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* src/main/java/ua/deti/tqs/controllers/VehicleController.java

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4BxCiTKQAbAE5IUhAyvpu8AwDlsZgFKLgAOAwBVRFDIADV4fCtcNAAlI31jcCgyenwAMxwCYjJlGnomVnYuXn5hUXEpGXkmJSpVdS0dTJMoOFRUTCLCUnIqcoUqjE5IKgB3SEQg5jQKeTkFNpU1TW1dMEMs0wNECgYAehX4DHOhNAk0c+xHpXFz3ABHRHOmaYokqwUb4AYVgqyI1yIAGUUuJ8BhgfDcP8LICNHcHhwDAAiXEGADE+MgAEEAJIlMbUOiLZareQFRhgjCkRBGYmLSHeAQWTAAa0gFmuJEgczQyDQtCU9DQ+RofFwsGFSi8q2oiSwDIVwt4kipi1h8AYkHy1zQFn1FEhkAABgAFVKkuIAfQAQsSoQBRJ224nQAAS1pQWC1NtB4MhMLV8MRfwBlEDKsQiA0kH8+EZmBZIsowpWSkgBALioF+AhDAANApY+b8hZ8HNK5R/nwmbRBczK/g+Jh6Vq+K1hflsBgxOqzepZBojEZCSSLHKoxhkIWQ8qeeN1cgGSQAB7cLsTLs8bDcw2QdjqeDSIxp8g4vEGCBgIynC5XG4Yx7Pc6veDvL4/EiKKAt8cQkJ4VgxsicYUOi9xoFiuLYgSRJkhSZTUksrB0vwhQMEyLJspA5ALKkHpQtAVbQailCMDySY2mBEEkFBwHxigyDXNBtDYAw1LDm0RbamgDC8mgpA2s8Gi/honzJr81EgdaKakrgHHoBgGD4LC1JzOosCQFCOrMgA5Mg1oAAKpNIuCsTBgaYPQKzcNw1IrsWAhisJCo2ucaC+OcEgAIznDqDw0IF4GGlYiDKTAxYKWxfCoCkRCkPQ+RHgA8q5GDErapKQLQ+AMEE7CLugyDYkx0XCvlpLYhp9DYDEyAADIsAI+D8pgWkGvCyCZXwdZpVajlVogyK8QQyUYCIo7wrh6CMVFXgkFClASIaJCBlxlD5CJJBTgYcDColMHnnu+Ctca+DYHw77nhgtD7lxiBYgYQUpgAVN9NgepR5y/Vw1nIleTToKi7irTFlWICV8BUvQek+SGpUUPY0wWPIaB4Iq0yGkjkAtZQKlqfkJC4Ph0hCcTMR8KSAAixr/Mwy0xOjE7E+Igq4LIlYMGaFjLsW9NbXxBbpqQakhoKk1LR4tWIJW432Lg91LpAfrQNAtqQAATAADIbIr6bTctqfAhSZQJ/B8NruuQAALIbTsoIUWnQ8xyC7kgmhGPrP3fbaWUUZAQPfVwwL2FS4rESQCyK2tt3ysWuNagTgsTCTsGQKp6AMHx3C4HH1o1WtgaCPNlvBsW9gfNgNmQF1tD80GEjdTTIZi9tkuMDHNC00nVgq89syUxryAO3rRsmyjBlowP1LD8KR7T87rvu/3JAVQd8DC8dADMQe2pEgPA5AkTcLQscaZdftWivKe0+n+PiFn/H02TBdFyXy1lzDHadRq6QAABTzzumpXc3BBQMHUDaKyJAG42RdIoWQDlNLaUXAASgFkLEWwoe4S0LNga+ep1Cj3oGrSeWsdYz2NqbVGxZSE3wmE/NedCN5uytkPQB6k+q3QEsdJ2QdGYejagDD04cADeK9SS0AAL4X0ZiQZINM0Be1qs3eQ6hkBM2fiGV+F4P7NS/nnNSgtUQEMWJtXuhYlBqN4cxJq491YUE1uvWe/AsBLELtILc9tOEu24YUEMT9io0wEb7Sax0PQiQMrkV60wSxEGQPYKwDxknXCGisOEWBxqincZCQaR5fF8QYuNPeFh7qEL4hgVYiRkzxTOkBC66SrxbnyTYzmfNub7y5mwBUig+6CBSNcF+eNjFExzmZPOzMhqQ3NPgVyG4BoplOrQx29hED7iXOo+wIoqAuWpOM601kdkDRIB6AmfNAyFl4PgLa+Z/IPJ1HqSa1AWqbHUWPbgaBZB1glE0nKZB6oaT6ouZAShEAMEtCEc88T+ArMXLMrCKw1iVmhbC+Axd1SUJ4NdRA8BuTCm2bsmI3zkwzlQvOMom4+6rlEOuSFS1oEHmpEebgJ5YFPXEOIa8j5UwJ2PKeI0iZzLl0gq0miFBdpYGtK+S42gPzwSeC8Smf45KAWrCBc4kqWLSrRJ+a0grbTcrPIM2AwyznSHJVcm5shgBtT9sAfVeg9CQGlsSVE+rEAulkNESg8jQHYIcpKNy6YAHMTsjKk1UAzWisgJa615y7XXL5Y6t128qT6tAfqzRa1Q3oHDfQQsUbaoxsBHGyACaeXJvoDai5ez00TldYAj1LCc2ALzXwleRaJRSj7uWtalb4ymvNUaetNpU2XJbXzV1+B4C0A9Q4ymJBc1cQLVYeR/aS1Dv1aO2V95kKPmOIq98txVXfl/P+b49h9xEpmh0vVgDrIPvUF2Scn5EJ4lnGhUYGF6BopwgyfCmYBXshIkGOUB0JbDqsG+66H61i7U4rGHifF6DjJDH80S4lhTWikjJOSGh71IafdIOK/Q0MwcOpdGgz1zIACk/mIcfZ+wM89aYXl6XzVyK1mIYPoDqdF8heQkHkHxgjpJpgkFILK7+a5VjqI5MybwpVJosEgMgtYSbKZWobSaZ63qLD+sDRQJ0wbN05x3ZxzwBlqHuPFPKnKeSzScaOb4Zk/9nWTUroUeDQCeMdONPvOU1INiGKTAjaZ9NZlM3WQgZAU6yAqFhmrS0JAHhLMKELLdNN2zidLemDROzRBWzPDnbRQl4B8Cqwl6cKE5wLjycudMjKVSrM1tuK6FBDx8C5Ym4LAqoD+GFXtCgsHhQDroFwQLbHkPoKDJJNA0kNWyS+KRkg76KOxXo7kK01oWNpG2+Rz9bbmKVhkzQeTehq1jYWFOpT9haBzdc2OCwTqXVuo9UZ2gJmzP00s7QUB1n6a2eWxNqbAnaoLZmug49GQz1nCVdcS9Dw1U/g1be84RDpAvuYhtCg4sSCkmYDAuCmJEd/vJAB8YmFaS6dAwRCD8cFh45QOTqwbBpgVXFTDtaROSdk5gah6D/wMN0ErPALnJAefiG8yGQLQvtpyto3xb+Dynk02BKkSIzNll0oGs/QLgZhvimi3AomXGc5NI2fzkmpd9Vw448/VhGiRLlOc1hkc1ToVFUptoKw9AlACGwEQFJEJvMLORCJK0u5RB4HVMdKA1ovU+sAX6gN4OQdg6DbQUNINKaZYhnlleyBCsRuWhCKQWB6uMxTKDGhQw5fF3kBbLeWlyDoAOTbZ6U5U+wp3jQXN+aV7S+STZgv1ouBxHHKwmm/iLxmny6F1RtBkCgIEFQZ6lZmCKFUZWWBZAKUwKpNg5+XewAYGwFDcaV/W+9Oy43JppJCjZaXRVP5SZpACyXt7xYe4FTKDJ+Hjdva4IrBlZhL+QVQjMhEfbtPPCgeRSsMfQBQvSAAAMWuA3zvmiQVwjyfg2CZkrCkEtBNBpnrDGEQAQG4GqxDBznxU7RoGQCvxvzvzHgf3J16QoIsFwK3x31oD3wPwsCP22j2R4B5BoAFnhHIDECPCk2wRTChCAOsWYOXkAQHxtFXQQOYlByySEOgzpnzwwOwMY2WiIPkBIMZFEF5GQCqyoMoBoJxXxR0K7mLCfh4Vfi7HgAAC86BYlEUp0RpkBxN5BJptsADlQkBNwJ8vBsBaBH559d4g8allZ+A5hqDaCk0kBclqZ0jxpDcut+A8BKhpAUxAgoZqZRIADHCgRsiP9WF6VeAst2BiZ6k8YfD/C8hZpGik1FAKss5NxjpqVmsjdNZ3IlQmVVRWtWVet+sRUeVzcMgSQ91+dldbE+IRcLA5UeARIxIJJCNVtiNNs8c9sZcYE5cLxvMoc6MNjidVctDiQ91Bs619NrVfNcALtaoPV08LBfVAd899C1Ip8i1xl1j9UVctiudlJBVnjB1XiLV3iG180h8u09C0DLsjDQTdiITAEoTScYSniXiJ09MhkUS+F1CN1J8c9UDe10DcT6IJV8TNjCTRdiSETSSp1rQuokgd4sA3DqTLZDCkCIdwSmSBcrACTtjYSkIkdnwTgUcL1PxMcb0tUzjzhbjykCdaoCTKcEJqdUJadSh6cgNGd6Q8IWdWQDBINxtZNJs7jITWSxcuIJdeITla5hI8NDiiN1sSMziNAtTKNEsBh7TodnsaYbYHpkS0lVEiZCwn4Vh6lSB5c4YYsJguMNEc5EtcwYygx4ilAuAMtwYxooZy9n4NEa9HB68wE09KYTMATs989rRcFs0CDloQC+FK9itloqtQFrQ0TdDaoWzKxmCxosB8DH4+EFksz6ZayqTAERyXEdCxpV8NhdE5kXEaz+zBTFylDmloN9o6NHdaZTdeUuZxoPlnpVh6AmN4IFAaIFpNYY9iwO8GRy8cyySDNxQDloV4AiByAezWxvB2FkVZiYVDd6ANgqsl0wDKxHMMB499JaJ2F6gxAAllpeSrAhgPl1YSk+AVz4QRimtvUWt6VJiA9OsWUet9w+sOUBtSTli4S90gzJT1pnTlsFUlTlV0cvx1U3h1TWTvggzQIWSHiNdjVGEF5ixMpUR6wrRETJ0YysRIBdAbRPjvi1pfj6yM9vZATkDc8aSTCTVVLU9USl5R96SsTRTp8DBTK2LiZ4D11ECjKDK6TnE+0TK1KeT8A+Shhdy9DN0l0J8QSc9Q1EdT0FTFUWDcBeLVTsctVzoZVRLo1DVKBoAbJ9Sf1kIad0JTSaRsImdLTwNrTbSFgYq6IxRmTUqdV0qbJOMxRi1B0EzKArZJMPJwJ7hEg+BNRixAtD1AwyIw4wVElF1phX9QqaYjJLRTJzILIAB1EgAQAAWQkAYAyr8ykptGWpKl5FWoYDuXTCJWYFvz1HXnrhfz/lVltUuWQAgTwH1FWHbJDCHChjFlJgPIqv533xqID1yiUBHBC2uALMOydPEp2krGtHMwJOtHxWtGJDxmgE7gwGwNpQU3MUhnhn6N+twrPEsWFiHQ2h6QDR5mTC9UmUziRnMxDUOo5BOqkOm3yQpvfli1ogUl3H9hOmLBiuQCYDINplkrrD0m8xhVS0tGug+igFBhL1LPNHLJfOm2ZsJmznpkbD3AaCQr7GWjfPf0zy2s8QYQ4UdmCU73hEHDun70FWjmH1XKfi4z6PdzVtclHG8wNpNnGkXmHw0OcQQroAAG4XEuNrgHbqA0AnaNbXaglXYtCr4mjvMNE7azYQ6Uhw6XaI83aXEGCnL6AV4A6CkzZg758ipQ7U72z15gktCVFkhxz75JopysToEI707OFZ486x4Vz47iJ4QwBJzvNx9Lpnay6o6REjA4l8ICwm4Yg/5SFuN1axAItOqtojxercxdrqR7iSdAx60ACyCKt3DhR15cKvlxomMoQsp/Bx4m0KV2aaTDsdrRJ9qHIf8+thjPqm53d8y/cVNEA0BZdjDuwx5cA5h0xyyqr0zdIzYFRqB/7PyvqJTEif6SVkAOZ7ouYTQ0a2tboNNvEqIkoUlDRPyp6Z6Pad4KBipMivzFBkBgLhRrhLxxxfCKpNR37Q6XFcbJ1drIRjosoyChZKw0YJStdYLeaWAWj8YiUpAFBeGJIV6k1lVIBdd9ckVxifYroYgoL2qCMD00rZUtrXlaIfreRxyc7ki8klpzqbq9kqVpw/00aWUKLntqLCg2U6KejFizwmLRthU4GqqmrZs2LD0NrcBdiuKLgYq4rr0EqAIkrdVtHaqKAgn9STU5TIqXwUdwmVTImBKAINSwaSdEnv1DSSRjTKQJhgMiqMxmRWcoNKgxGT9JBhQfGGIN7togmGrxQ90EzTHGmOqwQl6erQk+q8ntoZSbFwbv4Tz76jGVx0xDG/rcgyA4FKD5VndTt2MUMXEob6YXcUNYGbIRH+aQxHpFGDcwL6VFozzzc0yrcMyzYNEtn4wUxMCjxiysszRpcZZ9njRKZ8JZb8tmh/65lKxgKrRBYbo5hFQDlyz8D+G641nFtXEaFH824jxPZ8b1I8wjosCjxBy8UUA1Jd6KDkHeIvdXq2z1Qtrk6Pcx5GCXEELWDb9zQIXHAGC5zQy+ijxwlWHQzanHEjxkWnmjx1D0j4EeaaQ/EkwyX1CRR8YnEtF8CACQg6xmRMHWXKB8V6XiJGXn5C7BRTF1WcjEA8jFR9WGZGZOxej59zhkXV93dBWCLVENV4QPmqwTQKBmAoVHWzHNWpphRmXPTV8FWXElX4RUkoDhRaXKkzQKV/XaYYK0NGjYXhRwl8BIltJa7cALW425z9EIlWD03jW9nJp7CKUqrKBZiWryD5Bfa8g0K/4jwsL+TjQeQw3xo5myN1n1hF7uqf4uxEi1NJwDyiG6Cp06HxAGHv7f7LjAXxon4Fl7ASYC5/gGIebiLbGyLjcHHpiustxnH5j6L3GjRPGhVyqm5+cZtXs2KCS2nOLoqbIIn+LNUcmhKdTBdWSCn4JkmHxMgDBegno8hcs8ARgTSiZKh5ciy0B2dzTqsBx2gdguh9hDA/2wP1AnQl1EAnR7AtoE46AnQPk+tEOjgoAABWEIAQQ+BgMIFwFQYj/IFwWgBgQ2Q+JwfWIKJwBgFwfWDjp2NABwAAdicAEFoEPno/yAEH1kI7/bQDCENiCkLj48LkPj46Ni474/E6cGI5lGI5cEFkNkY84/yENk44lFcBNh/eQ5YGYFQ/Q8w6yyvDmFw9yEQ6AA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=GreenEV-TQS24-25/backend&utm_content=8):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE
user: login: sonarqubecloud[bot]
created_at: 2025-05-18T18:36:58Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=GreenEV-TQS24-25_backend&pullRequest=8) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=GreenEV-TQS24-25_backend&pullRequest=8&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=GreenEV-TQS24-25_backend&pullRequest=8&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=GreenEV-TQS24-25_backend&pullRequest=8&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=GreenEV-TQS24-25_backend&pullRequest=8&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=GreenEV-TQS24-25_backend&pullRequest=8&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=GreenEV-TQS24-25_backend&pullRequest=8)


author_association: NONE