Пример #1
0
  @Test
  public void testOnValueChanged() throws Exception {
    when(view.getMessage()).thenReturn(COMMIT_TEXT);

    presenter.onValueChanged();

    verify(view).setEnableCommitButton(eq(!DISABLE_BUTTON));
  }
Пример #2
0
  @Test
  public void testOnCommitClickedWhenCommitRequestIsFailed() throws Exception {
    when(view.getMessage()).thenReturn(COMMIT_TEXT);
    when(view.isAllFilesInclued()).thenReturn(ALL_FILE_INCLUDES);
    when(view.isAmend()).thenReturn(IS_OVERWRITTEN);
    doAnswer(
            new Answer() {
              @Override
              public Object answer(InvocationOnMock invocation) throws Throwable {
                Object[] arguments = invocation.getArguments();
                AsyncRequestCallback<Revision> callback =
                    (AsyncRequestCallback<Revision>) arguments[4];
                Method onFailure = GwtReflectionUtils.getMethod(callback.getClass(), "onFailure");
                onFailure.invoke(callback, mock(Throwable.class));
                return callback;
              }
            })
        .when(service)
        .commit(
            (ProjectDescriptor) anyObject(),
            anyString(),
            anyBoolean(),
            anyBoolean(),
            (AsyncRequestCallback<Revision>) anyObject());

    presenter.showDialog();
    presenter.onCommitClicked();

    verify(view, times(2)).getMessage();
    verify(view).isAllFilesInclued();
    verify(view).isAmend();
    verify(view).close();
    verify(view, times(0)).setMessage(anyString());

    verify(service)
        .commit(
            eq(rootProjectDescriptor),
            eq(COMMIT_TEXT),
            eq(ALL_FILE_INCLUDES),
            eq(IS_OVERWRITTEN),
            (AsyncRequestCallback<Revision>) anyObject());
    verify(constant).commitFailed();
    verify(console).printError(anyString());
    verify(notificationManager).showNotification((Notification) anyObject());
  }
Пример #3
0
  @Test
  public void testShowDialogWithExistingMessage() throws Exception {
    when(view.getMessage()).thenReturn("foo");
    presenter.showDialog();

    verify(view).setAmend(eq(!IS_OVERWRITTEN));
    verify(view).setAllFilesInclude(eq(!ALL_FILE_INCLUDES));
    verify(view).focusInMessageField();
    verify(view).setEnableCommitButton(eq(ENABLE_BUTTON));
    verify(view).getMessage();
    verify(view).showDialog();
  }