AwtDrawableSurface extends JPanel { public void mouseReact() { final MouseAdapter listener = new MouseZoomTranslate(this); this.addMouseMotionListener(listener); this.addMouseListener(listener); this.addMouseWheelListener(listener); } AwtDrawableSurface(); void mouseReact(); @Override void paint(final Graphics graphics); Surface context(); void zoomIn(); void zoomOut(); void translate(final double amountx, final double amounty); AwtDrawableSurface withSize(final int width, final int height); void add(final AbstractAwtPaint painter); void setFigure(final Figure fig);  }
@Test public void addsMouseListener() { final AwtDrawableSurface surface = new AwtDrawableSurface(); final int size = surface.getListeners(MouseListener.class).length; surface.mouseReact(); MatcherAssert.assertThat( surface.getListeners(MouseListener.class).length, Matchers.greaterThan(size) ); }