How to mock a Service that uses JdbcTemplate

13 Views Asked by At

I have a service which uses a JdbcTemplate. I want to use the service in a test but verify that the mock template is is invoked. I'd like to specify the class in ContextConfiguration but have the mock JdbcTemplate in place of the real one, how can I do this? Here is the class

         class NotificationService {
           
            private JdbcTemplate jdbcTemplate;
            
            @Autowired 
            public NotificationService(JdbcTemplate template){
               this.jdbcTemplate = template;

         }

I want to load the contest like this, but with a Mock JdbcTemplate

@ContextConfiguration(classes = { NotificationService.class })

0

There are 0 best solutions below