Guest User

Untitled

a guest
Oct 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. parent
  2. module-one
  3. module-two
  4. ...
  5. module-n
  6.  
  7. @Service
  8. public void MegaService {
  9. @Autowired
  10. MegaRepository repository;
  11. // ....
  12. }
  13.  
  14. public interface MegaRepository extends JpaRepository<MegaModel, Long> {
  15. // ...
  16. }
  17.  
  18. @Configuration
  19. public class TestRepoConfiguration {
  20.  
  21. @Bean
  22. MegaRepository megaRepository(MegaRepository repository) {
  23. return Mockito.spy(repository); // of course, it does not work
  24. }
  25. }
  26.  
  27. @RunWith(SpringJUnit4ClassRunner.class)
  28. public class MegaIntegrationTest {
  29. @Autowired
  30. MegaRepository repository;
  31.  
  32. public void testMegaLogic() {
  33. when(repository.findAll()).thenAnswer(invocation -> {
  34. System.out.println("Hello, comrades");
  35. return invocation;
  36. });
  37. }
  38. }
Add Comment
Please, Sign In to add comment