use of com.linkedin.restli.example.LatLong in project rest.li by linkedin.
the class TestPhotoResource method testBatchGet.
@Test
public void testBatchGet() {
final String[] titles = { "1", "2", "3" };
final long[] ids = new long[titles.length];
for (int i = 0; i < titles.length; i++) ids[i] = createPhoto(titles[i]);
// validate all data are correct
Set<Long> batchIds = new HashSet<Long>();
batchIds.add(ids[1]);
batchIds.add(ids[2]);
Map<Long, Photo> batchPhotos = _res.batchGet(batchIds);
Assert.assertEquals(batchPhotos.size(), 2);
for (// go through {1,2}
int i = 1; // go through {1,2}
i < titles.length; // go through {1,2}
i++) {
final Photo p = batchPhotos.get(ids[i]);
Assert.assertNotNull(p);
Assert.assertEquals(p.getTitle(), titles[i]);
Assert.assertEquals(p.getId().longValue(), ids[i]);
Assert.assertTrue(p.hasExif());
final EXIF e = p.getExif();
Assert.assertTrue(e.hasLocation());
final LatLong l = e.getLocation();
Assert.assertEquals(l.getLatitude(), 7.0f);
Assert.assertEquals(l.getLongitude(), 27.0f);
}
}
use of com.linkedin.restli.example.LatLong in project rest.li by linkedin.
the class TestPhotoResource method createPhoto.
private Long createPhoto(String title, PhotoFormats format) {
final LatLong l = new LatLong().setLatitude(7.0f).setLongitude(27.0f);
final EXIF e = new EXIF().setIsFlash(true).setLocation(l);
final Photo p = new Photo().setTitle(title).setFormat(format).setExif(e);
final CreateResponse cResp = _res.create(p);
Assert.assertTrue(cResp.hasId());
return (Long) cResp.getId();
}
use of com.linkedin.restli.example.LatLong in project rest.li by linkedin.
the class TestPhotoResource method testResourceUpdate.
@Test
public void testResourceUpdate() {
final Long id = createPhoto();
final LatLong l1 = new LatLong().setLongitude(-27.0f);
final EXIF e1 = new EXIF().setLocation(l1);
final Photo p1 = new Photo().setExif(e1);
final UpdateResponse uResp = _res.update(id, p1);
Assert.assertEquals(uResp.getStatus(), HttpStatus.S_204_NO_CONTENT);
// validate data is changed to correct value
final Photo p2 = _res.get(id);
Assert.assertNotNull(p2.hasExif());
final EXIF e2 = p2.getExif();
Assert.assertNotNull(e2.hasLocation());
final LatLong l2 = e2.getLocation();
Assert.assertEquals(l2.getLongitude(), -27.0f);
}
use of com.linkedin.restli.example.LatLong in project rest.li by linkedin.
the class TestPhotoResource method testResourceGet.
@Test
public void testResourceGet() {
// because the test function will take arbitrary order
// always create a photo and operate on that photo for a test function
final Long id = createPhoto();
// validate all data are correct
final Photo p = _res.get(id);
Assert.assertNotNull(p);
Assert.assertEquals(p.getId(), id);
Assert.assertTrue(p.hasExif());
final EXIF e = p.getExif();
Assert.assertTrue(e.hasLocation());
final LatLong l = e.getLocation();
Assert.assertEquals(l.getLatitude(), 7.0f);
Assert.assertEquals(l.getLongitude(), 27.0f);
}
Aggregations