Source:
public void testGetAllRatingsForPortletInLastXDays() { 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 i = 1; for (IPortletDefinition portlet : portletList) { for (ILocalAccountPerson person : personList) { today.add(Calendar.DAY_OF_YEAR, 0 - i); System.out.println( "Testing get ratings using " + today.getTime() + " for portlet creation date. Porlet is " + portlet.getFName()); 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); i = i + 20; } } return null; } }); this.execute( new Callable<Object>() { @Override public Object call() throws Exception { int daysBack = 7; Set<IMarketplaceRating> ratingList = marketplaceRatingDao.getAllRatingsForPortletInLastXDays( daysBack, "fname1"); assertEquals(ratingList.size(), 1); daysBack = 30; ratingList = marketplaceRatingDao.getAllRatingsForPortletInLastXDays( daysBack, "fname1"); assertEquals(ratingList.size(), 2); return null; } }); }

Target:
public void testGetAllRatingsForPortletInLastXDays() { 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. Porlet is " + portlet.getFName()); 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.getAllRatingsForPortletInLastXDays( daysBack, "fname1"); assertEquals(ratingList.size(), 1); daysBack = 30; ratingList = marketplaceRatingDao.getAllRatingsForPortletInLastXDays( daysBack, "fname1"); assertEquals(ratingList.size(), 2); return null; } }); }