use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testMetaDataTreeWithStereotypeMetaData.
@Test
public void testMetaDataTreeWithStereotypeMetaData() {
this.viewConfigExtension.addPageDefinition(Pages.Home.class);
this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class);
ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Home.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(2, node.getMetaData().size());
Assert.assertEquals(2, node.getMetaData().size());
boolean facesRedirectAnnotationFound = false;
boolean viewAnnotationFound = false;
for (Annotation metaData : node.getMetaData()) {
if (MyView.class.isAssignableFrom(metaData.annotationType())) {
facesRedirectAnnotationFound = true;
} else if (View.class.isAssignableFrom(metaData.annotationType())) {
viewAnnotationFound = true;
}
}
Assert.assertTrue(facesRedirectAnnotationFound);
Assert.assertTrue(viewAnnotationFound);
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
Assert.assertNotNull(node.getCallbackDescriptors());
Assert.assertEquals(0, node.getCallbackDescriptors().size());
node = this.viewConfigExtension.findNode(Pages.Public.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(1, node.getChildren().size());
Assert.assertNotNull(node.getMetaData());
Assert.assertEquals(1, node.getMetaData().size());
Assert.assertEquals(MyView.class, node.getMetaData().iterator().next().annotationType());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
Assert.assertNotNull(node.getCallbackDescriptors());
Assert.assertEquals(0, node.getCallbackDescriptors().size());
node = this.viewConfigExtension.findNode(Pages.Public.Index.class);
Assert.assertNotNull(node);
Assert.assertNotNull(node.getParent());
Assert.assertNotNull(node.getParent().getParent());
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(0, node.getMetaData().size());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
Assert.assertNotNull(node.getCallbackDescriptors());
Assert.assertEquals(0, node.getCallbackDescriptors().size());
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testNestedMetaDataTree.
@Test
public void testNestedMetaDataTree() {
this.viewConfigExtension.addPageDefinition(Pages.Index.class);
this.viewConfigExtension.addPageDefinition(Pages.Home.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(3, 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.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.Home.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(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());
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(0, node.getMetaData().size());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testMetaDataInheritanceInTree.
@Test
public // TODO discuss if #getInheritedMetaData should be tested as well by exposing the transformed tree for tests
void testMetaDataInheritanceInTree() {
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);
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(2, 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(3, node.getChildren().size());
Assert.assertNotNull(node.getMetaData());
Assert.assertEquals(1, node.getMetaData().size());
Assert.assertEquals(View.NavigationMode.REDIRECT, ((View) node.getMetaData().iterator().next()).navigation());
Assert.assertEquals(View.ViewParameterMode.INCLUDE, ((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());
node = this.viewConfigExtension.findNode(Pages.Admin.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(3, node.getChildren().size());
Assert.assertNotNull(node.getMetaData());
Assert.assertEquals(1, node.getMetaData().size());
Assert.assertEquals(View.class, node.getMetaData().iterator().next().annotationType());
Assert.assertEquals(View.NavigationMode.REDIRECT, ((View) node.getMetaData().iterator().next()).navigation());
Assert.assertEquals(View.ViewParameterMode.INCLUDE, ((View) node.getMetaData().iterator().next()).viewParams());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
node = this.viewConfigExtension.findNode(Pages.Admin.Statistics.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(2, 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.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(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("home", ((View) node.getMetaData().iterator().next()).name());
Assert.assertEquals("jsp", ((View) node.getMetaData().iterator().next()).extension());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(0, node.getInheritedMetaData().size());
node = this.viewConfigExtension.findNode(Pages.Admin.Statistics.Index.class);
Assert.assertNotNull(node);
// Statistics
Assert.assertNotNull(node.getParent());
// Admin
Assert.assertNotNull(node.getParent().getParent());
// Pages
Assert.assertNotNull(node.getParent().getParent().getParent());
// Root
Assert.assertNotNull(node.getParent().getParent().getParent().getParent());
Assert.assertNull(node.getParent().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());
node = this.viewConfigExtension.findNode(Pages.Admin.Statistics.Home.class);
Assert.assertNotNull(node);
// Statistics
Assert.assertNotNull(node.getParent());
// Admin
Assert.assertNotNull(node.getParent().getParent());
// Pages
Assert.assertNotNull(node.getParent().getParent().getParent());
// Root
Assert.assertNotNull(node.getParent().getParent().getParent().getParent());
Assert.assertNull(node.getParent().getParent().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());
// not processed at this point - node was just added
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(0, node.getMetaData().size());
Assert.assertNotNull(node.getInheritedMetaData());
// not processed at this point - node was just added
Assert.assertEquals(0, node.getInheritedMetaData().size());
node = this.viewConfigExtension.findNode(Pages.Admin.Home.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.FORWARD, ((View) node.getMetaData().iterator().next()).navigation());
Assert.assertEquals(View.ViewParameterMode.DEFAULT, ((View) node.getMetaData().iterator().next()).viewParams());
Assert.assertNotNull(node.getInheritedMetaData());
// not processed at this point - node was just added
Assert.assertEquals(0, node.getInheritedMetaData().size());
}
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.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);
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(1, 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());
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigExtension method findNode.
public ViewConfigNode findNode(Class nodeClass) {
if (nodeClass == null) {
return null;
}
List<Class> path = ViewConfigUtils.toNodeList(nodeClass);
ViewConfigNode currentNode = this.rootViewConfigNode;
next: for (int i = 0; i < path.size(); i++) {
Class nodeId = path.get(i);
for (ViewConfigNode node : currentNode.getChildren()) {
if (node.getSource().equals(nodeId)) {
currentNode = node;
if (i == (path.size() - 1)) {
return currentNode;
}
continue next;
}
}
return null;
}
return null;
}
Aggregations