### Question:
TicketRegistryDecorator extends AbstractTicketRegistry { @Override public boolean deleteTicket(final String ticketId) { boolean ticketDeleted = this.ticketRegistry.deleteTicket(ticketId); if(ticketDeleted) { this.cache.remove(ticketId); } return ticketDeleted; } TicketRegistryDecorator(final TicketRegistry actualTicketRegistry, final Map<String, String> cache); @Override void addTicket(final Ticket ticket); @Override Ticket getTicket(final String ticketId); @Override boolean deleteTicket(final String ticketId); @Override Collection<Ticket> getTickets(); @Override int sessionCount(); @Override int serviceTicketCount();  }### Answer:
@Test public void deleteTicketWithUser() { String ticket = "Ticket-123"; cache.put(ticket, "username"); cache.put("username", "password"); when(registry.deleteTicket(ticket)).thenReturn(true); decorator.deleteTicket(ticket); assertEquals(1, cache.size()); verify(registry).deleteTicket(ticket); }
@Test public void deleteTicketWithoutUser() { String ticket = "Ticket-123"; cache.put(ticket, "username"); when(registry.deleteTicket(ticket)).thenReturn(true); decorator.deleteTicket(ticket); assertEquals(0, cache.size()); verify(registry).deleteTicket(ticket); }