@Before public void setUp() { mockCommandBus = mock(CommandBus.class); mockApplicationContext = mock(ApplicationContext.class); testSubject = new AnnotationCommandHandlerBeanPostProcessor(); testSubject.setCommandBus(mockCommandBus); testSubject.setApplicationContext(mockApplicationContext); }
@Test public void testCommandBusIsAutowired() throws Exception { testSubject.setCommandBus(null); Map<String, CommandBus> map = new HashMap<String, CommandBus>(); map.put("ignored", mockCommandBus); when(mockApplicationContext.getBeansOfType(CommandBus.class)).thenReturn(map); testSubject.afterPropertiesSet(); verify(mockApplicationContext).getBeansOfType(CommandBus.class); }