getZero();
// Push a document and its translations
createResourceWithContentUsingPut();
TranslationsResource entity = new TranslationsResource();
TextFlowTarget target = new TextFlowTarget();
target.setResId("tf1");
target.setContents("hello world");
target.setState(ContentState.Approved);
target.setTranslator(new Person("root@localhost", "Admin user"));
entity.getTextFlowTargets().add(target);
ClientResponse<String> putResponse =
transResource.putTranslations("my.txt", de_DE, entity, null);
assertThat(putResponse.getResponseStatus(), is(Status.OK));
// Get the translations with PO headers
ClientResponse<TranslationsResource> response =
transResource.getTranslations("my.txt", de_DE, new StringSet(
"gettext"));
TranslationsResource translations = response.getEntity();
assertThat(translations.getTextFlowTargets().size(), greaterThan(0));
// Now translate and push them again
for (TextFlowTarget tft : translations.getTextFlowTargets()) {
tft.setContents("Translated");
tft.setState(ContentState.Approved);
}
putResponse =
transResource.putTranslations("my.txt", de_DE, translations,
null);
assertThat(putResponse.getStatus(),
is(Response.Status.OK.getStatusCode()));
// Fetch the translations again
response =
transResource.getTranslations("my.txt", de_DE, new StringSet(
"gettext"));
translations = response.getEntity();
assertThat(translations.getTextFlowTargets().size(), greaterThan(0));
// Make sure the headers are now populated
PoTargetHeader header =
translations.getExtensions(true).findByType(
PoTargetHeader.class);
assertThat(header, notNullValue());
assertThat(header.getEntries().size(), greaterThan(0));
// Make sure the headers have the correct value