X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmdsal-binding-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fgenerator%2Fimpl%2FMdsal810Test.java;fp=binding%2Fmdsal-binding-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fgenerator%2Fimpl%2FMdsal810Test.java;h=18eb5307fb5e75fca69d4cc8104862c62a1b110c;hb=f95f86719bb99367294c2694872aa727778bd458;hp=0000000000000000000000000000000000000000;hpb=5e2b5f9184beff37e898299339efa04bc343abec;p=mdsal.git diff --git a/binding/mdsal-binding-generator/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal810Test.java b/binding/mdsal-binding-generator/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal810Test.java new file mode 100644 index 0000000000..18eb5307fb --- /dev/null +++ b/binding/mdsal-binding-generator/src/test/java/org/opendaylight/mdsal/binding/generator/impl/Mdsal810Test.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.mdsal.binding.generator.impl; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import org.junit.Test; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; + +public class Mdsal810Test { + @Test + public void testKeyConflict() { + assertGeneratedNames("key-conflict.yang", + "org.opendaylight.yang.gen.v1.key.conflict.norev.KeyConflictData", + "org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LI", + "org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LIKey", + "org.opendaylight.yang.gen.v1.key.conflict.norev.FooKey$CO"); + } + + @Test + public void testListenerConflict() { + assertGeneratedNames("listener-conflict.yang", + "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictData", + "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictListener$CO", + "org.opendaylight.yang.gen.v1.listener.conflict.norev.Bar", + "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictListener"); + } + + @Test + public void testRootConflict() { + assertGeneratedNames("root-conflict.yang", + "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData", + "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData$CO"); + } + + @Test + public void testServiceConflict() { + assertGeneratedNames("service-conflict.yang", + "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictData", + "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictService$CO", + "org.opendaylight.yang.gen.v1.service.conflict.norev.Bar", + "org.opendaylight.yang.gen.v1.service.conflict.norev.BarInput", + "org.opendaylight.yang.gen.v1.service.conflict.norev.BarOutput", + "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictService"); + } + + @Test + public void testInputOutputConflict() { + assertGeneratedNames("io-conflict.yang", + "org.opendaylight.yang.gen.v1.io.conflict.norev.IoConflictData", + "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RP", + "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RPInput", + "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RPOutput", + "org.opendaylight.yang.gen.v1.io.conflict.norev.FooInput", + "org.opendaylight.yang.gen.v1.io.conflict.norev.FooOutput", + "org.opendaylight.yang.gen.v1.io.conflict.norev.IoConflictService"); + } + + @Test + public void testSchemaCollisions() { + assertGeneratedNames("schema-conflict.yang", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictData", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AD", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AX", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$CO", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$LI", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$NO", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RP", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RPInput", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$RPOutput", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictListener", + "org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictService"); + } + + private static void assertGeneratedNames(final String yangFile, final String... fqcns) { + assertEquals(Arrays.asList(fqcns), + DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal-810/" + yangFile)) + .stream().map(type -> type.getIdentifier().toString()).toList()); + } +}