JsfBeansAutoConfiguration { @Bean("viewScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) @ConditionalOnMissingBean(name = "viewScope") public Map<String, Object> viewMap() { return FacesContext.getCurrentInstance().getViewRoot().getViewMap(); }  @Bean("application") @ConditionalOnMissingBean(name = "application") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) Object application(); @Bean("applicationScope") @ConditionalOnMissingBean(name = "applicationScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, Object> applicationMap(); @Bean("cookie") @ConditionalOnMissingBean(name = "cookie") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, Object> requestCookieMap(); @Bean("facesContext") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean FacesContext facesContext(); @Bean("flash") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean Flash flash(); @Bean("flowScope") @ConditionalOnMissingBean(name = "flowScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<Object, Object> flowScope(); @Bean("header") @ConditionalOnMissingBean(name = "header") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, String> headerMap(); @Bean("headerValues") @ConditionalOnMissingBean(name = "headerValues") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, String[]> headerValuesMap(); @Bean("initParam") @ConditionalOnMissingBean(name = "initParam") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) @SuppressWarnings("unchecked") Map<String, String> initParameterMap(); @Bean("param") @ConditionalOnMissingBean(name = "param") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, String> requestParameterMap(); @Bean("paramValues") @ConditionalOnMissingBean(name = "paramValues") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, String[]> requestParameterValuesMap(); @Bean("request") @ConditionalOnMissingBean @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) Object request(); @Bean("requestScope") @ConditionalOnMissingBean(name = "requestScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, Object> requestMap(); @Bean("resource") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean ResourceHandler resourceHandler(); @Bean("session") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean Object session(); @Bean("sessionScope") @ConditionalOnMissingBean(name = "sessionScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) Map<String, Object> sessionMap(); @Bean("view") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean UIViewRoot viewRoot(); @Bean("viewScope") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.INTERFACES) @ConditionalOnMissingBean(name = "viewScope") Map<String, Object> viewMap(); @Bean("externalContext") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean ExternalContext externalContext();  }
@Test public void testViewMap() { UIViewRoot viewRoot = mock(UIViewRoot.class); when(this.facesContext.getViewRoot()).thenReturn(viewRoot); assertThat(this.jsfBeansAutoConfiguration.viewRoot()).isEqualTo(viewRoot); Map<String, Object> map = Collections.emptyMap(); when(viewRoot.getViewMap()).thenReturn(map); assertThat(this.jsfBeansAutoConfiguration.viewMap()).isSameAs(map); }