### Question:
MouseHeadless implements Mouse { @Override public void doClick(int click) { if (click < clicks.length) { clicks[click] = true; lastClick = click; } } MouseHeadless(); void mousePressed(MouseEvent event); void mouseReleased(MouseEvent event); void mouseMoved(MouseEvent event); void mouseDragged(MouseEvent event); @Override void doClick(int click); @Override void doSetMouse(int x, int y); @Override void doMoveMouse(int x, int y); @Override void doClickAt(int click, int x, int y); @Override int getOnScreenX(); @Override int getOnScreenY(); @Override int getX(); @Override int getY(); @Override int getMoveX(); @Override int getMoveY(); @Override int getClick(); @Override boolean hasClicked(int click); @Override boolean hasClickedOnce(int click); @Override boolean hasMoved(); @Override void update(double extrp); static final int LEFT; static final int MIDDLE; static final int RIGHT; static final int MAX_BUTTONS; }### Answer:
@Test void testDoClick() { final MouseHeadless mouse = new MouseHeadless(); assertFalse(mouse.hasClicked(MouseHeadless.RIGHT)); mouse.mouseMoved(createEvent(MouseHeadless.LEFT, 0, 0)); mouse.doClickAt(MouseHeadless.RIGHT, 500, 500); mouse.update(1.0); try { assertEquals(500, mouse.getOnScreenX()); assertEquals(500, mouse.getOnScreenY()); assertTrue(mouse.hasClicked(MouseHeadless.RIGHT)); } finally { mouse.doClickAt(MouseHeadless.LEFT, 499, 499); } assertTrue(mouse.hasClicked(MouseHeadless.LEFT)); mouse.doClick(MouseHeadless.LEFT); assertTrue(mouse.hasClicked(MouseHeadless.LEFT)); mouse.update(1.0); mouse.doClick(MouseHeadless.MIDDLE); mouse.update(1.0); mouse.doSetMouse(1, 2); assertEquals(1, mouse.getOnScreenX()); assertEquals(2, mouse.getOnScreenY()); mouse.doMoveMouse(3, 4); assertEquals(3, mouse.getOnScreenX()); assertEquals(4, mouse.getOnScreenY()); }