LoginTicket { public static LoginTicket newTicket(int validityTimeSeconds, String requestingApplication, String requestingApplicationUsername) { UUID id = UUID.randomUUID(); Duration duration = new Duration(validityTimeSeconds * SECONDS_MILLIS_RATIO); DateTime creationTime = new DateTime(); LoginTicket ticket = new LoginTicket(id, creationTime, duration, requestingApplication, requestingApplicationUsername); return ticket; } private  LoginTicket(UUID id, DateTime creationtime, Duration validityDuration, 
			String requestingApplication, String requestingApplicationUsername); UUID getId(); String getIdAsString(); DateTime getCreationTime(); void setCreationTime(org.joda.time.DateTime creationTime); Duration getValidityDuration(); void setValidityDuration(Duration validityDuration); String getRequistingApplication(); void setRequistingApplication(String requistingApplication); String getRequestingApplicationUsername(); void setRequestingApplicationUsername(String requestingApplicationUsername); static LoginTicket newTicket(int validityTimeSeconds, String requestingApplication, String requestingApplicationUsername); boolean isExpired(); static int SECONDS_MILLIS_RATIO; }
@Test public void testNewTicket() { int validity = 10; DateTime start = new DateTime(); LoginTicket ticket = LoginTicket.newTicket(validity, "test", "testUser"); DateTime end = new DateTime(); assertNotNull(ticket); assertEquals(validity, ticket.getValidityDuration().getStandardSeconds()); assertEquals("test", ticket.getRequistingApplication()); assertEquals("testUser", ticket.getRequestingApplicationUsername()); assertTrue(ticket.getCreationTime().compareTo(start) >= 0); assertTrue(ticket.getCreationTime().compareTo(end) <= 0); }