@Test(expected = IOException.class) public void shouldBeAbleToDetectExceptionEventLoopAndThrowOriginalException() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(ExtensionObservingExceptionLoop.class).create(); manager.fire(new IOException("should cause exception")); }
@Test(expected = IOException.class) public void shouldBeAbleToDetectExceptionEventLoopAndThrowOriginalException() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(ExtensionObservingExceptionLoop.class).create(); manager.fire(new IOException("should cause exception")); }
@Test public void shouldExecuteProducersOnSameEventBeforeConsumers() throws Exception { Manager manager = ManagerBuilder.from() .extensions(ConsumerOne.class, ProducerOne.class, ProducerTwo.class).create(); manager.fire("test"); Assert.assertEquals("ProducerOne", callOrder.get(0)); Assert.assertEquals("ProducerTwo", callOrder.get(1)); Assert.assertEquals("ConsumerOne", callOrder.get(2)); }
@Test public void shouldExecuteProducersOnSameEventBeforeConsumers() throws Exception { Manager manager = ManagerBuilder.from() .extensions(ConsumerOne.class, ProducerOne.class, ProducerTwo.class).create(); manager.fire("test"); Assert.assertEquals("ProducerOne", callOrder.get(0)); Assert.assertEquals("ProducerTwo", callOrder.get(1)); Assert.assertEquals("ConsumerOne", callOrder.get(2)); }
@Test public void shouldBeAbleToFireExceptionEventOnFailingObserver() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(ExtensionWithExceptionObserver.class, ExtensionObservingException.class).create(); manager.fire("should cause exception"); Assert.assertTrue(manager.getExtension(ExtensionObservingException.class).methodOneWasCalled); }
@Test public void shouldBeAbleToFireExceptionEventOnFailingObserver() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(ExtensionWithExceptionObserver.class, ExtensionObservingException.class).create(); manager.fire("should cause exception"); Assert.assertTrue(manager.getExtension(ExtensionObservingException.class).methodOneWasCalled); }
@Test public void shouldBeAbleToFireEvent() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(TestObserver.class).create(); EventImpl<Object> event = EventImpl.of(Object.class, manager); Object testObject = new TestCommand(); event.fire(testObject); TestObserver observer = manager.getExtension(TestObserver.class); Assert.assertTrue(observer.wasCalled); Assert.assertTrue(observer.observerWasCalled); Assert.assertEquals( "Verify same object was observed", testObject, observer.getObject()); }
@Test public void shouldBeAbleToFireEvent() throws Exception { ManagerImpl manager = (ManagerImpl) ManagerBuilder.from() .extensions(TestObserver.class).create(); EventImpl<Object> event = EventImpl.of(Object.class, manager); Object testObject = new TestCommand(); event.fire(testObject); TestObserver observer = manager.getExtension(TestObserver.class); Assert.assertTrue(observer.wasCalled); Assert.assertTrue(observer.observerWasCalled); Assert.assertEquals( "Verify same object was observed", testObject, observer.getObject()); }
.context(ManagerTestContextImpl.class) .context(ManagerTest2ContextImpl.class) .extensions( TestObserverOne.class, TestObserverTwo.class,
.context(ManagerTestContextImpl.class) .context(ManagerTest2ContextImpl.class) .extensions( TestObserverOne.class, TestObserverTwo.class,