}
@Test
@RunAsClient
public void putJsonProjectIteration() throws Exception {
final ProjectIteration newIteration =
new ProjectIteration("new-iteration");
new ResourceRequest(
getRestEndpointUrl("/projects/p/sample-project/iterations/i/"
+ newIteration.getId()), "PUT",
getAuthorizedEnvironment()) {
@Override
protected void prepareRequest(ClientRequest request) {
request.body(
MediaTypes.APPLICATION_ZANATA_PROJECT_ITERATION_JSON,
jsonMarshal(newIteration));
};
@Override
protected void onResponse(ClientResponse response) {
assertThat(response.getStatus(),
is(Status.CREATED.getStatusCode())); // 201
}
}.run();
// Retreive it again
IProjectIterationResource iterationClient =
super.createProxy(
createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
IProjectIterationResource.class,
"/projects/p/sample-project/iterations/i/"
+ newIteration.getId());
ClientResponse<ProjectIteration> getResponse = iterationClient.get();
assertThat(getResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
ProjectIteration it = getResponse.getEntity();
assertThat(it.getId(), is("new-iteration"));
}