Source:
public void testGetRatingsLastXDays() { this.execute( new Callable<Object>() { @Override public Object call() throws Exception { Calendar today = Calendar.getInstance(); List<IPortletDefinition> portletList = portletDefinitionDao.getPortletDefinitions(); List<ILocalAccountPerson> personList = localAccountDao.getAllAccounts(); assertNotEquals(portletList.size(), 0); assertNotEquals(personList.size(), 0); int numberOfDaysBack = 1; for (IPortletDefinition portlet : portletList) { for (ILocalAccountPerson person : personList) { today.add(Calendar.DAY_OF_YEAR, 0 - numberOfDaysBack); System.out.println( "Testing get ratings using " + today.getTime() + " for portlet creation date."); MarketplaceRatingImpl rating = new MarketplaceRatingImpl(); int starRating = random.nextInt(MarketplaceRatingImpl.MAX_RATING) + 1; rating.setRating(starRating); MarketplaceRatingPK ratingPK = new MarketplaceRatingPK(); ratingPK.setPortletDefinition((PortletDefinitionImpl) portlet); ratingPK.setUserName(person.getName()); rating.setMarketplaceRatingPK(ratingPK); rating.setRatingDate(today.getTime()); rating.setReview( "comment for " + ratingPK.getPortletDefinition().getFName()); marketplaceRatingDao.createOrUpdateRating(rating); numberOfDaysBack = numberOfDaysBack + TEST_DATE_INCREMENT; } } return null; } }); this.execute( new Callable<Object>() { @Override public Object call() throws Exception { int daysBack = 7; Set<IMarketplaceRating> ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 1); daysBack = 30; ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 2); daysBack = 5000; ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 4); return null; } }); }

Target:
public void testGetRatingsLastXDays() { this.execute( new Callable<Object>() { @Override public Object call() throws Exception { Calendar today = Calendar.getInstance(); List<IPortletDefinition> portletList = portletDefinitionDao.getPortletDefinitions(); List<ILocalAccountPerson> personList = localAccountDao.getAllAccounts(); assertNotEquals(portletList.size(), 0); assertNotEquals(personList.size(), 0); int numberOfDaysBack = 1; for (IPortletDefinition portlet : portletList) { for (ILocalAccountPerson person : personList) { today.add(Calendar.DAY_OF_YEAR, 0 - numberOfDaysBack); MarketplaceRatingImpl rating = new MarketplaceRatingImpl(); int starRating = random.nextInt(MarketplaceRatingImpl.MAX_RATING) + 1; rating.setRating(starRating); MarketplaceRatingPK ratingPK = new MarketplaceRatingPK(); ratingPK.setPortletDefinition((PortletDefinitionImpl) portlet); ratingPK.setUserName(person.getName()); rating.setMarketplaceRatingPK(ratingPK); rating.setRatingDate(today.getTime()); rating.setReview( "comment for " + ratingPK.getPortletDefinition().getFName()); marketplaceRatingDao.createOrUpdateRating(rating); numberOfDaysBack = numberOfDaysBack + TEST_DATE_INCREMENT; } } return null; } }); this.execute( new Callable<Object>() { @Override public Object call() throws Exception { int daysBack = 7; Set<IMarketplaceRating> ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 1); daysBack = 30; ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 2); daysBack = 5000; ratingList = marketplaceRatingDao.getAllRatingsInLastXDays(daysBack); assertEquals(ratingList.size(), 4); return null; } }); }