/** * 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()); } } }
} else if (o instanceof ActivityEntry) { ActivityEntry activity = (ActivityEntry)o; id = activity.getId(); title = activity.getTitle(); summary = new AtomSummary(activity.getObject().getSummary()); link = new AtomLink("alternate", activity.getObject().getUrl()); author = new AtomAuthor(activity); content = new AtomContent(activity); try { updated = new SimpleDateFormat().parse(activity.getPublished()); } catch (ParseException e) {
@Test public void testGetExpectedActivityEntry() throws Exception { ActivityEntry entry = db.getActivityEntry(JOHN_DOE, SELF_GROUP, APP_ID, ImmutableSet.of("title"), "activity2", new FakeGadgetToken()).get(); assertNotNull(entry); // Check that some fields are fetched and others are not assertNotNull(entry.getTitle()); assertNull(entry.getPublished()); }
} else if (o instanceof ActivityEntry) { ActivityEntry activity = (ActivityEntry)o; id = activity.getId(); title = activity.getTitle(); summary = new AtomSummary(activity.getObject().getSummary()); link = new AtomLink("alternate", activity.getObject().getUrl()); author = new AtomAuthor(activity); content = new AtomContent(activity); try { updated = new SimpleDateFormat().parse(activity.getPublished()); } catch (ParseException e) {
@Test public void testGetExpectedActivityEntry() throws Exception { ActivityEntry entry = db.getActivityEntry(JOHN_DOE, SELF_GROUP, APP_ID, ImmutableSet.of("title"), "activity2", new FakeGadgetToken()).get(); assertNotNull(entry); // Check that some fields are fetched and others are not assertNotNull(entry.getTitle()); assertNull(entry.getPublished()); }
/** * 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()); } } }