d9787d55b12c3dda5131e500300b86136d1a838e
[mdsal.git] / binding / mdsal-binding-generator-impl / src / test / java / org / opendaylight / mdsal / binding / generator / impl / Mdsal335Test.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.generator.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
17 import org.opendaylight.mdsal.binding.model.api.Type;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
20
21 public class Mdsal335Test {
22     @Test
23     public void mdsal335Test() {
24         final SchemaContext context = YangParserTestUtils.parseYangResource("/mdsal335.yang");
25
26         final List<Type> generateTypes = DefaultBindingGenerator.generateFor(context);
27         assertNotNull(generateTypes);
28         assertEquals(2, generateTypes.size());
29
30         final Type nozoneType = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
31             .equals("org.opendaylight.yang.gen.v1.mdsal335.norev.Ipv4AddressNoZone")).findFirst().get();
32
33         assertTrue(nozoneType instanceof GeneratedType);
34         final GeneratedType gen = (GeneratedType) nozoneType;
35         assertEquals(1, gen.getConstantDefinitions().size());
36     }
37 }