I have this in Mockito:
when(mockedMergeContext.createNewEntityOfType(IService.class)).thenReturn(new ServiceMock()); >
In Java 8 with Lambdas you can just use
when(mockedMergeContext.createNewEntityOfType(IService.class)).thenAnswer(invocation -> new ServiceMock());
So just replace .thenReturn(new MyMock());
.thenReturn(new MyMock());
with .thenAnswer(invocation -> new MyMock());
.thenAnswer(invocation -> new MyMock());