コード例 #1
0
  @BeforeMethod
  public void beforeMethod() {
    MockitoAnnotations.initMocks(this);
    configHolder = new UserConfigHolder();

    when(userOptionsService.getConfigHolder()).thenReturn(configHolder);

    userWorkspaceContext = TestFixture.userWorkspaceContext();
    presenter =
        new TargetContentsPresenter(
            displayProvider,
            editorTranslators,
            eventBus,
            tableEditorMessages,
            sourceContentPresenter,
            userWorkspaceContext,
            editorKeyShortcuts,
            historyPresenter,
            userOptionsService,
            saveAsApprovedConfirmation,
            reviewCommentPresenter);

    verify(eventBus).addHandler(UserConfigChangeEvent.TYPE, presenter);
    verify(eventBus).addHandler(RequestValidationEvent.getType(), presenter);
    verify(eventBus).addHandler(InsertStringInEditorEvent.getType(), presenter);
    verify(eventBus).addHandler(CopyDataToEditorEvent.getType(), presenter);
    verify(eventBus).addHandler(TransUnitEditEvent.getType(), presenter);
    verify(eventBus).addHandler(TransUnitEditEvent.getType(), presenter);
    verify(eventBus).addHandler(WorkspaceContextUpdateEvent.getType(), presenter);
    verify(saveAsApprovedConfirmation).setListener(presenter);

    when(displayProvider.get()).thenReturn(display);
    presenter.showData(currentPageRows);
  }
コード例 #2
0
  @Test
  public void onTransUnitEditEvent() {
    selectedTU = currentPageRows.get(0);
    TransUnitEditEvent event = mock(TransUnitEditEvent.class);
    when(event.getSelectedTransUnitId()).thenReturn(selectedTU.getId());
    ArrayList<ToggleEditor> currentEditors = Lists.newArrayList(editor);
    presenter.setStatesForTesting(selectedTU.getId(), 0, display);
    when(display.getEditors()).thenReturn(currentEditors);

    presenter.onTransUnitEdit(event);

    InOrder inOrder = inOrder(editorTranslators);
    inOrder.verify(editorTranslators).clearTranslatorList(currentEditors);
    inOrder.verify(editorTranslators).updateTranslator(currentEditors, selectedTU.getId());
    verifyNoMoreInteractions(editorTranslators);
  }