@Test public void testGetThumbnailUrl() throws Exception { Person person = new PersonImpl(); assertNull(person.getThumbnailUrl()); String url = "hi"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(url, person.getPhotos().get(0).getValue()); assertEquals(Person.THUMBNAIL_PHOTO_TYPE, person.getPhotos().get(0).getType()); url = "something new"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(1, person.getPhotos().size()); assertEquals(url, person.getPhotos().get(0).getValue()); } }
@Test public void testViewerCanUpdatePerson() throws Exception { // Create new user JSONArray people = db.getDb().getJSONArray("people"); JSONObject jsonPerson = new JSONObject(); jsonPerson.put("id", "updatePerson"); people.put(people.length(),jsonPerson); SecurityToken updateToken = new FakeGadgetToken("appId", "appUrl", "domain", "updatePerson", "trustedJson", "updatePerson", "20"); // Get user UserId userId = new UserId(UserId.Type.userId, "updatePerson"); Person person = db .getPerson(userId, Person.Field.ALL_FIELDS, token).get(); assertNotNull("User 'updatePerson' not found", person); // update a field in user object person.setThumbnailUrl("http://newthumbnail.url"); // Save user to db db.updatePerson(userId, person, updateToken); // Get user again from db and check if the fields were properly updated person = db.getPerson(userId, Person.Field.ALL_FIELDS, token).get(); assertNotNull("User 'updatePerson' not found", person); assertEquals("http://newthumbnail.url", person.getThumbnailUrl()); }
@Test public void testViewerCanUpdatePerson() throws Exception { // Create new user JSONArray people = db.getDb().getJSONArray("people"); JSONObject jsonPerson = new JSONObject(); jsonPerson.put("id", "updatePerson"); people.put(people.length(),jsonPerson); SecurityToken updateToken = new FakeGadgetToken("appId", "appUrl", "domain", "updatePerson", "trustedJson", "updatePerson", "20"); // Get user UserId userId = new UserId(UserId.Type.userId, "updatePerson"); Person person = db .getPerson(userId, Person.Field.ALL_FIELDS, token).get(); assertNotNull("User 'updatePerson' not found", person); // update a field in user object person.setThumbnailUrl("http://newthumbnail.url"); // Save user to db db.updatePerson(userId, person, updateToken); // Get user again from db and check if the fields were properly updated person = db.getPerson(userId, Person.Field.ALL_FIELDS, token).get(); assertNotNull("User 'updatePerson' not found", person); assertEquals("http://newthumbnail.url", person.getThumbnailUrl()); }
@Test public void testGetThumbnailUrl() throws Exception { Person person = new PersonImpl(); assertNull(person.getThumbnailUrl()); String url = "hi"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(url, person.getPhotos().get(0).getValue()); assertEquals(Person.THUMBNAIL_PHOTO_TYPE, person.getPhotos().get(0).getType()); url = "something new"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(1, person.getPhotos().size()); assertEquals(url, person.getPhotos().get(0).getValue()); } }
@Test public void testGetThumbnailUrl() throws Exception { Person person = new PersonImpl(); assertNull(person.getThumbnailUrl()); String url = "hi"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(url, person.getPhotos().get(0).getValue()); assertEquals(Person.THUMBNAIL_PHOTO_TYPE, person.getPhotos().get(0).getType()); url = "something new"; person.setThumbnailUrl(url); assertEquals(url, person.getThumbnailUrl()); assertEquals(1, person.getPhotos().size()); assertEquals(url, person.getPhotos().get(0).getValue()); } }
@Test public void testGetPersonDefaultFields() throws Exception { Person person = db .getPerson(CANON_USER, Person.Field.DEFAULT_FIELDS, token).get(); assertNotNull("Canonical user not found", person); assertNotNull("Canonical user has no id", person.getId()); assertNotNull("Canonical user has no name", person.getName()); assertNotNull("Canonical user has no thumbnail", person.getThumbnailUrl()); }
@Test public void testGetPersonDefaultFields() throws Exception { Person person = db .getPerson(CANON_USER, Person.Field.DEFAULT_FIELDS, token).get(); assertNotNull("Canonical user not found", person); assertNotNull("Canonical user has no id", person.getId()); assertNotNull("Canonical user has no name", person.getName()); assertNotNull("Canonical user has no thumbnail", person.getThumbnailUrl()); }
@Test public void testGetPersonDefaultFields() throws Exception { Person person = db .getPerson(CANON_USER, Person.Field.DEFAULT_FIELDS, token).get(); assertNotNull("Canonical user not found", person); assertNotNull("Canonical user has no id", person.getId()); assertNotNull("Canonical user has no name", person.getName()); assertNotNull("Canonical user has no thumbnail", person.getThumbnailUrl()); }
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertStringField(result, canonical.getStatus(), Person.Field.STATUS); assertStringListField(result, canonical.getTags(), Person.Field.TAGS); assertStringField(result, canonical.getThumbnailUrl(), Person.Field.THUMBNAIL_URL);
assertEquals(actual.getStatus(), expected.getStatus()); assertEquals(actual.getTags(), expected.getTags()); assertEquals(actual.getThumbnailUrl(), expected.getThumbnailUrl()); assertEquals(actual.getUtcOffset(), expected.getUtcOffset()); assertEquals(actual.getTurnOffs(), expected.getTurnOffs());