2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.generator.impl;
10 import static org.junit.Assert.assertEquals;
12 import java.util.List;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
16 public class Mdsal810Test {
18 public void testKeyConflict() {
19 assertGeneratedNames("key-conflict.yang",
20 "org.opendaylight.yang.gen.v1.key.conflict.norev.KeyConflictData",
21 "org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LI",
22 "org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LIKey",
23 "org.opendaylight.yang.gen.v1.key.conflict.norev.FooKey$CO");
27 public void testListenerConflict() {
28 assertGeneratedNames("listener-conflict.yang",
29 "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictData",
30 "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictListener",
31 "org.opendaylight.yang.gen.v1.listener.conflict.norev.Bar");
35 public void testRootConflict() {
36 assertGeneratedNames("root-conflict.yang",
37 "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData",
38 "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData$CO");
42 public void testServiceConflict() {
43 assertGeneratedNames("service-conflict.yang",
44 "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictData",
45 "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictService",
46 "org.opendaylight.yang.gen.v1.service.conflict.norev.Bar",
47 "org.opendaylight.yang.gen.v1.service.conflict.norev.BarInput",
48 "org.opendaylight.yang.gen.v1.service.conflict.norev.BarOutput");
52 public void testInputOutputConflict() {
53 assertGeneratedNames("io-conflict.yang",
54 "org.opendaylight.yang.gen.v1.io.conflict.norev.IoConflictData",
55 "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RP",
56 "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RPInput",
57 "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RPOutput",
58 "org.opendaylight.yang.gen.v1.io.conflict.norev.FooInput",
59 "org.opendaylight.yang.gen.v1.io.conflict.norev.FooOutput");
63 public void testSchemaCollisions() {
64 assertGeneratedNames("schema-conflict.yang",
65 "org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictData",
66 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AD",
67 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AX",
68 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$CO",
69 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$LI",
70 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$NO",
71 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RP",
72 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RPInput",
73 "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RPOutput");
76 private static void assertGeneratedNames(final String yangFile, final String... fqcns) {
77 assertEquals(List.of(fqcns),
78 DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal-810/" + yangFile))
79 .stream().map(type -> type.getIdentifier().toString()).toList());