use of org.opendaylight.yangtools.plugin.generator.api.GeneratedFile in project mdsal by opendaylight.
the class YangModuleInfoCompilationTest method generateTestSourcesWithAdditionalConfig.
@Test
public void generateTestSourcesWithAdditionalConfig() throws Exception {
final List<File> sourceFiles = getSourceFiles("/yang-module-info");
final EffectiveModelContext context = YangParserTestUtils.parseYangFiles(sourceFiles);
JavaFileGenerator codegen = new JavaFileGenerator(Map.of("test", "test"));
Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> files = codegen.generateFiles(context, Set.copyOf(context.getModules()), (module, representation) -> Optional.of(module.getName()));
assertEquals(15, files.size());
assertEquals(14, files.row(GeneratedFileType.SOURCE).size());
assertEquals(1, files.row(GeneratedFileType.RESOURCE).size());
}
use of org.opendaylight.yangtools.plugin.generator.api.GeneratedFile in project mdsal by opendaylight.
the class BaseCompilationTest method generateTestSources.
protected static final void generateTestSources(final List<GeneratedType> types, final File sourcesOutputDir) throws IOException {
types.sort((o1, o2) -> o2.getName().compareTo(o1.getName()));
final Table<?, GeneratedFilePath, GeneratedFile> generatedFiles = JavaFileGenerator.generateFiles(types, true);
for (Cell<?, GeneratedFilePath, GeneratedFile> cell : generatedFiles.cellSet()) {
final File target = new File(sourcesOutputDir, cell.getColumnKey().getPath());
Files.createParentDirs(target);
try (OutputStream os = newOutputStream(target.toPath())) {
cell.getValue().writeBody(os);
}
}
}
Aggregations