Mockito.when().thenReturn() doesn't work or returns null
<p>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:</p>

<pre class="lang-java prettyprint-override"><code>@Service
public class EventService {

    @Autowired 
    public EventService(EventRepository eventRepository) {
        this.eventRepository = eventRepository;
    }
    //...
    public void updateEvent(EventDTO eventDTO) {
        Optional&lt;Event&gt; eventOptional = eventRepository.findOneById(eventDTO.getId());

        eventOptional.orElseThrow(() -&gt; new BadRequestException(EVENT_NOT_FOUND));
        //...
    }
}
</code></pre>

<p>And the test class:</p>

<pre class="lang-java prettyprint-override"><code>@RunWith(MockitoJUnitRunner.class)
public class EventServiceTest {

    @Mock
    private EventRepository eventRepository;
    @InjectMocks
    private EventService eventService;

    private Event sampleEventFromDb;

    @Before
    public void setUp() throws Exception {

        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void shouldUpdateEventTestAndWithProperTime() throws Exception {
        EventDTO eventDTOMock = Mockito.mock(EventDTO.class);

        sampleEventFromDb = Event.builder()
            .name("name")
            .startDateTime(LocalDateTime.now())
            .placeName("place")
            .description("description")
            .publicEvent(true)
            .owner(new User())
            .build();

        Mockito.when(eventRepository.findOneById(anyString())).thenReturn(Optional.of(sampleEventFromDb));
        Mockito.when(eventDTOMock.getId()).thenReturn("1");

        eventService.updateEvent(eventDTOMock); //NullPointerException
        //...
    }
}
</code></pre>