862a163d8c289e6f4c8dccb08679077ee5d25290
[mdsal.git] / binding / mdsal-binding-generator-impl / src / test / java / org / opendaylight / mdsal / binding / generator / impl / Mdsal332Test.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
13 import com.google.common.collect.ImmutableList;
14 import com.google.common.collect.ImmutableSet;
15 import java.util.List;
16 import java.util.Set;
17 import org.junit.Test;
18 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
19 import org.opendaylight.mdsal.binding.model.api.Type;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
22
23 public class Mdsal332Test {
24     @Test
25     public void mdsal332Test() {
26         final SchemaContext context = YangParserTestUtils.parseYangResource("/mdsal332.yang");
27
28         final List<Type> generateTypes = DefaultBindingGenerator.generateFor(context);
29         assertNotNull(generateTypes);
30         assertEquals(5, generateTypes.size());
31
32         final List<JavaTypeName> names = generateTypes.stream().map(Type::getIdentifier)
33                 .collect(ImmutableList.toImmutableList());
34         final Set<JavaTypeName> uniqueNames = ImmutableSet.copyOf(names);
35         assertEquals(ImmutableList.copyOf(uniqueNames), names);
36     }
37 }