use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestSimpleResourceHierarchy method testSubsubsimpleResourcePartialUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubSubBuilderDataProvider")
public void testSubsubsimpleResourcePartialUpdate(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException {
Greeting greeting = new Greeting();
greeting.setMessage("Message1");
greeting.setTone(Tone.SINCERE);
greeting.setId(1L);
PatchRequest<Greeting> patch = PatchGenerator.diffEmpty(greeting);
// PUT
Request<EmptyRecord> writeRequest = builders.partialUpdate().setPathKey("subgreetingsId", 1L).input(patch).build();
getClient().sendRequest(writeRequest).getResponse();
// GET again, to verify that our POST worked.
Request<Greeting> request = builders.get().setPathKey("subgreetingsId", 1L).build();
Response<Greeting> response = getClient().sendRequest(request).getResponse();
greeting = response.getEntity();
Assert.assertEquals(greeting.getTone(), Tone.SINCERE);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestSimpleResourceHierarchy method testRootSimpleResourceDelete.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootSimpleResourceDelete(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException {
// DELETE
Request<EmptyRecord> writeRequest = builders.delete().build();
getClient().sendRequest(writeRequest).getResponse();
// GET again, to verify that our DELETE worked.
try {
Request<Greeting> request = builders.get().build();
Response<Greeting> response = getClient().sendRequest(request).getResponse();
Greeting greeting = response.getEntity();
Assert.fail("Entity should have been removed.");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.S_404_NOT_FOUND.getCode());
}
//Restore initial state
testRootSimpleResourceUpdate(builders);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestSimpleResourceHierarchy method testSubsubsimpleResourceUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubSubBuilderDataProvider")
public void testSubsubsimpleResourceUpdate(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException {
Greeting greeting = new Greeting();
greeting.setMessage("Message1");
greeting.setTone(Tone.INSULTING);
greeting.setId(1L);
// PUT
Request<EmptyRecord> writeRequest = builders.update().setPathKey("subgreetingsId", 1L).input(greeting).build();
getClient().sendRequest(writeRequest).getResponse();
// GET again, to verify that our POST worked.
Request<Greeting> request = builders.get().setPathKey("subgreetingsId", 1L).build();
Response<Greeting> response = getClient().sendRequest(request).getResponse();
greeting = response.getEntity();
Assert.assertEquals(greeting.getTone(), Tone.INSULTING);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestSimpleResourceHierarchy method testSubCollectionGet.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubBuilderDataProvider")
public void testSubCollectionGet(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Request<Greeting> request = builders.get().id(1L).build();
Response<Greeting> response = getClient().sendRequest(request).getResponse();
Greeting greeting = response.getEntity();
Assert.assertEquals(greeting.getId().longValue(), 1L);
}
use of com.linkedin.restli.examples.greetings.api.Greeting in project rest.li by linkedin.
the class TestSimpleResourceHierarchy method testRootSimpleResourcePartialUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRootSimpleResourcePartialUpdate(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException {
Greeting greeting = new Greeting();
greeting.setMessage("Message1");
greeting.setTone(Tone.SINCERE);
greeting.setId(12345L);
PatchRequest<Greeting> patch = PatchGenerator.diffEmpty(greeting);
// PUT
Request<EmptyRecord> writeRequest = builders.partialUpdate().input(patch).build();
getClient().sendRequest(writeRequest).getResponse();
// GET again, to verify that our PUT worked.
Request<Greeting> request = builders.get().build();
Response<Greeting> response = getClient().sendRequest(request).getResponse();
greeting = response.getEntity();
Assert.assertEquals(greeting.getTone(), Tone.SINCERE);
}
Aggregations