use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testMetaDataTreeWithRandomOrder.
@Test
public void testMetaDataTreeWithRandomOrder() {
this.viewConfigExtension.addPageDefinition(Pages.Index.class);
// simulates random processing-order
this.viewConfigExtension.addPageDefinition(Pages.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.getMetaData());
Assert.assertEquals(0, node.getMetaData().size());
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testCallbackExecutionPage.
@Test
public void testCallbackExecutionPage() {
this.viewConfigExtension.addPageDefinition(Pages.class);
this.viewConfigExtension.addPageDefinition(Pages.Secure.class);
this.viewConfigExtension.addPageDefinition(Pages.Secure.Settings.class);
final SimpleTestAccessDecisionVoter2 testInstance2 = new SimpleTestAccessDecisionVoter2();
ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Secure.Settings.class);
// add it to avoid in-container test for this simple constellation - usually not needed!
node.getCallbackDescriptors().put(TestSecured.class, new ArrayList<CallbackDescriptor>() {
{
add(new TestSecured.Descriptor(new Class[] { SimpleTestAccessDecisionVoter2.class }, DefaultCallback.class) {
@Override
protected Object getTargetObject(Class targetType) {
return testInstance2;
}
});
}
});
ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver();
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Secure.Settings.class);
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class));
List<Set<String>> /*return type of one callback*/
callbackResult = viewConfigDescriptor.getExecutableCallbackDescriptor(TestSecured.class, TestSecured.Descriptor.class).execute("param1", "param2");
Assert.assertNotNull(callbackResult);
Assert.assertEquals(1, callbackResult.size());
Assert.assertEquals(3, callbackResult.iterator().next().size());
Iterator<String> resultIterator = callbackResult.iterator().next().iterator();
// the order in the result isn't guaranteed
Set<String> expectedValues = new HashSet<String>();
expectedValues.add("param1");
expectedValues.add("param2");
expectedValues.add(SimpleTestAccessDecisionVoter2.class.getName());
while (resultIterator.hasNext()) {
String currentValue = resultIterator.next();
if (!expectedValues.remove(currentValue)) {
Assert.fail("value '" + currentValue + "' not found in the result");
}
}
Assert.assertTrue(expectedValues.isEmpty());
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testMetaDataTree.
@Test
public void testMetaDataTree() {
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);
}
ViewConfigNode node = this.viewConfigExtension.findNode(Pages.Index.class);
Assert.assertNotNull(node.getMetaData());
Assert.assertEquals(0, node.getMetaData().size());
for (Class<? extends ViewConfig> menuViewConfigClass : menuViewConfigClasses) {
node = this.viewConfigExtension.findNode(menuViewConfigClass);
Assert.assertNotNull(node.getMetaData());
Assert.assertEquals(1, node.getMetaData().size());
Assert.assertEquals(TestMenuEntry.class, node.getMetaData().iterator().next().annotationType());
}
}
use of org.apache.deltaspike.core.spi.config.view.ViewConfigNode in project deltaspike by apache.
the class ViewConfigTest method testFolderOnlyMetaData.
@Test
public void testFolderOnlyMetaData() {
this.viewConfigExtension.addPageDefinition(Pages.AdminArea.class);
this.viewConfigExtension.addFolderDefinition(Pages.VipArea.class);
ViewConfigNode node = this.viewConfigExtension.findNode(Pages.AdminArea.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.VipArea.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(Folder.class, node.getMetaData().iterator().next().annotationType());
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 testMetaDataTree.
private void testMetaDataTree() {
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(0, node.getMetaData().size());
Assert.assertNotNull(node.getInheritedMetaData());
Assert.assertEquals(1, node.getInheritedMetaData().size());
Assert.assertNotNull(node.getCallbackDescriptors());
Assert.assertEquals(0, node.getCallbackDescriptors().size());
}
Aggregations