@SuppressWarnings("unchecked")
 @Test
 public void testBuildModules() {
   builder.setModulesProviderClass(MockModulesProvidingContainerAdaptorFactory.class);
   builder.setInvocationFactoryClass(invocationFactory.getClass());
   builder.setInvocationInstanceProviderClass(
       (Class<? extends ContainerAdaptorFactory<? extends ContainerAdaptor>>)
           containerAdaptorFactory.getClass());
   builder.setInvokerFactoryClass(invokerFactory.getClass());
   builder.setResponseHandlerClass(directiontHandler.getClass());
   builder.setRenderableResolverClass(directionResolver.getClass());
   builder.addApplicationProcessorClass(invocationProcessor.getClass());
   builder.addInvocationInterceptorClass(invocationInterceptor.getClass());
   builder.addInvocationMetadataFactoriesClass(invocationMetadataFactory.getClass());
   builder.addAttributesHandlerClass(attributesHandler.getClass());
   builder.setExceptionHandlerClass(exceptionHandler.getClass());
   builder.setTypeMapperContextClass(typeMapperContext.getClass());
   Renderable mapToResponse = mock(Renderable.class);
   builder.addResponseFormatterClass(mapToResponse.getClass(), directionFormatter.getClass());
   Modules modules = builder.buildModules(resolver, adaptor);
   assertSame(modules.getInvocationMetadataFactories().get(0), invocationMetadataFactory);
   assertSame(modules.getInvocationInstanceProvider(), containerAdaptor);
   // same instance.
   assertSame(modules.getInvocationInstanceProvider(), containerAdaptor);
   assertSame(modules.getInvocationFactory(), invocationFactory);
   assertSame(modules.getResponseResolver(), directionResolver);
   assertSame(modules.getResponseHandler(), directiontHandler);
   assertSame(modules.getApplicationProcessors().get(0), invocationProcessor);
   assertSame(modules.getInvocationInterceptors().get(0), invocationInterceptor);
   assertSame(modules.getExceptionHandler(), exceptionHandler);
   assertSame(modules.getTypeMapperContext(), typeMapperContext);
   assertSame(modules.findResponseFormatter(mapToResponse.getClass()), directionFormatter);
 }
 @Test
 public void testClearMultipleModules() {
   builder.addInvocationMetadataFactoriesClass(invocationMetadataFactory.getClass());
   builder.addApplicationProcessorClass(invocationProcessor.getClass());
   builder.addAttributesHandlerClass(attributesHandler.getClass());
   assertThat(builder.getInvocationMetadataFactoryClasses().size(), is(1));
   assertThat(builder.getApplicationProcessorClasses().size(), is(1));
   assertThat(builder.getAttributesHandlerClasses().size(), is(1));
   assertSame(builder, builder.clearInvocationMetadataFactoriesClass());
   assertTrue(builder.getInvocationMetadataFactoryClasses().isEmpty());
   assertSame(builder, builder.clearApplicationProcessorClass());
   assertTrue(builder.getApplicationProcessorClasses().isEmpty());
   assertSame(builder, builder.clearAttributesHanderClass());
   assertTrue(builder.getAttributesHandlerClasses().isEmpty());
 }