Search in sources :

Example 21 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigPathValidatorTest method testMissingPath.

@Test(expected = IllegalStateException.class)
public void testMissingPath() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    List<String> supportedExtensions = new ArrayList<String>();
    supportedExtensions.add(View.Extension.XHTML);
    new MockedViewConfigPathValidator(false).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
}
Also used : ArrayList(java.util.ArrayList) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 22 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigPathValidatorTest method testValidViewConfig.

@Test
public void testValidViewConfig() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    List<String> supportedExtensions = new ArrayList<String>();
    supportedExtensions.add(View.Extension.XHTML);
    try {
        new MockedViewConfigPathValidator(true).validateViewConfigPaths(null, viewConfigResolver, supportedExtensions);
    } catch (Exception e) {
        Assert.fail("valid view-config was reported as invalid");
    }
}
Also used : ArrayList(java.util.ArrayList) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 23 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigTest method testSimpleViewConfigWithOptionalPageMetaData.

@Test
public void testSimpleViewConfigWithOptionalPageMetaData() {
    this.viewConfigExtension.addPageDefinition(SimplePageConfig001.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig001.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/simplePageConfig001.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(SimplePageConfig001.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    // @View gets added autom. if it isn't provided in-/directly
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
}
Also used : ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 24 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigTest method testSimpleViewConfigWithExplicitPageMetaData.

@Test
public void testSimpleViewConfigWithExplicitPageMetaData() {
    this.viewConfigExtension.addPageDefinition(SimplePageConfig002.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig002.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/simplePageConfig002.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(SimplePageConfig002.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
}
Also used : ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Example 25 with ViewConfigResolver

use of org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver in project deltaspike by apache.

the class ViewConfigTest method testNestedViewConfig.

@Test
public void testNestedViewConfig() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Home.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ConfigDescriptor configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.class);
    Assert.assertNotNull(configDescriptor);
    Assert.assertNotNull(configDescriptor.getConfigClass());
    Assert.assertEquals(Pages.class, configDescriptor.getConfigClass());
    Assert.assertNotNull(configDescriptor.getMetaData());
    Assert.assertEquals(1, configDescriptor.getMetaData().size());
    Assert.assertEquals("/pages/", ((Folder) configDescriptor.getMetaData().iterator().next()).name());
    configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.class);
    Assert.assertNotNull(configDescriptor);
    Assert.assertNotNull(configDescriptor.getConfigClass());
    Assert.assertEquals(Pages.Admin.class, configDescriptor.getConfigClass());
    Assert.assertNotNull(configDescriptor.getMetaData());
    Assert.assertEquals(1, configDescriptor.getMetaData().size());
    Assert.assertEquals("/pages/admin/", ((Folder) configDescriptor.getMetaData().iterator().next()).name());
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/index.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, ((View) viewConfigDescriptor.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).viewParams());
    Assert.assertEquals("index", (viewConfigDescriptor.getMetaData(View.class).iterator().next()).name());
    Assert.assertEquals(View.Extension.XHTML, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/home.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Home.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, ((View) viewConfigDescriptor.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).viewParams());
    Assert.assertEquals("home", (viewConfigDescriptor.getMetaData(View.class).iterator().next()).name());
    Assert.assertEquals(View.Extension.XHTML, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).extension());
    ConfigDescriptor folderDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.class);
    Assert.assertNotNull(folderDescriptor);
    Assert.assertEquals("/pages/admin/", folderDescriptor.getPath());
    Assert.assertEquals(Pages.Admin.class, folderDescriptor.getConfigClass());
    Assert.assertNotNull(folderDescriptor.getMetaData());
    Assert.assertEquals(1, folderDescriptor.getMetaData().size());
    Assert.assertEquals("/pages/admin/", ((Folder) folderDescriptor.getMetaData().iterator().next()).name());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/index.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, ((View) viewConfigDescriptor.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).viewParams());
    Assert.assertEquals("index", (viewConfigDescriptor.getMetaData(View.class).iterator().next()).name());
    Assert.assertEquals(View.Extension.XHTML, (viewConfigDescriptor.getMetaData(View.class).iterator().next()).extension());
}
Also used : ConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ConfigDescriptor) ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) ViewConfigDescriptor(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor) View(org.apache.deltaspike.jsf.api.config.view.View) ViewConfigResolver(org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver) Test(org.junit.Test)

Aggregations

ViewConfigResolver (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver)44 Test (org.junit.Test)37 ViewConfigDescriptor (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor)36 ArrayList (java.util.ArrayList)5 Method (java.lang.reflect.Method)3 ViewControllerRef (org.apache.deltaspike.core.api.config.view.controller.ViewControllerRef)3 View (org.apache.deltaspike.jsf.api.config.view.View)3 DefaultErrorView (org.apache.deltaspike.core.api.config.view.DefaultErrorView)2 ViewConfig (org.apache.deltaspike.core.api.config.view.ViewConfig)2 PreRenderView (org.apache.deltaspike.core.api.config.view.controller.PreRenderView)2 JsfModuleConfig (org.apache.deltaspike.jsf.api.config.JsfModuleConfig)2 ErrorViewAwareAccessDeniedException (org.apache.deltaspike.security.api.authorization.ErrorViewAwareAccessDeniedException)2 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 ConfigurableNavigationHandler (javax.faces.application.ConfigurableNavigationHandler)1 NavigationCase (javax.faces.application.NavigationCase)1 ProjectStage (javax.faces.application.ProjectStage)1