[ONOS-5080] YANG object builder coding
Change-Id: Ibef332b58f197a2f6626ee9b6d791b80002e2dfd
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
new file mode 100644
index 0000000..6b4b526
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class YobBitTest {
+
+/*
+ BINARY
+
+ Positive scenario
+ input with position 0
+ input with position 1
+ input with position 2
+*/
+
+
+ @Test
+ public void positiveTest() throws IOException {
+
+ //TODO for getYangObject
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
new file mode 100644
index 0000000..83ce3f6
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class YobBooleanTest {
+
+ private static final String BOOLEAN_LIST = "booleanList";
+ private static final String AUTO_PREFIX_BOOLEAN = "yangAutoPrefixBoolean";
+
+ /*
+ BOOLEAN
+ Positive scenario
+ input with in true and false
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.booleanYdt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+
+ Field field = yangObject.getClass().getDeclaredField(BOOLEAN_LIST);
+ field.setAccessible(true);
+ List booleanList = (List) field.get(yangObject);
+ Field invalidInterval = booleanList.get(0).getClass()
+ .getDeclaredField(AUTO_PREFIX_BOOLEAN);
+ invalidInterval.setAccessible(true);
+ assertTrue((boolean) invalidInterval.get(booleanList.get(0)));
+ assertFalse((boolean) invalidInterval.get(booleanList.get(1)));
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
new file mode 100644
index 0000000..b069ad2
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobDecimal64Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundary for decimal64 with fraction 2
+ i. min value
+ ii. max value
+
+ input at boundary for decimal64 with minimum fraction
+ i. min value
+ ii. mid value
+ iii. max value
+
+ input at boundary for decimal64 with maximum fraction
+ i. min value
+ ii. mid value
+ iii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for decimal64
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 3.14 | 10 | 20..max" for decimal64
+ i.1. input min
+ i.2. input 2.505
+ i.3. input 3.14
+ i.4. input 10
+ i.5. input 20
+ i.6. input 92233720368547757
+ i.7. input 92233720368547758.07
+
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.decimal64Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field negInt = yangObject.getClass().getDeclaredField("negInt");
+ negInt.setAccessible(true);
+ assertEquals("-92233720368547758.08", negInt
+ .get(yangObject).toString());
+ Field negIntWithMaxFraction = yangObject.getClass()
+ .getDeclaredField("negIntWithMaxFraction");
+ negIntWithMaxFraction.setAccessible(true);
+ assertEquals("-9.223372036854775808", negIntWithMaxFraction
+ .get(yangObject).toString());
+ Field negIntWithMinFraction = yangObject.getClass()
+ .getDeclaredField("negIntWithMinFraction");
+ negIntWithMinFraction.setAccessible(true);
+ assertEquals("-922337203685477580.8", negIntWithMinFraction
+ .get(yangObject).toString());
+ Field posInt = yangObject.getClass()
+ .getDeclaredField("posInt");
+ posInt.setAccessible(true);
+ assertEquals("92233720368547758.07", posInt
+ .get(yangObject).toString());
+ Field posIntWithMaxFraction = yangObject
+ .getClass().getDeclaredField("posIntWithMaxFraction");
+ posIntWithMaxFraction.setAccessible(true);
+ assertEquals("9.223372036854775807", posIntWithMaxFraction
+ .get(yangObject).toString());
+ Field posIntWithMinFraction = yangObject.getClass()
+ .getDeclaredField("posIntWithMinFraction");
+ posIntWithMinFraction.setAccessible(true);
+ assertEquals("922337203685477580.7", posIntWithMinFraction
+ .get(yangObject).toString());
+ Field minIntWithRange = yangObject.getClass()
+ .getDeclaredField("minIntWithRange");
+ minIntWithRange.setAccessible(true);
+ assertEquals("10", minIntWithRange
+ .get(yangObject).toString());
+ Field midIntWithRange = yangObject
+ .getClass().getDeclaredField("midIntWithRange");
+ midIntWithRange.setAccessible(true);
+ assertEquals("11", midIntWithRange.get(yangObject).toString());
+ Field maxIntWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ maxIntWithRange.setAccessible(true);
+ assertEquals("100", maxIntWithRange.get(yangObject).toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
new file mode 100644
index 0000000..55c416e
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobEmptyTest {
+
+ /*
+ EMPTY
+ Positive scenario
+ input with in empty.
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.emptyTypeYdt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+
+ Field field = yangObject.getClass().getDeclaredField("emptyList");
+ field.setAccessible(true);
+ List booleanList = (List) field.get(yangObject);
+ Field invalidInterval = booleanList.get(0)
+ .getClass().getDeclaredField("empty");
+ invalidInterval.setAccessible(true);
+ assertEquals(false, invalidInterval.get(booleanList.get(0)));
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
new file mode 100644
index 0000000..c479afa
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobEnumTest {
+
+/*
+ ENUM
+
+ Positive scenario
+
+ input with in enum
+ input with "ten"
+ input with "hundred"
+ input with "thousand"
+*/
+
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.enumYdt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field field = yangObject.getClass().getDeclaredField("enumList");
+ field.setAccessible(true);
+ List enumList = (List) field.get(yangObject);
+ assertEquals(false, enumList.isEmpty());
+ Field enumleaf = enumList.get(0)
+ .getClass().getDeclaredField("enumleaf");
+ enumleaf.setAccessible(true);
+ assertEquals("ten", enumleaf
+ .get(enumList.get(0)).toString().toLowerCase());
+ assertEquals("hundred", enumleaf
+ .get(enumList.get(1)).toString().toLowerCase());
+ assertEquals("thousand", enumleaf
+ .get(enumList.get(2)).toString().toLowerCase());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
new file mode 100644
index 0000000..462dccb
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import static org.junit.Assert.assertNotNull;
+
+public class YobIetfNetworkTest {
+
+ @Test
+ public void ietfNetwork1Test() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.ietfNetwork1Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ //TODO yangObject need to verify
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
new file mode 100644
index 0000000..39281b7
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobInteger16Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundary for integer
+ i. min value
+ ii. max value
+
+ input at boundary for unsigned integer
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for unsigned integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer16Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field negInt = yangObject.getClass().getDeclaredField("negInt");
+ negInt.setAccessible(true);
+ assertEquals("-32768", negInt.get(yangObject).toString());
+ Field posInt = yangObject.getClass().getDeclaredField("posInt");
+ posInt.setAccessible(true);
+ assertEquals("32767", posInt.get(yangObject).toString());
+ Field minIntWithRange = yangObject
+ .getClass().getDeclaredField("minIntWithRange");
+ minIntWithRange.setAccessible(true);
+ assertEquals("10", minIntWithRange.get(yangObject).toString());
+ Field midIntWithRange = yangObject
+ .getClass().getDeclaredField("midIntWithRange");
+ midIntWithRange.setAccessible(true);
+ assertEquals("11", midIntWithRange.get(yangObject).toString());
+ Field maxIntWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ maxIntWithRange.setAccessible(true);
+ assertEquals("100", maxIntWithRange.get(yangObject).toString());
+ Field minUint = yangObject.getClass().getDeclaredField("minUint");
+ minUint.setAccessible(true);
+ assertEquals("0", minUint.get(yangObject).toString());
+ Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
+ maxUint.setAccessible(true);
+ assertEquals("65535", maxUint.get(yangObject).toString());
+ Field minUintWithRange = yangObject
+ .getClass().getDeclaredField("minUintWithRange");
+ minUintWithRange.setAccessible(true);
+ assertEquals("10", minUintWithRange.get(yangObject).toString());
+ Field midUintWithRange = yangObject
+ .getClass().getDeclaredField("midUintWithRange");
+ midUintWithRange.setAccessible(true);
+ assertEquals("11", midUintWithRange.get(yangObject).toString());
+ Field maxUintWithRange = yangObject
+ .getClass().getDeclaredField("maxUintWithRange");
+ maxUintWithRange.setAccessible(true);
+ assertEquals("100", maxUintWithRange.get(yangObject).toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
new file mode 100644
index 0000000..d97f783
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobInteger32Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundary for integer
+ i. min value
+ ii. max value
+
+ input at boundary for unsigned integer
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for unsigned integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer32Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field negInt = yangObject.getClass().getDeclaredField("negInt");
+ negInt.setAccessible(true);
+ assertEquals("-2147483648", negInt.get(yangObject).toString());
+ Field posInt = yangObject.getClass().getDeclaredField("posInt");
+ posInt.setAccessible(true);
+ assertEquals("2147483647", posInt.get(yangObject).toString());
+ Field minIntWithRange = yangObject
+ .getClass().getDeclaredField("minIntWithRange");
+ minIntWithRange.setAccessible(true);
+ assertEquals("10", minIntWithRange.get(yangObject).toString());
+ Field midIntWithRange = yangObject
+ .getClass().getDeclaredField("midIntWithRange");
+ midIntWithRange.setAccessible(true);
+ assertEquals("11", midIntWithRange.get(yangObject).toString());
+ Field maxIntWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ maxIntWithRange.setAccessible(true);
+ assertEquals("100", maxIntWithRange.get(yangObject).toString());
+ Field minUint = yangObject.getClass().getDeclaredField("minUint");
+ minUint.setAccessible(true);
+ assertEquals("0", minUint.get(yangObject).toString());
+ Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
+ maxUint.setAccessible(true);
+ assertEquals("4294967295", maxUint.get(yangObject).toString());
+ Field minUintWithRange = yangObject
+ .getClass().getDeclaredField("minUintWithRange");
+ minUintWithRange.setAccessible(true);
+ assertEquals("10", minUintWithRange.get(yangObject).toString());
+ Field midUintWithRange = yangObject
+ .getClass().getDeclaredField("midUintWithRange");
+ midUintWithRange.setAccessible(true);
+ assertEquals("11", midUintWithRange.get(yangObject).toString());
+ Field maxUintWithRange = yangObject
+ .getClass().getDeclaredField("maxUintWithRange");
+ maxUintWithRange.setAccessible(true);
+ assertEquals("100", maxUintWithRange.get(yangObject).toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
new file mode 100644
index 0000000..a3ee166
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+public class YobInteger64Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundary for integer
+ i. min value
+ ii. max value
+
+ input at boundary for unsigned integer
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for unsigned integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer64Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field negInt = yangObject.getClass().getDeclaredField("negInt");
+ negInt.setAccessible(true);
+ assertEquals("-9223372036854775808", negInt
+ .get(yangObject).toString());
+ Field posIntField = yangObject
+ .getClass().getDeclaredField("posInt");
+ posIntField.setAccessible(true);
+ assertEquals("9223372036854775807", posIntField
+ .get(yangObject).toString());
+ Field minIntWithRange = yangObject
+ .getClass().getDeclaredField("minIntWithRange");
+ minIntWithRange.setAccessible(true);
+ assertEquals("10", minIntWithRange.get(yangObject).toString());
+ Field midIntWithRange = yangObject
+ .getClass().getDeclaredField("midIntWithRange");
+ midIntWithRange.setAccessible(true);
+ assertEquals("11", midIntWithRange.get(yangObject).toString());
+ Field maxIntWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ maxIntWithRange.setAccessible(true);
+ assertEquals("100", maxIntWithRange.get(yangObject).toString());
+ Field minUint = yangObject.getClass().getDeclaredField("minUint");
+ minUint.setAccessible(true);
+ assertEquals("0", minUint.get(yangObject).toString());
+ Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
+ maxUint.setAccessible(true);
+ assertEquals("18446744073709551615", maxUint
+ .get(yangObject).toString());
+ Field minUintWithRange = yangObject
+ .getClass().getDeclaredField("minUintWithRange");
+ minUintWithRange.setAccessible(true);
+ assertEquals("10", minUintWithRange.get(yangObject).toString());
+ Field midUintWithRange = yangObject
+ .getClass().getDeclaredField("midUintWithRange");
+ midUintWithRange.setAccessible(true);
+ assertEquals("11", midUintWithRange.get(yangObject).toString());
+ Field maxUintWithRange = yangObject
+ .getClass().getDeclaredField("maxUintWithRange");
+ maxUintWithRange.setAccessible(true);
+ assertEquals("100", maxUintWithRange.get(yangObject).toString());
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
new file mode 100644
index 0000000..11bd8e5
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class YobInteger8Test {
+
+ /*
+
+ Positive scenario
+
+ input at boundary for integer
+ i. min value
+ ii. max value
+
+ input at boundary for unsigned integer
+ i. min value
+ ii. max value
+
+ input with in range
+ if range is 10 to 100 for integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ if range is 10 to 100 for unsigned integer
+ i.1. input 11
+ i.2. min value 10
+ i.3. max value 100
+
+ input with multi interval range
+ if range is 10..40 | 50..100 for integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is 10..40 | 50..100 for unsigned integer
+ i.1. input 11
+ i.2. input 10
+ i.3. input 40
+ i.4. input 50
+ i.5. input 55
+ i.6. input 100
+
+ if range is "min .. 2 | 10 | 20..max" for integer
+ i.1. input -128
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 127
+
+ if range is "min .. 2 | 10 | 20..max" for unsigned Integer
+ i.1. input 0
+ i.2. input 1
+ i.3. input 2
+ i.4. input 10
+ i.5. input 20
+ i.6. input 100
+ i.7. input 255
+ */
+ @Test
+ public void positiveTest() {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer8Ydt();
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ try {
+ Field negInt = yangObject.getClass().getDeclaredField("negInt");
+ negInt.setAccessible(true);
+ assertEquals("-128", negInt.get(yangObject).toString());
+ Field posInt = yangObject.getClass().getDeclaredField("posInt");
+ posInt.setAccessible(true);
+ assertEquals("127", posInt.get(yangObject).toString());
+ Field minIntWithRange = yangObject
+ .getClass().getDeclaredField("minIntWithRange");
+ minIntWithRange.setAccessible(true);
+ assertEquals("10", minIntWithRange
+ .get(yangObject).toString());
+ Field midIntWithRange = yangObject
+ .getClass().getDeclaredField("midIntWithRange");
+ midIntWithRange.setAccessible(true);
+ assertEquals("11", midIntWithRange
+ .get(yangObject).toString());
+ Field maxIntWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ maxIntWithRange.setAccessible(true);
+ assertEquals("100", maxIntWithRange.get(yangObject).toString());
+ Field minUint = yangObject.getClass().getDeclaredField("minUint");
+ minUint.setAccessible(true);
+ assertEquals("0", minUint.get(yangObject).toString());
+ Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
+ maxUint.setAccessible(true);
+ assertEquals("255", maxUint.get(yangObject).toString());
+ Field minUintWithRange = yangObject
+ .getClass().getDeclaredField("maxIntWithRange");
+ minUintWithRange.setAccessible(true);
+ assertEquals("100", minUintWithRange.get(yangObject).toString());
+ Field midUintWithRange = yangObject
+ .getClass().getDeclaredField("midUintWithRange");
+ midUintWithRange.setAccessible(true);
+ assertEquals("11", midUintWithRange.get(yangObject).toString());
+ Field maxUintWithRange = yangObject
+ .getClass().getDeclaredField("maxUintWithRange");
+ maxUintWithRange.setAccessible(true);
+ assertEquals("100", maxUintWithRange.get(yangObject).toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
new file mode 100644
index 0000000..47ec8ef
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class YobListTest {
+
+ @Test
+ public void listwithoutcontainerTest() {
+ YangRequestWorkBench defaultYdtBuilder =
+ YdtTestUtils.listWithoutContainerYdt();
+ validateYangObjectList(defaultYdtBuilder);
+ }
+
+ private void validateYangObjectList(
+ YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils.
+ getSchemaRegistry());
+ assertNotNull(yangObject);
+ assertTrue(yangObject.getClass().getSimpleName()
+ .equals("RootlistOpParam"));
+ try {
+
+ Field field =
+ yangObject.getClass().getDeclaredField("listwithcontainer");
+ field.setAccessible(true);
+ List listwithcontainer = (List) field.get(yangObject);
+ assertEquals(true, listwithcontainer.isEmpty());
+ Field field1 = yangObject.getClass()
+ .getDeclaredField("listwithoutcontainer");
+ field1.setAccessible(true);
+ List listwithoutcontainer = (List) field1.get(yangObject);
+ assertEquals(false, listwithoutcontainer.isEmpty());
+ Field invalidinterval = listwithoutcontainer.get(0).getClass()
+ .getDeclaredField("invalidinterval");
+ invalidinterval.setAccessible(true);
+ assertEquals("12", invalidinterval.get(listwithoutcontainer.get(0))
+ .toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+
+ @Test
+ public void listwithcontainerTest()
+ throws IOException {
+ YangRequestWorkBench defaultYdtBuilder =
+ YdtTestUtils.listWithContainerYdt();
+
+ validateYangObject(defaultYdtBuilder);
+ }
+
+ public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
+
+ YdtContext ydtContext = defaultYdtBuilder.getRootNode();
+
+ YdtContext ydtContext1 = ydtContext.getFirstChild();
+
+ DefaultYobBuilder defaultYobBuilder = new DefaultYobBuilder();
+
+ Object yangObject = defaultYobBuilder.getYangObject(
+ (YdtExtendedContext) ydtContext1, YdtTestUtils
+ .getSchemaRegistry());
+ assertNotNull(yangObject);
+ assertTrue(yangObject.getClass().getSimpleName()
+ .equals("RootlistOpParam"));
+ try {
+
+ Field field = yangObject.getClass()
+ .getDeclaredField("listwithoutcontainer");
+ field.setAccessible(true);
+ List listwithoutcontainer = (List) field.get(yangObject);
+ assertEquals(true, listwithoutcontainer.isEmpty());
+ Field listwithcontainerField =
+ yangObject.getClass().getDeclaredField("listwithcontainer");
+ listwithcontainerField.setAccessible(true);
+ List listwithcontainer =
+ (List) listwithcontainerField.get(yangObject);
+ Field invalid = listwithcontainer.get(0).getClass()
+ .getDeclaredField("invalid");
+ invalid.setAccessible(true);
+ assertEquals("12",
+ invalid.get(listwithcontainer.get(0)).toString());
+ Field invalidinterval = listwithcontainer.get(0).getClass()
+ .getDeclaredField("invalidinterval");
+ invalidinterval.setAccessible(true);
+ List invalidintervalList =
+ (List) invalidinterval.get(listwithcontainer.get(0));
+ assertEquals("1", invalidintervalList.get(0).toString());
+ assertEquals("2", invalidintervalList.get(1).toString());
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ fail("No such field or illegal access exception: " + e);
+ }
+ }
+}
diff --git a/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
new file mode 100644
index 0000000..c66f555
--- /dev/null
+++ b/apps/yms/app/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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 org.onosproject.yms.app.yob;
+
+import org.junit.Test;
+import org.onosproject.yms.app.ydt.YangRequestWorkBench;
+import org.onosproject.yms.app.ydt.YdtExtendedContext;
+import org.onosproject.yms.app.ydt.YdtTestUtils;
+import org.onosproject.yms.ydt.YdtContext;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class YobLogisticsManagerTest {
+
+ @Test
+ public void logisticsManagerTest() throws IOException {
+ YangRequestWorkBench defaultYdtBuilder = YdtTestUtils
+ .logisticsManagerYdt();
+
+ YdtContext rootCtx = defaultYdtBuilder.getRootNode();
+
+ YdtContext childCtx = rootCtx.getFirstChild();
+
+ DefaultYobBuilder builder = new DefaultYobBuilder();
+
+ while (childCtx != null) {
+
+ Object yangObject = builder.getYangObject(
+ (YdtExtendedContext) childCtx, YdtTestUtils
+ .getSchemaRegistry());
+ Class<?> aClass = yangObject.getClass();
+ if (aClass.getSimpleName().equals("CustomssupervisorOpParam")) {
+ try {
+ Field field = aClass.getDeclaredField("supervisor");
+ Field onosYangNodeOperationType = aClass
+ .getDeclaredField("onosYangNodeOperationType");
+ field.setAccessible(true);
+ onosYangNodeOperationType.setAccessible(true);
+ try {
+ assertEquals("abc", field.get(yangObject).toString());
+ assertEquals("MERGE", onosYangNodeOperationType
+ .get(yangObject).toString());
+ } catch (IllegalAccessException e) {
+ fail("Illegal access exception: " + e);
+ }
+ } catch (NoSuchFieldException e) {
+ fail("No such field exception: " + e);
+ }
+ }
+
+ if (aClass.getSimpleName().equals(
+ "MerchandisersupervisorOpParam")) {
+ try {
+ Field field = aClass.getDeclaredField("supervisor");
+ field.setAccessible(true);
+ try {
+ assertEquals("abc", field.get(yangObject).toString());
+ } catch (IllegalAccessException e) {
+ fail("Illegal access exception: " + e);
+ }
+ } catch (NoSuchFieldException e) {
+ fail("No such field found exception: " + e);
+ }
+ }
+
+ if (aClass.getSimpleName().equals("WarehousesupervisorOpParam")) {
+ try {
+ Field field = aClass.getDeclaredField("supervisor");
+ field.setAccessible(true);
+ try {
+ ArrayList<String> arrayList =
+ (ArrayList<String>) field.get(yangObject);
+ assertEquals("1", arrayList.get(0));
+ assertEquals("2", arrayList.get(1));
+ assertEquals("3", arrayList.get(2));
+ assertEquals("4", arrayList.get(3));
+ assertEquals("5", arrayList.get(4));
+ } catch (IllegalAccessException e) {
+ fail("Illegal access exception: " + e);
+ }
+ } catch (NoSuchFieldException e) {
+ fail("No such field exception: " + e);
+ }
+ }
+ childCtx = childCtx.getNextSibling();
+ }
+ }
+}