summaryrefslogtreecommitdiffstats
path: root/infra/test-utils/test-tools/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'infra/test-utils/test-tools/src/test')
-rw-r--r--infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java48
-rw-r--r--infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java60
-rw-r--r--infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java (renamed from infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerTest.java)33
-rw-r--r--infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/InjectionTestData.java46
-rw-r--r--infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java79
-rw-r--r--infra/test-utils/test-tools/src/test/resources/augmentListEntry.json10
-rw-r--r--infra/test-utils/test-tools/src/test/resources/nestedListEntry.json10
-rw-r--r--infra/test-utils/test-tools/src/test/resources/rootListEntry.json10
-rw-r--r--infra/test-utils/test-tools/src/test/resources/simpleListEntry.json10
9 files changed, 296 insertions, 10 deletions
diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java
new file mode 100644
index 000000000..2d5f0259d
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed 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 io.fd.honeycomb.test.tools;
+
+
+import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor;
+import org.junit.Before;
+import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.$YangModuleInfoImpl;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+
+abstract class AbstractYangDataProcessorTest implements InjectablesProcessor, YangContextProducer {
+
+ ModuleInfoBackedContext moduleInfoBackedContext;
+ AbstractModuleStringInstanceIdentifierCodec codec;
+ BindingToNormalizedNodeCodec serializer;
+
+ @Before
+ public void init() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
+ moduleInfoBackedContext = provideSchemaContextFor(Collections.singleton($YangModuleInfoImpl.getInstance()));
+ codec = getIIDCodec(moduleInfoBackedContext);
+ serializer = createSerializer(moduleInfoBackedContext);
+
+ // to init children
+ setUp();
+ }
+
+ // for children init
+ abstract void setUp();
+}
diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java
new file mode 100644
index 000000000..e1dbc1803
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed 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 io.fd.honeycomb.test.tools;
+
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import static org.junit.Assert.*;
+
+public class ContainerNodeDataProcessorTest extends AbstractYangDataProcessorTest {
+
+ private ContainerNodeDataProcessor processor;
+
+ @Override
+ void setUp() {
+ processor = new ContainerNodeDataProcessor(moduleInfoBackedContext.getSchemaContext(), serializer);
+ }
+
+ @Test
+ public void testGetNodeDataNestedContainer() {
+ final DataObject nodeData = processor.getNodeData(codec.deserialize(InjectionTestData.CONTAINER_UNDER_LIST_DATA_PATH),
+ InjectionTestData.CONTAINER_UNDER_LIST_RESOURCE);
+ assertNotNull(nodeData);
+ }
+
+ @Test
+ public void testGetNodeDataRootContainer() {
+ final DataObject nodeData = processor.getNodeData(YangInstanceIdentifier.EMPTY, InjectionTestData.CONTAINER_IN_ROOT_RESOURCE);
+ assertNotNull(nodeData);
+ }
+
+
+ @Test
+ public void testCanProcessNegative() {
+ assertFalse(processor.canProcess(codec.deserialize(InjectionTestData.SIMPLE_LIST_DATA_PATH)));
+ assertFalse(processor.canProcess(codec.deserialize(InjectionTestData.NESTED_LIST_DATA_PATH)));
+ }
+
+ @Test
+ public void testCanProcessPositive() {
+ assertTrue(processor.canProcess(YangInstanceIdentifier.EMPTY));
+ assertTrue(processor.canProcess(codec.deserialize(InjectionTestData.CONTAINER_UNDER_LIST_DATA_PATH)));
+ }
+}
diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java
index 42de7ed4d..1461fa377 100644
--- a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerTest.java
+++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java
@@ -16,27 +16,27 @@
package io.fd.honeycomb.test.tools;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor;
import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider;
-import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.$YangModuleInfoImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.AugContainerAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.SimpleContainer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.SimpleContainerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.*;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.NestedContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.SimpleList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.augmented.container.ListInAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.ContUnderList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.ContUnderListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.NestedList;
import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import java.util.Collections;
+
+import static io.fd.honeycomb.test.tools.InjectionTestData.*;
+import static org.junit.Assert.*;
+
@RunWith(HoneycombTestRunner.class)
-public class HoneycombTestRunnerTest implements InjectablesProcessor {
+public class HoneycombTestRunnerContainerTest implements InjectablesProcessor {
@InjectTestData(resourcePath = "/simpleContainerEmpty.json")
private SimpleContainer simpleContainer;
@@ -52,6 +52,19 @@ public class HoneycombTestRunnerTest implements InjectablesProcessor {
"/hc-data:cont-under-list")
private ContUnderList containerUnderList;
+ @InjectTestData(resourcePath = AUGMENT_LIST_RESOURCE, id = AUGMENT_LIST_DATA_PATH)
+ private ListInAugment listInAugment;
+
+ @InjectTestData(resourcePath = NESTED_LIST_RESOURCE, id = NESTED_LIST_DATA_PATH)
+ private NestedList nestedList;
+
+ @InjectTestData(resourcePath = ROOT_LIST_RESOURCE, id = ROOT_LIST_DATA_PATH)
+ private RootList rootList;
+
+ @InjectTestData(resourcePath = SIMPLES_LIST_RESOURCE, id = SIMPLE_LIST_DATA_PATH)
+ private SimpleList simpleList;
+
+
@SchemaContextProvider
public ModuleInfoBackedContext getSchemaContext() {
return provideSchemaContextFor(Collections.singleton($YangModuleInfoImpl.getInstance()));
diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/InjectionTestData.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/InjectionTestData.java
new file mode 100644
index 000000000..4d4ab5420
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/InjectionTestData.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed 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 io.fd.honeycomb.test.tools;
+
+final class InjectionTestData {
+
+ static final String CONTAINER_UNDER_LIST_DATA_PATH = "/hc-data:simple-container" +
+ "/hc-data:simple-list[hc-data:name='nameUnderSimpleList']" +
+ "/hc-data:cont-under-list";
+
+ static final String SIMPLE_LIST_DATA_PATH = "/hc-data:simple-container" +
+ "/hc-data:simple-list[hc-data:name='nameUnderSimpleList']";
+
+ static final String NESTED_LIST_DATA_PATH = "/hc-data:simple-container" +
+ "/hc-data:simple-list[hc-data:name='nameUnderSimpleList']" +
+ "/hc-data:nested-list[hc-data:nested-name='nameUnderNestedList']";
+
+ static final String ROOT_LIST_DATA_PATH = "/hc-data:root-list[hc-data:root-name='rootName']";
+ static final String AUGMENT_LIST_DATA_PATH = "/hc-data:simple-container" +
+ "/hc-data:augmented-container" +
+ "/hc-data:list-in-augment[hc-data:key-in-augment='keyInAugment']";
+
+ static final String CONTAINER_IN_ROOT_RESOURCE = "/simpleContainerEmpty.json";
+ static final String CONTAINER_UNDER_LIST_RESOURCE = "/containerInList.json";
+ static final String SIMPLES_LIST_RESOURCE = "/simpleListEntry.json";
+ static final String NESTED_LIST_RESOURCE = "/nestedListEntry.json";
+ static final String ROOT_LIST_RESOURCE = "/rootListEntry.json";
+ static final String AUGMENT_LIST_RESOURCE = "/augmentListEntry.json";
+
+ private InjectionTestData() {
+ }
+}
diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java
new file mode 100644
index 000000000..1118d3387
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed 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 io.fd.honeycomb.test.tools;
+
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.RootList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.SimpleList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.augmented.container.ListInAugment;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.NestedList;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+import static io.fd.honeycomb.test.tools.InjectionTestData.*;
+import static org.junit.Assert.*;
+
+public class ListNodeDataProcessorTest extends AbstractYangDataProcessorTest {
+
+ private ListNodeDataProcessor processor;
+
+ @Override
+ void setUp() {
+ processor = new ListNodeDataProcessor(moduleInfoBackedContext.getSchemaContext(), serializer);
+ }
+
+ @Test
+ public void testCanProcessPositive() {
+ assertTrue(processor.canProcess(codec.deserialize(SIMPLE_LIST_DATA_PATH)));
+ assertTrue(processor.canProcess(codec.deserialize(NESTED_LIST_DATA_PATH)));
+ }
+
+ @Test
+ public void testCanProcessNegative() {
+ assertFalse(processor.canProcess(codec.deserialize(CONTAINER_UNDER_LIST_DATA_PATH)));
+ assertFalse(processor.canProcess(YangInstanceIdentifier.EMPTY));
+ }
+
+ @Test
+ public void testGetNodeDataSimpleList() {
+ final DataObject nodeData = processor.getNodeData(codec.deserialize(SIMPLE_LIST_DATA_PATH), SIMPLES_LIST_RESOURCE);
+ assertNotNull(nodeData);
+ assertEquals("nameUnderSimpleList", ((SimpleList) nodeData).getName());
+ }
+
+ @Test
+ public void testGetNodeDataNestedList() {
+ final DataObject nodeData = processor.getNodeData(codec.deserialize(NESTED_LIST_DATA_PATH), NESTED_LIST_RESOURCE);
+ assertNotNull(nodeData);
+ assertEquals("nameUnderNestedList", ((NestedList) nodeData).getNestedName());
+ }
+
+ @Test
+ public void testGetNodeDataRootList() {
+ final DataObject nodeData = processor.getNodeData(codec.deserialize(ROOT_LIST_DATA_PATH), ROOT_LIST_RESOURCE);
+ assertNotNull(nodeData);
+ assertEquals("rootName", ((RootList) nodeData).getRootName());
+ }
+
+ @Test
+ public void testGetNodeDataAugmentList() {
+ final DataObject nodeData = processor.getNodeData(codec.deserialize(AUGMENT_LIST_DATA_PATH), AUGMENT_LIST_RESOURCE);
+ assertNotNull(nodeData);
+ assertEquals("keyInAugment", ((ListInAugment) nodeData).getKeyInAugment());
+ }
+}
diff --git a/infra/test-utils/test-tools/src/test/resources/augmentListEntry.json b/infra/test-utils/test-tools/src/test/resources/augmentListEntry.json
new file mode 100644
index 000000000..1bdc3e6e2
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/resources/augmentListEntry.json
@@ -0,0 +1,10 @@
+{
+ "list-in-augment":[
+ {
+ "key-in-augment":"keyInAugment"
+ },
+ {
+ "key-in-augment":"otherKeyInAugment"
+ }
+ ]
+} \ No newline at end of file
diff --git a/infra/test-utils/test-tools/src/test/resources/nestedListEntry.json b/infra/test-utils/test-tools/src/test/resources/nestedListEntry.json
new file mode 100644
index 000000000..c874f1c94
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/resources/nestedListEntry.json
@@ -0,0 +1,10 @@
+{
+ "nested-list": [
+ {
+ "nested-name": "nameUnderNestedList"
+ },
+ {
+ "nested-name": "otherName"
+ }
+ ]
+}
diff --git a/infra/test-utils/test-tools/src/test/resources/rootListEntry.json b/infra/test-utils/test-tools/src/test/resources/rootListEntry.json
new file mode 100644
index 000000000..cd09c685e
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/resources/rootListEntry.json
@@ -0,0 +1,10 @@
+{
+ "root-list":[
+ {
+ "root-name":"rootName"
+ },
+ {
+ "root-name":"otherRootName"
+ }
+ ]
+} \ No newline at end of file
diff --git a/infra/test-utils/test-tools/src/test/resources/simpleListEntry.json b/infra/test-utils/test-tools/src/test/resources/simpleListEntry.json
new file mode 100644
index 000000000..64ad3e6bd
--- /dev/null
+++ b/infra/test-utils/test-tools/src/test/resources/simpleListEntry.json
@@ -0,0 +1,10 @@
+{
+ "simple-list": [
+ {
+ "name": "nameUnderSimpleList"
+ },
+ {
+ "name": "otherName"
+ }
+ ]
+}