@Test public void responseBodyResultHandler() throws Exception { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.responseBodyResultHandler(); verify(webFluxConfigurer).configureHttpMessageCodecs(codecsConfigurer.capture()); verify(webFluxConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class)); }
@Test public void viewResolutionResultHandler() throws Exception { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.viewResolutionResultHandler(); verify(webFluxConfigurer).configureViewResolvers(any(ViewResolverRegistry.class)); }
@Before public void setup() { MockitoAnnotations.initMocks(this); delegatingConfig = new DelegatingWebFluxConfiguration(); delegatingConfig.setApplicationContext(new StaticApplicationContext()); given(webFluxConfigurer.getValidator()).willReturn(null); given(webFluxConfigurer.getMessageCodesResolver()).willReturn(null); }
@Test public void resourceHandlerMapping() throws Exception { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); doAnswer(invocation -> { ResourceHandlerRegistry registry = invocation.getArgument(0); registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static"); return null; }).when(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class)); delegatingConfig.resourceHandlerMapping(); verify(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class)); verify(webFluxConfigurer).configurePathMatching(any(PathMatchConfigurer.class)); }
@Test public void requestMappingHandlerMapping() throws Exception { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); delegatingConfig.requestMappingHandlerMapping(); verify(webFluxConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class)); verify(webFluxConfigurer).addCorsMappings(any(CorsRegistry.class)); verify(webFluxConfigurer).configurePathMatching(any(PathMatchConfigurer.class)); }
@Test public void requestMappingHandlerAdapter() throws Exception { delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer)); ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) this.delegatingConfig.requestMappingHandlerAdapter().getWebBindingInitializer(); verify(webFluxConfigurer).configureHttpMessageCodecs(codecsConfigurer.capture()); verify(webFluxConfigurer).getValidator(); verify(webFluxConfigurer).getMessageCodesResolver(); verify(webFluxConfigurer).addFormatters(formatterRegistry.capture()); verify(webFluxConfigurer).configureArgumentResolvers(any()); assertNotNull(initializer); assertTrue(initializer.getValidator() instanceof LocalValidatorFactoryBean); assertSame(formatterRegistry.getValue(), initializer.getConversionService()); assertEquals(13, codecsConfigurer.getValue().getReaders().size()); }