public void testTickets() throws Exception { User testuser = getUser(userDao, "testuser"); String name = "ticketable:" + System.currentTimeMillis(); ContentItem item = generateTestContent(name, "testuser"); CollectionItem root = (CollectionItem) contentDao.getRootItem(testuser); ContentItem newItem = contentDao.createContent(root, item); clearSession(); newItem = contentDao.findContentByUid(newItem.getUid()); Ticket ticket1 = new HibTicket(); ticket1.setKey("ticket1"); ticket1.setTimeout(10); ticket1.setOwner(testuser); HashSet privs = new HashSet(); privs.add("priv1"); privs.add("privs2"); ticket1.setPrivileges(privs); contentDao.createTicket(newItem, ticket1); Ticket ticket2 = new HibTicket(); ticket2.setKey("ticket2"); ticket2.setTimeout(100); ticket2.setOwner(testuser); privs = new HashSet(); privs.add("priv3"); privs.add("priv4"); ticket2.setPrivileges(privs); contentDao.createTicket(newItem, ticket2); clearSession(); newItem = contentDao.findContentByUid(newItem.getUid()); Ticket queryTicket1 = contentDao.getTicket(newItem, "ticket1"); Assert.assertNotNull(queryTicket1); verifyTicket(queryTicket1, ticket1); Collection tickets = contentDao.getTickets(newItem); Assert.assertEquals(2, tickets.size()); verifyTicketInCollection(tickets, ticket1.getKey()); verifyTicketInCollection(tickets, ticket2.getKey()); contentDao.removeTicket(newItem, ticket1); clearSession(); newItem = contentDao.findContentByUid(newItem.getUid()); tickets = contentDao.getTickets(newItem); Assert.assertEquals(1, tickets.size()); verifyTicketInCollection(tickets, ticket2.getKey()); queryTicket1 = contentDao.getTicket(newItem, "ticket1"); Assert.assertNull(queryTicket1); Ticket queryTicket2 = contentDao.getTicket(newItem, "ticket2"); Assert.assertNotNull(queryTicket2); verifyTicket(queryTicket2, ticket2); contentDao.removeTicket(newItem, ticket2); clearSession(); newItem = contentDao.findContentByUid(newItem.getUid()); tickets = contentDao.getTickets(newItem); Assert.assertEquals(0, tickets.size()); }