Search in sources :

Example 16 with UserAction

use of org.opencastproject.usertracking.api.UserAction in project opencast by opencast.

the class UserActionImplTest method testForwardLength.

/**
 * Ensures a positive length user action calculates its length correctly.
 */
@Test
public void testForwardLength() {
    UserSession us = new UserSessionImpl();
    us.setSessionId("4");
    us.setUserId("testing user");
    us.setUserIp("127.0.0.1");
    UserAction ua = new UserActionImpl();
    ua.setId(4L);
    ua.setInpoint(90);
    ua.setIsPlaying(true);
    ua.setMediapackageId("false");
    ua.setOutpoint(100);
    ua.setSession(us);
    ua.setType("test");
    Assert.assertEquals(new Long(4), ua.getId());
    Assert.assertEquals(90, ua.getInpoint());
    Assert.assertEquals(true, ua.getIsPlaying());
    Assert.assertEquals("false", ua.getMediapackageId());
    Assert.assertEquals(100, ua.getOutpoint());
    Assert.assertEquals("4", ua.getSession().getSessionId());
    Assert.assertEquals("test", ua.getType());
    Assert.assertEquals("testing user", ua.getSession().getUserId());
    Assert.assertEquals("127.0.0.1", ua.getSession().getUserIp());
    Assert.assertEquals(10, ua.getLength());
}
Also used : UserAction(org.opencastproject.usertracking.api.UserAction) UserSession(org.opencastproject.usertracking.api.UserSession) Test(org.junit.Test)

Aggregations

UserAction (org.opencastproject.usertracking.api.UserAction)16 EntityManager (javax.persistence.EntityManager)9 Query (javax.persistence.Query)9 UserActionList (org.opencastproject.usertracking.api.UserActionList)9 UserSession (org.opencastproject.usertracking.api.UserSession)6 Test (org.junit.Test)5 Footprint (org.opencastproject.usertracking.api.Footprint)3 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 ParseException (java.text.ParseException)1 LinkedList (java.util.LinkedList)1 EntityTransaction (javax.persistence.EntityTransaction)1 NoResultException (javax.persistence.NoResultException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Response (javax.ws.rs.core.Response)1 Ignore (org.junit.Ignore)1 FootprintList (org.opencastproject.usertracking.api.FootprintList)1 UserTrackingException (org.opencastproject.usertracking.api.UserTrackingException)1 FootprintImpl (org.opencastproject.usertracking.endpoint.FootprintImpl)1 FootprintsListImpl (org.opencastproject.usertracking.endpoint.FootprintsListImpl)1