Merge "OF plugin classes must have a strict dependency on Connection Service"
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / test / java / org / opendaylight / controller / sal / binding / generator / impl / GeneratedTypesTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.binding.generator.impl;
9
10 import static org.junit.Assert.*;
11
12 import java.io.File;
13 import java.util.ArrayList;
14 import java.util.List;
15 import java.util.Set;
16
17 import org.junit.Test;
18 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
19 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
20 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
21 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
22 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
23 import org.opendaylight.controller.sal.binding.model.api.Type;
24 import org.opendaylight.yangtools.yang.model.api.Module;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
26 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
27 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
28
29 public class GeneratedTypesTest {
30
31     private SchemaContext resolveSchemaContextFromFiles(final String... yangFiles) {
32         final YangModelParser parser = new YangParserImpl();
33
34         final List<File> inputFiles = new ArrayList<File>();
35         for (int i = 0; i < yangFiles.length; ++i) {
36             inputFiles.add(new File(yangFiles[i]));
37         }
38
39         final Set<Module> modules = parser.parseYangModels(inputFiles);
40         return parser.resolveSchemaContext(modules);
41     }
42
43     @Test
44     public void testMultipleModulesResolving() {
45         final String topologyPath = getClass().getResource("/abstract-topology.yang").getPath();
46         final String typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").getPath();
47         final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
48         assertNotNull(context);
49
50         final BindingGenerator bindingGen = new BindingGeneratorImpl();
51         final List<Type> genTypes = bindingGen.generateTypes(context);
52
53         assertNotNull(genTypes);
54         assertEquals(29, genTypes.size());
55     }
56
57     @Test
58     public void testLeafrefResolving() {
59         final String topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
60                 .getPath();
61         final String interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
62                 .getPath();
63         // final String ifTypePath = getClass().getResource(
64         // "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
65         final String inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")
66                 .getPath();
67         final String yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")
68                 .getPath();
69
70         assertNotNull(topologyPath);
71         assertNotNull(interfacesPath);
72         // assertTrue(ifTypePath != null);
73         assertNotNull(inetTypesPath);
74         assertNotNull(yangTypesPath);
75
76         // final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, ifTypePath,
77         // inetTypesPath, yangTypesPath);
78         final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,
79                 yangTypesPath);
80         assertNotNull(context);
81         assertEquals(4, context.getModules().size());
82
83         final BindingGenerator bindingGen = new BindingGeneratorImpl();
84         final List<Type> genTypes = bindingGen.generateTypes(context);
85
86         assertEquals(57, genTypes.size());
87         assertNotNull(genTypes);
88
89         GeneratedTransferObject gtIfcKey = null;
90         GeneratedType gtIfc = null;
91         GeneratedType gtNetworkLink = null;
92         GeneratedType gtSource = null;
93         GeneratedType gtDest = null;
94         GeneratedType gtTunnel = null;
95         GeneratedTransferObject gtTunnelKey = null;
96         GeneratedType gtTopology = null;
97         for (final Type type : genTypes) {
98             String name = type.getName();
99             if ("InterfaceKey".equals(name)) {
100                 gtIfcKey = (GeneratedTransferObject) type;
101             } else if ("Interface".equals(name)) {
102                 gtIfc = (GeneratedType) type;
103             } else if ("NetworkLink".equals(name)) {
104                 gtNetworkLink = (GeneratedType) type;
105             } else if ("SourceNode".equals(name)) {
106                 gtSource = (GeneratedType) type;
107             } else if ("DestinationNode".equals(name)) {
108                 gtDest = (GeneratedType) type;
109             } else if ("Tunnel".equals(name)) {
110                 gtTunnel = (GeneratedType) type;
111             } else if ("TunnelKey".equals(name)) {
112                 gtTunnelKey = (GeneratedTransferObject) type;
113             } else if ("Topology".equals(name)) {
114                 gtTopology = (GeneratedType) type;
115             }
116         }
117
118         assertNotNull(gtIfcKey);
119         assertNotNull(gtIfc);
120         assertNotNull(gtNetworkLink);
121         assertNotNull(gtSource);
122         assertNotNull(gtDest);
123         assertNotNull(gtTunnel);
124         assertNotNull(gtTunnelKey);
125         assertNotNull(gtTopology);
126
127         // Topology
128         final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();
129         assertNotNull(gtTopoMethods);
130         MethodSignature condLeafref = null;
131         for (final MethodSignature method : gtTopoMethods) {
132             if (method.getName().equals("getCondLeafref")) {
133                 condLeafref = method;
134             }
135         }
136         assertNotNull(condLeafref);
137         Type condLeafRT = condLeafref.getReturnType();
138         assertNotNull(condLeafRT);
139         assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());
140
141         // InterfaceId
142         final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
143         assertNotNull(gtIfcKeyProps);
144         GeneratedProperty ifcIdProp = null;
145         for (final GeneratedProperty property : gtIfcKeyProps) {
146             if (property.getName().equals("InterfaceId")) {
147                 ifcIdProp = property;
148             }
149         }
150         assertNotNull(ifcIdProp);
151         Type ifcIdPropType = ifcIdProp.getReturnType();
152         assertNotNull(ifcIdPropType);
153         assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());
154
155         // Interface
156         final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
157         assertNotNull(gtIfcMethods);
158         MethodSignature getIfcKey = null;
159         MethodSignature getHigherLayerIf = null;
160         for (final MethodSignature method : gtIfcMethods) {
161             if (method.getName().equals("getInterfaceKey")) {
162                 getIfcKey = method;
163             } else if (method.getName().equals("getHigherLayerIf")) {
164                 getHigherLayerIf = method;
165             }
166         }
167         assertNotNull(getIfcKey);
168         Type getIfcKeyType = getIfcKey.getReturnType();
169         assertNotNull(getIfcKeyType);
170         assertNotSame("java.lang.Void", getIfcKeyType);
171         assertEquals("InterfaceKey", getIfcKeyType.getName());
172
173         assertNotNull(getHigherLayerIf);
174         Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
175         assertNotNull(getHigherLayerIfType);
176         assertNotSame("java.lang.Void", getHigherLayerIfType);
177         assertEquals("List", getHigherLayerIfType.getName());
178
179         // NetworkLink
180         final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
181         assertNotNull(gtNetworkLinkMethods);
182         MethodSignature getIfc = null;
183         for (MethodSignature method : gtNetworkLinkMethods) {
184             if (method.getName().equals("getInterface")) {
185                 getIfc = method;
186             }
187         }
188         assertNotNull(getIfc);
189         Type getIfcType = getIfc.getReturnType();
190         assertNotNull(getIfcType);
191         assertNotSame("java.lang.Void", getIfcType);
192         assertEquals("String", getIfcType.getName());
193
194         // SourceNode
195         final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();
196         assertNotNull(gtSourceMethods);
197         MethodSignature getIdSource = null;
198         for (MethodSignature method : gtSourceMethods) {
199             if (method.getName().equals("getId")) {
200                 getIdSource = method;
201             }
202         }
203         assertNotNull(getIdSource);
204         Type getIdType = getIdSource.getReturnType();
205         assertNotNull(getIdType);
206         assertNotSame("java.lang.Void", getIdType);
207         assertEquals("Uri", getIdType.getName());
208
209         // DestinationNode
210         final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();
211         assertNotNull(gtDestMethods);
212         MethodSignature getIdDest = null;
213         for (MethodSignature method : gtDestMethods) {
214             if (method.getName().equals("getId")) {
215                 getIdDest = method;
216             }
217         }
218         assertNotNull(getIdDest);
219         Type getIdDestType = getIdDest.getReturnType();
220         assertNotNull(getIdDestType);
221         assertNotSame("java.lang.Void", getIdDestType);
222         assertEquals("Uri", getIdDestType.getName());
223
224         // Tunnel
225         final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();
226         assertNotNull(gtTunnelMethods);
227         MethodSignature getTunnelKey = null;
228         for (MethodSignature method : gtTunnelMethods) {
229             if (method.getName().equals("getTunnelKey")) {
230                 getTunnelKey = method;
231             }
232         }
233         assertNotNull(getTunnelKey);
234         Type getTunnelKeyType = getTunnelKey.getReturnType();
235         assertNotNull(getTunnelKeyType);
236         assertNotSame("java.lang.Void", getTunnelKeyType);
237         assertEquals("TunnelKey", getTunnelKeyType.getName());
238
239         // TunnelKey
240         final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();
241         assertNotNull(gtTunnelKeyProps);
242         GeneratedProperty tunnelId = null;
243         for (final GeneratedProperty property : gtTunnelKeyProps) {
244             if (property.getName().equals("TunnelId")) {
245                 tunnelId = property;
246             }
247         }
248         assertNotNull(tunnelId);
249         Type tunnelIdType = tunnelId.getReturnType();
250         assertNotNull(tunnelIdType);
251         assertNotSame("java.lang.Void", tunnelIdType);
252         assertEquals("Uri", tunnelIdType.getName());
253     }
254
255     @Test
256     public void testContainerResolving() {
257         final String filePath = getClass().getResource("/simple-container-demo.yang").getPath();
258         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
259         assert (context != null);
260
261         final BindingGenerator bindingGen = new BindingGeneratorImpl();
262         final List<Type> genTypes = bindingGen.generateTypes(context);
263
264         assertNotNull(genTypes);
265         assertEquals(4, genTypes.size());
266
267         final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
268         final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
269
270         assertEquals("SimpleContainer", simpleContainer.getName());
271         assertEquals("NestedContainer", nestedContainer.getName());
272         assertEquals(3, simpleContainer.getMethodDefinitions().size());
273         assertEquals(2, nestedContainer.getMethodDefinitions().size());
274
275         int getFooMethodCounter = 0;
276         int getBarMethodCounter = 0;
277         int getNestedContainerCounter = 0;
278
279         String getFooMethodReturnTypeName = "";
280         String getBarMethodReturnTypeName = "";
281         String getNestedContainerReturnTypeName = "";
282         for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
283             if (method.getName().equals("getFoo")) {
284                 getFooMethodCounter++;
285                 getFooMethodReturnTypeName = method.getReturnType().getName();
286             }
287
288             if (method.getName().equals("getBar")) {
289                 getBarMethodCounter++;
290                 getBarMethodReturnTypeName = method.getReturnType().getName();
291             }
292
293             if (method.getName().equals("getNestedContainer")) {
294                 getNestedContainerCounter++;
295                 getNestedContainerReturnTypeName = method.getReturnType().getName();
296             }
297         }
298
299         assertEquals(1, getFooMethodCounter);
300         assertEquals("Integer", getFooMethodReturnTypeName);
301
302         assertEquals(1, getBarMethodCounter);
303         assertEquals("String", getBarMethodReturnTypeName);
304
305         assertEquals(1, getNestedContainerCounter);
306         assertEquals("NestedContainer", getNestedContainerReturnTypeName);
307
308         getFooMethodCounter = 0;
309         getBarMethodCounter = 0;
310
311         getFooMethodReturnTypeName = "";
312         getBarMethodReturnTypeName = "";
313
314         for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
315
316             if (method.getName().equals("getFoo")) {
317                 getFooMethodCounter++;
318                 getFooMethodReturnTypeName = method.getReturnType().getName();
319             }
320
321             if (method.getName().equals("getBar")) {
322                 getBarMethodCounter++;
323                 getBarMethodReturnTypeName = method.getReturnType().getName();
324             }
325         }
326
327         assertEquals(1, getFooMethodCounter);
328         assertEquals("Short", getFooMethodReturnTypeName);
329
330         assertEquals(1, getBarMethodCounter);
331         assertEquals("String", getBarMethodReturnTypeName);
332     }
333
334     @Test
335     public void testLeafListResolving() {
336         final String filePath = getClass().getResource("/simple-leaf-list-demo.yang").getPath();
337         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
338         assertNotNull(context);
339
340         final BindingGenerator bindingGen = new BindingGeneratorImpl();
341         final List<Type> genTypes = bindingGen.generateTypes(context);
342
343         assertNotNull(genTypes);
344         assertEquals(4, genTypes.size());
345
346         final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
347         final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
348
349         assertEquals("SimpleContainer", simpleContainer.getName());
350         assertEquals("NestedContainer", nestedContainer.getName());
351         assertEquals(3, simpleContainer.getMethodDefinitions().size());
352         assertEquals(2, nestedContainer.getMethodDefinitions().size());
353
354         int getFooMethodCounter = 0;
355         int getBarMethodCounter = 0;
356         int getNestedContainerCounter = 0;
357
358         String getFooMethodReturnTypeName = "";
359         String getBarMethodReturnTypeName = "";
360         String getNestedContainerReturnTypeName = "";
361         for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
362             if (method.getName().equals("getFoo")) {
363                 getFooMethodCounter++;
364                 getFooMethodReturnTypeName = method.getReturnType().getName();
365             }
366
367             if (method.getName().equals("getBar")) {
368                 getBarMethodCounter++;
369                 getBarMethodReturnTypeName = method.getReturnType().getName();
370             }
371
372             if (method.getName().equals("getNestedContainer")) {
373                 getNestedContainerCounter++;
374                 getNestedContainerReturnTypeName = method.getReturnType().getName();
375             }
376         }
377
378         assertEquals(1, getFooMethodCounter);
379         assertEquals("List", getFooMethodReturnTypeName);
380
381         assertEquals(1, getBarMethodCounter);
382         assertEquals("String", getBarMethodReturnTypeName);
383
384         assertEquals(1, getNestedContainerCounter);
385         assertEquals("NestedContainer", getNestedContainerReturnTypeName);
386
387         getFooMethodCounter = 0;
388         getBarMethodCounter = 0;
389
390         getFooMethodReturnTypeName = "";
391         getBarMethodReturnTypeName = "";
392
393         for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
394             if (method.getName().equals("getFoo")) {
395                 getFooMethodCounter++;
396                 getFooMethodReturnTypeName = method.getReturnType().getName();
397             }
398
399             if (method.getName().equals("getBar")) {
400                 getBarMethodCounter++;
401                 getBarMethodReturnTypeName = method.getReturnType().getName();
402             }
403         }
404
405         assertEquals(1, getFooMethodCounter);
406         assertEquals("Short", getFooMethodReturnTypeName);
407
408         assertEquals(1, getBarMethodCounter);
409         assertEquals("List", getBarMethodReturnTypeName);
410     }
411
412     @Test
413     public void testListResolving() {
414         final String filePath = getClass().getResource("/simple-list-demo.yang").getPath();
415         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
416         assertNotNull(context);
417
418         final BindingGenerator bindingGen = new BindingGeneratorImpl();
419         final List<Type> genTypes = bindingGen.generateTypes(context);
420
421         assertNotNull(genTypes);
422         assertEquals(6, genTypes.size());
423
424         int listParentContainerMethodsCount = 0;
425         int simpleListMethodsCount = 0;
426         int listChildContainerMethodsCount = 0;
427         int listKeyClassCount = 0;
428
429         int getSimpleListKeyMethodCount = 0;
430         int getListChildContainerMethodCount = 0;
431         int getFooMethodCount = 0;
432         int setFooMethodCount = 0;
433         int getSimpleLeafListMethodCount = 0;
434         int setSimpleLeafListMethodCount = 0;
435         int getBarMethodCount = 0;
436
437         String getSimpleListKeyMethodReturnTypeName = "";
438         String getListChildContainerMethodReturnTypeName = "";
439
440         int listKeyClassPropertyCount = 0;
441         String listKeyClassPropertyName = "";
442         String listKeyClassPropertyTypeName = "";
443         boolean listKeyClassPropertyReadOnly = false;
444
445         int hashMethodParameterCount = 0;
446         String hashMethodParameterName = "";
447         String hashMethodParameterReturnTypeName = "";
448
449         int equalMethodParameterCount = 0;
450         String equalMethodParameterName = "";
451         String equalMethodParameterReturnTypeName = "";
452
453         for (final Type type : genTypes) {
454             if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
455                 final GeneratedType genType = (GeneratedType) type;
456                 if (genType.getName().equals("ListParentContainer")) {
457                     listParentContainerMethodsCount = genType.getMethodDefinitions().size();
458                 } else if (genType.getName().equals("SimpleList")) {
459                     simpleListMethodsCount = genType.getMethodDefinitions().size();
460                     final List<MethodSignature> methods = genType.getMethodDefinitions();
461                     for (final MethodSignature method : methods) {
462                         if (method.getName().equals("getSimpleListKey")) {
463                             getSimpleListKeyMethodCount++;
464                             getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();
465                         } else if (method.getName().equals("getListChildContainer")) {
466                             getListChildContainerMethodCount++;
467                             getListChildContainerMethodReturnTypeName = method.getReturnType().getName();
468                         } else if (method.getName().equals("getFoo")) {
469                             getFooMethodCount++;
470                         } else if (method.getName().equals("setFoo")) {
471                             setFooMethodCount++;
472                         } else if (method.getName().equals("getSimpleLeafList")) {
473                             getSimpleLeafListMethodCount++;
474                         } else if (method.getName().equals("setSimpleLeafList")) {
475                             setSimpleLeafListMethodCount++;
476                         } else if (method.getName().equals("getBar")) {
477                             getBarMethodCount++;
478                         }
479                     }
480                 } else if (genType.getName().equals("ListChildContainer")) {
481                     listChildContainerMethodsCount = genType.getMethodDefinitions().size();
482                 }
483             } else if (type instanceof GeneratedTransferObject) {
484                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
485                 final List<GeneratedProperty> properties = genTO.getProperties();
486                 final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();
487                 final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();
488
489                 listKeyClassCount++;
490                 listKeyClassPropertyCount = properties.size();
491                 listKeyClassPropertyName = properties.get(0).getName();
492                 listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();
493                 listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();
494
495                 hashMethodParameterCount = hashProps.size();
496                 hashMethodParameterName = hashProps.get(0).getName();
497                 hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();
498
499                 equalMethodParameterCount = equalProps.size();
500                 equalMethodParameterName = equalProps.get(0).getName();
501                 equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();
502
503             }
504         }
505
506         assertEquals(1, listParentContainerMethodsCount);
507         assertEquals(1, listChildContainerMethodsCount);
508         assertEquals(1, getSimpleListKeyMethodCount);
509         assertEquals(1, listKeyClassCount);
510
511         assertEquals(1, listKeyClassPropertyCount);
512         assertEquals("ListKey", listKeyClassPropertyName);
513         assertEquals("Byte", listKeyClassPropertyTypeName);
514         assertEquals(true, listKeyClassPropertyReadOnly);
515         assertEquals(1, hashMethodParameterCount);
516         assertEquals("ListKey", hashMethodParameterName);
517         assertEquals("Byte", hashMethodParameterReturnTypeName);
518         assertEquals(1, equalMethodParameterCount);
519         assertEquals("ListKey", equalMethodParameterName);
520         assertEquals("Byte", equalMethodParameterReturnTypeName);
521
522         assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);
523
524         assertEquals(1, getListChildContainerMethodCount);
525         assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);
526         assertEquals(1, getFooMethodCount);
527         assertEquals(0, setFooMethodCount);
528         assertEquals(1, getSimpleLeafListMethodCount);
529         assertEquals(0, setSimpleLeafListMethodCount);
530         assertEquals(1, getBarMethodCount);
531
532         assertEquals(5, simpleListMethodsCount);
533     }
534
535     @Test
536     public void testListCompositeKeyResolving() {
537         final String filePath = getClass().getResource("/list-composite-key.yang").getPath();
538         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
539
540         assertNotNull(context);
541
542         final BindingGenerator bindingGen = new BindingGeneratorImpl();
543         final List<Type> genTypes = bindingGen.generateTypes(context);
544
545         assertNotNull(genTypes);
546         assertEquals(8, genTypes.size());
547
548         int genTypesCount = 0;
549         int genTOsCount = 0;
550
551         int compositeKeyListKeyPropertyCount = 0;
552         int compositeKeyListKeyCount = 0;
553         int innerListKeyPropertyCount = 0;
554
555         for (final Type type : genTypes) {
556             if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
557                 genTypesCount++;
558             } else if (type instanceof GeneratedTransferObject) {
559                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
560
561                 if (genTO.getName().equals("CompositeKeyListKey")) {
562                     compositeKeyListKeyCount++;
563                     final List<GeneratedProperty> properties = genTO.getProperties();
564                     for (final GeneratedProperty prop : properties) {
565                         if (prop.getName().equals("Key1")) {
566                             compositeKeyListKeyPropertyCount++;
567                         } else if (prop.getName().equals("Key2")) {
568                             compositeKeyListKeyPropertyCount++;
569                         }
570                     }
571                     genTOsCount++;
572                 } else if (genTO.getName().equals("InnerListKey")) {
573                     final List<GeneratedProperty> properties = genTO.getProperties();
574                     innerListKeyPropertyCount = properties.size();
575                     genTOsCount++;
576                 }
577             }
578         }
579         assertEquals(1, compositeKeyListKeyCount);
580         assertEquals(2, compositeKeyListKeyPropertyCount);
581
582         assertEquals(1, innerListKeyPropertyCount);
583
584         assertEquals(6, genTypesCount);
585         assertEquals(2, genTOsCount);
586     }
587
588     @Test
589     public void testGeneratedTypes() {
590         final String filePath = getClass().getResource("/demo-topology.yang").getPath();
591         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
592         assertNotNull(context);
593
594         final BindingGenerator bindingGen = new BindingGeneratorImpl();
595         final List<Type> genTypes = bindingGen.generateTypes(context);
596
597         assertNotNull(genTypes);
598         assertEquals(15, genTypes.size());
599
600         int genTypesCount = 0;
601         int genTOsCount = 0;
602         for (final Type type : genTypes) {
603             if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
604                 genTypesCount++;
605             } else if (type instanceof GeneratedTransferObject) {
606                 genTOsCount++;
607             }
608         }
609
610         assertEquals(12, genTypesCount);
611         assertEquals(3, genTOsCount);
612     }
613 }