UserTrackingServiceImpl implements UserTrackingService, ManagedService { public int getViews(String mediapackageId) { EntityManager em = null; try { em = emf.createEntityManager(); Query q = em.createNamedQuery("countSessionsOfMediapackage"); q.setParameter("mediapackageId", mediapackageId); return ((Long) q.getSingleResult()).intValue(); } finally { if (em != null && em.isOpen()) { em.close(); } } }  void activate(); @Override void updated(Dictionary props); int getViews(String mediapackageId); @SuppressWarnings("unchecked") UserAction addUserFootprint(UserAction a, UserSession session); UserAction addUserTrackingEvent(UserAction a, UserSession session); @SuppressWarnings("unchecked") UserActionList getUserActions(int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByType(String type, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageId(String type, String mediapackageId, int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByTypeAndDay(String type, String day, int offset, int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDate(String type, String mediapackageId, int offset,
          int limit); UserActionList getUserActionsByTypeAndMediapackageIdByDescendingDate(String type, String mediapackageId,
          int offset, int limit); @SuppressWarnings("unchecked") UserActionList getUserActionsByDay(String day, int offset, int limit); Report getReport(int offset, int limit); Report getReport(String from, String to, int offset, int limit); FootprintList getFootprints(String mediapackageId, String userId); @Override UserAction getUserAction(Long id); @Override boolean getUserTrackingEnabled(); static final String PERSISTENCE_UNIT; static final String FOOTPRINT_KEY; static final String DETAILED_TRACKING; static final String IP_LOGGING; static final String USER_LOGGING; static final String SESSION_LOGGING; }
@Test public void testfootprints() throws Exception { FootprintList list = getFootprintList("mp", null, 1); verifyFootprintViewsAndPositions(list, 0, 0, 0); list = getFootprintList("mp", "me", 1); verifyFootprintViewsAndPositions(list, 0, 0, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); list = getFootprintList("mp", null, 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 20, 0); list = getFootprintList("mp", "someone else", 1); verifyFootprintViewsAndPositions(list, 0, 0, 0); list = getFootprintList("mp", "me", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 20, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session456", "mp", "someone else", "127.0.01", 560, 720); Assert.assertEquals(2, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); list = getFootprintList("mp", null, 5); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 20, 0); verifyFootprintViewsAndPositions(list, 3, 560, 1); verifyFootprintViewsAndPositions(list, 4, 720, 0); list = getFootprintList("mp", "someone else", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 560, 1); verifyFootprintViewsAndPositions(list, 2, 720, 0); list = getFootprintList("mp", "me", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 20, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 20, 30); Assert.assertEquals(2, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); list = getFootprintList("mp", null, 5); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 30, 0); verifyFootprintViewsAndPositions(list, 3, 560, 1); verifyFootprintViewsAndPositions(list, 4, 720, 0); list = getFootprintList("mp", "someone else", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 560, 1); verifyFootprintViewsAndPositions(list, 2, 720, 0); list = getFootprintList("mp", "me", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 30, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session456", "mp", "someone else", "127.0.01", 950, 960); Assert.assertEquals(2, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); list = getFootprintList("mp", null, 7); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 30, 0); verifyFootprintViewsAndPositions(list, 3, 560, 1); verifyFootprintViewsAndPositions(list, 4, 720, 0); verifyFootprintViewsAndPositions(list, 5, 950, 1); verifyFootprintViewsAndPositions(list, 6, 960, 0); list = getFootprintList("mp", "someone else", 5); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 560, 1); verifyFootprintViewsAndPositions(list, 2, 720, 0); verifyFootprintViewsAndPositions(list, 3, 950, 1); verifyFootprintViewsAndPositions(list, 4, 960, 0); list = getFootprintList("mp", "me", 3); verifyFootprintViewsAndPositions(list, 0, 0, 0); verifyFootprintViewsAndPositions(list, 1, 10, 1); verifyFootprintViewsAndPositions(list, 2, 30, 0); }
@Test public void testBasicUserActionLists() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(1, 0, 0, 1); verifyUserActionLists(1, 0, 1, 1); verifyUserActionLists(0, 1, 0, 1); verifyUserActionLists(0, 1, 1, 1); verifyUserActionLists(1, 0, 10, 1); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 20, 30); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(1, 0, 0, 1); verifyUserActionLists(1, 0, 1, 1); verifyUserActionLists(0, 1, 0, 1); verifyUserActionLists(0, 1, 1, 1); verifyUserActionLists(1, 0, 10, 1); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 40, 50); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(2, 0, 0, 2); verifyUserActionLists(1, 0, 1, 2); verifyUserActionLists(1, 1, 0, 2); verifyUserActionLists(1, 1, 1, 2); verifyUserActionLists(2, 0, 10, 2); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 50, 60); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(2, 0, 0, 2); verifyUserActionLists(1, 0, 1, 2); verifyUserActionLists(1, 1, 0, 2); verifyUserActionLists(1, 1, 1, 2); verifyUserActionLists(2, 0, 10, 2); }
@Test public void testUserActionListsByType() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 0, 1); verifyUserActionListsByType("other", 0, 0, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 1, 1); verifyUserActionListsByType("other", 0, 0, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 0, 1, 0, 1); verifyUserActionListsByType("other", 0, 1, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 0, 1, 1, 1); verifyUserActionListsByType("other", 0, 1, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 10, 1); verifyUserActionListsByType("other", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 20, 30); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 0, 1); verifyUserActionListsByType("other", 0, 0, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 1, 1); verifyUserActionListsByType("other", 0, 0, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 0, 1, 0, 1); verifyUserActionListsByType("other", 0, 1, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 0, 1, 1, 1); verifyUserActionListsByType("other", 0, 1, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 10, 1); verifyUserActionListsByType("other", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 40, 50); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 2, 0, 0, 2); verifyUserActionListsByType("other", 0, 0, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 1, 2); verifyUserActionListsByType("other", 0, 0, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 1, 0, 2); verifyUserActionListsByType("other", 0, 1, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 1, 1, 2); verifyUserActionListsByType("other", 0, 1, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 2, 0, 10, 2); verifyUserActionListsByType("other", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 50, 60); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 2, 0, 0, 2); verifyUserActionListsByType("other", 0, 0, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 0, 1, 2); verifyUserActionListsByType("other", 0, 0, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 1, 0, 2); verifyUserActionListsByType("other", 0, 1, 0, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 1, 1, 1, 2); verifyUserActionListsByType("other", 0, 1, 1, 0); verifyUserActionListsByType(UserTrackingServiceImpl.FOOTPRINT_KEY, 2, 0, 10, 2); verifyUserActionListsByType("other", 0, 0, 10, 0); }
@Test public void testUserActionListsByTypeAndMediapackage() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 0, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 1, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 0, 1, 0, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 0, 1, 1, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 10, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 20, 30); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 0, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 1, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 0, 1, 0, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 0, 1, 1, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 10, 1); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 40, 50); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 2, 0, 0, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 1, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 1, 0, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 1, 1, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 2, 0, 10, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 10, 0); createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 50, 60); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 2, 0, 0, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 0, 1, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 1, 0, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 0, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 1, 1, 1, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 1, 1, 0); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "mp", 2, 0, 10, 2); verifyUserActionListsByTypeAndMediapackage(UserTrackingServiceImpl.FOOTPRINT_KEY, "not-mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "mp", 0, 0, 10, 0); verifyUserActionListsByTypeAndMediapackage("other", "not-mp", 0, 0, 10, 0); }
@Test public void testUserActionsListsByTypeAndDay() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); DateFormat df = new SimpleDateFormat("yyyyMMdd"); Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c2.add(Calendar.DAY_OF_YEAR, -1); String now = df.format(c1.getTime()); String yesterday = df.format(c2.getTime()); testUserActionListsByTypeAndDay(now, yesterday); }
@Test public void testUserActionsListsByTypeAndDayWithTime() throws Exception { createAndVerifyUserAction(UserTrackingServiceImpl.FOOTPRINT_KEY, "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c2.add(Calendar.DAY_OF_YEAR, -1); String now = df.format(c1.getTime()); String yesterday = df.format(c2.getTime()); testUserActionListsByTypeAndDay(now, yesterday); }
@Test public void testArbitraryAction() throws Exception { createAndVerifyUserAction("arbitraryType", "session123", "mp", "me", "127.0.0.1", 10, 20); Assert.assertEquals(1, service.getViews("mp")); Assert.assertEquals(0, service.getViews("other")); verifyUserActionLists(1, 0, 0, 1); verifyUserActionLists(1, 0, 1, 1); verifyUserActionLists(0, 1, 0, 1); verifyUserActionLists(0, 1, 1, 1); verifyUserActionLists(1, 0, 10, 1); }