$YangModuleInfoImpl not generated for only extensions model
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / mdsal / binding / java / api / generator / test / CompilationTest.java
index e9d9802c45077a560095642b32ba4d114b18f10e..753ab98bdc06dc6643320659e2aefb3ba6ecaae4 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Range;
 import java.io.File;
@@ -30,15 +31,12 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 import org.junit.Test;
-import org.opendaylight.mdsal.binding.java.api.generator.GeneratorJavaFile;
-import org.opendaylight.mdsal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.binding.ChildOf;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+import org.opendaylight.yangtools.yang.common.Empty;
 
 /**
  * Test correct code generation.
@@ -53,7 +51,8 @@ public class CompilationTest extends BaseCompilationTest {
      */
     private static Collection<Method> abstractMethods(final Class<?> clazz) {
         // Filter out
-        return Collections2.filter(Arrays.asList(clazz.getDeclaredMethods()), input -> Modifier.isAbstract(input.getModifiers()));
+        return Collections2.filter(Arrays.asList(clazz.getDeclaredMethods()),
+            input -> Modifier.isAbstract(input.getModifiers()));
     }
 
     @Test
@@ -74,7 +73,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(linksBuilder.exists());
         assertTrue(linksKey.exists());
         assertTrue(testData.exists());
-        CompilationTestUtils.assertFilesCount(parent, 6);
+        CompilationTestUtils.assertFilesCount(parent, 7);
 
         parent = new File(sourcesOutputDir, CompilationTestUtils.NS_TEST + CompilationTestUtils.FS + "links");
         final File level = new File(parent, "Level.java");
@@ -91,27 +90,29 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(nodeList.exists());
         assertTrue(nodeListBuilder.exists());
         assertTrue(nodesType.exists());
-        CompilationTestUtils.assertFilesCount(parent, 7);
+        CompilationTestUtils.assertFilesCount(parent, 8);
 
         // Test if sources are compilable
         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
 
         final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
-        final Class<?> keyArgsClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.test.rev131008.KeyArgs", true, loader);
-        final Class<?> linksClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.test.rev131008.Links", true, loader);
-        final Class<?> linksKeyClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.test.rev131008.LinksKey", true, loader);
+        final Class<?> keyArgsClass = Class.forName(CompilationTestUtils.BASE_PKG
+            + ".urn.opendaylight.test.rev131008.KeyArgs", true, loader);
+        final Class<?> linksClass = Class.forName(CompilationTestUtils.BASE_PKG
+            + ".urn.opendaylight.test.rev131008.Links", true, loader);
+        final Class<?> linksKeyClass = Class.forName(CompilationTestUtils.BASE_PKG
+            + ".urn.opendaylight.test.rev131008.LinksKey", true, loader);
 
         // Test generated 'grouping key-args'
         assertTrue(keyArgsClass.isInterface());
         CompilationTestUtils.assertContainsMethod(keyArgsClass, String.class, "getName");
         CompilationTestUtils.assertContainsMethod(keyArgsClass, Integer.class, "getSize");
-        assertEquals(2, abstractMethods(keyArgsClass).size());
+        assertEquals(3, abstractMethods(keyArgsClass).size());
 
         // Test generated 'list links'
         assertTrue(linksClass.isInterface());
         CompilationTestUtils.assertImplementsIfc(linksClass, keyArgsClass);
-        // TODO: anyxml
-        assertEquals(6, abstractMethods(linksClass).size());
+        assertEquals(7, abstractMethods(linksClass).size());
 
         // Test list key constructor arguments ordering
         CompilationTestUtils.assertContainsConstructor(linksKeyClass, Byte.class, String.class, Integer.class);
@@ -136,7 +137,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(new File(parent, "OpenObject.java").exists());
         assertTrue(new File(parent, "ExplicitRouteObject.java").exists());
         assertTrue(new File(parent, "PathKeySubobject.java").exists());
-        CompilationTestUtils.assertFilesCount(parent, 9);
+        CompilationTestUtils.assertFilesCount(parent, 10);
 
         parent = new File(parent, "object");
         assertTrue(new File(parent, "Nodes.java").exists());
@@ -194,7 +195,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(new File(parent, "BasicExplicitRouteSubobjects.java").exists());
         assertTrue(new File(parent, "ExplicitRouteSubobjects.java").exists());
         assertTrue(new File(parent, "RouteSubobjects.java").exists());
-        CompilationTestUtils.assertFilesCount(parent, 5);
+        CompilationTestUtils.assertFilesCount(parent, 6);
 
         parent = new File(parent, "route");
         CompilationTestUtils.assertFilesCount(parent, 1);
@@ -241,7 +242,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(pathAttributes.exists());
         assertTrue(update.exists());
         assertTrue(updateBuilder.exists());
-        CompilationTestUtils.assertFilesCount(parent, 6);
+        CompilationTestUtils.assertFilesCount(parent, 7);
 
         parent = new File(sourcesOutputDir, CompilationTestUtils.NS_FOO + CompilationTestUtils.FS + "path");
         CompilationTestUtils.assertFilesCount(parent, 1);
@@ -267,7 +268,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(destination.exists());
         assertTrue(pathAttributes1.exists());
         assertTrue(pathAttributes1Builder.exists());
-        CompilationTestUtils.assertFilesCount(parent, 5);
+        CompilationTestUtils.assertFilesCount(parent, 6);
 
         parent = new File(sourcesOutputDir, CompilationTestUtils.NS_BAR + CompilationTestUtils.FS + "destination");
         CompilationTestUtils.assertFilesCount(parent, 2);
@@ -307,7 +308,7 @@ public class CompilationTest extends BaseCompilationTest {
 
         // Test if all sources were generated from 'module baz'
         parent = new File(sourcesOutputDir, CompilationTestUtils.NS_BAZ);
-        CompilationTestUtils.assertFilesCount(parent, 2);
+        CompilationTestUtils.assertFilesCount(parent, 3);
         final File linkstateDestination = new File(parent, "LinkstateDestination.java");
         assertTrue(linkstateDestination.exists());
 
@@ -374,7 +375,7 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(new File(parent, "NodesBuilder.java").exists());
         assertTrue(new File(parent, "Alg.java").exists());
         assertTrue(new File(parent, "NodesIdUnionBuilder.java").exists());
-        CompilationTestUtils.assertFilesCount(parent, 5);
+        CompilationTestUtils.assertFilesCount(parent, 6);
 
         // Test if sources are compilable
         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
@@ -390,7 +391,7 @@ public class CompilationTest extends BaseCompilationTest {
         CompilationTestUtils.assertContainsMethod(nodesClass, pkg + ".Nodes$IdBits", "getIdBits", loader);
         CompilationTestUtils.assertContainsMethod(nodesClass, Boolean.class, "isIdBoolean");
         CompilationTestUtils.assertContainsMethod(nodesClass, BigDecimal.class, "getIdDecimal64");
-        CompilationTestUtils.assertContainsMethod(nodesClass, Boolean.class, "isIdEmpty");
+        CompilationTestUtils.assertContainsMethod(nodesClass, Empty.class, "getIdEmpty");
         CompilationTestUtils.assertContainsMethod(nodesClass, pkg + ".Nodes$IdEnumeration", "getIdEnumeration", loader);
         testReturnTypeIdentityref(nodesClass, "getIdIdentityref", pkg + ".Alg");
         testReturnTypeInstanceIdentitifer(loader, nodesClass, "getIdInstanceIdentifier");
@@ -406,70 +407,70 @@ public class CompilationTest extends BaseCompilationTest {
         CompilationTestUtils.assertContainsMethod(nodesClass, BigInteger.class, "getIdU64");
         CompilationTestUtils.assertContainsMethod(nodesClass, pkg + ".Nodes$IdUnion", "getIdUnion", loader);
 
-        final Object builderObj = builderClass.newInstance();
+        final Object builderObj = builderClass.getDeclaredConstructor().newInstance();
 
-        Method m = CompilationTestUtils.assertContainsMethod(builderClass, builderClass, "setIdBinary", b.getClass());
+        Method method = CompilationTestUtils.assertContainsMethod(builderClass, builderClass, "setIdBinary",
+            b.getClass());
         final List<Range<Integer>> lengthConstraints = new ArrayList<>();
         lengthConstraints.add(Range.closed(1, 10));
         byte[] arg = new byte[] {};
-        String expectedMsg = String.format("Invalid length: %s, expected: %s.", Arrays.toString(arg), lengthConstraints);
-        CompilationTestUtils.assertContainsRestrictionCheck(builderObj, m, expectedMsg, arg);
+        String expectedMsg = String.format("Invalid length: %s, expected: %s.", Arrays.toString(arg),
+            lengthConstraints);
+        CompilationTestUtils.assertContainsRestrictionCheck(builderObj, method, expectedMsg, arg);
 
-        m = CompilationTestUtils.assertContainsMethod(builderClass, builderClass, "setIdDecimal64", BigDecimal.class);
+        method = CompilationTestUtils.assertContainsMethod(builderClass, builderClass, "setIdDecimal64",
+            BigDecimal.class);
         final List<Range<BigDecimal>> rangeConstraints = new ArrayList<>();
         rangeConstraints.add(Range.closed(new BigDecimal("1.5"), new BigDecimal("5.5")));
         Object arg1 = new BigDecimal("1.4");
         expectedMsg = String.format("Invalid range: %s, expected: %s.", arg1, rangeConstraints);
-        CompilationTestUtils.assertContainsRestrictionCheck(builderObj, m, expectedMsg, arg1);
+        CompilationTestUtils.assertContainsRestrictionCheck(builderObj, method, expectedMsg, arg1);
 
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
     @Test
-    public void testGenerationContextReferenceExtension() throws Exception {
+    public void testGenerationContextReferenceExtension() throws IOException, URISyntaxException,
+            ClassNotFoundException {
         final File sourcesOutputDir = CompilationTestUtils.generatorOutput("context-reference");
         final File compiledOutputDir = CompilationTestUtils.compilerOutput("context-reference");
         generateTestSources("/compilation/context-reference", sourcesOutputDir);
 
         // Test if all sources are generated
         final File fooParent = new File(sourcesOutputDir, CompilationTestUtils.NS_FOO);
-        CompilationTestUtils.assertFilesCount(fooParent, 3);
+        CompilationTestUtils.assertFilesCount(fooParent, 4);
         assertTrue(new File(fooParent, "FooData.java").exists());
         assertTrue(new File(fooParent, "Nodes.java").exists());
         assertTrue(new File(fooParent, "NodesBuilder.java").exists());
 
         final File barParent = new File(sourcesOutputDir, CompilationTestUtils.NS_BAR);
-        CompilationTestUtils.assertFilesCount(barParent, 1);
+        CompilationTestUtils.assertFilesCount(barParent, 2);
         assertTrue(new File(barParent, "IdentityClass.java").exists());
 
         // Test if sources are compilable
         CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
 
         final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
-        final Class<?> nodesClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.foo.rev131008.Nodes", true, loader);
+        final Class<?> nodesClass = Class.forName(CompilationTestUtils.BASE_PKG
+            + ".urn.opendaylight.foo.rev131008.Nodes", true, loader);
         final Class<?> identityClass = Class
                 .forName(CompilationTestUtils.BASE_PKG + ".urn.opendaylight.bar.rev131008.IdentityClass", true, loader);
 
         // test identity
-        try {
-            identityClass.getConstructor();
-            final Class<?> baseIdentity = Class.forName("org.opendaylight.yangtools.yang.binding.BaseIdentity", true, loader);
-            assertEquals(baseIdentity, identityClass.getSuperclass());
-        } catch (final NoSuchMethodException e) {
-            throw new AssertionError("IdentityClass must have no-arg constructor");
-        }
+        final Class<?> baseIdentity = Class.forName("org.opendaylight.yangtools.yang.binding.BaseIdentity", true,
+            loader);
+        assertEquals(ImmutableList.of(baseIdentity), Arrays.asList(identityClass.getInterfaces()));
 
         // Test annotation
+        final Method getId;
         try {
-            final Method getId = nodesClass.getMethod("getId");
-            final Annotation[] annotations = getId.getAnnotations();
-            assertEquals(1, annotations.length);
-            final Annotation routingContext = annotations[0];
-            assertEquals(RoutingContext.class, routingContext.annotationType());
+            getId = nodesClass.getMethod("getId");
         } catch (final NoSuchMethodException e) {
-            throw new AssertionError("Method getId() not found");
+            throw new AssertionError("Method getId() not found", e);
         }
 
+        assertEquals(ImmutableSet.of(RoutingContext.class), Arrays.stream(getId.getAnnotations())
+            .map(Annotation::annotationType).collect(Collectors.toSet()));
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
@@ -511,8 +512,6 @@ public class CompilationTest extends BaseCompilationTest {
 
     /**
      * Test handling nested uses-augmentations.
-     *
-     * @throws Exception
      */
     @Test
     public void testBug1172() throws Exception {
@@ -552,49 +551,48 @@ public class CompilationTest extends BaseCompilationTest {
         assertTrue(new File(parent, "TypedefCurrent.java").exists());
         assertTrue(new File(parent, "TypedefDeprecated.java").exists());
 
-        final String pkg = CompilationTestUtils.BASE_PKG + ".urn.yang.foo.rev160102";
-        final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
-        final Class<?> cls = loader.loadClass(pkg + ".FooData");
-        final Class<?> clsContainer = loader.loadClass(pkg + ".ContainerMain");
-        final Class<?> clsTypedefDepr = loader.loadClass(pkg + ".TypedefDeprecated");
-        final Class<?> clsTypedefCur = loader.loadClass(pkg + ".TypedefCurrent");
-        final Class<?> clsGroupingDepr = loader.loadClass(pkg + ".GroupingDeprecated");
-        final Class<?> clsGroupingCur = loader.loadClass(pkg + ".GroupingCurrent");
-        final Class<?> clsTypeDef1 = loader.loadClass(pkg + ".Typedef1");
-        final Class<?> clsTypeDef2 = loader.loadClass(pkg + ".Typedef2");
-        final Class<?> clsTypeDef3 = loader.loadClass(pkg + ".Typedef3");
-        assertTrue(clsTypedefDepr.getAnnotations()[0].toString().contains("Deprecated"));
-        assertTrue(clsTypedefCur.getAnnotations().length == 0);
-        assertTrue(clsGroupingDepr.getAnnotations()[0].toString().contains("Deprecated"));
-        assertTrue(clsGroupingCur.getAnnotations().length == 0);
-        assertTrue(clsTypeDef1.getAnnotations().length == 0);
-        assertTrue(clsTypeDef3.getAnnotations().length == 0);
-        assertTrue(clsTypeDef2.getAnnotations()[0].toString().contains("Deprecated"));
-
-        /*methods inside container*/
-        assertTrue(clsContainer.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
-        assertTrue(clsContainer.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
-        assertTrue(clsContainer.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
-        assertFalse(clsContainer.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
-        assertFalse(clsContainer.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
-        assertFalse(clsContainer.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
-
-        /*methods inside module*/
-        assertTrue(cls.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
-        assertTrue(cls.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
-        assertTrue(cls.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
-        assertFalse(cls.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
-        assertFalse(cls.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
-        assertFalse(cls.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
-        assertTrue(cls.getMethod("getLeafDeprecated").isAnnotationPresent(Deprecated.class));
+        try (URLClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() })) {
+            final String pkg = CompilationTestUtils.BASE_PKG + ".urn.yang.foo.rev160102";
+            final Class<?> cls = loader.loadClass(pkg + ".FooData");
+            final Class<?> clsContainer = loader.loadClass(pkg + ".ContainerMain");
+            final Class<?> clsTypedefDepr = loader.loadClass(pkg + ".TypedefDeprecated");
+            final Class<?> clsTypedefCur = loader.loadClass(pkg + ".TypedefCurrent");
+            final Class<?> clsGroupingDepr = loader.loadClass(pkg + ".GroupingDeprecated");
+            final Class<?> clsGroupingCur = loader.loadClass(pkg + ".GroupingCurrent");
+            final Class<?> clsTypeDef1 = loader.loadClass(pkg + ".Typedef1");
+            final Class<?> clsTypeDef2 = loader.loadClass(pkg + ".Typedef2");
+            final Class<?> clsTypeDef3 = loader.loadClass(pkg + ".Typedef3");
+            assertTrue(clsTypedefDepr.getAnnotations()[0].toString().contains("Deprecated"));
+            assertTrue(clsTypedefCur.getAnnotations().length == 0);
+            assertTrue(clsGroupingDepr.getAnnotations()[0].toString().contains("Deprecated"));
+            assertTrue(clsGroupingCur.getAnnotations().length == 0);
+            assertTrue(clsTypeDef1.getAnnotations().length == 0);
+            assertTrue(clsTypeDef3.getAnnotations().length == 0);
+            assertTrue(clsTypeDef2.getAnnotations()[0].toString().contains("Deprecated"));
+
+            /*methods inside container*/
+            assertTrue(clsContainer.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
+            assertTrue(clsContainer.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
+            assertTrue(clsContainer.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
+            assertFalse(clsContainer.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
+            assertFalse(clsContainer.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
+            assertFalse(clsContainer.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
+
+            /*methods inside module*/
+            assertTrue(cls.getMethod("getContainerMainLeafDepr").isAnnotationPresent(Deprecated.class));
+            assertTrue(cls.getMethod("getContainerMainListDepr").isAnnotationPresent(Deprecated.class));
+            assertTrue(cls.getMethod("getContainerMainChoiceDepr").isAnnotationPresent(Deprecated.class));
+            assertFalse(cls.getMethod("getContainerMainLeafCurrent").isAnnotationPresent(Deprecated.class));
+            assertFalse(cls.getMethod("getContainerMainListCurrent").isAnnotationPresent(Deprecated.class));
+            assertFalse(cls.getMethod("getContainerMainChoiceCur").isAnnotationPresent(Deprecated.class));
+            assertTrue(cls.getMethod("getLeafDeprecated").isAnnotationPresent(Deprecated.class));
+        }
 
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
     /**
      * Test if class generated for node from grouping implements ChildOf.
-     *
-     * @throws Exception
      */
     @Test
     public void testBug1377() throws Exception {
@@ -609,12 +607,41 @@ public class CompilationTest extends BaseCompilationTest {
         final ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
         final Class<?> outputActionClass = Class.forName(CompilationTestUtils.BASE_PKG
                 + ".urn.test.foo.rev140717.action.action.output.action._case.OutputAction", true, loader);
-        final Class<?> actionClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.test.foo.rev140717.Action", true, loader);
+        final Class<?> actionClass = Class.forName(CompilationTestUtils.BASE_PKG + ".urn.test.foo.rev140717.Action",
+            true, loader);
 
         // Test generated 'container output-action'
         assertTrue(outputActionClass.isInterface());
-        CompilationTestUtils.assertImplementsParameterizedIfc(outputActionClass, ChildOf.class.toString(), actionClass.getCanonicalName());
+        CompilationTestUtils.assertImplementsParameterizedIfc(outputActionClass, ChildOf.class.toString(),
+            actionClass.getCanonicalName());
+
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
+    }
+
+    @Test
+    public void testMdsal327() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal327");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal327");
+        generateTestSources("/compilation/mdsal327", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
+    }
 
+    @Test
+    public void testMdsal365() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal365");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal365");
+        generateTestSources("/compilation/mdsal365", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
+    }
+
+    @Test
+    public void testMdsal395() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal395");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal395");
+        generateTestSources("/compilation/mdsal395", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
@@ -636,7 +663,6 @@ public class CompilationTest extends BaseCompilationTest {
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
-
     @Test
     public void twoNestedUnionsTest() throws Exception {
         final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal320");
@@ -646,57 +672,62 @@ public class CompilationTest extends BaseCompilationTest {
         CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
-    private void generateTestSources(final String resourceDirPath, final File sourcesOutputDir)
-            throws IOException, URISyntaxException {
-        final List<File> sourceFiles = CompilationTestUtils.getSourceFiles(resourceDirPath);
-        final SchemaContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
-        final List<Type> types = bindingGenerator.generateTypes(context);
-        Collections.sort(types, (o1, o2) -> o2.getName().compareTo(o1.getName()));
-        final GeneratorJavaFile generator = new GeneratorJavaFile(ImmutableSet.copyOf(types));
-        generator.generateToFile(sourcesOutputDir);
+    @Test
+    public void testMdsal425() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal425");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal425");
+        generateTestSources("/compilation/mdsal425", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
-    private static void testReturnTypeIdentityref(final Class<?> clazz, final String methodName, final String returnTypeStr) throws Exception {
-        Method method;
-        java.lang.reflect.Type returnType;
-        try {
-            method = clazz.getMethod(methodName);
-            assertEquals(java.lang.Class.class, method.getReturnType());
-            returnType = method.getGenericReturnType();
-            assertTrue(returnType instanceof ParameterizedType);
-            final ParameterizedType pt = (ParameterizedType) returnType;
-            final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
-            assertEquals(1, parameters.length);
-            final java.lang.reflect.Type parameter = parameters[0];
-            assertTrue(parameter instanceof WildcardType);
-            final WildcardType wildcardType = (WildcardType) parameter;
-            assertEquals("? extends " + returnTypeStr, wildcardType.toString());
-        } catch (final NoSuchMethodException e) {
-            throw new AssertionError("Method '" + methodName + "' not found");
-        }
+    @Test
+    public void testMdsal529() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal529");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal529");
+        generateTestSources("/compilation/mdsal529", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
-    private static void testReturnTypeInstanceIdentitifer(final ClassLoader loader, final Class<?> clazz, final String methodName)
-            throws Exception {
-        Method method;
-        Class<?> rawReturnType;
-        java.lang.reflect.Type returnType;
-        try {
-            method = clazz.getMethod(methodName);
-            rawReturnType = Class.forName("org.opendaylight.yangtools.yang.binding.InstanceIdentifier", true, loader);
-            assertEquals(rawReturnType, method.getReturnType());
-            returnType = method.getGenericReturnType();
-            assertTrue(returnType instanceof ParameterizedType);
-            final ParameterizedType pt = (ParameterizedType) returnType;
-            final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
-            assertEquals(1, parameters.length);
-            final java.lang.reflect.Type parameter = parameters[0];
-            assertTrue(parameter instanceof WildcardType);
-            final WildcardType wildcardType = (WildcardType) parameter;
-            assertEquals("?", wildcardType.toString());
-        } catch (final NoSuchMethodException e) {
-            throw new AssertionError("Method '" + methodName + "' not found");
-        }
+    @Test
+    public void testMdsal589() throws Exception {
+        final File sourcesOutputDir = CompilationTestUtils.generatorOutput("mdsal589");
+        final File compiledOutputDir = CompilationTestUtils.compilerOutput("mdsal589");
+        generateTestSources("/compilation/mdsal589", sourcesOutputDir);
+        CompilationTestUtils.testCompilation(sourcesOutputDir, compiledOutputDir);
+        CompilationTestUtils.cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
+    private static void testReturnTypeIdentityref(final Class<?> clazz, final String methodName,
+            final String returnTypeStr) throws NoSuchMethodException {
+        Method method = clazz.getMethod(methodName);
+        assertEquals(java.lang.Class.class, method.getReturnType());
+        java.lang.reflect.Type returnType = method.getGenericReturnType();
+        assertTrue(returnType instanceof ParameterizedType);
+        final ParameterizedType pt = (ParameterizedType) returnType;
+        final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
+        assertEquals(1, parameters.length);
+        final java.lang.reflect.Type parameter = parameters[0];
+        assertTrue(parameter instanceof WildcardType);
+        final WildcardType wildcardType = (WildcardType) parameter;
+        assertEquals("? extends " + returnTypeStr, wildcardType.toString());
+    }
+
+    private static void testReturnTypeInstanceIdentitifer(final ClassLoader loader, final Class<?> clazz,
+            final String methodName) throws ClassNotFoundException, NoSuchMethodException, SecurityException {
+        final Method method = clazz.getMethod(methodName);
+        final Class<?> rawReturnType = Class.forName("org.opendaylight.yangtools.yang.binding.InstanceIdentifier", true,
+            loader);
+        assertEquals(rawReturnType, method.getReturnType());
+        final java.lang.reflect.Type returnType = method.getGenericReturnType();
+        assertTrue(returnType instanceof ParameterizedType);
+        final ParameterizedType pt = (ParameterizedType) returnType;
+        final java.lang.reflect.Type[] parameters = pt.getActualTypeArguments();
+        assertEquals(1, parameters.length);
+        final java.lang.reflect.Type parameter = parameters[0];
+        assertTrue(parameter instanceof WildcardType);
+        final WildcardType wildcardType = (WildcardType) parameter;
+        assertEquals("?", wildcardType.toString());
+    }
 }