Java Code Examples for org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver#getConfigDescriptor()

The following examples show how to use org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver#getConfigDescriptor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@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());

}
 
Example 2
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@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());
}
 
Example 3
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Test
public void testMetaDataInheritanceInViewConfig()
{
    this.viewConfigExtension.addPageDefinition(Pages.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());
}
 
Example 4
Source File: ViewConfigTest.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Test
public void testMetaDataInheritanceInViewConfig()
{
    this.viewConfigExtension.addPageDefinition(Pages.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.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(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/", configDescriptor.getMetaData(Folder.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(1, configDescriptor.getMetaData().size());
    Assert.assertEquals(1, configDescriptor.getMetaData(Folder.class).size());
    Assert.assertEquals("/pages/admin/", configDescriptor.getMetaData(Folder.class).iterator().next().name());


    ViewConfigDescriptor 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, 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("/pages/admin/", viewConfigDescriptor.getMetaData(View.class).iterator().next().basePath());
}