Mocking Object that returns Java 8 Optional Object with Mockito returns Empty Optional
Your @Mock
in class is doing nothing. You created a separate instance of orderRepository
which is not injected into your service class. To inject your mock into context use @MockBean
Difference between @Mock
and @MockBean
here