Merge "Added export of augmentation schemas to Binding Context"
[yangtools.git] / code-generator / binding-java-api-generator / src / test / java / org / opendaylight / yangtools / sal / java / api / generator / test / CascadeUsesCompilationTest.java
index c29d28bd8524eeb0fc21f254aad269f9aa2eb0ea..a4f42fe8605c9b74e141ef9d7c671aafc8e5d571 100644 (file)
@@ -8,9 +8,11 @@
 package org.opendaylight.yangtools.sal.java.api.generator.test;
 
 import static org.junit.Assert.*;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.*;
 
 import java.io.File;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.HashSet;
@@ -41,7 +43,7 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
 
         // Test if all sources are generated from module foo
         File parent = new File(sourcesOutputDir, NS_FOO);
-        testFilesCount(parent, 5);
+        assertFilesCount(parent, 5);
         File fooData = new File(parent, "FooData.java");
         File foo_gr1 = new File(parent, "FooGr1.java");
         File nodes = new File(parent, "Nodes.java");
@@ -53,7 +55,7 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
 
         // Test if all sources are generated from module bar
         parent = new File(sourcesOutputDir, NS_BAR);
-        testFilesCount(parent, 2);
+        assertFilesCount(parent, 2);
         File barGr1 = new File(parent, "BarGr1.java");
         File barGr2 = new File(parent, "BarGr2.java");
         assertTrue(barGr1.exists());
@@ -61,7 +63,7 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
 
         // Test if all sources are generated from module baz
         parent = new File(sourcesOutputDir, NS_BAZ);
-        testFilesCount(parent, 1);
+        assertFilesCount(parent, 1);
         File bazGr1 = new File(parent, "BazGr1.java");
         assertTrue(bazGr1.exists());
 
@@ -79,8 +81,8 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
         Class<?> bazGr1Class = Class.forName(BASE_PKG + ".urn.opendaylight.baz.rev131008.BazGr1", true, loader);
 
         // test generated interface from 'container nodes'
-        testImplementsIfc(nodesClass, fooGr1Class);
-        testImplementsIfc(nodesClass, barGr2Class);
+        assertImplementsIfc(nodesClass, fooGr1Class);
+        assertImplementsIfc(nodesClass, barGr2Class);
 
         // test generated builder for 'container nodes'
         assertFalse(nodesBuilderClass.isInterface());
@@ -116,6 +118,16 @@ public class CascadeUsesCompilationTest extends BaseCompilationTest {
         assertNotNull(usesBarGr1);
         assertNotNull(usesBazGr1);
 
+        Method fieldsFromMethod = null;
+        for (Method m : nodesBuilderClass.getDeclaredMethods()) {
+            String methodName = m.getName();
+            if ("fieldsFrom".equals(methodName)) {
+                fieldsFromMethod = m;
+            }
+        }
+        assertNotNull(fieldsFromMethod);
+        assertEquals(1, fieldsFromMethod.getParameterTypes().length);
+
         cleanUp(sourcesOutputDir, compiledOutputDir);
     }