SessionDaoImpl implements SessionDao { @Override public void updateSessionPosition(final String deviceId, final Long position, final Long duration) throws UnknownSessionException { StreamingSession session = getSession(deviceId); if (session.getDuration() > 0 && (position >= duration || duration == 0)) { session.setStatus(SessionStatus.WAITING); } session.setPosition(position); session.setDuration(duration); } SessionDaoImpl(); @Override void initSession(final String deviceId, final String contentUrl, final String contentName); @Override void updateSessionStatus(final String deviceId, final SessionStatus status); @Override void updateSessionPosition(final String deviceId, final Long position, final Long duration); @Override void removeDevice(final String deviceId); @Override StreamingSession getSession(final String deviceId); @Override Map<String, StreamingSession> getSessions();  }
@Test public void testUpdateSessionPosition() throws UnknownSessionException { SessionDaoImpl sessionDao = new SessionDaoImpl(); sessionDao.initSession("deviceId", "contentUrl", "contentName"); sessionDao.updateSessionPosition("deviceId", 1l, 2l); StreamingSession session = sessionDao.getSession("deviceId"); assertNotNull(session); assertTrue(session.getPosition() == 1l); assertTrue(session.getDuration() == 2l); }