@Test
  public void rollbackPaymentOrderProcessing() {
    final String actionName = "Status2 -> Status1";
    controller.disbandDownstreamDocuments(actionName);

    verify(cache).disbandDownstreamDocuments(actionName);
    verify(dialog, never()).dispose();
  }
  @Test(expected = RowNotSelectedException.class)
  public void aFundingSouldBeSelectedInOrderToRemoveItsElectronicDocuments() {
    final String CONFIRNATION_DIALOG_OUTCOME = "RollbackPaymentOrderProcessing";

    when(cache.getFunding()).thenReturn(null);

    controller.openDisbandDownstreamDocumentsDialog(CONFIRNATION_DIALOG_OUTCOME);
  }
  @Test
  public void displayConfirmationDialogBeforeGeneratingSufdDocument() {

    controller.openCreateSufdDocumentConfirmationDialog(mock(ActionEvent.class));

    verify(dialog).displayConfirmationForm("CreateSufdDocument");
    verifyNoMoreInteractions(cache, dialog);
  }
  @Test
  public void openProcessAccrualsConfirmationDialog() {
    final String OUTCOME = "ProcessAccrualsAndGeneratePayments";

    controller.openProcessAccrualsConfirmationDialog(OUTCOME);

    verify(dialog).displayInputForm(OUTCOME);
  }
  @Test
  public void openGenerateAccrualGroupsDialog() {
    final String GENERATE_ACCRUAL_GROUPS_OUTCOME = "GenerateAccrualGroups";

    controller.openGenerateAccrualGroupsDialog(GENERATE_ACCRUAL_GROUPS_OUTCOME);

    verify(dialog).displayInputForm(GENERATE_ACCRUAL_GROUPS_OUTCOME);
  }
  @Test(expected = RowNotSelectedException.class)
  public void throwRowNotSelectedExceptionWhenAFundingIsNotSelected() {
    final String GENERATE_PAYMENT_ORDERS_DIALOG_OUTCOME = "GeneratePaymentOrders";

    when(cache.getFunding()).thenReturn(null);

    controller.openProcessPaymentsConfirmationDialog(GENERATE_PAYMENT_ORDERS_DIALOG_OUTCOME);
  }
  @Test
  public void openDisbandAccrualGroupsDialog() {
    final String DISBAND_ACCRUAL_GROUPS_OUTCOME = "DisbandAccrualGroups";

    controller.openDisbandAccrualGroupsDialog(DISBAND_ACCRUAL_GROUPS_OUTCOME);

    verify(dialog).displayInputForm(DISBAND_ACCRUAL_GROUPS_OUTCOME);
  }
  @Test
  public void openKosguReferenceParameterGatherer() {
    final String PARAM_GATHERER_OUTCOME = "KosguReferenceParameterGatherer";

    controller.openKosguReferenceParameterGathererDialog(PARAM_GATHERER_OUTCOME);

    verify(dialog).displayInputForm(PARAM_GATHERER_OUTCOME);
  }
  @Test
  public void displayPaymentOrderRosterReportParameterGatherer() {
    final String outcome = "PaymentOrderRosterReportParameterGatherer";

    controller.openPaymentOrderRosterReportParameterGathererDialog();

    verify(dialog).displayInputForm(outcome);
  }
  @Test(expected = RowNotSelectedException.class)
  public void verifyIfAnyFundingIsSelectedBeforePaymentOrderRemoval() {
    final String CONFIRMATION_DIALOG_OUTCOME = "RollbackPaymentProcessing";

    when(cache.getFunding()).thenReturn(null);

    controller.openUndoPaymentsProcessingConfirmationDialog(CONFIRMATION_DIALOG_OUTCOME);
  }
  @Test(expected = RowNotSelectedException.class)
  public void verifyAFundingIsSelectedBeforeGeneratingElectronicDocuments() {
    final String GENERATE_ELECTRONIC_DOCUMENT_DIALOG_OUTCOME = "GenerateElectronicDocument";

    when(cache.getFunding()).thenReturn(null);

    controller.openProcessPaymentOrdersConfirmationDialog(
        GENERATE_ELECTRONIC_DOCUMENT_DIALOG_OUTCOME);
  }
  @Test
  public void scheduleAnEditOperationAndDisplayEditDialog() {

    controller.openEditSelectedFundingDialog(EDIT_OUTCOME);

    InOrder inOrder = inOrder(cache, dialog);

    inOrder.verify(cache).scheduleEditOperation();
    inOrder.verify(dialog).displayInputForm(EDIT_OUTCOME);
  }
  @Test
  public void scheduleARemoveOperationAndDisplayConfirmationDialog() {

    controller.openRemoveSelectedFundingConfirmationDialog(REMOVE_OUTCOME);

    InOrder inOrder = inOrder(cache, dialog);

    inOrder.verify(cache).scheduleRemoveOperation();
    inOrder.verify(dialog).displayBeforeRemoveConfirmationDialog(REMOVE_OUTCOME);
  }
  @Test
  public void openProcessPaymentsConfirmationDialog() {
    final String GENERATE_PAYMENT_ORDERS_DIALOG_OUTCOME = "GeneratePaymentOrders";

    when(cache.getFunding()).thenReturn(mock(Funding.class));

    controller.openProcessPaymentsConfirmationDialog(GENERATE_PAYMENT_ORDERS_DIALOG_OUTCOME);

    verify(dialog).displayProgressPopup(GENERATE_PAYMENT_ORDERS_DIALOG_OUTCOME);
  }
  @Test
  public void openUndoPaymentsProcessingConfirmationDialog() {
    final String CONFIRMATION_DIALOG_OUTCOME = "RollbackPaymentProcessing";

    when(cache.getFunding()).thenReturn(mock(Funding.class));

    controller.openUndoPaymentsProcessingConfirmationDialog(CONFIRMATION_DIALOG_OUTCOME);

    verify(dialog).displayBeforeRemoveConfirmationDialog(CONFIRMATION_DIALOG_OUTCOME);
  }
  @Test
  public void creteANewFundingAndScheduleACreateOperationAndDisplayEditDialog() {

    controller.openCreateNewFundingDialog(EDIT_OUTCOME);

    InOrder inOrder = inOrder(cache, dialog);

    inOrder.verify(cache).createNewFunding();
    inOrder.verify(cache).scheduleCreateOperation();
    inOrder.verify(dialog).displayInputForm(EDIT_OUTCOME);
  }
  @Test
  public void openProcessPaymentOrdersConfirmationDialog() {
    final String GENERATE_ELECTRONIC_DOCUMENT_DIALOG_OUTCOME = "GenerateElectronicDocument";

    when(cache.getFunding()).thenReturn(mock(Funding.class));

    controller.openProcessPaymentOrdersConfirmationDialog(
        GENERATE_ELECTRONIC_DOCUMENT_DIALOG_OUTCOME);

    verify(dialog).displayProgressPopup(GENERATE_ELECTRONIC_DOCUMENT_DIALOG_OUTCOME);
  }