assertThat(route.getTargetClass()).isEqualTo(ErrorTarget.class);
}
@Test
public void exceptionRoutesOrder() {
Routes routes = new AbstractRoutingModule() {
@Override
public void configuration() throws Exception {
route().on(SubException.class).to(SampleController.class).subException();
route().on(SuperException.class).to(SampleController.class).superException();
route().on(Exception.class).to(SampleController.class).error(param(Exception.class));
route().from("/home").on(GET).to(SampleController.class).index();
}
}.build();
final Route superErrorRoute = routes.routeFor(new SuperException());
assertThat(superErrorRoute.canHandle(new SuperException())).isTrue();
assertThat(superErrorRoute.canHandle(new SubException())).isTrue();
assertThat(superErrorRoute.getTargetMethod().getName()).isEqualTo("superException");
final Route subErrorRoute = routes.routeFor(new SubException());
assertThat(subErrorRoute.canHandle(new SubException())).isTrue();
assertThat(subErrorRoute.canHandle(new SuperException())).isFalse();
assertThat(subErrorRoute.getTargetMethod().getName()).isEqualTo("subException");
final Route genErrorRoute = routes.routeFor(new Exception());
assertThat(genErrorRoute.canHandle(new SuperException())).isTrue();
assertThat(genErrorRoute.canHandle(new SubException())).isTrue();
assertThat(genErrorRoute.getTargetMethod().getName()).isEqualTo("error");
}