use of com.linkedin.restli.example.AlbumEntry 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.example.AlbumEntry 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.example.AlbumEntry 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.example.AlbumEntry in project rest.li by linkedin.
the class AlbumEntryResource method search.
/**
* Find all entries matching the given album and photo IDs. <code>null</code> is treated
* as a wildcard.
*
* @param albumId provides the id to match for albums to match, if not provided, it is treated as a wildcard
* @param photoId provides the id to match for photos to match, if not provided, it is treated as a wildcard
* @return a list of {@link AlbumEntry} matching the given parameters
*/
@Finder("search")
public List<AlbumEntry> search(@Optional @QueryParam("albumId") Long albumId, @Optional @QueryParam("photoId") Long photoId) {
List<AlbumEntry> result = new ArrayList<AlbumEntry>();
for (Map.Entry<CompoundKey, AlbumEntry> entry : _db.getData().entrySet()) {
CompoundKey key = entry.getKey();
// (treat all values as a match)
if (albumId != null && !key.getPart("albumId").equals(albumId))
continue;
if (photoId != null && !key.getPart("photoId").equals(photoId))
continue;
result.add(entry.getValue());
}
return result;
}
use of com.linkedin.restli.example.AlbumEntry in project rest.li by linkedin.
the class TestAlbumEntryResource method testBadUpdateIdsInEntry.
@Test(expectedExceptions = RestLiServiceException.class)
public void testBadUpdateIdsInEntry() {
// shouldn't be able to put IDs in update entry
CompoundKey key = new CompoundKey().append("photoId", 1L).append("albumId", 1L);
AlbumEntry entry = new AlbumEntry().setAddTime(4).setPhotoId(1);
_entryRes.update(key, entry);
}
Aggregations