@Test public void uninterestingNullTest() { final Long activityID = 1L; CONTEXT.checking(new Expectations() { { allowing(activity).getId(); will(returnValue(activityID)); oneOf(commentIdsByActivityIdDAOMock).execute(activityID); will(returnValue(null)); oneOf(commentorIdsByActivityDAOMock).execute(activityID); will(returnValue(null)); oneOf(getPeopleWhoLikedMapper).execute(Arrays.asList(activityID)); will(returnValue(null)); } }); Assert.assertEquals(new Long(0L), sut.computeInterestingness(activity)); }
public Long computeInterestingness(final Activity activity) { Long interestingNess = 0L; List<Long> commentList = commentIdsByActivityIdDAO.execute(activity.getId()); if (commentList != null) { interestingNess += commentList.size() * commentWeight; } List<Long> commentorList = commentorIdsByActivityIdDao.execute(activity.getId()); if (commentorList != null) { interestingNess += commentorList.size() * uniqueUserCommentWeight; } Collection<Collection<Long>> peopleWhoLikedActivity = getPeopleWhoLikedMapper.execute(Arrays.asList(activity .getId())); if (peopleWhoLikedActivity != null && peopleWhoLikedActivity.size() > 0) { interestingNess += peopleWhoLikedActivity.iterator().next().size() * likeWeight; } if (interestingNess > 0L) { interestingNess += activity.getPostedTime().getTime() / MILLISECONDS_IN_DAY * timeWeight; } return interestingNess; }
WeightedInterestingnessStrategy implements ComputeInterestingnessOfActivityStrategy { public Long computeInterestingness(final Activity activity) { Long interestingNess = 0L; List<Long> commentList = commentIdsByActivityIdDAO.execute(activity.getId()); if (commentList != null) { interestingNess += commentList.size() * commentWeight; } List<Long> commentorList = commentorIdsByActivityIdDao.execute(activity.getId()); if (commentorList != null) { interestingNess += commentorList.size() * uniqueUserCommentWeight; } Collection<Collection<Long>> peopleWhoLikedActivity = getPeopleWhoLikedMapper.execute(Arrays.asList(activity .getId())); if (peopleWhoLikedActivity != null && peopleWhoLikedActivity.size() > 0) { interestingNess += peopleWhoLikedActivity.iterator().next().size() * likeWeight; } if (interestingNess > 0L) { interestingNess += activity.getPostedTime().getTime() / MILLISECONDS_IN_DAY * timeWeight; } return interestingNess; } }
WeightedInterestingnessStrategy implements ComputeInterestingnessOfActivityStrategy { public Long computeInterestingness(final Activity activity) { Long interestingNess = 0L; List<Long> commentList = commentIdsByActivityIdDAO.execute(activity.getId()); if (commentList != null) { interestingNess += commentList.size() * commentWeight; } List<Long> commentorList = commentorIdsByActivityIdDao.execute(activity.getId()); if (commentorList != null) { interestingNess += commentorList.size() * uniqueUserCommentWeight; } Collection<Collection<Long>> peopleWhoLikedActivity = getPeopleWhoLikedMapper.execute(Arrays.asList(activity .getId())); if (peopleWhoLikedActivity != null && peopleWhoLikedActivity.size() > 0) { interestingNess += peopleWhoLikedActivity.iterator().next().size() * likeWeight; } if (interestingNess > 0L) { interestingNess += activity.getPostedTime().getTime() / MILLISECONDS_IN_DAY * timeWeight; } return interestingNess; } WeightedInterestingnessStrategy(final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetCommentorIdsByActivityId inCommentorIdsByActivityIdDao,
            final DomainMapper<Collection<Long>, Collection<Collection<Long>>> inGetPeopleWhoLikedMapper,
            final int inCommentWeight, final int inUniqueUserCommentWeight, final int inLikeWeight,
            final int inTimeWeight); }
WeightedInterestingnessStrategy implements ComputeInterestingnessOfActivityStrategy { public Long computeInterestingness(final Activity activity) { Long interestingNess = 0L; List<Long> commentList = commentIdsByActivityIdDAO.execute(activity.getId()); if (commentList != null) { interestingNess += commentList.size() * commentWeight; } List<Long> commentorList = commentorIdsByActivityIdDao.execute(activity.getId()); if (commentorList != null) { interestingNess += commentorList.size() * uniqueUserCommentWeight; } Collection<Collection<Long>> peopleWhoLikedActivity = getPeopleWhoLikedMapper.execute(Arrays.asList(activity .getId())); if (peopleWhoLikedActivity != null && peopleWhoLikedActivity.size() > 0) { interestingNess += peopleWhoLikedActivity.iterator().next().size() * likeWeight; } if (interestingNess > 0L) { interestingNess += activity.getPostedTime().getTime() / MILLISECONDS_IN_DAY * timeWeight; } return interestingNess; } WeightedInterestingnessStrategy(final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetCommentorIdsByActivityId inCommentorIdsByActivityIdDao,
            final DomainMapper<Collection<Long>, Collection<Collection<Long>>> inGetPeopleWhoLikedMapper,
            final int inCommentWeight, final int inUniqueUserCommentWeight, final int inLikeWeight,
            final int inTimeWeight); Long computeInterestingness(final Activity activity); }
WeightedInterestingnessStrategy implements ComputeInterestingnessOfActivityStrategy { public Long computeInterestingness(final Activity activity) { Long interestingNess = 0L; List<Long> commentList = commentIdsByActivityIdDAO.execute(activity.getId()); if (commentList != null) { interestingNess += commentList.size() * commentWeight; } List<Long> commentorList = commentorIdsByActivityIdDao.execute(activity.getId()); if (commentorList != null) { interestingNess += commentorList.size() * uniqueUserCommentWeight; } Collection<Collection<Long>> peopleWhoLikedActivity = getPeopleWhoLikedMapper.execute(Arrays.asList(activity .getId())); if (peopleWhoLikedActivity != null && peopleWhoLikedActivity.size() > 0) { interestingNess += peopleWhoLikedActivity.iterator().next().size() * likeWeight; } if (interestingNess > 0L) { interestingNess += activity.getPostedTime().getTime() / MILLISECONDS_IN_DAY * timeWeight; } return interestingNess; } WeightedInterestingnessStrategy(final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetCommentorIdsByActivityId inCommentorIdsByActivityIdDao,
            final DomainMapper<Collection<Long>, Collection<Collection<Long>>> inGetPeopleWhoLikedMapper,
            final int inCommentWeight, final int inUniqueUserCommentWeight, final int inLikeWeight,
            final int inTimeWeight); Long computeInterestingness(final Activity activity); static final Long MILLISECONDS_IN_DAY; }