use of com.linkedin.restli.example.Album in project rest.li by linkedin.
the class TestMockHttpServerFactory method runTest.
/**
* Starts the server, makes a request, runs assertions, stops the server
*
* @param server the test server
* @throws IOException
* @throws RemoteInvocationException
*/
private void runTest(HttpServer server) throws IOException, RemoteInvocationException {
server.start();
Photo photoEntity = REST_CLIENT.sendRequest(PHOTOS_BUILDERS.get().id(1L).build()).getResponseEntity();
Assert.assertEquals(photoEntity.getTitle(), "Photo 1");
Album albumEntity = REST_CLIENT.sendRequest(ALBUMS_BUILDERS.get().id(1L).build()).getResponseEntity();
Assert.assertEquals(albumEntity.getTitle(), "Awesome Album #1");
server.stop();
}
use of com.linkedin.restli.example.Album in project rest.li by linkedin.
the class AlbumResource method update.
// update an existing photo with given entity
@Override
public UpdateResponse update(Long key, Album entity) {
final Album currPhoto = _db.getData().get(key);
if (currPhoto == null) {
return new UpdateResponse(HttpStatus.S_404_NOT_FOUND);
}
// disallow changing entity ID and URN
if (entity.hasId() || entity.hasUrn()) {
throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "Album ID is not acceptable in request");
}
// make sure the ID in the entity is consistent with the key in the database
entity.setId(key);
entity.setUrn(String.valueOf(key));
_db.getData().put(key, entity);
return new UpdateResponse(HttpStatus.S_204_NO_CONTENT);
}
Aggregations