InterceptorCache { @PostConstruct public void initialise() { final HashMap<String, Set<InterceptorChainEntryInstance>> orderedComponentInterceptors = new HashMap<>(); final Map<Class<?>, Interceptor> interceptorInstancesByType = interceptorInstancesByType(); interceptorChainObserver.getInterceptorChainProviderBeans().forEach(providerBean -> createInterceptorChainsByComponent(interceptorInstancesByType, orderedComponentInterceptors, providerBean)); createComponentInterceptorsFrom(orderedComponentInterceptors); }  @PostConstruct void initialise();  }
@SuppressWarnings("unchecked") @Test public void shouldThrowExceptionIfInterceptorBeanNotInstantiated() throws Exception { expectedException.expect(InterceptorCacheException.class); expectedException.expectMessage("Could not instantiate interceptor bean of type: uk.gov.justice.services.core.interceptor.InterceptorCacheTest$InterceptorOne"); final Class interceptorClass_1 = InterceptorOne.class; final Bean<Interceptor> interceptorBean_1 = mock(Bean.class); when(observer.getInterceptorBeans()).thenReturn(singletonList(interceptorBean_1)); when(interceptorBean_1.getBeanClass()).thenReturn(interceptorClass_1); when(beanInstantiater.instantiate(interceptorBean_1)).thenReturn(null); final Bean<InterceptorChainEntryProvider> interceptorChainProviderBean = mock(Bean.class); when(observer.getInterceptorChainProviderBeans()).thenReturn(singletonList(interceptorChainProviderBean)); when(beanInstantiater.instantiate(interceptorChainProviderBean)).thenReturn(new InterceptorChainEntryProvider() { @Override public String component() { return "some component"; } @Override public List<InterceptorChainEntry> interceptorChainTypes() { final List<InterceptorChainEntry> interceptorChainTypes = new ArrayList<>(); interceptorChainTypes.add(new InterceptorChainEntry(1, interceptorClass_1)); return interceptorChainTypes; } }); interceptorCache.initialise(); }