- @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(1);
- assertTrue(type instanceof GeneratedTransferObject);
-
- final GeneratedTransferObject genTransObj = (GeneratedTransferObject) type;
- final List<GeneratedProperty> properties = genTransObj.getProperties();
- assertNotNull(properties);
- assertEquals(1, properties.size());
-
- GeneratedProperty property = properties.get(0);
- assertNotNull(property);
- assertNotNull(property.getReturnType());
-
- assertTrue(property.getReturnType() instanceof Enumeration);
- final Enumeration enumer = (Enumeration) property.getReturnType();
- assertEquals(272, enumer.getValues().size());
- }
-