Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- parent
- module-one
- module-two
- ...
- module-n
- @Service
- public void MegaService {
- @Autowired
- MegaRepository repository;
- // ....
- }
- public interface MegaRepository extends JpaRepository<MegaModel, Long> {
- // ...
- }
- @Configuration
- public class TestRepoConfiguration {
- @Bean
- MegaRepository megaRepository(MegaRepository repository) {
- return Mockito.spy(repository); // of course, it does not work
- }
- }
- @RunWith(SpringJUnit4ClassRunner.class)
- public class MegaIntegrationTest {
- @Autowired
- MegaRepository repository;
- public void testMegaLogic() {
- when(repository.findAll()).thenAnswer(invocation -> {
- System.out.println("Hello, comrades");
- return invocation;
- });
- }
- }
Add Comment
Please, Sign In to add comment