}
}
}
// Create the document
HDocument doc = new HDocument();
doc.setContentType(ContentType.TextPlain);
doc.setLocale(localeDAO.findByLocaleId(LocaleId.EN_US));
doc.setProjectIteration(projectIteration);
if (execution.documentMatches) {
doc.setFullPath("/same/document");
} else {
doc.setFullPath("/different/document");
}
projectIteration.getDocuments().put(doc.getDocId(), doc);
// Create the text Flow
HTextFlow textFlow = new HTextFlow();
textFlow.setContents("Source Content"); // Source content matches
textFlow.setPlural(false);
textFlow.setObsolete(false);
textFlow.setDocument(doc);
if (execution.contextMatches) {
textFlow.setResId("same-context");
} else {
textFlow.setResId("different-context");
}
doc.getTextFlows().add(textFlow);
projectIteration = iterationDAO.makePersistent(projectIteration);
getEm().flush(); // So the rest of the test sees the results
HCopyTransOptions options =
new HCopyTransOptions(execution.getContextMismatchAction(),
execution.getDocumentMismatchAction(),
execution.getProjectMismatchAction());
CopyTransService copyTransService =
seam.autowire(CopyTransServiceImpl.class);
copyTransService.copyTransForIteration(projectIteration, options,
new CopyTransTaskHandle());
getEm().flush();
// Validate execution
HTextFlow targetTextFlow =
(HTextFlow) getEm()
.createQuery(
"from HTextFlow tf where tf.document.projectIteration = :projectIteration "
+ "and tf.document.docId = :docId and tf.resId = :resId")
.setParameter("projectIteration", projectIteration)
.setParameter("docId", doc.getDocId())
.setParameter("resId", textFlow.getResId())
.getSingleResult();
// Id: 3L for Locale de
HTextFlowTarget target = targetTextFlow.getTargets().get(3L);