/** {@inheritDoc} */ public void setActor(ActivityObject actor) { this.actor = actor; put("actor", actor); }
private Future<?> setupBodyRequest(String method) throws ProtocolException { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, method); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.createActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); return operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); }
/** * Sorts ActivityEntries in ascending order based on publish date. * * @param that is the ActivityEntry to compare to this ActivityEntry * * @return int represents how the ActivityEntries compare */ public int compareTo(ActivityEntry that) { if (this.getPublished() == null && that.getPublished() == null) { return 0; // both are null, equal } else if (this.getPublished() == null) { return -1; // this is null, comes before real date } else if (that.getPublished() == null) { return 1; // that is null, this comes after } else { // compare publish dates in lexicographical order return this.getPublished().compareTo(that.getPublished()); } } }
private Future<?> setupBodyRequest(String method) throws ProtocolException { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, method); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.createActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); return operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); }
/** * Sorts ActivityEntries in ascending order based on publish date. * * @param that is the ActivityEntry to compare to this ActivityEntry * * @return int represents how the ActivityEntries compare */ public int compareTo(ActivityEntry that) { if (this.getPublished() == null && that.getPublished() == null) { return 0; // both are null, equal } else if (this.getPublished() == null) { return -1; // this is null, comes before real date } else if (that.getPublished() == null) { return 1; // that is null, this comes after } else { // compare publish dates in lexicographical order return this.getPublished().compareTo(that.getPublished()); } } }
/** {@inheritDoc} */ public void setObject(ActivityObject object) { this.object = object; put("object", object); }
@Test public void testHandleGetActivityEntryById() throws Exception { String path = "/activitystreams/john.doe/@friends/@app/myObjectId123"; // TODO: change id=1 in DB for consistency RestHandler operation = registry.getRestHandler(path, "GET"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(service.getActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.friends, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq("myObjectId123"), eq(token))).andReturn( Futures.immediateFuture(entry)); replay(); assertEquals(entry, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
/** {@inheritDoc} */ public void setUrl(String url) { this.url = url; put("url", url); }
@Test public void testHandlePost() throws Exception { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, "POST"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.createActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); Future<?> future = operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); assertNull(future.get()); verify(); reset(); }
/** {@inheritDoc} */ public void setIcon(MediaLink icon) { this.icon = icon; put("icon", icon); }
@Test public void testHandleGetActivityEntryById() throws Exception { String path = "/activitystreams/john.doe/@friends/@app/myObjectId123"; // TODO: change id=1 in DB for consistency RestHandler operation = registry.getRestHandler(path, "GET"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(service.getActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.friends, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq("myObjectId123"), eq(token))).andReturn( Futures.immediateFuture(entry)); replay(); assertEquals(entry, operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
/** {@inheritDoc} */ public void setObject(ActivityObject object) { this.object = object; put("object", object); }
@Test public void testHandlePut() throws Exception { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app/testObject"; RestHandler operation = registry.getRestHandler(path, "PUT"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.updateActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq("testObject"), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); Future<?> future = operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); assertNull(future.get()); verify(); reset(); }
/** {@inheritDoc} */ public void setPublished(String published) { this.published = published; put("published", published); }
@Test public void testHandlePost() throws Exception { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app"; RestHandler operation = registry.getRestHandler(path, "POST"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.createActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); Future<?> future = operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); assertNull(future.get()); verify(); reset(); }
/** {@inheritDoc} */ public void setProvider(ActivityObject provider) { this.provider = provider; put("provider", provider); }
@Test public void testHandlePut() throws Exception { String jsonActivityEntry = "{title: 'hi mom!', object: {id: 'testObject'}}"; String path = "/activitystreams/john.doe/@self/@app/testObject"; RestHandler operation = registry.getRestHandler(path, "PUT"); ActivityEntry entry = new ActivityEntryImpl(); org.easymock.EasyMock.expect(converter.convertToObject(eq(jsonActivityEntry), eq(ActivityEntry.class))) .andReturn(entry); org.easymock.EasyMock.expect(service.updateActivityEntry(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.<String>of()), eq(entry), eq("testObject"), eq(token))).andReturn(Futures.immediateFuture((ActivityEntry) null)); replay(); Future<?> future = operation.execute(Maps.<String, String[]>newHashMap(), new StringReader(jsonActivityEntry), token, converter); assertNull(future.get()); verify(); reset(); }
/** {@inheritDoc} */ public void setUpdated(String updated) { this.updated = updated; put("updated", updated); }
/** {@inheritDoc} */ public void setVerb(String verb) { this.verb = verb; put("verb", verb); }
/** {@inheritDoc} */ public void setActor(ActivityObject actor) { this.actor = actor; put("actor", actor); }