I want to mock database call with fake data but I got stuck in the following scenario:
MyService
public class MyService {
// some stuff
Page<SampleDto> sample = repo.findAllSample();
// other stuff
}
I want to stub this with when() but I am not able to do this. My test is:
MyServiceTest
public class MySampleTest {
@Test
void myTest() {
// initialisation and all stuff
when(myRepo.findAll()).thenReturn(......)
// I want to pass 2 fake SampleDto from
// here but don't know how to do that
}
}