I have a registration service. I also use other entities in this service, such as passenger and trip. And I have a registerPassengerToTrip method inside registration service.
When I want to test this method, I get an error
...ValidationException: Passenger with id 9b81fdd1-9444-48bf-bdaf-bbec5f750959 not found
public void whenRegisterPassengerToTrip_thenReturnPassInTrip(){
// prepare
UUID passengerId = UUID.randomUUID();
UUID tripId = UUID.randomUUID();
Integer seatNumber = 5;
// testing
PassInTrip passInTrip = registrationService.registerPassengerToTrip(passengerId, tripId, seatNumber);
// validate
verify(registrationRepository).save(any());
}
How do I correctly add new passenger and new trip to whenRegisterPassengerToTrip_thenReturnPassInTrip method so that passengerId is not null? Does this require a mock PassengerRepository and TripRepository?