public long timeout()
    {
        if (tickets.isEmpty()) {
            return -1;
        }
        sortIfNeeded();
        //  Tickets are sorted, so check first ticket
        Ticket first = tickets.get(0);
        long time = first.start - now() + first.delay;

        if (time > 0) {
            return time;
        }
        else {
            return 0;
        }
    }
@Test
    public void testNoTicket()
    {
        assertThat(tickets.timeout(), is(-1L));
    }