@Test public void testExecuteNotInCache() { final StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.PERSON, "foobar"); context.checking(new Expectations() { { oneOf(popularHashTagsMapper).execute(request); will(returnValue(null)); } }); assertNull(sut.execute(request)); context.assertIsSatisfied(); }
@Override public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { StreamPopularHashTagsReportDTO hashTagReport = popularHashTagsMapper.execute(inRequest); if (hashTagReport != null) { Calendar earliestValidReportDate = Calendar.getInstance(); earliestValidReportDate.add(Calendar.MINUTE, 0 - popularHashTagsExpirationInMinutes); if (hashTagReport.getReportGenerationDate().before(earliestValidReportDate.getTime())) { if (log.isInfoEnabled()) { log.info("Popular HashTag report for stream " + inRequest.getStreamEntityScopeType() + " #" + inRequest.getStreamEntityUniqueKey() + " is expired - regenerating."); } return null; } } return hashTagReport; }
StreamPopularHashTagsMapper implements
        DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { @Override public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { StreamPopularHashTagsReportDTO hashTagReport = popularHashTagsMapper.execute(inRequest); if (hashTagReport != null) { Calendar earliestValidReportDate = Calendar.getInstance(); earliestValidReportDate.add(Calendar.MINUTE, 0 - popularHashTagsExpirationInMinutes); if (hashTagReport.getReportGenerationDate().before(earliestValidReportDate.getTime())) { if (log.isInfoEnabled()) { log.info("Popular HashTag report for stream " + inRequest.getStreamEntityScopeType() + " #" + inRequest.getStreamEntityUniqueKey() + " is expired - regenerating."); } return null; } } return hashTagReport; } }
StreamPopularHashTagsMapper implements
        DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { @Override public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { StreamPopularHashTagsReportDTO hashTagReport = popularHashTagsMapper.execute(inRequest); if (hashTagReport != null) { Calendar earliestValidReportDate = Calendar.getInstance(); earliestValidReportDate.add(Calendar.MINUTE, 0 - popularHashTagsExpirationInMinutes); if (hashTagReport.getReportGenerationDate().before(earliestValidReportDate.getTime())) { if (log.isInfoEnabled()) { log.info("Popular HashTag report for stream " + inRequest.getStreamEntityScopeType() + " #" + inRequest.getStreamEntityUniqueKey() + " is expired - regenerating."); } return null; } } return hashTagReport; } StreamPopularHashTagsMapper(
            final DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> inPopularHashTagsMapper,
            final Integer inPopularHashTagsExpirationInMinutes); }
StreamPopularHashTagsMapper implements
        DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { @Override public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { StreamPopularHashTagsReportDTO hashTagReport = popularHashTagsMapper.execute(inRequest); if (hashTagReport != null) { Calendar earliestValidReportDate = Calendar.getInstance(); earliestValidReportDate.add(Calendar.MINUTE, 0 - popularHashTagsExpirationInMinutes); if (hashTagReport.getReportGenerationDate().before(earliestValidReportDate.getTime())) { if (log.isInfoEnabled()) { log.info("Popular HashTag report for stream " + inRequest.getStreamEntityScopeType() + " #" + inRequest.getStreamEntityUniqueKey() + " is expired - regenerating."); } return null; } } return hashTagReport; } StreamPopularHashTagsMapper(
            final DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> inPopularHashTagsMapper,
            final Integer inPopularHashTagsExpirationInMinutes); @Override StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest); }
StreamPopularHashTagsMapper implements
        DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { @Override public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { StreamPopularHashTagsReportDTO hashTagReport = popularHashTagsMapper.execute(inRequest); if (hashTagReport != null) { Calendar earliestValidReportDate = Calendar.getInstance(); earliestValidReportDate.add(Calendar.MINUTE, 0 - popularHashTagsExpirationInMinutes); if (hashTagReport.getReportGenerationDate().before(earliestValidReportDate.getTime())) { if (log.isInfoEnabled()) { log.info("Popular HashTag report for stream " + inRequest.getStreamEntityScopeType() + " #" + inRequest.getStreamEntityUniqueKey() + " is expired - regenerating."); } return null; } } return hashTagReport; } StreamPopularHashTagsMapper(
            final DomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> inPopularHashTagsMapper,
            final Integer inPopularHashTagsExpirationInMinutes); @Override StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest);  }