@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)); }
@Test public void canSaveAsFuzzy() { // Given: selected one trans unit with some new targets inputted 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.saveAsFuzzy(selectedTU.getId()); // Then: verify(eventBus, atLeastOnce()).fireEvent(eventCaptor.capture()); TransUnitSaveEvent event = TestFixture.extractFromEvents(eventCaptor.getAllValues(), TransUnitSaveEvent.class); assertThat(event.getTransUnitId(), equalTo(selectedTU.getId())); assertThat(event.getTargets(), Matchers.equalTo(NEW_TARGETS)); assertThat(event.getStatus(), equalTo(ContentState.NeedReview)); }