super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
ITranslatedDocResource.class,
"/projects/p/sample-project/iterations/i/1.0/r/");
ClientResponse<TranslationsResource> response =
translationsClient.getTranslations("my,path,document-2.txt",
LocaleId.EN_US, new StringSet(SimpleComment.ID));
TranslationsResource transRes = response.getEntity();
assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
assertThat(transRes.getTextFlowTargets().size(),
greaterThanOrEqualTo(3));
// Alter the translations
transRes.getTextFlowTargets().get(0).setContents("Translated 1");
transRes.getTextFlowTargets().get(1).setContents("Translated 2");
transRes.getTextFlowTargets().get(2).setContents("Translated 3");
transRes.getTextFlowTargets().get(0).setState(ContentState.Approved);
transRes.getTextFlowTargets().get(1).setState(ContentState.Approved);
transRes.getTextFlowTargets().get(2).setState(ContentState.Approved);
transRes.getTextFlowTargets().get(0).getExtensions(true)
.add(new SimpleComment("Translated Comment 1"));
transRes.getTextFlowTargets().get(1).getExtensions(true)
.add(new SimpleComment("Translated Comment 2"));
transRes.getTextFlowTargets().get(2).getExtensions(true)
.add(new SimpleComment("Translated Comment 3"));
// Put the translations
ClientResponse<String> putResponse =
translationsClient.putTranslations("my,path,document-2.txt",
LocaleId.EN_US, transRes, new StringSet(
SimpleComment.ID));
assertThat(putResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
putResponse.releaseConnection();
// Retrieve the translations once more to make sure they were changed
// accordingly
response =
translationsClient.getTranslations("my,path,document-2.txt",
LocaleId.EN_US, new StringSet(SimpleComment.ID));
transRes = response.getEntity();
assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
assertThat(transRes.getTextFlowTargets().size(),
greaterThanOrEqualTo(3));