@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); }
@Override public boolean deleteTicket(final String ticketId) { boolean ticketDeleted = this.ticketRegistry.deleteTicket(ticketId); if(ticketDeleted) { this.cache.remove(ticketId); } return ticketDeleted; }
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 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); }
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(); }
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();  }