AlertRouter { @MotechListener(subjects = {EventSubjects.MILESTONE_ALERT}) public void handle(MotechEvent realEvent) { logger.info("Handling motech event : " + realEvent); MilestoneEvent event = new MilestoneEvent(realEvent); for (Route route : routes) { if (route.isSatisfiedBy(event.scheduleName(), event.milestoneName(), event.windowName())) { route.invokeAction(event); return; } } throw new NoRoutesMatchException(event); } AlertRouter(); Route addRoute(Matcher scheduleMatcher, Matcher milestoneMatcher, Matcher windowMatcher, Action action); @MotechListener(subjects = {EventSubjects.MILESTONE_ALERT}) void handle(MotechEvent realEvent);  }
@Test(expected = NoRoutesMatchException.class) public void shouldFailIfNoRoutesMatch() { router.handle(event("scheduleName", "milestoneName", "windowName")); }