@Test
  public void willSaveAndMoveToNextRow() {
    // Given: selected display and there is only one entry(no plural or last entry of plural)
    selectedTU = currentPageRows.get(0);
    when(display.getNewTargets()).thenReturn(NEW_TARGETS);
    when(display.getCachedTargets()).thenReturn(CACHED_TARGETS);
    when(display.getId()).thenReturn(selectedTU.getId());
    when(display.getEditors()).thenReturn(Lists.newArrayList(editor));
    presenter.setStatesForTesting(selectedTU.getId(), 0, display);

    // When:
    presenter.saveAsApprovedAndMoveNext(selectedTU.getId());

    // Then:
    verify(eventBus, atLeastOnce()).fireEvent(eventCaptor.capture());

    TransUnitSaveEvent saveEvent =
        TestFixture.extractFromEvents(eventCaptor.getAllValues(), TransUnitSaveEvent.class);
    assertThat(saveEvent.getTransUnitId(), equalTo(selectedTU.getId()));
    assertThat(saveEvent.getTargets(), Matchers.equalTo(NEW_TARGETS));
    assertThat(saveEvent.getStatus(), equalTo(ContentState.Translated));

    NavTransUnitEvent navEvent =
        TestFixture.extractFromEvents(eventCaptor.getAllValues(), NavTransUnitEvent.class);
    assertThat(navEvent.getRowType(), equalTo(NavTransUnitEvent.NavigationType.NextEntry));
  }
Ejemplo n.º 2
0
  @BeforeMethod
  public void beforeMethod() {
    MockitoAnnotations.initMocks(this);
    initData();
    UserConfigHolder configHolder = new UserConfigHolder();
    configHolder.setEditorPageSize(EDITOR_PAGE_SIZE);
    SinglePageDataModelImpl pageModel = new SinglePageDataModelImpl();
    ModalNavigationStateHolder navigationStateHolder = new ModalNavigationStateHolder(configHolder);
    service =
        new NavigationService(
            eventBus,
            dispatcher,
            configHolder,
            mock(TableEditorMessages.class),
            pageModel,
            navigationStateHolder);
    service.addPageDataChangeListener(pageDataChangeListener);

    verify(eventBus).addHandler(DocumentSelectionEvent.getType(), service);
    verify(eventBus).addHandler(TransUnitUpdatedEvent.getType(), service);
    verify(eventBus).addHandler(FindMessageEvent.getType(), service);
    verify(eventBus).addHandler(NavTransUnitEvent.getType(), service);
    verify(eventBus).addHandler(EditorPageSizeChangeEvent.TYPE, service);

    pageModel.setData(data.subList(0, configHolder.getState().getEditorPageSize()));
    navigationStateHolder.init(idStateMap, idIndexList);
    initContext =
        new GetTransUnitActionContext(new DocumentId(1, ""))
            .changeCount(configHolder.getState().getEditorPageSize());
  }