@Test public void hasNoClipboardContents() { when(clipboardHistory.hasContents()).thenReturn(false); action.performAction(nodes); verifyZeroInteractions(clipboard, dialogDisplayer); }
@Test public void hasClipboardContentsAndUserCancels() { when(clipboardHistory.hasContents()).thenReturn(true); when(dialogDisplayer.display(clipboardHistory)).thenReturn(-1); action.performAction(nodes); verifyZeroInteractions(clipboard); }
@Test public void hasClipboardContentsAndUserSelectsSomethingToPaste() { InOrder inOrder = inOrder(clipboardHistory, clipboard, pasteAction); when(clipboardHistory.hasContents()).thenReturn(true); when(dialogDisplayer.display(clipboardHistory)).thenReturn(1); when(clipboardHistory.top()).thenReturn("value"); when(actionMap.get("paste")).thenReturn(pasteAction); action.performAction(nodes); inOrder.verify(clipboardHistory).moveToTop(1); inOrder.verify(clipboard).setContents(isA(StringSelection.class), isA(StringSelection.class)); inOrder.verify(pasteAction).actionPerformed(isA(ActionEvent.class)); }