-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransportServiceTest.java
More file actions
33 lines (27 loc) · 1.06 KB
/
Copy pathTransportServiceTest.java
File metadata and controls
33 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.*;
public class TransportServiceTest {
@Mock
private TransportRepository transportRepository;
@InjectMocks
private TransportService transportService;
@Test
void getTransportsByBrandTest() {
String brand = "Tatra";
Transport transport1 = new Transport();
Transport transport2 = new Transport();
when(transportRepository.findByBrand(brand)).thenReturn(Arrays.asList(transport1, transport2));
List<Transport> result = transportService.getTransportsByBrand(brand);
assertSame(2, result.size());
verify(transportRepository, times(1)).findByBrand(brand);
}
@Test
void deleteTransportTest() {
String registrationNumber = "3009";
transportService.deleteTransport(registrationNumber);
verify(transportRepository, times(1)).deleteByRegistrationNumber(registrationNumber);
}
}