View Javadoc
1   package com.atlassian.plugin.event.listeners;
2   
3   import static org.junit.Assert.assertEquals;
4   import static org.junit.Assert.assertTrue;
5   
6   public class PassListener {
7       private final Class<?> clazz;
8       private int called = 0;
9   
10      public PassListener(final Class<?> clazz) {
11          this.clazz = clazz;
12      }
13  
14      public void channel(final Object o) {
15          if (clazz.isInstance(o)) {
16              called++;
17          }
18      }
19  
20      public void assertCalled() {
21          assertTrue("Event not thrown " + clazz.getName(), called > 0);
22          reset();
23      }
24  
25      public void assertCalled(final int times) {
26          assertEquals("Event not thrown " + clazz.getName(), times, called);
27          reset();
28      }
29  
30      public void reset() {
31          called = 0;
32      }
33  }