testExecution(TranslationMemoryServiceImpl.class, execution);
}
private void testExecution(Class<? extends TranslationFinder> impl, Execution execution) {
TranslationFinder service = seam.autowire(impl);
// Prepare Execution
ProjectIterationDAO iterationDAO =
seam.autowire(ProjectIterationDAO.class);
// Get the project iteration
HProjectIteration queryProjIter =
iterationDAO.getBySlug(execution.getProject(), execution.getVersion());
assert queryProjIter != null;
// Create the document
HDocument queryDoc = new HDocument();
queryDoc.setContentType(ContentType.TextPlain);
queryDoc.setLocale(sourceLocale);
queryDoc.setProjectIteration(queryProjIter);
queryDoc.setFullPath(execution.getDocument());
// Create the text Flow
HTextFlow queryTextFlow = new HTextFlow();
// TODO test that the query textflow is excluded from results
// (when the query textflow has been persisted and indexed)
queryTextFlow.setId(-999L);
queryTextFlow.setContents(execution.getContent()); // Source content matches
queryTextFlow.setPlural(false);
queryTextFlow.setObsolete(false);
queryTextFlow.setDocument(queryDoc);
queryTextFlow.setResId(execution.getContext());
// For all the executions whose queries are expected to find a match,
// the target which is expected to match is HTextFlowTarget 100
// (which belongs to HTextFlow 100, HDocument 100,
// HProjectIteration 100, HProject 100)
Optional<HTextFlowTarget> matchingTarget =
service.searchBestMatchTransMemory(
queryTextFlow, LocaleId.DE, LocaleId.EN_US,
execution.isCheckContext(), execution.isCheckDocument(),
execution.isCheckProject());
assertThat(matchingTarget.isPresent()).as("match present").isEqualTo(