@Test(dataProvider = "CopyTrans")
@SlowTest
public void testCopyTrans(CopyTransExecution execution) {
// Prepare Execution
ProjectIterationDAO iterationDAO =
seam.autowire(ProjectIterationDAO.class);
LocaleDAO localeDAO = seam.autowire(LocaleDAO.class);
// Get the project iteration
HProjectIteration projectIteration;
if (execution.projectMatches) {
projectIteration =
iterationDAO.getBySlug("same-project", "different-version");
} else {
projectIteration =
iterationDAO.getBySlug("different-project",
"different-version");
}
assert projectIteration != null;
// Set require translation review
projectIteration
.setRequireTranslationReview(execution.requireTranslationReview);
// Change all targets to have the execution's match state
for (HDocument doc : projectIteration.getDocuments().values()) {
for (HTextFlow tf : doc.getAllTextFlows().values()) {
for (HTextFlowTarget tft : tf.getTargets().values()) {
tft.setState(execution.matchState);
}
}
}
// 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(),