controllerClasses.add(TestMethodInterceptorController2.class);
controllerClasses.add(TestMethodInterceptorController4.class);
controllerClasses.add(TestMethodInterceptorController5.class);
controllerClasses.add(TestMethodInterceptorController6.class);
FakeRouteMap rm = new FakeRouteMap();
ControllerDatabase db = new MappedControllerDatabase(controllerClasses, rm,
new HashMap<String, EntityMarshaller>());
FastClass fc = db.getFastClass(TestInterceptorController1.class);
assertNotNull(fc);
assertEquals(TestInterceptorController1.class, fc.getJavaClass());
fc = db.getFastClass(TestInterceptorController2.class);
assertNotNull(fc);
assertEquals(TestInterceptorController2.class, fc.getJavaClass());
fc = db.getFastClass(TestMethodInterceptorController1.class);
assertNotNull(fc);
assertEquals(TestMethodInterceptorController1.class, fc.getJavaClass());
fc = db.getFastClass(TestMethodInterceptorController2.class);
assertNotNull(fc);
assertEquals(TestMethodInterceptorController2.class, fc.getJavaClass());
fc = db.getFastClass(TestMethodInterceptorController4.class);
assertNotNull(fc);
assertEquals(TestMethodInterceptorController4.class, fc.getJavaClass());
fc = db.getFastClass(TestMethodInterceptorController5.class);
assertNotNull(fc);
assertEquals(TestMethodInterceptorController5.class, fc.getJavaClass());
fc = db.getFastClass(TestMethodInterceptorController6.class);
assertNotNull(fc);
assertEquals(TestMethodInterceptorController6.class, fc.getJavaClass());
fc = db.getFastClass(Interceptor1.class);
assertNotNull(fc);
assertEquals(Interceptor1.class, fc.getJavaClass());
fc = db.getFastClass(Interceptor2.class);
assertNotNull(fc);
assertEquals(Interceptor2.class, fc.getJavaClass());
fc = db.getFastClass(Interceptor3.class);
assertNotNull(fc);
assertEquals(Interceptor3.class, fc.getJavaClass());
List<Class<?>> interceptors = db.getInterceptorsFor(TestInterceptorController1.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsFor(TestInterceptorController2.class);
assertNotNull(interceptors);
assertEquals(2, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
assertEquals(Interceptor2.class, interceptors.get(1));
interceptors = db.getInterceptorsForAction(TestMethodInterceptorController1.class, "someAction");
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController1.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsForAction(TestMethodInterceptorController2.class, "someAction");
assertNotNull(interceptors);
assertEquals(2, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
assertEquals(Interceptor2.class, interceptors.get(1));
interceptors = db.getInterceptorsForAction(TestMethodInterceptorController4.class, "someAction");
assertNotNull(interceptors);
assertEquals(2, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
assertEquals(Interceptor2.class, interceptors.get(1));
interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController4.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsFor(TestMethodInterceptorController5.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsForAction(TestMethodInterceptorController5.class, "someAction");
assertNotNull(interceptors);
assertEquals(2, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
assertEquals(Interceptor2.class, interceptors.get(1));
interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController5.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
interceptors = db.getInterceptorsFor(TestMethodInterceptorController6.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor3.class, interceptors.get(0));
interceptors = db.getInterceptorsForAction(TestMethodInterceptorController6.class, "someAction");
assertNotNull(interceptors);
assertEquals(2, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
assertEquals(Interceptor2.class, interceptors.get(1));
interceptors = db.getInterceptorsForDefaultAction(TestMethodInterceptorController6.class);
assertNotNull(interceptors);
assertEquals(1, interceptors.size());
assertEquals(Interceptor1.class, interceptors.get(0));
ActionSignature beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor1.class);
assertNotNull(beforeActionMethod);
assertEquals("before", beforeActionMethod.methodName());
beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor2.class);
assertNotNull(beforeActionMethod);
assertEquals("before2", beforeActionMethod.methodName());
beforeActionMethod = db.getBeforeActionMethodForInterceptor(Interceptor3.class);
assertNotNull(beforeActionMethod);
assertEquals("before3", beforeActionMethod.methodName());
ActionSignature afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor1.class);
assertNotNull(afterActionMethod);
assertEquals("after", afterActionMethod.methodName());
afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor2.class);
assertNotNull(afterActionMethod);
assertEquals("after2", afterActionMethod.methodName());
afterActionMethod = db.getAfterActionMethodForInterceptor(Interceptor3.class);
assertNotNull(afterActionMethod);
assertEquals("after3", afterActionMethod.methodName());
assertEquals(11, rm.size());
assertTrue(rm.contains(new MojaveRoute("interceptor1", "someAction", null)));