Increased version of binding-generator to 0.5.5-SNAPSHOT.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / test / java / org / opendaylight / controller / sal / binding / generator / impl / GeneratedTypesTest.java
index 92d9359130967008ccc76ea4bccb4f510023d8d6..88c4ae16ccadfde05227933ac0cf4de3314729ab 100644 (file)
@@ -16,21 +16,19 @@ import java.util.Set;
 
 import org.junit.Test;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
 import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
-import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesTest {
 
-    private SchemaContext resolveSchemaContextFromFiles(
-            final String... yangFiles) {
+    private SchemaContext resolveSchemaContextFromFiles(final String... yangFiles) {
         final YangModelParser parser = new YangParserImpl();
 
         final List<File> inputFiles = new ArrayList<File>();
@@ -42,465 +40,518 @@ public class GeneratedTypesTest {
         return parser.resolveSchemaContext(modules);
     }
 
-    @Test
-    public void testLeafEnumResolving() {
-        final String ietfInterfacesPath = getClass().getResource(
-                "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();
-        final String ifTypePath = getClass().getResource(
-                "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();
-        final String yangTypesPath = getClass().getResource(
-                "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();
-
-        final SchemaContext context = resolveSchemaContextFromFiles(
-                ietfInterfacesPath, ifTypePath, yangTypesPath);
-        assertTrue(context != null);
-
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<Type> genTypes = bindingGen.generateTypes(context);
-        assertTrue(genTypes != null);
-    }
-
-    @Test
-    public void testTypedefEnumResolving() {
-        final String ianaIfTypePath = getClass().getResource(
-                "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
-
-        final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
-        assertTrue(context != null);
-
-        final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<Type> genTypes = bindingGen.generateTypes(context);
-        assertTrue(genTypes != null);
-        assertEquals(2, genTypes.size());
-
-        final Type type = genTypes.get(0);
-        assertTrue(type instanceof GeneratedType);
-
-        final GeneratedType genType = (GeneratedType) type;
-        assertEquals(1, genType.getEnumDefintions().size());
-
-        final Enumeration enumer = genType.getEnumDefintions().get(0);
-        assertEquals(272, enumer.getValues().size());
-    }
-
     @Test
     public void testMultipleModulesResolving() {
-        final String topologyPath = getClass().getResource(
-                "/abstract-topology.yang").getPath();
-        final String typesPath = getClass().getResource(
-                "/ietf-inet-types@2010-09-24.yang").getPath();
-        final SchemaContext context = resolveSchemaContextFromFiles(
-                topologyPath, typesPath);
-        assertTrue(context != null);
+        final String topologyPath = getClass().getResource("/abstract-topology.yang").getPath();
+        final String typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
+        assertNotNull(context);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(24, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(29, genTypes.size());
     }
 
     @Test
     public void testLeafrefResolving() {
-        final String topologyPath = getClass().getResource(
-                "/leafref-test-models/abstract-topology@2013-02-08.yang")
+        final String topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
                 .getPath();
-        final String interfacesPath = getClass().getResource(
-                "/leafref-test-models/ietf-interfaces@2012-11-15.yang")
+        final String interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
                 .getPath();
         // final String ifTypePath = getClass().getResource(
         // "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
-        final String inetTypesPath = getClass().getResource(
-                "/leafref-test-models/ietf-inet-types@2010-09-24.yang")
+        final String inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")
                 .getPath();
-        final String yangTypesPath = getClass().getResource(
-                "/leafref-test-models/ietf-yang-types@2010-09-24.yang")
+        final String yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")
                 .getPath();
 
-        assertTrue(topologyPath != null);
-        assertTrue(interfacesPath != null);
+        assertNotNull(topologyPath);
+        assertNotNull(interfacesPath);
         // assertTrue(ifTypePath != null);
-        assertTrue(inetTypesPath != null);
-        assertTrue(yangTypesPath != null);
-
-        // final SchemaContext context = resolveSchemaContextFromFiles(
-        // topologyPath, interfacesPath, ifTypePath, inetTypesPath,
-        // yangTypesPath);
-        final SchemaContext context = resolveSchemaContextFromFiles(
-                topologyPath, interfacesPath, inetTypesPath, yangTypesPath);
-        assertTrue(context != null);
+        assertNotNull(inetTypesPath);
+        assertNotNull(yangTypesPath);
+
+        // final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, ifTypePath,
+        // inetTypesPath, yangTypesPath);
+        final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,
+                yangTypesPath);
+        assertNotNull(context);
         assertEquals(4, context.getModules().size());
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertEquals(46, genTypes.size());
-        assertTrue(genTypes != null);
-
-        int resolvedLeafrefCount = 0;
+        assertEquals(57, genTypes.size());
+        assertNotNull(genTypes);
+
+        GeneratedTransferObject gtIfcKey = null;
+        GeneratedType gtIfc = null;
+        GeneratedType gtNetworkLink = null;
+        GeneratedType gtSource = null;
+        GeneratedType gtDest = null;
+        GeneratedType gtTunnel = null;
+        GeneratedTransferObject gtTunnelKey = null;
+        GeneratedType gtTopology = null;
         for (final Type type : genTypes) {
-            if (type.getName().equals("InterfaceKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("InterfaceId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
+            String name = type.getName();
+            if ("InterfaceKey".equals(name)) {
+                gtIfcKey = (GeneratedTransferObject) type;
+            } else if ("Interface".equals(name)) {
+                gtIfc = (GeneratedType) type;
+            } else if ("NetworkLink".equals(name)) {
+                gtNetworkLink = (GeneratedType) type;
+            } else if ("SourceNode".equals(name)) {
+                gtSource = (GeneratedType) type;
+            } else if ("DestinationNode".equals(name)) {
+                gtDest = (GeneratedType) type;
+            } else if ("Tunnel".equals(name)) {
+                gtTunnel = (GeneratedType) type;
+            } else if ("TunnelKey".equals(name)) {
+                gtTunnelKey = (GeneratedTransferObject) type;
+            } else if ("Topology".equals(name)) {
+                gtTopology = (GeneratedType) type;
+            }
+        }
 
-            } else if (type.getName().equals("Interface")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-
-                assertTrue(methods != null);
-                for (final MethodSignature method : methods) {
-                    if (method.getName().equals("getInterfaceKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("InterfaceKey"));
-                        resolvedLeafrefCount++;
-                    } else if (method.getName().equals("getHigherLayerIf")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("List"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("NetworkLink")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getInterface")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("String"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if ((type.getName().equals("SourceNode") || type.getName()
-                    .equals("DestinationNode"))
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getId")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("Tunnel")
-                    && type instanceof GeneratedType) {
-                final GeneratedType genType = (GeneratedType) type;
-                final List<MethodSignature> methods = genType
-                        .getMethodDefinitions();
-                assertTrue(methods != null);
-                for (MethodSignature method : methods) {
-                    if (method.getName().equals("getTunnelKey")) {
-                        assertTrue(method.getReturnType() != null);
-                        assertFalse(method.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(method.getReturnType().getName()
-                                .equals("TunnelKey"));
-                        resolvedLeafrefCount++;
-                    }
-                }
-            } else if (type.getName().equals("TunnelKey")
-                    && type instanceof GeneratedTransferObject) {
-                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-
-                assertTrue(properties != null);
-                for (final GeneratedProperty property : properties) {
-                    if (property.getName().equals("TunnelId")) {
-                        assertTrue(property.getReturnType() != null);
-                        assertFalse(property.getReturnType().equals(
-                                "java.lang.Void"));
-                        assertTrue(property.getReturnType().getName()
-                                .equals("Uri"));
-                        resolvedLeafrefCount++;
-                    }
-                }
+        assertNotNull(gtIfcKey);
+        assertNotNull(gtIfc);
+        assertNotNull(gtNetworkLink);
+        assertNotNull(gtSource);
+        assertNotNull(gtDest);
+        assertNotNull(gtTunnel);
+        assertNotNull(gtTunnelKey);
+        assertNotNull(gtTopology);
+
+        // Topology
+        final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();
+        assertNotNull(gtTopoMethods);
+        MethodSignature condLeafref = null;
+        for (final MethodSignature method : gtTopoMethods) {
+            if (method.getName().equals("getCondLeafref")) {
+                condLeafref = method;
+            }
+        }
+        assertNotNull(condLeafref);
+        Type condLeafRT = condLeafref.getReturnType();
+        assertNotNull(condLeafRT);
+        assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());
+
+        // InterfaceId
+        final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
+        assertNotNull(gtIfcKeyProps);
+        GeneratedProperty ifcIdProp = null;
+        for (final GeneratedProperty property : gtIfcKeyProps) {
+            if (property.getName().equals("InterfaceId")) {
+                ifcIdProp = property;
+            }
+        }
+        assertNotNull(ifcIdProp);
+        Type ifcIdPropType = ifcIdProp.getReturnType();
+        assertNotNull(ifcIdPropType);
+        assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());
+
+        // Interface
+        final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
+        assertNotNull(gtIfcMethods);
+        MethodSignature getIfcKey = null;
+        MethodSignature getHigherLayerIf = null;
+        for (final MethodSignature method : gtIfcMethods) {
+            if (method.getName().equals("getInterfaceKey")) {
+                getIfcKey = method;
+            } else if (method.getName().equals("getHigherLayerIf")) {
+                getHigherLayerIf = method;
+            }
+        }
+        assertNotNull(getIfcKey);
+        Type getIfcKeyType = getIfcKey.getReturnType();
+        assertNotNull(getIfcKeyType);
+        assertNotSame("java.lang.Void", getIfcKeyType);
+        assertEquals("InterfaceKey", getIfcKeyType.getName());
+
+        assertNotNull(getHigherLayerIf);
+        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+        assertNotNull(getHigherLayerIfType);
+        assertNotSame("java.lang.Void", getHigherLayerIfType);
+        assertEquals("List", getHigherLayerIfType.getName());
+
+        // NetworkLink
+        final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
+        assertNotNull(gtNetworkLinkMethods);
+        MethodSignature getIfc = null;
+        for (MethodSignature method : gtNetworkLinkMethods) {
+            if (method.getName().equals("getInterface")) {
+                getIfc = method;
+            }
+        }
+        assertNotNull(getIfc);
+        Type getIfcType = getIfc.getReturnType();
+        assertNotNull(getIfcType);
+        assertNotSame("java.lang.Void", getIfcType);
+        assertEquals("String", getIfcType.getName());
+
+        // SourceNode
+        final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();
+        assertNotNull(gtSourceMethods);
+        MethodSignature getIdSource = null;
+        for (MethodSignature method : gtSourceMethods) {
+            if (method.getName().equals("getId")) {
+                getIdSource = method;
+            }
+        }
+        assertNotNull(getIdSource);
+        Type getIdType = getIdSource.getReturnType();
+        assertNotNull(getIdType);
+        assertNotSame("java.lang.Void", getIdType);
+        assertEquals("Uri", getIdType.getName());
+
+        // DestinationNode
+        final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();
+        assertNotNull(gtDestMethods);
+        MethodSignature getIdDest = null;
+        for (MethodSignature method : gtDestMethods) {
+            if (method.getName().equals("getId")) {
+                getIdDest = method;
+            }
+        }
+        assertNotNull(getIdDest);
+        Type getIdDestType = getIdDest.getReturnType();
+        assertNotNull(getIdDestType);
+        assertNotSame("java.lang.Void", getIdDestType);
+        assertEquals("Uri", getIdDestType.getName());
+
+        // Tunnel
+        final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();
+        assertNotNull(gtTunnelMethods);
+        MethodSignature getTunnelKey = null;
+        for (MethodSignature method : gtTunnelMethods) {
+            if (method.getName().equals("getTunnelKey")) {
+                getTunnelKey = method;
+            }
+        }
+        assertNotNull(getTunnelKey);
+        Type getTunnelKeyType = getTunnelKey.getReturnType();
+        assertNotNull(getTunnelKeyType);
+        assertNotSame("java.lang.Void", getTunnelKeyType);
+        assertEquals("TunnelKey", getTunnelKeyType.getName());
+
+        // TunnelKey
+        final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();
+        assertNotNull(gtTunnelKeyProps);
+        GeneratedProperty tunnelId = null;
+        for (final GeneratedProperty property : gtTunnelKeyProps) {
+            if (property.getName().equals("TunnelId")) {
+                tunnelId = property;
             }
         }
-        assertEquals(10, resolvedLeafrefCount);
+        assertNotNull(tunnelId);
+        Type tunnelIdType = tunnelId.getReturnType();
+        assertNotNull(tunnelIdType);
+        assertNotSame("java.lang.Void", tunnelIdType);
+        assertEquals("Uri", tunnelIdType.getName());
     }
 
     @Test
     public void testContainerResolving() {
-        final String filePath = getClass().getResource(
-                "/simple-container-demo.yang").getPath();
+        final String filePath = getClass().getResource("/simple-container-demo.yang").getPath();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
-        assertTrue(context != null);
+        assert (context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(3, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(4, genTypes.size());
 
-        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
-        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
+        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
+        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
 
         assertEquals("SimpleContainer", simpleContainer.getName());
         assertEquals("NestedContainer", nestedContainer.getName());
-        assertEquals(5, simpleContainer.getMethodDefinitions().size());
-        assertEquals(4, nestedContainer.getMethodDefinitions().size());
+        assertEquals(3, simpleContainer.getMethodDefinitions().size());
+        assertEquals(2, nestedContainer.getMethodDefinitions().size());
 
-        int methodsCount = 0;
-        for (final MethodSignature method : simpleContainer
-                .getMethodDefinitions()) {
-            if (method.getName().equals("getFoo")) {
-                method.getReturnType().getName().equals("Integer");
-                methodsCount++;
-            }
+        int getFooMethodCounter = 0;
+        int getBarMethodCounter = 0;
+        int getNestedContainerCounter = 0;
 
-            if (method.getName().equals("setFoo")) {
-                methodsCount++;
-                final MethodSignature.Parameter param = method.getParameters()
-                        .get(0);
-                assertEquals("foo", param.getName());
-                assertEquals("Integer", param.getType().getName());
+        String getFooMethodReturnTypeName = "";
+        String getBarMethodReturnTypeName = "";
+        String getNestedContainerReturnTypeName = "";
+        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
             }
 
             if (method.getName().equals("getBar")) {
-                method.getReturnType().getName().equals("String");
-                methodsCount++;
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
             }
 
             if (method.getName().equals("getNestedContainer")) {
-                method.getReturnType().getName().equals("NestedContainer");
-                methodsCount++;
+                getNestedContainerCounter++;
+                getNestedContainerReturnTypeName = method.getReturnType().getName();
             }
         }
-        assertEquals(4, methodsCount);
 
-        methodsCount = 0;
-        for (final MethodSignature method : nestedContainer
-                .getMethodDefinitions()) {
-            if (method.getName().equals("getFoo")) {
-                method.getReturnType().getName().equals("Short");
-                methodsCount++;
-            }
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Integer", getFooMethodReturnTypeName);
 
-            if (method.getName().equals("setFoo")) {
-                methodsCount++;
-                final MethodSignature.Parameter param = method.getParameters()
-                        .get(0);
-                assertEquals("foo", param.getName());
-                assertEquals("Short", param.getType().getName());
-            }
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
 
-            if (method.getName().equals("getBar")) {
-                method.getReturnType().getName().equals("String");
-                methodsCount++;
+        assertEquals(1, getNestedContainerCounter);
+        assertEquals("NestedContainer", getNestedContainerReturnTypeName);
+
+        getFooMethodCounter = 0;
+        getBarMethodCounter = 0;
+
+        getFooMethodReturnTypeName = "";
+        getBarMethodReturnTypeName = "";
+
+        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
+
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
             }
 
-            if (method.getName().equals("setBar")) {
-                method.getReturnType().getName().equals("String");
-                methodsCount++;
+            if (method.getName().equals("getBar")) {
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
             }
         }
-        assertEquals(4, methodsCount);
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Short", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
     }
 
     @Test
     public void testLeafListResolving() {
-        final String filePath = getClass().getResource(
-                "/simple-leaf-list-demo.yang").getPath();
+        final String filePath = getClass().getResource("/simple-leaf-list-demo.yang").getPath();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
-        assertTrue(context != null);
+        assertNotNull(context);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(3, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(4, genTypes.size());
 
-        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
-        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
+        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
+        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
 
         assertEquals("SimpleContainer", simpleContainer.getName());
         assertEquals("NestedContainer", nestedContainer.getName());
-        assertEquals(5, simpleContainer.getMethodDefinitions().size());
-        assertEquals(3, nestedContainer.getMethodDefinitions().size());
+        assertEquals(3, simpleContainer.getMethodDefinitions().size());
+        assertEquals(2, nestedContainer.getMethodDefinitions().size());
 
-        int methodsCount = 0;
-        for (final MethodSignature method : simpleContainer
-                .getMethodDefinitions()) {
-            if (method.getName().equals("getFoo")) {
-                method.getReturnType().getName().equals("List");
-                methodsCount++;
-            }
+        int getFooMethodCounter = 0;
+        int getBarMethodCounter = 0;
+        int getNestedContainerCounter = 0;
 
-            if (method.getName().equals("setFoo")) {
-                methodsCount++;
-                final MethodSignature.Parameter param = method.getParameters()
-                        .get(0);
-                assertEquals("foo", param.getName());
-                assertEquals("List", param.getType().getName());
+        String getFooMethodReturnTypeName = "";
+        String getBarMethodReturnTypeName = "";
+        String getNestedContainerReturnTypeName = "";
+        for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
             }
 
             if (method.getName().equals("getBar")) {
-                method.getReturnType().getName().equals("String");
-                methodsCount++;
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
             }
 
             if (method.getName().equals("getNestedContainer")) {
-                method.getReturnType().getName().equals("NestedContainer");
-                methodsCount++;
+                getNestedContainerCounter++;
+                getNestedContainerReturnTypeName = method.getReturnType().getName();
             }
         }
-        assertEquals(4, methodsCount);
 
-        methodsCount = 0;
-        for (final MethodSignature method : nestedContainer
-                .getMethodDefinitions()) {
-            if (method.getName().equals("getFoo")) {
-                method.getReturnType().getName().equals("Short");
-                methodsCount++;
-            }
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("List", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("String", getBarMethodReturnTypeName);
 
-            if (method.getName().equals("setFoo")) {
-                methodsCount++;
-                final MethodSignature.Parameter param = method.getParameters()
-                        .get(0);
-                assertEquals("foo", param.getName());
-                assertEquals("Short", param.getType().getName());
+        assertEquals(1, getNestedContainerCounter);
+        assertEquals("NestedContainer", getNestedContainerReturnTypeName);
+
+        getFooMethodCounter = 0;
+        getBarMethodCounter = 0;
+
+        getFooMethodReturnTypeName = "";
+        getBarMethodReturnTypeName = "";
+
+        for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
+            if (method.getName().equals("getFoo")) {
+                getFooMethodCounter++;
+                getFooMethodReturnTypeName = method.getReturnType().getName();
             }
 
             if (method.getName().equals("getBar")) {
-                method.getReturnType().getName().equals("List");
-                methodsCount++;
+                getBarMethodCounter++;
+                getBarMethodReturnTypeName = method.getReturnType().getName();
             }
         }
-        assertEquals(3, methodsCount);
+
+        assertEquals(1, getFooMethodCounter);
+        assertEquals("Short", getFooMethodReturnTypeName);
+
+        assertEquals(1, getBarMethodCounter);
+        assertEquals("List", getBarMethodReturnTypeName);
     }
 
     @Test
     public void testListResolving() {
-        final String filePath = getClass()
-                .getResource("/simple-list-demo.yang").getPath();
+        final String filePath = getClass().getResource("/simple-list-demo.yang").getPath();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
-        assertTrue(context != null);
+        assertNotNull(context);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(5, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(6, genTypes.size());
+
+        int listParentContainerMethodsCount = 0;
+        int simpleListMethodsCount = 0;
+        int listChildContainerMethodsCount = 0;
+        int listKeyClassCount = 0;
+
+        int getSimpleListKeyMethodCount = 0;
+        int getListChildContainerMethodCount = 0;
+        int getFooMethodCount = 0;
+        int setFooMethodCount = 0;
+        int getSimpleLeafListMethodCount = 0;
+        int setSimpleLeafListMethodCount = 0;
+        int getBarMethodCount = 0;
+
+        String getSimpleListKeyMethodReturnTypeName = "";
+        String getListChildContainerMethodReturnTypeName = "";
+
+        int listKeyClassPropertyCount = 0;
+        String listKeyClassPropertyName = "";
+        String listKeyClassPropertyTypeName = "";
+        boolean listKeyClassPropertyReadOnly = false;
+
+        int hashMethodParameterCount = 0;
+        String hashMethodParameterName = "";
+        String hashMethodParameterReturnTypeName = "";
+
+        int equalMethodParameterCount = 0;
+        String equalMethodParameterName = "";
+        String equalMethodParameterReturnTypeName = "";
 
-        int genTypesCount = 0;
-        int genTOsCount = 0;
         for (final Type type : genTypes) {
             if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
-                    assertEquals(2, genType.getMethodDefinitions().size());
-                    genTypesCount++;
+                    listParentContainerMethodsCount = genType.getMethodDefinitions().size();
                 } else if (genType.getName().equals("SimpleList")) {
-                    assertEquals(8, genType.getMethodDefinitions().size());
-                    final List<MethodSignature> methods = genType
-                            .getMethodDefinitions();
-                    int methodsCount = 0;
+                    simpleListMethodsCount = genType.getMethodDefinitions().size();
+                    final List<MethodSignature> methods = genType.getMethodDefinitions();
                     for (final MethodSignature method : methods) {
                         if (method.getName().equals("getSimpleListKey")) {
-                            assertEquals("SimpleListKey", method
-                                    .getReturnType().getName());
-                            methodsCount++;
-                        } else if (method.getName().equals(
-                                "getListChildContainer")) {
-                            assertEquals("ListChildContainer", method
-                                    .getReturnType().getName());
-                            methodsCount++;
+                            getSimpleListKeyMethodCount++;
+                            getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();
+                        } else if (method.getName().equals("getListChildContainer")) {
+                            getListChildContainerMethodCount++;
+                            getListChildContainerMethodReturnTypeName = method.getReturnType().getName();
                         } else if (method.getName().equals("getFoo")) {
-                            methodsCount++;
+                            getFooMethodCount++;
                         } else if (method.getName().equals("setFoo")) {
-                            methodsCount++;
+                            setFooMethodCount++;
                         } else if (method.getName().equals("getSimpleLeafList")) {
-                            methodsCount++;
+                            getSimpleLeafListMethodCount++;
                         } else if (method.getName().equals("setSimpleLeafList")) {
-                            methodsCount++;
+                            setSimpleLeafListMethodCount++;
                         } else if (method.getName().equals("getBar")) {
-                            methodsCount++;
+                            getBarMethodCount++;
                         }
                     }
-                    assertEquals(7, methodsCount);
-                    genTypesCount++;
                 } else if (genType.getName().equals("ListChildContainer")) {
-                    assertEquals(2, genType.getMethodDefinitions().size());
-                    genTypesCount++;
+                    listChildContainerMethodsCount = genType.getMethodDefinitions().size();
                 }
             } else if (type instanceof GeneratedTransferObject) {
-                genTOsCount++;
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-                final List<GeneratedProperty> properties = genTO
-                        .getProperties();
-                final List<GeneratedProperty> hashProps = genTO
-                        .getHashCodeIdentifiers();
-                final List<GeneratedProperty> equalProps = genTO
-                        .getEqualsIdentifiers();
-
-                assertEquals(1, properties.size());
-                assertEquals("ListKey", properties.get(0).getName());
-                assertEquals("Byte", properties.get(0).getReturnType()
-                        .getName());
-                assertEquals(true, properties.get(0).isReadOnly());
-                assertEquals(1, hashProps.size());
-                assertEquals("ListKey", hashProps.get(0).getName());
-                assertEquals("Byte", hashProps.get(0).getReturnType().getName());
-                assertEquals(1, equalProps.size());
-                assertEquals("ListKey", equalProps.get(0).getName());
-                assertEquals("Byte", equalProps.get(0).getReturnType()
-                        .getName());
+                final List<GeneratedProperty> properties = genTO.getProperties();
+                final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();
+                final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();
+
+                listKeyClassCount++;
+                listKeyClassPropertyCount = properties.size();
+                listKeyClassPropertyName = properties.get(0).getName();
+                listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();
+                listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();
+
+                hashMethodParameterCount = hashProps.size();
+                hashMethodParameterName = hashProps.get(0).getName();
+                hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();
+
+                equalMethodParameterCount = equalProps.size();
+                equalMethodParameterName = equalProps.get(0).getName();
+                equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();
+
             }
         }
-        assertEquals(3, genTypesCount);
-        assertEquals(1, genTOsCount);
+
+        assertEquals(1, listParentContainerMethodsCount);
+        assertEquals(1, listChildContainerMethodsCount);
+        assertEquals(1, getSimpleListKeyMethodCount);
+        assertEquals(1, listKeyClassCount);
+
+        assertEquals(1, listKeyClassPropertyCount);
+        assertEquals("ListKey", listKeyClassPropertyName);
+        assertEquals("Byte", listKeyClassPropertyTypeName);
+        assertEquals(true, listKeyClassPropertyReadOnly);
+        assertEquals(1, hashMethodParameterCount);
+        assertEquals("ListKey", hashMethodParameterName);
+        assertEquals("Byte", hashMethodParameterReturnTypeName);
+        assertEquals(1, equalMethodParameterCount);
+        assertEquals("ListKey", equalMethodParameterName);
+        assertEquals("Byte", equalMethodParameterReturnTypeName);
+
+        assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);
+
+        assertEquals(1, getListChildContainerMethodCount);
+        assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);
+        assertEquals(1, getFooMethodCount);
+        assertEquals(0, setFooMethodCount);
+        assertEquals(1, getSimpleLeafListMethodCount);
+        assertEquals(0, setSimpleLeafListMethodCount);
+        assertEquals(1, getBarMethodCount);
+
+        assertEquals(5, simpleListMethodsCount);
     }
 
     @Test
     public void testListCompositeKeyResolving() {
-        final String filePath = getClass().getResource(
-                "/list-composite-key.yang").getPath();
+        final String filePath = getClass().getResource("/list-composite-key.yang").getPath();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
 
-        assertTrue(context != null);
+        assertNotNull(context);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(7, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(8, genTypes.size());
 
         int genTypesCount = 0;
         int genTOsCount = 0;
+
+        int compositeKeyListKeyPropertyCount = 0;
+        int compositeKeyListKeyCount = 0;
+        int innerListKeyPropertyCount = 0;
+
         for (final Type type : genTypes) {
             if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
@@ -508,43 +559,43 @@ public class GeneratedTypesTest {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
 
                 if (genTO.getName().equals("CompositeKeyListKey")) {
-                    final List<GeneratedProperty> properties = genTO
-                            .getProperties();
-                    int propertyCount = 0;
+                    compositeKeyListKeyCount++;
+                    final List<GeneratedProperty> properties = genTO.getProperties();
                     for (final GeneratedProperty prop : properties) {
                         if (prop.getName().equals("Key1")) {
-                            propertyCount++;
+                            compositeKeyListKeyPropertyCount++;
                         } else if (prop.getName().equals("Key2")) {
-                            propertyCount++;
+                            compositeKeyListKeyPropertyCount++;
                         }
                     }
-                    assertEquals(2, propertyCount);
                     genTOsCount++;
                 } else if (genTO.getName().equals("InnerListKey")) {
-                    final List<GeneratedProperty> properties = genTO
-                            .getProperties();
-                    assertEquals(1, properties.size());
+                    final List<GeneratedProperty> properties = genTO.getProperties();
+                    innerListKeyPropertyCount = properties.size();
                     genTOsCount++;
                 }
             }
         }
+        assertEquals(1, compositeKeyListKeyCount);
+        assertEquals(2, compositeKeyListKeyPropertyCount);
+
+        assertEquals(1, innerListKeyPropertyCount);
 
-        assertEquals(5, genTypesCount);
+        assertEquals(6, genTypesCount);
         assertEquals(2, genTOsCount);
     }
 
     @Test
     public void testGeneratedTypes() {
-        final String filePath = getClass().getResource("/demo-topology.yang")
-                .getPath();
+        final String filePath = getClass().getResource("/demo-topology.yang").getPath();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
-        assertTrue(context != null);
+        assertNotNull(context);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertTrue(genTypes != null);
-        assertEquals(14, genTypes.size());
+        assertNotNull(genTypes);
+        assertEquals(15, genTypes.size());
 
         int genTypesCount = 0;
         int genTOsCount = 0;
@@ -556,7 +607,7 @@ public class GeneratedTypesTest {
             }
         }
 
-        assertEquals(11, genTypesCount);
+        assertEquals(12, genTypesCount);
         assertEquals(3, genTOsCount);
     }
 }