}
@Test
@RunAsClient
public void putJsonResourceMeta() throws Exception {
ISourceDocResource translationsClient =
super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
ISourceDocResource.class,
"/projects/p/sample-project/iterations/i/1.0/r/");
final ResourceMeta resMeta = new ResourceMeta();
resMeta.setName("my/path/document-2.txt");
resMeta.setType(ResourceType.FILE);
resMeta.setContentType(ContentType.TextPlain);
resMeta.setLang(LocaleId.EN_US);
resMeta.setRevision(1);
new ResourceRequest(
getRestEndpointUrl("/projects/p/sample-project/iterations/i/1.0/r/my,path,document-2.txt"),
"PUT", getAuthorizedEnvironment()) {
@Override
protected void prepareRequest(ClientRequest request) {
request.queryParameter("ext", SimpleComment.ID);
request.body(MediaType.APPLICATION_JSON, jsonMarshal(resMeta));
}
@Override
protected void onResponse(ClientResponse response) {
assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
}
}.run();
// Fetch again
ClientResponse<ResourceMeta> getResponse =
translationsClient.getResourceMeta("my,path,document-2.txt",
null);
ResourceMeta newResMeta = getResponse.getEntity();
assertThat(getResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
assertThat(newResMeta.getName(), is(resMeta.getName()));