LibShapeDraw { public LibShapeDraw addEventListener(LSDEventListener listener) { if (listener == null) { throw new IllegalArgumentException("listener cannot be null"); } eventListeners.add(listener); return this; } LibShapeDraw();  LibShapeDraw(String ownerId); boolean unregister(); @Deprecated static String getVersion(); @Deprecated static boolean isControllerInitialized(); LibShapeDraw verifyInitialized(); MinecraftAccess getMinecraftAccess(); boolean isVisible(); LibShapeDraw setVisible(boolean visible); boolean isVisibleWhenHidingGui(); LibShapeDraw setVisibleWhenHidingGui(boolean visibleWhenHidingGui); Set<Shape> getShapes(); LibShapeDraw addShape(Shape shape); LibShapeDraw removeShape(Shape shape); LibShapeDraw clearShapes(); Set<LSDEventListener> getEventListeners(); LibShapeDraw addEventListener(LSDEventListener listener); LibShapeDraw removeEventListener(LSDEventListener listener); LibShapeDraw clearEventListeners(); boolean debugDump(); String getInstanceId(); @Override String toString();  }
@Test(expected=IllegalArgumentException.class) public void testEventListenersAddNull() { lib.addEventListener(null); }
@Test public void testEventListenersFire() { MockLSDEventListener counter = new MockLSDEventListener(); counter.assertCountsEqual(0, 0, 0); LSDController.getInstance().respawn(new Vector3(0,0,0), true, true); LSDController.getInstance().gameTick(new Vector3(0,0,0)); LSDController.getInstance().render(new Vector3(0,0,0), false); counter.assertCountsEqual(0, 0, 0); lib.addEventListener(counter); LSDController.getInstance().respawn(new Vector3(0,0,0), true, true); counter.assertCountsEqual(1, 0, 0); LSDController.getInstance().gameTick(new Vector3(0,0,0)); counter.assertCountsEqual(1, 1, 0); LSDController.getInstance().render(new Vector3(0,0,0), false); counter.assertCountsEqual(1, 1, 1); }
@Test public void testEventListenersFireMultiple() { MockLSDEventListener counter0 = new MockLSDEventListener(); MockLSDEventListener counter1 = new MockLSDEventListener(); MockLSDEventListener counter2 = new MockLSDEventListener(); lib.addEventListener(counter0).addEventListener(counter1).addEventListener(counter2); LSDController.getInstance().respawn(new Vector3(0,0,0), true, true); counter0.assertCountsEqual(1, 0, 0); counter1.assertCountsEqual(1, 0, 0); counter2.assertCountsEqual(1, 0, 0); LSDController.getInstance().gameTick(new Vector3(0,0,0)); counter0.assertCountsEqual(1, 1, 0); counter1.assertCountsEqual(1, 1, 0); counter2.assertCountsEqual(1, 1, 0); LSDController.getInstance().render(new Vector3(0,0,0), false); counter0.assertCountsEqual(1, 1, 1); counter1.assertCountsEqual(1, 1, 1); counter2.assertCountsEqual(1, 1, 1); }