final long idWith90MatchTM = 4L;
TransMemoryMerge action =
prepareAction(90, idWith100MatchTM, idWithoutTM,
idWith80MatchTM, idWith90MatchTM);
HTextFlow textFlow100TM =
TestFixture.makeHTextFlow(idWith100MatchTM, sourceLocale,
targetLocale, ContentState.New, docId, versionSlug,
projectSlug);
HTextFlow textFlowNoTM =
TestFixture.makeHTextFlow(idWithoutTM, sourceLocale,
targetLocale, ContentState.New, docId, versionSlug,
projectSlug);
HTextFlow textFlow80TM =
TestFixture.makeHTextFlow(idWith80MatchTM, sourceLocale,
targetLocale, ContentState.New, docId, versionSlug,
projectSlug);
HTextFlow textFLow90TM =
TestFixture.makeHTextFlow(idWith90MatchTM, sourceLocale,
targetLocale, ContentState.New, docId, versionSlug,
projectSlug);
when(localeService.getByLocaleId(action.getWorkspaceId().getLocaleId()))
.thenReturn(targetLocale);
when(
textFlowDAO.findByIdList(newArrayList(idWith100MatchTM,
idWithoutTM, idWith80MatchTM, idWith90MatchTM)))
.thenReturn(
newArrayList(textFlow100TM, textFlowNoTM, textFlow80TM,
textFLow90TM));
// Given: TM results
HTextFlow tmResultSource =
TestFixture.makeApprovedHTextFlow(11L, targetLocale);
Optional<TransMemoryResultItem> tm100 =
Optional.of(tmResult(tmResultSource.getId(), 100));
Optional<TransMemoryResultItem> tm90 =
Optional.of(tmResult(tmResultSource.getId(), 90));
Optional<TransMemoryResultItem> tm80 =
Optional.of(tmResult(tmResultSource.getId(), 80));
Optional<TransMemoryResultItem> noMatch = Optional.absent();
when(
translationMemoryService.searchBestMatchTransMemory(
textFlow100TM, targetLocale.getLocaleId(),
sourceLocale.getLocaleId(), false, false, false, 90))
.thenReturn(tm100);
when(
translationMemoryService.searchBestMatchTransMemory(
textFLow90TM, targetLocale.getLocaleId(),
sourceLocale.getLocaleId(), false, false, false, 90))
.thenReturn(tm90);
when(
translationMemoryService.searchBestMatchTransMemory(
textFlow80TM, targetLocale.getLocaleId(),
sourceLocale.getLocaleId(), false, false, false, 90))
.thenReturn(tm80);
when(
translationMemoryService.searchBestMatchTransMemory(
textFlowNoTM, targetLocale.getLocaleId(),
sourceLocale.getLocaleId(), false, false, false, 90))
.thenReturn(noMatch);
when(textFlowDAO.findById(tmResultSource.getId(), false)).thenReturn(
tmResultSource);
// Given: tm detail of text flow id 11
when(
translationMemoryService.getTransMemoryDetail(targetLocale,
tmResultSource)).thenReturn(tmDetail());