import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsRestrictionCheck;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertFilesCount;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertImplementsIfc;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertImplementsParameterizedIfc;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
import org.junit.Test;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
cleanUp(sourcesOutputDir, compiledOutputDir);
}
+ /**
+ * Test if class generated for node from grouping implements ChildOf.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBug1377() throws Exception {
+ final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug1377");
+ assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
+ final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug1377");
+ assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+
+ generateTestSources("/compilation/bug1377", sourcesOutputDir);
+
+ // Test if sources are compilable
+ testCompilation(sourcesOutputDir, compiledOutputDir);
+
+ ClassLoader loader = new URLClassLoader(new URL[] { compiledOutputDir.toURI().toURL() });
+ Class<?> outputActionClass = Class.forName(BASE_PKG
+ + ".urn.test.foo.rev140717.action.action.output.action._case.OutputAction", true, loader);
+ Class<?> actionClass = Class.forName(BASE_PKG + ".urn.test.foo.rev140717.Action", true, loader);
+
+ // Test generated 'container output-action'
+ assertTrue(outputActionClass.isInterface());
+ assertImplementsParameterizedIfc(outputActionClass, ChildOf.class.toString(), actionClass.getCanonicalName());
+
+ cleanUp(sourcesOutputDir, compiledOutputDir);
+ }
+
@Test
public void classNamesColisionTest() throws Exception {
final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "class-name-collision");
static final String COMPILER_OUTPUT_PATH = TEST_PATH + FS + "bin";
static final File COMPILER_OUTPUT_DIR = new File(COMPILER_OUTPUT_PATH);
+ static final String AUGMENTATION = "interface org.opendaylight.yangtools.yang.binding.Augmentation";
+
static final String BASE_PATH = "org" + FS + "opendaylight" + FS + "yang" + FS + "gen" + FS + "v1";
static final String NS_TEST = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "test" + FS + "rev131008";
static final String NS_FOO = BASE_PATH + FS + "urn" + FS + "opendaylight" + FS + "foo" + FS + "rev131008";
* fully qualified name of expected parameter type
*/
static void testAugmentation(Class<?> clazz, String genericTypeName) {
- final String ifcName = "interface org.opendaylight.yangtools.yang.binding.Augmentation";
- assertImplementsParameterizedIfc(clazz, ifcName, genericTypeName);
+ assertImplementsParameterizedIfc(clazz, AUGMENTATION, genericTypeName);
}
/**