Mockito.when().thenReturn() doesn't work or returns null
问题 During the test there is a NullPointerException thrown. I tried to debug it and the only thing I worked out was that eventOptional is always null. Just as if Mockito.when().thenReturn() didn't work. Can anybody help? Here's my code for a tested service and for the test itself: @Service public class EventService { @Autowired public EventService(EventRepository eventRepository) { this.eventRepository = eventRepository; } //... public void updateEvent(EventDTO eventDTO) { Optional<Event>