@Test public void testRemoveEvent() throws InterruptedException { final Character chara = MockFactory.mockCharacter(); event = MockFactory.mockTimedEvent(chara); service.addEvent(chara, event, 50L); service.removeEvent(event); Thread.sleep(55L); verify(event, never()).execute(); }
@Override public void removeEvent(TimedEvent event) { Map<TimedEvent, TimerTaskAdapter> characterEvents = events.get(event.getCharacter()); if (characterEvents != null) { TimerTaskAdapter task; synchronized (characterEvents) { task = characterEvents.remove(event); } if (task != null) { task.cancel(); } } }
TimedEventsServiceImpl implements TimedEventsService { @Override public void removeEvent(TimedEvent event) { Map<TimedEvent, TimerTaskAdapter> characterEvents = events.get(event.getCharacter()); if (characterEvents != null) { TimerTaskAdapter task; synchronized (characterEvents) { task = characterEvents.remove(event); } if (task != null) { task.cancel(); } } } }
TimedEventsServiceImpl implements TimedEventsService { @Override public void removeEvent(TimedEvent event) { Map<TimedEvent, TimerTaskAdapter> characterEvents = events.get(event.getCharacter()); if (characterEvents != null) { TimerTaskAdapter task; synchronized (characterEvents) { task = characterEvents.remove(event); } if (task != null) { task.cancel(); } } }  }
TimedEventsServiceImpl implements TimedEventsService { @Override public void removeEvent(TimedEvent event) { Map<TimedEvent, TimerTaskAdapter> characterEvents = events.get(event.getCharacter()); if (characterEvents != null) { TimerTaskAdapter task; synchronized (characterEvents) { task = characterEvents.remove(event); } if (task != null) { task.cancel(); } } }  @Override void addEvent(Character chara, TimedEvent event, long delay, long interval, long repeatFor); @Override void addEvent(Character chara, TimedEvent event, long delay); @Override void removeCharacterEvents(Character chara); @Override void removeEvent(TimedEvent event); }
TimedEventsServiceImpl implements TimedEventsService { @Override public void removeEvent(TimedEvent event) { Map<TimedEvent, TimerTaskAdapter> characterEvents = events.get(event.getCharacter()); if (characterEvents != null) { TimerTaskAdapter task; synchronized (characterEvents) { task = characterEvents.remove(event); } if (task != null) { task.cancel(); } } }  @Override void addEvent(Character chara, TimedEvent event, long delay, long interval, long repeatFor); @Override void addEvent(Character chara, TimedEvent event, long delay); @Override void removeCharacterEvents(Character chara); @Override void removeEvent(TimedEvent event);  }