Java Code Examples for org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver#getViewConfigDescriptor()
The following examples show how to use
org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver#getViewConfigDescriptor() .
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 | 6 votes |
@Test public void testSimpleViewConfigWithViewControllerCallback() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); this.viewConfigExtension.addIndirectlyInheritedMetaData(PageBean003.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class)); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class)); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class)); Assert.assertNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class)); Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class).getCallbackMethods().keySet().iterator().next()); Assert.assertEquals("callbackMethod1", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName()); Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class).getCallbackMethods().keySet().iterator().next()); Assert.assertEquals("callbackMethod1", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreViewAction.class).getCallbackMethods().values().iterator().next()).iterator().next().getName()); Assert.assertEquals(PageBean003.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().keySet().iterator().next()); Assert.assertEquals("callbackMethod2", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName()); }
Example 2
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testSimpleViewConfigWithOptionalPageMetaData() { this.viewConfigExtension.addPageDefinition(SimplePageConfig001.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig001.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/simplePageConfig001.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(SimplePageConfig001.class, viewConfigDescriptor.getConfigClass()); Assert.assertNotNull(viewConfigDescriptor.getMetaData()); //@View gets added autom. if it isn't provided in-/directly Assert.assertEquals(1, viewConfigDescriptor.getMetaData().size()); Assert.assertEquals(1, viewConfigDescriptor.getMetaData(View.class).size()); }
Example 3
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 6 votes |
@Test public void testNamesWizard4() { this.viewConfigExtension.addPageDefinition(Pages.Wizard4.Step1.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard4.Step2.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard4.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/wizard4/step1.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard4.Step2.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId()); }
Example 4
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testSimpleViewConfigWithViewControllerCallback() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class)); Assert.assertEquals(PageBean002.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class).getCallbackMethods().keySet().iterator().next()); Assert.assertEquals("postRenderViewCallbackMethod", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PostRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName()); }
Example 5
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testNamesWizard9() { this.viewConfigExtension.addPageDefinition(Pages.Wizard9.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard9.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/w9/step1.xhtml", viewConfigDescriptor.getViewId()); }
Example 6
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testNamesWizard8() { this.viewConfigExtension.addPageDefinition(Pages.Wizard8.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard8.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w8/step1.xhtml", viewConfigDescriptor.getViewId()); }
Example 7
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testNamesWizard7() { this.viewConfigExtension.addPageDefinition(Pages.Wizard7.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard7.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/wizard7/step1.xhtml", viewConfigDescriptor.getViewId()); }
Example 8
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testNamesWizard6() { this.viewConfigExtension.addPageDefinition(Pages.Wizard6.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard6.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/wizard6/step1.xhtml", viewConfigDescriptor.getViewId()); }
Example 9
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testNamesWizard5() { this.viewConfigExtension.addPageDefinition(Pages.Wizard5.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard5.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/wizard5/step1.xhtml", viewConfigDescriptor.getViewId()); }
Example 10
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigWithStereotypeMetaData() { this.viewConfigExtension.addPageDefinition(Pages.Home.class); this.viewConfigExtension.addPageDefinition(Pages.Public.Index.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Home.class); Assert.assertNotNull(viewConfigDescriptor); 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.INCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Public.Index.class); Assert.assertNotNull(viewConfigDescriptor); 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()); }
Example 11
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test(expected = IllegalStateException.class) public void testNamesWizard14() { this.viewConfigExtension.addPageDefinition(Pages.Wizard14.Step1.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); viewConfigResolver.getViewConfigDescriptor(Pages.Wizard14.Step1.class); }
Example 12
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testSimpleViewConfigWithViewControllerCallback() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class)); Assert.assertEquals(PageBean001.class, viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().keySet().iterator().next()); Assert.assertEquals("preRenderViewCallbackMethod", ((List<Method>) viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class).getCallbackMethods().values().iterator().next()).iterator().next().getName()); }
Example 13
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testSimpleViewConfigWithCallbacks() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, InitView.class)); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(ViewControllerRef.class, PreRenderView.class)); Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class)); }
Example 14
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 5 votes |
@Test public void testViewConfigWithRandomOrder() { this.viewConfigExtension.addPageDefinition(Pages.Index.class); this.viewConfigExtension.addPageDefinition(Pages.class); //simulates random processing-order ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class); Assert.assertEquals("/pages/index.xhtml", viewConfigDescriptor.getViewId()); Assert.assertEquals(View.ViewParameterMode.EXCLUDE, viewConfigDescriptor.getMetaData(View.class).iterator().next().viewParams()); }
Example 15
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testNamesWizard13() { this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step1.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step2.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step3.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step4.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step5.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step6.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard13.Step7.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w13a/step1.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step2.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step3.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w13a/step3.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step4.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w13a/w13b/step4.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step5.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/w13b/step5.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step6.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w13a/w13b/step6.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard13.Step7.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w13a/w13b/step7.xhtml", viewConfigDescriptor.getViewId()); }
Example 16
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@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()); }
Example 17
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@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 18
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testCallbackExecution() { this.viewConfigExtension.addPageDefinition(SimplePageConfig.class); final SimpleTestAccessDecisionVoter testInstance = new SimpleTestAccessDecisionVoter(); ViewConfigNode node = this.viewConfigExtension.findNode(SimplePageConfig.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[] {SimpleTestAccessDecisionVoter.class}, DefaultCallback.class) { @Override protected Object getTargetObject(Class targetType) { return testInstance; } }); }}); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.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(2, 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"); while (resultIterator.hasNext()) { String currentValue = resultIterator.next(); if (!expectedValues.remove(currentValue)) { Assert.fail("value '" + currentValue + "' not found in the result"); } } Assert.assertTrue(expectedValues.isEmpty()); }
Example 19
Source File: ViewConfigPathTest.java From deltaspike with Apache License 2.0 | 4 votes |
@Test public void testNamesWizard11() { this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step1.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step2.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step3.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step4.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step5.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step6.class); this.viewConfigExtension.addPageDefinition(Pages.Wizard11.Step7.class); ViewConfigResolver viewConfigResolver = this.viewConfigResolverProducer.createViewConfigResolver(); ViewConfigDescriptor viewConfigDescriptor; viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step1.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w11/step1.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step2.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/step2.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step3.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w11/step3.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step4.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w11/w11b/step4.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step5.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/w11b/step5.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step6.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w11/w11b/step6.xhtml", viewConfigDescriptor.getViewId()); viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Wizard11.Step7.class); Assert.assertNotNull(viewConfigDescriptor); Assert.assertEquals("/pages/w11/w11b/step7.xhtml", viewConfigDescriptor.getViewId()); }
Example 20
Source File: ViewConfigTest.java From deltaspike with Apache License 2.0 | 4 votes |
@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()); }