testUser = TestUtils.getManagedUser(testUser);
Weblog blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
Weblog blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
Weblog blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
WeblogHitCount cnt1 = TestUtils.setupHitCount(blog1, 10);
WeblogHitCount cnt2 = TestUtils.setupHitCount(blog2, 20);
WeblogHitCount cnt3 = TestUtils.setupHitCount(blog3, 30);
TestUtils.endSession(true);
try {
// make sure data was properly initialized
WeblogHitCount 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
blog1 = TestUtils.getManagedWebsite(blog1);
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());
} finally {
// cleanup
TestUtils.teardownHitCount(cnt1.getId());
TestUtils.teardownHitCount(cnt2.getId());