Why does the cache get filled with Values when using
@Autowired
ServiceXY serviceXY
@TestConfiguration
static class AppDefCachingTestConfiguration {
@Bean
public ServiceXY ServiceXYMock() {
return mock(ServiceXY.class);
}
}
But not with
@MockBean
ServiceXY serviceXY
When using @MockBean i get a NullPointerException when accessing the cache values like that in my test:
@Autowired
ConcurrentMapCacheManager cmcm;
@Test
void anTest(){
when(serviceXY.methodThatFillsCache(anyString()).thenReturn("ABC");
serviceXY.methodThatFillsCache("TEST1");
cmcm.getCache("Cachename").get("TEST1",String.class).equals("ABC");
...
}