@Test public void testFilterComments() { final ActivityDTO activity = context.mock(ActivityDTO.class); final CommentDTO firstComment = context.mock(CommentDTO.class, "firstComment"); final CommentDTO lastComment = context.mock(CommentDTO.class, "lastComment"); PersonModelView user = new PersonModelView(); context.checking(new Expectations() { { oneOf(activity).setServerDateTime(with(any(Date.class))); allowing(activity).getFirstComment(); will(returnValue(firstComment)); allowing(activity).getLastComment(); will(returnValue(lastComment)); oneOf(firstComment).setServerDateTime(with(any(Date.class))); oneOf(lastComment).setServerDateTime(with(any(Date.class))); } }); sut.filter(Arrays.asList(activity), user); context.assertIsSatisfied(); }
public void filter(final List<ActivityDTO> activities, final PersonModelView user) { Date currentServerDate = new Date(); for (ActivityDTO activity : activities) { activity.setServerDateTime(currentServerDate); if (activity.getFirstComment() != null) { activity.getFirstComment().setServerDateTime(currentServerDate); } if (activity.getLastComment() != null) { activity.getLastComment().setServerDateTime(currentServerDate); } } }
PopulateActivityDTOServerDateTime implements ActivityFilter { public void filter(final List<ActivityDTO> activities, final PersonModelView user) { Date currentServerDate = new Date(); for (ActivityDTO activity : activities) { activity.setServerDateTime(currentServerDate); if (activity.getFirstComment() != null) { activity.getFirstComment().setServerDateTime(currentServerDate); } if (activity.getLastComment() != null) { activity.getLastComment().setServerDateTime(currentServerDate); } } } }
PopulateActivityDTOServerDateTime implements ActivityFilter { public void filter(final List<ActivityDTO> activities, final PersonModelView user) { Date currentServerDate = new Date(); for (ActivityDTO activity : activities) { activity.setServerDateTime(currentServerDate); if (activity.getFirstComment() != null) { activity.getFirstComment().setServerDateTime(currentServerDate); } if (activity.getLastComment() != null) { activity.getLastComment().setServerDateTime(currentServerDate); } } }  }
PopulateActivityDTOServerDateTime implements ActivityFilter { public void filter(final List<ActivityDTO> activities, final PersonModelView user) { Date currentServerDate = new Date(); for (ActivityDTO activity : activities) { activity.setServerDateTime(currentServerDate); if (activity.getFirstComment() != null) { activity.getFirstComment().setServerDateTime(currentServerDate); } if (activity.getLastComment() != null) { activity.getLastComment().setServerDateTime(currentServerDate); } } }  void filter(final List<ActivityDTO> activities, final PersonModelView user); }
PopulateActivityDTOServerDateTime implements ActivityFilter { public void filter(final List<ActivityDTO> activities, final PersonModelView user) { Date currentServerDate = new Date(); for (ActivityDTO activity : activities) { activity.setServerDateTime(currentServerDate); if (activity.getFirstComment() != null) { activity.getFirstComment().setServerDateTime(currentServerDate); } if (activity.getLastComment() != null) { activity.getLastComment().setServerDateTime(currentServerDate); } } }  void filter(final List<ActivityDTO> activities, final PersonModelView user);  }