Search in sources :

Example 1 with BiomeTypes

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);
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) BiomeTypes(org.spongepowered.api.world.biome.BiomeTypes) Cause(org.spongepowered.api.event.cause.Cause) AllCauseListener(org.spongepowered.common.event.listener.AllCauseListener) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Player (org.spongepowered.api.entity.living.player.Player)1 Cause (org.spongepowered.api.event.cause.Cause)1 BiomeTypes (org.spongepowered.api.world.biome.BiomeTypes)1 AllCauseListener (org.spongepowered.common.event.listener.AllCauseListener)1