RouteBuilderImpl implements RouteBuilder { @Override public RouteBuilder globalFilters(List<Class<? extends Filter>> filtersToAdd) { this.globalFiltersOptional = Optional.of(filtersToAdd); return this; } @Inject  RouteBuilderImpl(
            NinjaProperties ninjaProperties,
            NinjaBaseDirectoryResolver ninjaBaseDirectoryResolver); RouteBuilderImpl GET(); RouteBuilderImpl POST(); RouteBuilderImpl PUT(); RouteBuilderImpl DELETE(); RouteBuilderImpl OPTIONS(); RouteBuilderImpl HEAD(); RouteBuilderImpl WS(); RouteBuilderImpl METHOD(String method); @Override void with(Class<?> controllerClass, String controllerMethod); @Override @Deprecated void with(MethodReference methodRef); @Override @Deprecated void with(final Result result); @Override Void with(ControllerMethod controllerMethod); @Override RouteBuilder globalFilters(List<Class<? extends Filter>> filtersToAdd); @Override RouteBuilder globalFilters(Class<? extends Filter> ... filtersToAdd); @Override RouteBuilder filters(List<Class<? extends Filter>> filtersToAdd); @Override RouteBuilder filters(Class<? extends Filter> ... filtersToAdd); @Override RouteBuilder route(String uri); Route buildRoute(Injector injector);  }
@Test public void testGlobalFilters() throws Exception { Mockito.when(ninjaProperties.get(NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE)) .thenReturn("com.example"); this.ninjaBaseDirectoryResolver = new NinjaBaseDirectoryResolver(ninjaProperties); this.routeBuilder = new RouteBuilderImpl(ninjaProperties, ninjaBaseDirectoryResolver); DummyFilter dummyFilter = new DummyFilter(); Result expectedResult = Mockito.mock(Result.class); Context context = Mockito.mock(Context.class); Provider filterProvider = Mockito.mock(Provider.class); com.example.conf.Filters filters = new com.example.conf.Filters(DummyFilter.class); Mockito.when(injector.getInstance(com.example.conf.Filters.class)).thenReturn(filters); Mockito.when(injector.getProvider(DummyFilter.class)).thenReturn(filterProvider); Mockito.when(filterProvider.get()).thenReturn(dummyFilter); routeBuilder.GET().route("/").with(() -> expectedResult); Route route = routeBuilder.buildRoute(injector); FilterChain filterChain = route.getFilterChain(); Result result = filterChain.next(context); Mockito.verify(injector).getInstance(com.example.conf.Filters.class); assertThat(dummyFilter.executed, Matchers.equalTo(1)); assertThat(result, org.hamcrest.Matchers.equalTo(expectedResult)); }