Repository: deltaspike
Updated Branches:
  refs/heads/master 1c8bd4bdf -> 0ccd9d436


DELTASPIKE-1332 added tests


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/0ccd9d43
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/0ccd9d43
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/0ccd9d43

Branch: refs/heads/master
Commit: 0ccd9d436ae9b5cb3f7c726e035be8ab78c90616
Parents: 1c8bd4b
Author: gpetracek <gpetra...@apache.org>
Authored: Mon Apr 2 23:43:39 2018 +0200
Committer: gpetracek <gpetra...@apache.org>
Committed: Mon Apr 2 23:49:35 2018 +0200

----------------------------------------------------------------------
 .../impl/config/view/custom/uc008/Pages.java    |  56 +++++++++
 .../config/view/custom/uc008/TestMenuEntry.java |  36 ++++++
 .../view/custom/uc008/ViewConfigTest.java       | 114 +++++++++++++++++++
 3 files changed, 206 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0ccd9d43/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/Pages.java
----------------------------------------------------------------------
diff --git 
a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/Pages.java
 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/Pages.java
new file mode 100644
index 0000000..53a08f1
--- /dev/null
+++ 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/Pages.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jsf.impl.config.view.custom.uc008;
+
+import org.apache.deltaspike.core.api.config.view.ViewConfig;
+
+interface Pages extends ViewConfig
+{
+    class Index implements Pages
+    {
+    }
+
+    @TestMenuEntry(pos = 1)
+    interface Section1 extends Pages
+    {
+        @TestMenuEntry(pos = 1)
+        class Content1 implements Section1
+        {
+        }
+
+        @TestMenuEntry(pos =2)
+        class Content2 implements Section1
+        {
+        }
+    }
+
+    @TestMenuEntry(pos = 2)
+    interface Section2 extends Pages
+    {
+        @TestMenuEntry(pos = 1)
+        class Content1 implements Section2
+        {
+        }
+
+        @TestMenuEntry(pos =2)
+        class Content2 implements Section2
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0ccd9d43/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/TestMenuEntry.java
----------------------------------------------------------------------
diff --git 
a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/TestMenuEntry.java
 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/TestMenuEntry.java
new file mode 100644
index 0000000..7fa0d22
--- /dev/null
+++ 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/TestMenuEntry.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jsf.impl.config.view.custom.uc008;
+
+import org.apache.deltaspike.core.api.config.view.metadata.ViewMetaData;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@ViewMetaData
+
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface TestMenuEntry
+{
+    int pos();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/0ccd9d43/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/ViewConfigTest.java
----------------------------------------------------------------------
diff --git 
a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/ViewConfigTest.java
 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/ViewConfigTest.java
new file mode 100644
index 0000000..9b9508e
--- /dev/null
+++ 
b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/custom/uc008/ViewConfigTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jsf.impl.config.view.custom.uc008;
+
+import org.apache.deltaspike.core.api.config.view.ViewConfig;
+import 
org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor;
+import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver;
+import org.apache.deltaspike.core.spi.config.view.ViewConfigNode;
+import org.apache.deltaspike.jsf.impl.config.view.ViewConfigExtension;
+import org.apache.deltaspike.jsf.impl.config.view.ViewConfigResolverProducer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ViewConfigTest
+{
+    private ViewConfigExtension viewConfigExtension;
+
+    private ViewConfigResolverProducer viewConfigResolverProducer;
+
+    @Before
+    public void before()
+    {
+        this.viewConfigExtension = new ViewConfigExtension();
+        this.viewConfigResolverProducer = new 
ViewConfigResolverProducer(this.viewConfigExtension);
+    }
+
+    @After
+    public void after()
+    {
+        this.viewConfigExtension.freeViewConfigCache(null);
+    }
+
+    @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());
+        }
+    }
+
+    @Test
+    public void testViewConfig()
+    {
+        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);
+        }
+
+        ViewConfigResolver viewConfigResolver = 
this.viewConfigResolverProducer.createViewConfigResolver();
+        ViewConfigDescriptor viewConfigDescriptor = 
viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
+
+        
Assert.assertTrue(viewConfigDescriptor.getMetaData(TestMenuEntry.class).isEmpty());
+
+        for (Class<? extends ViewConfig> menuViewConfigClass : 
menuViewConfigClasses)
+        {
+            viewConfigDescriptor = 
viewConfigResolver.getViewConfigDescriptor(menuViewConfigClass);
+
+            Assert.assertEquals(1, 
viewConfigDescriptor.getMetaData(TestMenuEntry.class).size());
+            
Assert.assertTrue(viewConfigDescriptor.getMetaData(TestMenuEntry.class).iterator().next().pos()
 > 0);
+        }
+    }
+}

Reply via email to