### Question:
WriteOptimizedGraphity extends SocialGraph { @Override public List<JSONObject> readStatusUpdates(final Node poster, final Node user, final int numItems, boolean ownUpdates) { if (!poster.equals(user)) { ownUpdates = true; } final List<JSONObject> statusUpdates = new LinkedList<JSONObject>(); if (!ownUpdates) { final TreeSet<StatusUpdateUser> users = new TreeSet<StatusUpdateUser>( new StatusUpdateUserComparator()); Node userNode; StatusUpdateUser crrUser; for (Relationship relationship : poster.getRelationships( SocialGraphRelationshipType.FOLLOW, Direction.OUTGOING)) { userNode = relationship.getEndNode(); crrUser = new StatusUpdateUser(userNode); if (crrUser.hasStatusUpdate()) { users.add(crrUser); } } while ((statusUpdates.size() < numItems) && !users.isEmpty()) { crrUser = users.pollLast(); statusUpdates.add(crrUser.getStatusUpdate()); if (crrUser.hasStatusUpdate()) { users.add(crrUser); } } } else { final StatusUpdateUser posterNode = new StatusUpdateUser(poster); while ((statusUpdates.size() < numItems) && posterNode.hasStatusUpdate()) { statusUpdates.add(posterNode.getStatusUpdate()); } } return statusUpdates; } WriteOptimizedGraphity(final AbstractGraphDatabase graph); @Override void createFriendship(final Node following, final Node followed); @Override void createStatusUpdate(final long timestamp, final Node user,
			StatusUpdate content); @Override List<JSONObject> readStatusUpdates(final Node poster,
			final Node user, final int numItems, boolean ownUpdates); @Override boolean removeFriendship(final Node following, final Node followed); @Override boolean deleteStatusUpdate(final Node user, final Node statusUpdate);  }### Answer:
@Test public void testReadStatusUpdates_Regular() { List<JSONObject> activities; activities = this.algorithm.readStatusUpdates(this.USER_A, this.USER_A, 7, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 13, 12, 11, 10, 8, 7, 6 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_A, this.USER_A, 10, false); assertNotNull(activities); AlgorithmTest.compareValues( new long[] { 13, 12, 11, 10, 8, 7, 6, 5, 4 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_A, this.USER_B, 2, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 17, 14 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_A, this.USER_B, 2, true); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 17, 14 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_C, this.USER_C, 4, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 17, 14, 9 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_A, this.USER_C, 4, true); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 17, 14, 9 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_D, this.USER_D, 2, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 13, 7 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_D, this.USER_D, 4, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] { 13, 7, 6 }, activities); activities = this.algorithm.readStatusUpdates(this.USER_E, this.USER_E, 10, false); assertNotNull(activities); AlgorithmTest.compareValues(new long[] {}, activities); }