@Test
  public void testBuildCommandFail() {
    BuildMessage message = mock(BuildMessage.class);
    List<BuildMessage> messages = new ArrayList<BuildMessage>();
    messages.add(message);

    BuildResults results = mock(BuildResults.class);
    when(results.getErrorMessages()).thenReturn(messages);

    when(buildService.buildAndDeploy(any(Project.class))).thenReturn(results);

    presenter.triggerBuild();

    verify(notificationEvent)
        .fire(
            argThat(
                new ArgumentMatcher<NotificationEvent>() {
                  @Override
                  public boolean matches(final Object argument) {
                    final NotificationEvent event = (NotificationEvent) argument;
                    final String notification = event.getNotification();
                    final NotificationEvent.NotificationType type = event.getType();

                    return notification.equals(ProjectEditorResources.CONSTANTS.BuildFailed())
                        && type.equals(NotificationEvent.NotificationType.ERROR);
                  }
                }));

    verify(view, times(1)).showBusyIndicator(eq(ProjectEditorResources.CONSTANTS.Building()));
    // There are two calls to "hide" by this stage; one from the view initialisation one for the
    // build
    verify(view, times(2)).hideBusyIndicator();
  }
  @Test
  public void testIsDirtyBuild() {
    model.setPOM(mock(POM.class)); // causes isDirty evaluates as true
    presenter.triggerBuild();

    verify(view, times(1))
        .showSaveBeforeContinue(any(Command.class), any(Command.class), any(Command.class));
    verify(notificationEvent, never()).fire(any(NotificationEvent.class));
    verifyBusyShowHideAnyString(1, 1);
  }
  @Test
  public void testAlreadyRunningBuild() {
    constructProjectScreenPresenter(
        buildServiceCaller(), new CallerMock<AssetManagementService>(assetManagementServiceMock));

    presenter.triggerBuild();
    presenter.triggerBuild();

    verify(view, times(1)).showABuildIsAlreadyRunning();
    verify(notificationEvent, never()).fire(any(NotificationEvent.class));
    verifyBusyShowHideAnyString(2, 1);
  }
  @Test
  public void testBuildCommand() {
    presenter.triggerBuild();

    verify(notificationEvent)
        .fire(
            argThat(
                new ArgumentMatcher<NotificationEvent>() {
                  @Override
                  public boolean matches(final Object argument) {
                    final NotificationEvent event = (NotificationEvent) argument;
                    final String notification = event.getNotification();
                    final NotificationEvent.NotificationType type = event.getType();

                    return notification.equals(ProjectEditorResources.CONSTANTS.BuildSuccessful())
                        && type.equals(NotificationEvent.NotificationType.SUCCESS);
                  }
                }));

    verify(view, times(1)).showBusyIndicator(eq(ProjectEditorResources.CONSTANTS.Building()));
    // There are two calls to "hide" by this stage; one from the view initialisation one for the
    // build
    verify(view, times(2)).hideBusyIndicator();
  }