### Question:
PastebinTaskListener implements BackgroundTaskListener { @Override public void onSuccess() { final String pasteUrl = task.getPasteUrl(); if (pasteUrl == null) { uiInvoker.raiseVisibleException("The server returned no URL for the paste. Please contact TMC support."); return; } uiInvoker.invokePastebinResultDialog(pasteUrl); } PastebinTaskListener(PastebinTask task, IdeUIInvoker uiInvoker); @Override void onBegin(); @Override void onSuccess(); @Override void onFailure(); @Override void onInterruption();  }### Answer:
@Test public void InvokesTheUIAfterSuccess() { when(task.getPasteUrl()).thenReturn("pasteurl"); listener.onSuccess(); verify(task, times(1)).getPasteUrl(); verify(invoker, times(1)).invokePastebinResultDialog("pasteurl"); }
@Test public void raiseErrorWithoutUIInvocationIfUrlIsNull() { when(task.getPasteUrl()).thenReturn(null); listener.onSuccess(); verify(invoker, times(1)).raiseVisibleException( "The server returned no URL for the paste. Please contact TMC support."); verify(task, times(1)).getPasteUrl(); verify(invoker, times(0)).invokePastebinResultDialog(any(String.class)); }