Skip to content

Commit

Permalink
add test for private method listener
Browse files Browse the repository at this point in the history
  • Loading branch information
orsondmc committed May 20, 2024
1 parent 49acd61 commit 337d621
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/java/com/collarmc/pounce/EventBusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

public class EventBusTest {

@Test
public void privateSubscriber() {
PrivateListener listener = new PrivateListener();
EventBus eventBus = new EventBus(Runnable::run);
eventBus.subscribe(listener);
Event e = new Event();
// Fire it
eventBus.dispatch(e);
Assert.assertEquals(e, listener.event);
}

@Test
public void unsubscribe() {
// Subscribe to the event
Expand Down Expand Up @@ -205,4 +216,12 @@ public void exec3(Event event) {
this.event3 = event;
}
}

public static class PrivateListener {
Event event;
@Subscribe(Preference.CALLER)
private void exec(Event event) {
this.event = event;
}
}
}

0 comments on commit 337d621

Please sign in to comment.