### Question:
WheelScaler implements MouseWheelClosure { @Override public void mouseWheelMoved(int wheelClicks, Coordinate coordinate) { polygonPanel.scaleToPoint(calculateScale(wheelClicks), coordinate); polygonPanel.refresh(); } WheelScaler(PolygonPanel polygonPanel); @Override void mouseWheelMoved(int wheelClicks, Coordinate coordinate); static final double MIN_SCALE; }### Answer:
@Test public void triggersScaleOnPanelCenteredOnEvent() throws Exception { new WheelScaler(panel).mouseWheelMoved(5, new Coordinate(100, 120)); InOrder inOrder = inOrder(panel); inOrder.verify(panel).scaleToPoint(anyDouble(), eq(new Coordinate(100, 120))); }
@Test public void calculatesScaleFromNumberOfUnits() throws Exception { new WheelScaler(panel).mouseWheelMoved(5, new Coordinate(100, 120)); scalesToAnyPoint(0.75); }
@Test public void doesNotGoToZero() throws Exception { new WheelScaler(panel).mouseWheelMoved(20, new Coordinate(100, 120)); scalesToAnyPoint(0.00001); }
@Test public void limitsChangeToOne100Percent() throws Exception { new WheelScaler(panel).mouseWheelMoved(-21, new Coordinate(100, 120)); scalesToAnyPoint(2); }
@Test public void repaintsAfterTranslation() throws Exception { new WheelScaler(panel).mouseWheelMoved(5, new Coordinate(100, 120)); InOrder inOrder = inOrder(panel); inOrder.verify(panel).scaleToPoint(anyDouble(), any(Coordinate.class)); inOrder.verify(panel).refresh(); }