ApplicationContext implements UriInfo, InitialProperties, Lifecycle { public MethodInvoker getMethodInvoker(GenericResourceMethod methodDescriptor) { String method = request.getMethod(); if ("OPTIONS".equals(method) && methodDescriptor.getMethod() == null) { return new OptionsRequestMethodInvoker(new WadlProcessor()); } MethodInvoker invoker = null; if (isAsynchronous() && methodDescriptor instanceof ResourceMethodDescriptor) { ContextResolver<AsynchronousJobPool> asyncJobsResolver = getProviders().getContextResolver(AsynchronousJobPool.class, null); if (asyncJobsResolver == null) { throw new IllegalStateException("Asynchronous jobs feature is not configured properly. "); } invoker = new AsynchronousMethodInvoker(asyncJobsResolver.getContext(null), new ParameterResolverFactory()); } if (invoker == null) { invoker = new DefaultMethodInvoker(new ParameterResolverFactory()); } if (methodInvokerDecoratorFactory != null) { return methodInvokerDecoratorFactory.makeDecorator(invoker); } return invoker; } private  ApplicationContext(ApplicationContextBuilder builder); static ApplicationContext getCurrent(); static void setCurrent(ApplicationContext context); void addMatchedResource(Object resource); void addMatchedURI(String uri); @Override URI getAbsolutePath(); @Override UriBuilder getAbsolutePathBuilder(); Map<String, Object> getAttributes(); @Override URI getBaseUri(); @Override UriBuilder getBaseUriBuilder(); GenericContainerRequest getContainerRequest(); GenericContainerResponse getContainerResponse(); DependencySupplier getDependencySupplier(); HttpHeaders getHttpHeaders(); InitialProperties getInitialProperties(); @Override List<Object> getMatchedResources(); @Override URI resolve(URI uri); @Override URI relativize(URI uri); @Override List<String> getMatchedURIs(); @Override List<String> getMatchedURIs(boolean decode); MethodInvoker getMethodInvoker(GenericResourceMethod methodDescriptor); List<String> getParameterValues(); @Override String getPath(); @Override String getPath(boolean decode); @Override MultivaluedMap<String, String> getPathParameters(); @Override MultivaluedMap<String, String> getPathParameters(boolean decode); @Override List<PathSegment> getPathSegments(); @Override List<PathSegment> getPathSegments(boolean decode); @Override Map<String, String> getProperties(); @Override String getProperty(String name); @Override void setProperty(String name, String value); ProviderBinder getProviders(); void setProviders(ProviderBinder providers); @Override MultivaluedMap<String, String> getQueryParameters(); @Override MultivaluedMap<String, String> getQueryParameters(boolean decode); Request getRequest(); @Override URI getRequestUri(); @Override UriBuilder getRequestUriBuilder(); SecurityContext getSecurityContext(); UriInfo getUriInfo(); void setDependencySupplier(DependencySupplier dependencySupplier); void setParameterNames(List<String> parameterNames); boolean isAsynchronous(); Application getApplication(); void setApplication(Application application); EverrestConfiguration getEverrestConfiguration(); void setEverrestConfiguration(EverrestConfiguration config); @Override final void start(); @Override final void stop(); static ApplicationContextBuilder anApplicationContext();  }
@Test public void getsMethodInvokerFor_OPTIONS_Request() { when(request.getMethod()).thenReturn("OPTIONS"); MethodInvoker methodInvoker = applicationContext.getMethodInvoker(mock(GenericResourceMethod.class)); assertTrue(String.format("Expected instance of OptionsRequestMethodInvoker but actual is %s", methodInvoker), methodInvoker instanceof OptionsRequestMethodInvoker); }