@Test
  public void onWorkspaceContextUpdateEventBecomeReadOnly() {
    // Given: event sets workspace to read only
    WorkspaceContextUpdateEvent event = mock(WorkspaceContextUpdateEvent.class);
    when(event.isProjectActive()).thenReturn(false);
    userWorkspaceContext.setHasEditTranslationAccess(false);

    // When:
    presenter.onWorkspaceContextUpdated(event);

    // Then:
    verify(display, times(3)).setToMode(ToggleEditor.ViewMode.VIEW);
    verify(display, times(3)).showButtons(false);
    verify(editorKeyShortcuts).enableNavigationContext();
  }
  @Test
  public void onWorkspaceContextUpdateEventFromReadOnlyToWritable() {
    // Given: event sets workspace to writable and we first have workspace as read only
    userWorkspaceContext.setProjectActive(false);
    WorkspaceContextUpdateEvent event = mock(WorkspaceContextUpdateEvent.class);
    when(event.isProjectActive()).thenReturn(true);

    // When:
    presenter.onWorkspaceContextUpdated(event);

    // Then:
    verify(display, times(3)).setToMode(ToggleEditor.ViewMode.EDIT);
    verify(display, atLeast(3)).showButtons(true);
    verify(editorKeyShortcuts).enableEditContext();
  }
  @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);
  }