use of org.spongepowered.api.world.biome.BiomeTypes in project SpongeCommon by SpongePowered.
the class EventFilterTest method testAllCauseListener.
@Test
public void testAllCauseListener() throws Exception {
AllCauseListener listener = new AllCauseListener();
AnnotatedEventListener emptyListener = this.getListener(listener, "emptyListener", SubEvent.class, BiomeTypes[].class);
AnnotatedEventListener allCauseListener = this.getListener(listener, "allCauseListener", SubEvent.class, Player[].class);
Cause cause1 = TEST_CAUSE;
Cause cause2 = Cause.of(EventContext.empty(), mock(Player.class), "Hi", mock(Player.class));
SubEvent event1 = new SubEvent(cause1);
SubEvent event2 = new SubEvent(cause2);
emptyListener.handle(event1);
Assert.assertTrue("Listener with @All(ignoreEmpty = false) was not called!", listener.emptyListenerCalled);
listener.emptyListenerCalled = false;
emptyListener.handle(event2);
Assert.assertTrue("Listener with @All(ignoreEmpty = false) was not called!", listener.emptyListenerCalled);
allCauseListener.handle(event1);
Assert.assertFalse("Listener with @All was called with improper array parameter!", listener.allCauseListenerCalled);
allCauseListener.handle(event2);
Assert.assertTrue("Listener with @All was not called when proper Cause was provided!", listener.allCauseListenerCalled);
}
Aggregations