Search in sources :

Example 26 with ViewConfigResolver

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

the class ViewConfigTest method testMetaDataInheritanceInViewConfig.

@Test
public void testMetaDataInheritanceInViewConfig() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Home.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Statistics.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Statistics.Home.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(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals(View.Extension.XHTML, configDescriptor.getMetaData(View.class).iterator().next().extension());
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).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(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    Assert.assertEquals(1, configDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    // the following is correct because it's @View at the folder level:
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("/pages/", configDescriptor.getMetaData(View.class).iterator().next().basePath());
    Assert.assertEquals("xhtml", configDescriptor.getMetaData(View.class).iterator().next().extension());
    configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.Statistics.class);
    Assert.assertNotNull(configDescriptor);
    Assert.assertNotNull(configDescriptor.getConfigClass());
    Assert.assertEquals(Pages.Admin.Statistics.class, configDescriptor.getConfigClass());
    Assert.assertNotNull(configDescriptor.getMetaData());
    Assert.assertEquals(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/admin/statistics/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    // TODO update uc004 with these lines
    Assert.assertEquals(1, configDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    // the following is correct because it's @View at the folder level:
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(View.class).iterator().next().basePath());
    Assert.assertEquals("xhtml", configDescriptor.getMetaData(View.class).iterator().next().extension());
    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(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Statistics.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/statistics/index.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Statistics.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Statistics.Home.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/statistics/home.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Statistics.Home.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    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.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Home.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/home.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Home.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
}
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 27 with ViewConfigResolver

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

the class ViewConfigTest method testMetaDataInheritanceInViewConfig.

@Test
public void testMetaDataInheritanceInViewConfig() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Home.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Statistics.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Statistics.Home.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(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals(View.Extension.JSF, configDescriptor.getMetaData(View.class).iterator().next().extension());
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).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(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    Assert.assertEquals(1, configDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.EXCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    // the following is correct because it's @View at the folder level:
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("/pages/", configDescriptor.getMetaData(View.class).iterator().next().basePath());
    Assert.assertEquals("jsf", configDescriptor.getMetaData(View.class).iterator().next().extension());
    configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Admin.Statistics.class);
    Assert.assertNotNull(configDescriptor);
    Assert.assertNotNull(configDescriptor.getConfigClass());
    Assert.assertEquals(Pages.Admin.Statistics.class, configDescriptor.getConfigClass());
    Assert.assertNotNull(configDescriptor.getMetaData());
    Assert.assertEquals(2, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/admin/statistics/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    Assert.assertEquals(1, configDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, configDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, configDescriptor.getMetaData(View.class).iterator().next().viewParams());
    // the following is correct because it's @View at the folder level:
    Assert.assertEquals("", configDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(View.class).iterator().next().basePath());
    Assert.assertEquals("faces", configDescriptor.getMetaData(View.class).iterator().next().extension());
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/index.jsf", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("jsf", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Statistics.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/statistics/index.faces", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Statistics.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).iterator().next().navigation());
    Assert.assertEquals(View.ViewParameterMode.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams());
    Assert.assertEquals("index", viewConfigDescriptor.getMetaData(View.class).iterator().next().name());
    Assert.assertEquals("faces", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Statistics.Home.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/statistics/home.jsf", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Statistics.Home.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("jsf", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    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.REDIRECT, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Home.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/admin/home.jsf", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Admin.Home.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).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("jsf", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
}
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 28 with ViewConfigResolver

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

the class ViewConfigTest method testViewConfig.

@Test
public void testViewConfig() {
    List<Class<? extends ViewConfig>> menuViewConfigClasses = new ArrayList<>();
    menuViewConfigClasses.add(Pages.Section1.Content1.class);
    menuViewConfigClasses.add(Pages.Section1.Content2.class);
    menuViewConfigClasses.add(Pages.Section2.Content1.class);
    menuViewConfigClasses.add(Pages.Section2.Content2.class);
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    for (Class<? extends ViewConfig> menuViewConfigClass : menuViewConfigClasses) {
        this.viewConfigExtension.addPageDefinition(menuViewConfigClass);
    }
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
    Assert.assertTrue(viewConfigDescriptor.getMetaData(TestMenuEntry.class).isEmpty());
    for (Class<? extends ViewConfig> menuViewConfigClass : menuViewConfigClasses) {
        viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(menuViewConfigClass);
        Assert.assertEquals(1, viewConfigDescriptor.getMetaData(TestMenuEntry.class).size());
        Assert.assertTrue(viewConfigDescriptor.getMetaData(TestMenuEntry.class).iterator().next().pos() > 0);
    }
}
Also used : ArrayList(java.util.ArrayList) ViewConfig(org.apache.deltaspike.core.api.config.view.ViewConfig) 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 29 with ViewConfigResolver

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

the class ViewConfigTest method testMetaDataInheritanceInViewConfig.

@Test
public void testMetaDataInheritanceInViewConfig() {
    this.viewConfigExtension.addPageDefinition(Pages.class);
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Public.class);
    this.viewConfigExtension.addPageDefinition(Pages.Public.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(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/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, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    Assert.assertEquals("/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
    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(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Admin.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/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, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    Assert.assertEquals("/admin/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
    configDescriptor = viewConfigResolver.getConfigDescriptor(Pages.Public.class);
    Assert.assertNotNull(configDescriptor);
    Assert.assertNotNull(configDescriptor.getConfigClass());
    Assert.assertEquals(Pages.Public.class, configDescriptor.getConfigClass());
    Assert.assertNotNull(configDescriptor.getMetaData());
    Assert.assertEquals(1, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/public/", configDescriptor.getMetaData(Folder.class).iterator().next().name());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/public/index.xhtml", viewConfigDescriptor.getViewId());
    Assert.assertEquals(Pages.Public.Index.class, viewConfigDescriptor.getConfigClass());
    Assert.assertNotNull(viewConfigDescriptor.getMetaData());
    Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.FORWARD, viewConfigDescriptor.getMetaData(View.class).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("xhtml", viewConfigDescriptor.getMetaData(View.class).iterator().next().extension());
    Assert.assertEquals("/public/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
}
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 30 with ViewConfigResolver

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

the class ViewConfigPathTest method testNamesWizard1.

@Test
public void testNamesWizard1() {
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step1.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step2.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step3.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step4.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step5.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step6.class);
    this.viewConfigExtension.addPageDefinition(Pages.Wizard1.Step7.class);
    ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
    ViewConfigDescriptor viewConfigDescriptor;
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step1.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard1/step1.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step2.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step3.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard1/step3.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step4.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard1/w1/step4.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step5.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/w1/step5.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step6.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard1/w1b/step6.xhtml", viewConfigDescriptor.getViewId());
    viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard1.Step7.class);
    Assert.assertNotNull(viewConfigDescriptor);
    Assert.assertEquals("/pages/wizard1/w1b/step7.xhtml", viewConfigDescriptor.getViewId());
}
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)

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