@Test
@Ignore("see https://github.com/zanata/zanata-server/pull/571#issuecomment-56011217 this test can be used to reproduce that issue.")
// see org.zanata.dao.TextFlowDAO.getByDocumentAndResIds
public
void testPushTranslationRepeatedly() {
ZanataRestCaller restCaller =
new ZanataRestCaller();
String projectSlug = "push-test";
String iterationSlug = "master";
String projectType = "gettext";
restCaller.createProjectAndVersion(projectSlug, iterationSlug,
projectType);
String docId = "messages";
Resource sourceResource = buildSourceResource(docId);
TranslationsResource transResource = buildTranslationResource();
int numOfMessages = 10;
for (int i = 0; i < numOfMessages; i++) {
String resId = "res" + i;
String content = "content" + i;
sourceResource.getTextFlows().add(buildTextFlow(resId, content));
transResource.getTextFlowTargets().add(
buildTextFlowTarget(resId, content));
}
restCaller.asyncPushSource(projectSlug, iterationSlug, sourceResource,
false);
LocaleId localeId = new LocaleId("pl");
restCaller.asyncPushTarget(projectSlug, iterationSlug, docId,
localeId, transResource, "auto");
restCaller.runCopyTrans(projectSlug, iterationSlug, docId);
assertThat(true, Matchers.is(true));
// create some obsolete text flows
Resource updatedSource = buildSourceResource(docId);
TranslationsResource updatedTransResource = buildTranslationResource();
for (int i = 0; i < numOfMessages; i++) {
String resId = "res" + i;
String content = "content" + i + " changed";
updatedSource.getTextFlows().add(buildTextFlow(resId, content));
updatedTransResource.getTextFlowTargets().add(buildTextFlowTarget(resId, content));
}
// push updated source (same resId different content)
restCaller.asyncPushSource(projectSlug, iterationSlug, updatedSource, false);
restCaller.asyncPushTarget(projectSlug, iterationSlug, docId, localeId, updatedTransResource, "auto");
// push again
restCaller.asyncPushSource(projectSlug, iterationSlug, updatedSource, false);
restCaller.asyncPushTarget(projectSlug, iterationSlug, docId, localeId, updatedTransResource, "auto");
}