Changes in generated Code for keyClass, enum, list & ModelObjectId test
Change-Id: I74fe67e1c184ad38a606df3e449684507bb135b8
diff --git a/runtime/src/main/test/java/org/onosproject/yang/runtime/impl/ModelObjectIdTest.java b/runtime/src/main/test/java/org/onosproject/yang/runtime/impl/ModelObjectIdTest.java
new file mode 100644
index 0000000..ccadffe
--- /dev/null
+++ b/runtime/src/main/test/java/org/onosproject/yang/runtime/impl/ModelObjectIdTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2017-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.yang.runtime.app;
+
+import org.junit.Test;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.Cont53;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.DefaultCont50;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.DefaultCont53;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.DefaultList52;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.DefaultList56;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.List52Keys;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.List56;
+import org.onosproject.yang.gen.v1.modelobjecttest.check.List56Keys;
+import org.onosproject.yang.model.ModelObjectId;
+
+import java.io.IOException;
+
+/**
+ * Unit test for model object id.
+ */
+public class ModelObjectIdTest {
+
+ /**
+ * Unit test case for creating model object id for container.
+ *
+ * @throws IOException when fails to do IO operation
+ */
+ @Test
+ public void testCreateContainerModelObjectId()
+ throws IOException {
+ ModelObjectId id = new ModelObjectId.Builder()
+ .addChild(DefaultCont50.class).build();
+ }
+
+ /**
+ * Unit test case for creating model object id for list.
+ *
+ * @throws IOException when fails to do IO operation
+ */
+ @Test
+ public void testCreateListModelObjectId()
+ throws IOException {
+ List52Keys key = new List52Keys();
+ key.leaf52(52);
+ ModelObjectId id = new ModelObjectId.Builder()
+ .addChild(DefaultList52.class, key).build();
+ }
+
+ /**
+ * Unit test case for creating model object id for leaf.
+ *
+ * @throws IOException when fails to do IO operation
+ */
+ @Test
+ public void testCreateleafModelObjectId()
+ throws IOException {
+ ModelObjectId id = new ModelObjectId.Builder()
+ .addChild(DefaultCont53.class)
+ .addChild(Cont53.LeafIdentifier.LEAF55).build();
+ }
+
+ /**
+ * Unit test case for creating model object id for leaf-list.
+ *
+ * @throws IOException when fails to do IO operation
+ */
+ @Test
+ public void testCreateleaflistModelObjectId()
+ throws IOException {
+ ModelObjectId id = new ModelObjectId.Builder()
+ .addChild(DefaultCont53.class)
+ .addChild(Cont53.LeafIdentifier.LEAF54, "hello").build();
+ }
+
+ /**
+ * Unit test case for creating model object id for leaf-list.
+ *
+ * @throws IOException when fails to do IO operation
+ */
+ @Test
+ public void testCreatelistWithoutKeyModelObjectId()
+ throws IOException {
+ List56Keys key = new List56Keys();
+ ModelObjectId id = new ModelObjectId.Builder()
+ .addChild(DefaultList56.class, key)
+ .addChild(List56.LeafIdentifier.LEAF57, "hello").build();
+ }
+}
diff --git a/runtime/src/main/test/resources/modelObjectId/modelObjectIdTest.yang b/runtime/src/main/test/resources/modelObjectId/modelObjectIdTest.yang
new file mode 100644
index 0000000..24ec4eb
--- /dev/null
+++ b/runtime/src/main/test/resources/modelObjectId/modelObjectIdTest.yang
@@ -0,0 +1,35 @@
+module check {
+ yang-version 1;
+ namespace "modelObjectTest";
+ prefix nd;
+ container cont50 {
+ leaf leaf51 {
+ type int32;
+ }
+ }
+ list list52 {
+ key leaf52;
+ leaf leaf52 {
+ type int32;
+ }
+ }
+
+ container cont53 {
+ leaf-list leaf54 {
+ type string;
+ }
+ leaf leaf55 {
+ type string;
+ }
+ }
+
+ list list56 {
+ config false;
+ leaf-list leaf57 {
+ type string;
+ }
+ leaf leaf58 {
+ type string;
+ }
+ }
+}
\ No newline at end of file