Calendar poRevDate = Calendar.getInstance();
poRevDate.add(Calendar.YEAR, 1); // 1 year in the future
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mmZ");
// Add initial headers to the translations
PoTargetHeader transHeader = new PoTargetHeader();
transHeader.getEntries().add(
new HeaderEntry(HeaderFields.KEY_LastTranslator,
"Test User <test@zanata.org>"));
transHeader.getEntries().add(
new HeaderEntry(HeaderFields.KEY_PoRevisionDate, dateFormat
.format(poRevDate.getTime()))); // Date in the future
entity.getExtensions(true).add(transHeader);
// Push the translations
ClientResponse<String> putResponse =
transResource.putTranslations("my.txt", de_DE, entity,
new StringSet("gettext"));
assertThat(putResponse.getResponseStatus(), is(Status.OK));
getEm().flush();
getEm().clear();
// Get the translations with PO headers
ClientResponse<TranslationsResource> transResponse =
transResource.getTranslations("my.txt", de_DE, new StringSet(
"gettext"));
TranslationsResource translations = transResponse.getEntity();
// Make sure the headers are populated
PoTargetHeader header =
translations.getExtensions(true).findByType(
PoTargetHeader.class);
assertThat(header, notNullValue());
assertThat(header.getEntries().size(), greaterThan(0));
// Make sure the header values are the same as the ones pushed with the
// document
for (HeaderEntry entry : header.getEntries()) {
if (entry.getKey().equals(HeaderFields.KEY_LastTranslator)) {
assertThat(entry.getValue().trim(),
is("Test User <test@zanata.org>"));
} else if (entry.getKey().equals(HeaderFields.KEY_PoRevisionDate)) {
assertThat(entry.getValue().trim(),