use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestAlbumEntryResource method testBadUpdatePhotoId.
@Test(expectedExceptions = RestLiServiceException.class)
public void testBadUpdatePhotoId() {
// photo 100 doesn't exist
CompoundKey key = new CompoundKey().append("photoId", 100L).append("albumId", 1L);
AlbumEntry entry = new AlbumEntry().setAddTime(4);
_entryRes.update(key, entry);
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestAlbumEntryResource method testBadUpdateAlbumId.
@Test(expectedExceptions = RestLiServiceException.class)
public void testBadUpdateAlbumId() {
// album 100 doesn't exist
CompoundKey key = new CompoundKey().append("photoId", 1L).append("albumId", 100L);
AlbumEntry entry = new AlbumEntry().setAddTime(4);
_entryRes.update(key, entry);
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestAlbumEntryResource method makeData.
private void makeData() {
_entries = new AlbumEntry[] { new AlbumEntry().setAddTime(1), new AlbumEntry().setAddTime(2), new AlbumEntry().setAddTime(3), new AlbumEntry().setAddTime(4), new AlbumEntry().setAddTime(5) };
_keys = new CompoundKey[] { new CompoundKey().append("photoId", 1L).append("albumId", 1L), new CompoundKey().append("photoId", 2L).append("albumId", 1L), new CompoundKey().append("photoId", 3L).append("albumId", 1L), new CompoundKey().append("photoId", 1L).append("albumId", 2L), new CompoundKey().append("photoId", 4L).append("albumId", 2L) };
for (int i = 0; i < _entries.length; i++) {
final UpdateResponse uResp = _entryRes.update(_keys[i], _entries[i]);
Assert.assertEquals(uResp.getStatus(), HttpStatus.S_204_NO_CONTENT);
}
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class CustomTypesResource3 method batchUpdate.
@Override
public BatchUpdateResult<CompoundKey, Greeting> batchUpdate(BatchUpdateRequest<CompoundKey, Greeting> entities) {
Set<CompoundKey> keys = entities.getData().keySet();
Map<CompoundKey, UpdateResponse> responseMap = new HashMap<CompoundKey, UpdateResponse>();
Map<CompoundKey, RestLiServiceException> errorMap = new HashMap<CompoundKey, RestLiServiceException>();
for (CompoundKey key : keys) {
responseMap.put(key, new UpdateResponse(HttpStatus.S_201_CREATED));
}
return new BatchUpdateResult<CompoundKey, Greeting>(responseMap);
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestCustomTypesClient method testBatchUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProvider")
public void testBatchUpdate(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException {
Long lo = 5L;
Long date = 13L;
CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(lo)).setDateId(new Date(date));
RequestBuilder<? extends Request<BatchKVResponse<CompoundKey, UpdateStatus>>> batchUpdateRequest = builders.batchUpdate().input(key, new Greeting().setId(1).setMessage("foo")).getBuilder();
BatchKVResponse<CompoundKey, UpdateStatus> response = getClient().sendRequest(batchUpdateRequest).getResponse().getEntity();
Assert.assertEquals(response.getResults().keySet().size(), 1);
CompoundKey expected = new CompoundKey();
expected.append("dateId", new Date(date));
expected.append("longId", new CustomLong(lo));
Assert.assertEquals(response.getResults().keySet().iterator().next(), expected);
}
Aggregations