diff --git a/core/src/test/java/cz/muni/pa165/service/CarComponentServiceTest.java b/core/src/test/java/cz/muni/pa165/service/CarComponentServiceTest.java
index 8e0f2261cec06af1d958e1f0c753162a74bc39f1..ea22d3a0dcde775827c3d39df3fa115c8c3a6a8c 100644
--- a/core/src/test/java/cz/muni/pa165/service/CarComponentServiceTest.java
+++ b/core/src/test/java/cz/muni/pa165/service/CarComponentServiceTest.java
@@ -52,7 +52,7 @@ class CarComponentServiceTest {
     void updateNonExistingComponent() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(carComponentRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(carComponentRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             carComponentService.update(Long.MAX_VALUE, null);
@@ -72,7 +72,7 @@ class CarComponentServiceTest {
     void findNonExistingComponentById() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(carComponentRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(carComponentRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             carComponentService.findById(Long.MAX_VALUE);
@@ -117,7 +117,7 @@ class CarComponentServiceTest {
     void deleteNonExisting() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(carComponentRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(carComponentRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             carComponentService.delete(Long.MAX_VALUE);
diff --git a/core/src/test/java/cz/muni/pa165/service/DepartmentServiceTest.java b/core/src/test/java/cz/muni/pa165/service/DepartmentServiceTest.java
index 1f27da626a23ef8e7cdc78a033c0dc35ce98fb40..72dcb8c99ffe195ea853d18c3f8b5c03367d0a26 100644
--- a/core/src/test/java/cz/muni/pa165/service/DepartmentServiceTest.java
+++ b/core/src/test/java/cz/muni/pa165/service/DepartmentServiceTest.java
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
 import java.util.HashSet;
+import java.util.Optional;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -58,7 +59,7 @@ class DepartmentServiceTest {
 
     @Test
     void addNonExistingEngineer() {
-        when(engineerRepository.findById(1L)).thenThrow(new ResourceNotFoundException(Engineer.class, 1L));
+        when(engineerRepository.findById(1L)).thenReturn(Optional.empty());
         when(departmentRepository.findById(emptyDepartment.getId())).thenReturn(java.util.Optional.of(emptyDepartment));
 
         assertThrows(ResourceNotFoundException.class, () -> service.addEngineer(emptyDepartment.getId(), 1L));
diff --git a/core/src/test/java/cz/muni/pa165/service/DriverServiceTest.java b/core/src/test/java/cz/muni/pa165/service/DriverServiceTest.java
index 8dfc26da6e7abbdf2f3acb88b82e2eb0bfb5ca74..842f2678ada8eec16bb2ff1eee257e473ad7d532 100644
--- a/core/src/test/java/cz/muni/pa165/service/DriverServiceTest.java
+++ b/core/src/test/java/cz/muni/pa165/service/DriverServiceTest.java
@@ -57,7 +57,7 @@ class DriverServiceTest {
     void updateNonExistingDriver() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(driverRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(driverRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             driverService.update(Long.MAX_VALUE, null);
@@ -77,7 +77,7 @@ class DriverServiceTest {
     void findNonExistingDriverById() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(driverRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(driverRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             driverService.findById(Long.MAX_VALUE);
@@ -110,7 +110,7 @@ class DriverServiceTest {
     void deleteNonExisting() {
         var exceptionToThrow = new ResourceNotFoundException(CarComponent.class, Long.MAX_VALUE);
 
-        when(driverRepository.findById(Long.MAX_VALUE)).thenThrow(exceptionToThrow);
+        when(driverRepository.findById(Long.MAX_VALUE)).thenReturn(Optional.empty());
 
         assertThrows(exceptionToThrow.getClass(), () -> {
             driverService.delete(Long.MAX_VALUE);
diff --git a/core/src/test/java/cz/muni/pa165/service/EngineerServiceTest.java b/core/src/test/java/cz/muni/pa165/service/EngineerServiceTest.java
index 06f98ea84b151d45d3a0bae7d7ca3318a3761162..c51b597ab5740efaba4d106f2da9773e9aea7349 100644
--- a/core/src/test/java/cz/muni/pa165/service/EngineerServiceTest.java
+++ b/core/src/test/java/cz/muni/pa165/service/EngineerServiceTest.java
@@ -35,7 +35,7 @@ class EngineerServiceTest {
 
     @Test
     void findNonExistingEngineerById() {
-        when(engineerRepository.findById(1L)).thenThrow(new ResourceNotFoundException(Engineer.class, 1L));
+        when(engineerRepository.findById(1L)).thenReturn(Optional.empty());
 
         assertThrows(ResourceNotFoundException.class, () -> service.findById(1L));
     }