Search in sources :

Example 6 with ViewConfigNode

use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.

the class ViewConfigTest method testMetaDataInheritanceInTree.

@Test
public void testMetaDataInheritanceInTree() {
    this.viewConfigExtension.addPageDefinition(Pages.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.class);
    this.viewConfigExtension.addPageDefinition(Pages.Admin.Index.class);
    ViewConfigNode node = this.viewConfigExtension.findNode(Pages.class);
    Assert.assertNotNull(node);
    // Root
    Assert.assertNotNull(node.getParent());
    Assert.assertNull(node.getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(1, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(".", ((Folder) node.getMetaData().iterator().next()).name());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Admin.class);
    Assert.assertNotNull(node);
    // Admin
    Assert.assertNotNull(node.getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(1, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(Folder.class, node.getMetaData().iterator().next().annotationType());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Admin.Index.class);
    Assert.assertNotNull(node);
    // Admin
    Assert.assertNotNull(node.getParent());
    // Pages
    Assert.assertNotNull(node.getParent().getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.DEFAULT, ((View) node.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams());
    Assert.assertEquals("", ((View) node.getMetaData().iterator().next()).name());
    Assert.assertEquals(View.Extension.DEFAULT, ((View) node.getMetaData().iterator().next()).extension());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
}
Also used : ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) Test(org.junit.Test)

Example 7 with ViewConfigNode

use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.

the class ViewConfigTest method testDuplicatedDefaultErrorViewInMetaDataTree.

@Test
public void testDuplicatedDefaultErrorViewInMetaDataTree() {
    this.viewConfigExtension.addPageDefinition(Pages.Index.class);
    this.viewConfigExtension.addPageDefinition(Pages.Overview.class);
    ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Index.class);
    Assert.assertNotNull(node);
    Assert.assertNotNull(node.getParent());
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(0, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Overview.class);
    Assert.assertNotNull(node);
    Assert.assertNotNull(node.getParent());
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(0, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
}
Also used : ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) Test(org.junit.Test)

Example 8 with ViewConfigNode

use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.

the class ViewConfigTest method testMetaDataInheritanceInTree.

@Test
public void testMetaDataInheritanceInTree() {
    this.viewConfigExtension.addPageDefinition(Pages.class);
    ViewConfigNode node = this.viewConfigExtension.findNode(Pages.class);
    Assert.assertNotNull(node);
    // Root
    Assert.assertNotNull(node.getParent());
    Assert.assertNull(node.getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(3, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(3, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Index.class);
    Assert.assertNotNull(node);
    // Pages
    Assert.assertNotNull(node.getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(0, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Admin.class);
    Assert.assertNotNull(node);
    // Admin
    Assert.assertNotNull(node.getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(1, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(0, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Admin.Index.class);
    Assert.assertNotNull(node);
    // Admin
    Assert.assertNotNull(node.getParent());
    // Pages
    Assert.assertNotNull(node.getParent().getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.DEFAULT, ((View) node.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams());
    Assert.assertEquals("", ((View) node.getMetaData().iterator().next()).name());
    Assert.assertEquals(View.Extension.DEFAULT, ((View) node.getMetaData().iterator().next()).extension());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Public.class);
    Assert.assertNotNull(node);
    // Public
    Assert.assertNotNull(node.getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(1, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(Folder.class, node.getMetaData().iterator().next().annotationType());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(Pages.Public.Index.class);
    Assert.assertNotNull(node);
    // Public
    Assert.assertNotNull(node.getParent());
    // Pages
    Assert.assertNotNull(node.getParent().getParent());
    // Root
    Assert.assertNotNull(node.getParent().getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(View.NavigationMode.DEFAULT, ((View) node.getMetaData().iterator().next()).navigation());
    Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams());
    Assert.assertEquals("", ((View) node.getMetaData().iterator().next()).name());
    Assert.assertEquals(View.Extension.DEFAULT, ((View) node.getMetaData().iterator().next()).extension());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
}
Also used : ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) Test(org.junit.Test)

Example 9 with ViewConfigNode

use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.

the class ViewConfigTest method testDuplicatedNavigationTargetsInMetaDataTree.

@Test
public void testDuplicatedNavigationTargetsInMetaDataTree() {
    this.viewConfigExtension.addPageDefinition(PagesViolation.Index.class);
    this.viewConfigExtension.addPageDefinition(PagesViolation.Overview.class);
    ViewConfigNode node = this.viewConfigExtension.findNode(PagesViolation.Index.class);
    Assert.assertNotNull(node);
    Assert.assertNotNull(node.getParent());
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(0, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    node = this.viewConfigExtension.findNode(PagesViolation.Overview.class);
    Assert.assertNotNull(node);
    Assert.assertNotNull(node.getParent());
    Assert.assertNotNull(node.getParent().getParent());
    Assert.assertNull(node.getParent().getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertEquals(View.class, node.getMetaData().iterator().next().annotationType());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
}
Also used : ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) Test(org.junit.Test)

Example 10 with ViewConfigNode

use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.

the class ViewConfigTest method testSimpleMetaDataTreeWithViewControllerCallback.

@Test
public void testSimpleMetaDataTreeWithViewControllerCallback() {
    this.viewConfigExtension.addPageDefinition(SimplePageConfig.class);
    ViewConfigNode node = this.viewConfigExtension.findNode(SimplePageConfig.class);
    Assert.assertNotNull(node);
    Assert.assertNotNull(node.getParent());
    Assert.assertNull(node.getParent().getParent());
    Assert.assertNotNull(node.getChildren());
    Assert.assertEquals(0, node.getChildren().size());
    Assert.assertNotNull(node.getMetaData());
    Assert.assertEquals(1, node.getMetaData().size());
    Assert.assertNotNull(node.getInheritedMetaData());
    Assert.assertEquals(0, node.getInheritedMetaData().size());
    Assert.assertNotNull(node.getCallbackDescriptors());
    // TODO related to the discussion about #getInheritedMetaData (see TODOs in other use-cases)
    Assert.assertEquals(0, node.getCallbackDescriptors().size());
}
Also used : ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) Test(org.junit.Test)

Aggregations

ViewConfigNode (org.apache.deltaspike.core.spi.config.view.ViewConfigNode)31 Test (org.junit.Test)24 Annotation (java.lang.annotation.Annotation)7 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Set (java.util.Set)3 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)2 ViewConfig (org.apache.deltaspike.core.api.config.view.ViewConfig)2 View (org.apache.deltaspike.jsf.api.config.view.View)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 CallbackDescriptor (org.apache.deltaspike.core.api.config.view.metadata.CallbackDescriptor)1 InlineViewMetaData (org.apache.deltaspike.core.api.config.view.metadata.InlineViewMetaData)1 ViewConfigDescriptor (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor)1 ViewConfigResolver (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver)1 InlineMetaDataTransformer (org.apache.deltaspike.core.spi.config.view.InlineMetaDataTransformer)1 TargetViewConfigProvider (org.apache.deltaspike.core.spi.config.view.TargetViewConfigProvider)1