fix NullPointerException in ITicketService and add TestCase
| | |
| | | TicketKey key = new TicketKey(repository, ticketId); |
| | | TicketModel ticket = ticketsCache.getIfPresent(key); |
| | | |
| | | // if ticket not cached |
| | | if (ticket == null) { |
| | | // load & cache ticket |
| | | //load ticket |
| | | ticket = getTicketImpl(repository, ticketId); |
| | | // if ticket exists |
| | | if (ticket != null) { |
| | | if (ticket.hasPatchsets()) { |
| | | Repository r = repositoryManager.getRepository(repository.name); |
| | | try { |
| | |
| | | r.close(); |
| | | } |
| | | } |
| | | if (ticket != null) { |
| | | //cache ticket |
| | | ticketsCache.put(key, ticket); |
| | | } |
| | | } |
| | |
| | |
|
| | | @Test
|
| | | public void testLifecycle() throws Exception {
|
| | | // query non-existent ticket
|
| | | TicketModel nonExistent = service.getTicket(getRepository(), 0);
|
| | | assertNull(nonExistent);
|
| | | |
| | | // create and insert a ticket
|
| | | Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));
|
| | | TicketModel ticket = service.createTicket(getRepository(), c1);
|