WebsiteData blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
WebsiteData blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
WebsiteData blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
HitCountData cnt1 = TestUtils.setupHitCount(blog1, 10);
HitCountData cnt2 = TestUtils.setupHitCount(blog2, 20);
HitCountData cnt3 = TestUtils.setupHitCount(blog3, 30);
TestUtils.endSession(true);
// make sure data was properly initialized
HitCountData testCount = null;
testCount = mgr.getHitCount(cnt1.getId());
assertEquals(10, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt2.getId());
assertEquals(20, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt3.getId());
assertEquals(30, testCount.getDailyHits());
// reset count for one weblog
mgr.resetHitCount(blog1);
TestUtils.endSession(true);
// make sure it reset only one weblog
testCount = mgr.getHitCount(cnt1.getId());
assertEquals(0, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt2.getId());
assertEquals(20, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt3.getId());
assertEquals(30, testCount.getDailyHits());
// reset all counts
mgr.resetAllHitCounts();
TestUtils.endSession(true);
// make sure it reset all counts
testCount = mgr.getHitCount(cnt1.getId());
assertEquals(0, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt2.getId());
assertEquals(0, testCount.getDailyHits());
testCount = mgr.getHitCount(cnt3.getId());
assertEquals(0, testCount.getDailyHits());
// cleanup
TestUtils.teardownHitCount(cnt1.getId());
TestUtils.teardownHitCount(cnt2.getId());
TestUtils.teardownHitCount(cnt3.getId());