From be3497e16055abc7a52e6dac164d6f2b4cf537e5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 17 Oct 2017 18:03:40 +0200 Subject: [PATCH] Fix checkstyle in maven-sal-api-gen-plugin Fix violations and enable enforcement. Change-Id: Ibc88fbe40b09a0aeff977bd1aaeed408954c201a Signed-off-by: Robert Varga --- binding/maven-sal-api-gen-plugin/pom.xml | 33 +- .../api/gen/plugin/CodeGeneratorImpl.java | 24 +- .../unified/doc/generator/GeneratorImpl.xtend | 46 +- .../maven/DocumentationGeneratorImpl.java | 5 +- .../generator/WadlRestconfGenerator.xtend | 444 +++++++++--------- .../wadl/generator/maven/WadlGenerator.java | 4 +- .../doc/generator/maven/DocGenTest.java | 1 - .../maven/YangModuleInfoCompilationTest.java | 45 +- .../wadl/generator/maven/WadlGenTest.java | 3 +- 9 files changed, 308 insertions(+), 297 deletions(-) diff --git a/binding/maven-sal-api-gen-plugin/pom.xml b/binding/maven-sal-api-gen-plugin/pom.xml index 31c9572cec..4dc0132723 100644 --- a/binding/maven-sal-api-gen-plugin/pom.xml +++ b/binding/maven-sal-api-gen-plugin/pom.xml @@ -92,23 +92,30 @@ org.eclipse.xtend xtend-maven-plugin + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + The following configuration is necessary for maven-site-plugin to + correctly identify the correct deployment path for OpenDaylight Maven + sites. + --> + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java index 26d935d468..84f94eca6c 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/maven/api/gen/plugin/CodeGeneratorImpl.java @@ -51,6 +51,13 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext private MavenProject mavenProject; private File resourceBaseDir; + @Override + public Collection generateSources(final SchemaContext context, final File outputBaseDir, + final Set currentModules) throws IOException { + return generateSources(context, outputBaseDir, currentModules, + module -> Optional.of("/" + module.getModuleSourcePath().replace(File.separator, "/"))); + } + @Override public Collection generateSources(final SchemaContext context, final File outputDir, final Set yangModules, final Function> moduleResourcePathResolver) @@ -150,7 +157,7 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext private Set generateYangModuleInfo(final File outputBaseDir, final Module module, final SchemaContext ctx, final Function> moduleResourcePathResolver, final Builder providerSourceSet) { - Builder generatedFiles = ImmutableSet. builder(); + Builder generatedFiles = ImmutableSet.builder(); final YangModuleInfoTemplate template = new YangModuleInfoTemplate(module, ctx, moduleResourcePathResolver); String moduleInfoSource = template.generate(); @@ -180,10 +187,11 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext return file; } + @SuppressWarnings("checkstyle:illegalCatch") private File writeFile(final File file, final String source) { - try (final OutputStream stream = buildContext.newFileOutputStream(file)) { - try (final Writer fw = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) { - try (final BufferedWriter bw = new BufferedWriter(fw)) { + try (OutputStream stream = buildContext.newFileOutputStream(file)) { + try (Writer fw = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) { + try (BufferedWriter bw = new BufferedWriter(fw)) { bw.write(source); } } catch (Exception e) { @@ -194,12 +202,4 @@ public final class CodeGeneratorImpl implements BasicCodeGenerator, BuildContext } return file; } - - @Override - public Collection generateSources(final SchemaContext context, final File outputBaseDir, final Set currentModules) - throws IOException { - return generateSources(context, outputBaseDir, currentModules, - m -> Optional.of("/" + m.getModuleSourcePath().replace(File.separator, "/"))); - } - } diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/GeneratorImpl.xtend b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/GeneratorImpl.xtend index 31f615247b..04b7f1e80e 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/GeneratorImpl.xtend +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/GeneratorImpl.xtend @@ -66,9 +66,9 @@ class GeneratorImpl { var Module currentModule; val Map imports = new HashMap(); var SchemaContext ctx; - + StringBuilder augmentChildNodesAsString - + DataSchemaNode lastNodeInTargetPath = null def generate(SchemaContext context, File targetPath, Set modulesToGen) throws IOException { @@ -305,7 +305,7 @@ class GeneratorImpl { } return '''

Augmentations

- +
    «FOR augment : module.augmentations»
  • @@ -322,7 +322,7 @@ class GeneratorImpl { «FOR childNode : augment.childNodes» «childNode.printSchemaNodeInfo» «ENDFOR» - +

    Example

    «createAugmentChildNodesAsString(new ArrayList(augment.childNodes))» «printNodeChildren(parseTargetPath(augment.targetPath))» @@ -331,13 +331,13 @@ class GeneratorImpl {
''' } - + private def createAugmentChildNodesAsString(List childNodes) { augmentChildNodesAsString = new StringBuilder(); augmentChildNodesAsString.append(printNodeChildren(childNodes)) return '' } - + private def parseTargetPath(SchemaPath path) { val List nodes = new ArrayList(); for (QName pathElement : path.pathFromRoot) { @@ -359,13 +359,13 @@ class GeneratorImpl { if(! nodes.empty) { lastNodeInTargetPath = nodes.get(nodes.size() - 1) } - + val List targetPathNodes = new ArrayList(); targetPathNodes.add(lastNodeInTargetPath) - + return targetPathNodes } - + private def DataSchemaNode findNodeInChildNodes(QName findingNode, Iterable childNodes) { for(child : childNodes) { if (child.QName.equals(findingNode)) @@ -384,25 +384,25 @@ class GeneratorImpl { } } } - + private def printNodeChildren(List childNodes) { if (childNodes.empty) { return '' } - - return + + return '''
         «printAugmentedNode(childNodes.get(0))»
         
''' } - + private def CharSequence printAugmentedNode(DataSchemaNode child) { - + if(child instanceof ChoiceCaseNode) return '' - + return ''' «IF child instanceof ContainerSchemaNode» @@ -425,7 +425,7 @@ class GeneratorImpl { «ENDIF» ''' } - + private def printChoiceNode(ChoiceSchemaNode child) { val List cases = new ArrayList(child.cases); if(!cases.empty) { @@ -434,7 +434,7 @@ class GeneratorImpl { printAugmentedNode(caseChildNode) } } - + private def printListNode(ListSchemaNode listNode) { return ''' @@ -445,7 +445,7 @@ class GeneratorImpl { </«listNode.QName.localName»> ''' } - + private def printContainerNode(ContainerSchemaNode containerNode) { return ''' @@ -456,7 +456,7 @@ class GeneratorImpl { </«containerNode.QName.localName»> ''' } - + private def printLeafListNode(LeafListSchemaNode leafListNode) { return ''' @@ -465,16 +465,16 @@ class GeneratorImpl { <«leafListNode.QName.localName»>. . .</«leafListNode.QName.localName»> ''' } - + private def printAnyXmlNode(AnyXmlSchemaNode anyXmlNode) { - return + return ''' <«anyXmlNode.QName.localName»>. . .</«anyXmlNode.QName.localName»> ''' } - + private def printLeafNode(LeafSchemaNode leafNode) { - return + return ''' <«leafNode.QName.localName»>. . .</«leafNode.QName.localName»> ''' diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocumentationGeneratorImpl.java b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocumentationGeneratorImpl.java index 0452b0774c..b528c6d3d8 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocumentationGeneratorImpl.java +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocumentationGeneratorImpl.java @@ -20,8 +20,9 @@ import org.opendaylight.yangtools.yang2sources.spi.BasicCodeGenerator; public class DocumentationGeneratorImpl extends GeneratorImpl implements BasicCodeGenerator { @Override - public Collection generateSources(final SchemaContext arg0, final File arg1, final Set arg2) throws IOException { - return generate(arg0, arg1, arg2); + public Collection generateSources(final SchemaContext arg0, final File arg1, final Set arg2) + throws IOException { + return generate(arg0, arg1, arg2); } @Override diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/WadlRestconfGenerator.xtend b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/WadlRestconfGenerator.xtend index 8b1a4885ee..5045a08df7 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/WadlRestconfGenerator.xtend +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/WadlRestconfGenerator.xtend @@ -27,228 +27,228 @@ import org.sonatype.plexus.build.incremental.BuildContext import org.sonatype.plexus.build.incremental.DefaultBuildContext class WadlRestconfGenerator { - - File path - static val BuildContext CTX = new DefaultBuildContext(); - static val PATH_DELIMETER = '/' - var SchemaContext context; - var List configData; - var List operationalData; - var Module module; - var List pathListParams; - - new(File targetPath) { - if (!targetPath.exists) targetPath.mkdirs - path = targetPath - } - - def generate(SchemaContext context, Set modules) { + + File path + static val BuildContext CTX = new DefaultBuildContext(); + static val PATH_DELIMETER = '/' + var SchemaContext context; + var List configData; + var List operationalData; + var Module module; + var List pathListParams; + + new(File targetPath) { + if (!targetPath.exists) targetPath.mkdirs + path = targetPath + } + + def generate(SchemaContext context, Set modules) { val result = new HashSet; - this.context = context - for (module : modules) { - val dataContainers = module.childNodes.filter[it|it.listOrContainer] - if (!dataContainers.empty || !module.rpcs.nullOrEmpty) { - configData = new ArrayList - operationalData = new ArrayList - - for (data : dataContainers) { - if (data.configuration) { - configData.add(data) - } else { - operationalData.add(data) - } - } - - this.module = module - val destination = new File(path, '''«module.name».wadl''') - val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination), StandardCharsets.UTF_8) - val bw = new BufferedWriter(fw) - bw.append(application); - bw.close(); - fw.close(); - result.add(destination) - } - } - return result - } - - private def application() ''' - - - - «grammars» - - «resources» - - ''' - - private def importsAsNamespaces(Module module) ''' - «FOR imprt : module.imports» - xmlns:«imprt.prefix»="«context.findModuleByName(imprt.moduleName, imprt.revision).namespace»" - «ENDFOR» - ''' - - private def grammars() ''' - - - «FOR imprt : module.imports» - - «ENDFOR» - - ''' - - private def resources() ''' - - «resourceOperational» - «resourceConfig» - «resourceOperations» - - ''' - - private def resourceOperational() ''' - «IF !operationalData.nullOrEmpty» - - «FOR schemaNode : operationalData» - «schemaNode.firstResource(false)» - «ENDFOR» - - «ENDIF» - ''' - - private def resourceConfig() ''' - «IF !configData.nullOrEmpty» - - «FOR schemaNode : configData» - «schemaNode.mehodPost» - «ENDFOR» - «FOR schemaNode : configData» - «schemaNode.firstResource(true)» - «ENDFOR» - - «ENDIF» - ''' - - private def resourceOperations() ''' - «IF !module.rpcs.nullOrEmpty» - - «FOR rpc : module.rpcs» - - «methodPostRpc(rpc.input !== null, rpc.output !== null)» - - «ENDFOR» - - «ENDIF» - ''' - - private def String firstResource(DataSchemaNode schemaNode, boolean config) ''' - - «resourceBody(schemaNode, config)» - - ''' - - private def String resource(DataSchemaNode schemaNode, boolean config) ''' - - «resourceBody(schemaNode, config)» - - ''' - - private def String createPath(DataSchemaNode schemaNode) { - pathListParams = new ArrayList - var StringBuilder path = new StringBuilder - path.append(schemaNode.QName.localName) - if (schemaNode instanceof ListSchemaNode) { - for (listKey : schemaNode.keyDefinition) { - pathListParams.add((schemaNode as DataNodeContainer).getDataChildByName(listKey) as LeafSchemaNode) - path.append(PATH_DELIMETER) - path.append('{') - path.append(listKey.localName) - path.append('}') - } - } - return path.toString - } - - private def String resourceBody(DataSchemaNode schemaNode, boolean config) ''' - «IF !pathListParams.nullOrEmpty» - «resourceParams» - «ENDIF» - «schemaNode.methodGet» - «val children = (schemaNode as DataNodeContainer).childNodes.filter[it|it.listOrContainer]» - «IF config» - «schemaNode.methodDelete» - «schemaNode.mehodPut» - «FOR child : children» - «child.mehodPost» - «ENDFOR» - «ENDIF» - «FOR child : children» - «child.resource(config)» - «ENDFOR» - ''' - - private def resourceParams() ''' - «FOR pathParam : pathListParams» - «IF pathParam !== null» - «val type = pathParam.type.QName.localName» - - «ENDIF» - «ENDFOR» - ''' - - private def methodGet(DataSchemaNode schemaNode) ''' - - - «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» - - - ''' - - private def mehodPut(DataSchemaNode schemaNode) ''' - - - «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» - - - ''' - - private def mehodPost(DataSchemaNode schemaNode) ''' - - - «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» - - - ''' - - private def methodPostRpc(boolean input, boolean output) ''' - - «IF input» - - «representation(null, "input")» - - «ENDIF» - «IF output» - - «representation(null, "output")» - - «ENDIF» - - ''' - - private def methodDelete(DataSchemaNode schemaNode) ''' - - ''' - - private def representation(URI prefix, String name) ''' - «val elementData = name» - - - - - - ''' - - private def boolean isListOrContainer(DataSchemaNode schemaNode) { - return (schemaNode instanceof ListSchemaNode || schemaNode instanceof ContainerSchemaNode) - } + this.context = context + for (module : modules) { + val dataContainers = module.childNodes.filter[it|it.listOrContainer] + if (!dataContainers.empty || !module.rpcs.nullOrEmpty) { + configData = new ArrayList + operationalData = new ArrayList + + for (data : dataContainers) { + if (data.configuration) { + configData.add(data) + } else { + operationalData.add(data) + } + } + + this.module = module + val destination = new File(path, '''«module.name».wadl''') + val fw = new OutputStreamWriter(CTX.newFileOutputStream(destination), StandardCharsets.UTF_8) + val bw = new BufferedWriter(fw) + bw.append(application); + bw.close(); + fw.close(); + result.add(destination) + } + } + return result + } + + private def application() ''' + + + + «grammars» + + «resources» + + ''' + + private def importsAsNamespaces(Module module) ''' + «FOR imprt : module.imports» + xmlns:«imprt.prefix»="«context.findModuleByName(imprt.moduleName, imprt.revision).namespace»" + «ENDFOR» + ''' + + private def grammars() ''' + + + «FOR imprt : module.imports» + + «ENDFOR» + + ''' + + private def resources() ''' + + «resourceOperational» + «resourceConfig» + «resourceOperations» + + ''' + + private def resourceOperational() ''' + «IF !operationalData.nullOrEmpty» + + «FOR schemaNode : operationalData» + «schemaNode.firstResource(false)» + «ENDFOR» + + «ENDIF» + ''' + + private def resourceConfig() ''' + «IF !configData.nullOrEmpty» + + «FOR schemaNode : configData» + «schemaNode.mehodPost» + «ENDFOR» + «FOR schemaNode : configData» + «schemaNode.firstResource(true)» + «ENDFOR» + + «ENDIF» + ''' + + private def resourceOperations() ''' + «IF !module.rpcs.nullOrEmpty» + + «FOR rpc : module.rpcs» + + «methodPostRpc(rpc.input !== null, rpc.output !== null)» + + «ENDFOR» + + «ENDIF» + ''' + + private def String firstResource(DataSchemaNode schemaNode, boolean config) ''' + + «resourceBody(schemaNode, config)» + + ''' + + private def String resource(DataSchemaNode schemaNode, boolean config) ''' + + «resourceBody(schemaNode, config)» + + ''' + + private def String createPath(DataSchemaNode schemaNode) { + pathListParams = new ArrayList + var StringBuilder path = new StringBuilder + path.append(schemaNode.QName.localName) + if (schemaNode instanceof ListSchemaNode) { + for (listKey : schemaNode.keyDefinition) { + pathListParams.add((schemaNode as DataNodeContainer).getDataChildByName(listKey) as LeafSchemaNode) + path.append(PATH_DELIMETER) + path.append('{') + path.append(listKey.localName) + path.append('}') + } + } + return path.toString + } + + private def String resourceBody(DataSchemaNode schemaNode, boolean config) ''' + «IF !pathListParams.nullOrEmpty» + «resourceParams» + «ENDIF» + «schemaNode.methodGet» + «val children = (schemaNode as DataNodeContainer).childNodes.filter[it|it.listOrContainer]» + «IF config» + «schemaNode.methodDelete» + «schemaNode.mehodPut» + «FOR child : children» + «child.mehodPost» + «ENDFOR» + «ENDIF» + «FOR child : children» + «child.resource(config)» + «ENDFOR» + ''' + + private def resourceParams() ''' + «FOR pathParam : pathListParams» + «IF pathParam !== null» + «val type = pathParam.type.QName.localName» + + «ENDIF» + «ENDFOR» + ''' + + private def methodGet(DataSchemaNode schemaNode) ''' + + + «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» + + + ''' + + private def mehodPut(DataSchemaNode schemaNode) ''' + + + «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» + + + ''' + + private def mehodPost(DataSchemaNode schemaNode) ''' + + + «representation(schemaNode.QName.namespace, schemaNode.QName.localName)» + + + ''' + + private def methodPostRpc(boolean input, boolean output) ''' + + «IF input» + + «representation(null, "input")» + + «ENDIF» + «IF output» + + «representation(null, "output")» + + «ENDIF» + + ''' + + private def methodDelete(DataSchemaNode schemaNode) ''' + + ''' + + private def representation(URI prefix, String name) ''' + «val elementData = name» + + + + + + ''' + + private def boolean isListOrContainer(DataSchemaNode schemaNode) { + return (schemaNode instanceof ListSchemaNode || schemaNode instanceof ContainerSchemaNode) + } } diff --git a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenerator.java b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenerator.java index 69fc52d7c7..8f0fc163a7 100644 --- a/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenerator.java +++ b/binding/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenerator.java @@ -20,8 +20,8 @@ import org.opendaylight.yangtools.yang2sources.spi.BasicCodeGenerator; public class WadlGenerator implements BasicCodeGenerator { @Override - public Collection generateSources(final SchemaContext context, final File outputDir, final Set currentModules) - throws IOException { + public Collection generateSources(final SchemaContext context, final File outputDir, + final Set currentModules) throws IOException { final File outputBaseDir; if (outputDir == null) { diff --git a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocGenTest.java b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocGenTest.java index 0a38e9320e..4d004c1bc3 100644 --- a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocGenTest.java +++ b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/DocGenTest.java @@ -21,7 +21,6 @@ import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.opendaylight.mdsal.binding.yang.unified.doc.generator.maven.DocumentationGeneratorImpl; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; diff --git a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/YangModuleInfoCompilationTest.java b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/YangModuleInfoCompilationTest.java index 1a0731851a..c63824a1b1 100644 --- a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/YangModuleInfoCompilationTest.java +++ b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/unified/doc/generator/maven/YangModuleInfoCompilationTest.java @@ -113,17 +113,20 @@ public class YangModuleInfoCompilationTest { String name = ymi.getName(); switch (name) { - case "import-module": - infoImport = ymi; - break; - case "submodule1": - infoSub1 = ymi; - break; - case "submodule2": - infoSub2 = ymi; - break; - case "submodule3": - infoSub3 = ymi; + case "import-module": + infoImport = ymi; + break; + case "submodule1": + infoSub1 = ymi; + break; + case "submodule2": + infoSub2 = ymi; + break; + case "submodule3": + infoSub3 = ymi; + break; + default: + // no-op } } assertNotNull(infoImport); @@ -134,7 +137,8 @@ public class YangModuleInfoCompilationTest { cleanUp(sourcesOutputDir, compiledOutputDir); } - private static void generateTestSources(final String resourceDirPath, final File sourcesOutputDir) throws Exception { + private static void generateTestSources(final String resourceDirPath, final File sourcesOutputDir) + throws Exception { final List sourceFiles = getSourceFiles(resourceDirPath); final SchemaContext context = YangParserTestUtils.parseYangSources(sourceFiles); CodeGeneratorImpl codegen = new CodeGeneratorImpl(); @@ -153,10 +157,10 @@ public class YangModuleInfoCompilationTest { codegen.setAdditionalConfig(ImmutableMap.of("test", "test")); Collection files = codegen.generateSources(context, null, context.getModules()); assertFalse(files.isEmpty()); - files.forEach((file -> { + files.forEach(file -> { deleteTestDir(file); assertFalse(file.exists()); - })); + }); } private static void testCompilation(final File sourcesOutputDir, final File compiledOutputDir) { @@ -210,8 +214,8 @@ public class YangModuleInfoCompilationTest { if (file.isDirectory()) { File[] filesToDelete = file.listFiles(); if (filesToDelete != null) { - for (File f : filesToDelete) { - deleteTestDir(f); + for (File ftd : filesToDelete) { + deleteTestDir(ftd); } } } @@ -220,11 +224,12 @@ public class YangModuleInfoCompilationTest { } } - private static Method assertContainsMethod(final Class clazz, final Class returnType, final String name, final Class... args) { + private static Method assertContainsMethod(final Class clazz, final Class returnType, final String name, + final Class... args) { try { - Method m = clazz.getDeclaredMethod(name, args); - assertEquals(returnType, m.getReturnType()); - return m; + Method method = clazz.getDeclaredMethod(name, args); + assertEquals(returnType, method.getReturnType()); + return method; } catch (NoSuchMethodException e) { throw new AssertionError("Method " + name + " with args " + Arrays.toString(args) + " does not exists in class " + clazz.getSimpleName()); diff --git a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenTest.java b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenTest.java index c94f8f40d0..e6210901ac 100644 --- a/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenTest.java +++ b/binding/maven-sal-api-gen-plugin/src/test/java/org/opendaylight/mdsal/binding/yang/wadl/generator/maven/WadlGenTest.java @@ -22,7 +22,6 @@ import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.opendaylight.mdsal.binding.yang.wadl.generator.maven.WadlGenerator; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; @@ -103,4 +102,4 @@ public class WadlGenTest { throw new RuntimeException("Failed to clean up after test"); } } -} \ No newline at end of file +} -- 2.36.6