From 370a8d136fd0c86eb3b47f0303a793b74b52d162 Mon Sep 17 00:00:00 2001 From: Maelig Nantel Date: Mon, 18 Jan 2016 11:35:57 +0100 Subject: [PATCH] fixes --- modules/swagger-codegen-cli/pom.xml | 4 ++-- .../io/swagger/codegen/cmd/utils/OptionUtilsTest.java | 3 ++- modules/swagger-codegen-maven-plugin/pom.xml | 2 +- .../test/java/io/swagger/codegen/AbstractOptionsTest.java | 3 ++- .../test/java/io/swagger/codegen/ClientAuthInputTest.java | 1 + .../java/io/swagger/codegen/CodegenConfigLoaderTest.java | 1 + .../src/test/java/io/swagger/codegen/CodegenTest.java | 2 +- .../java/io/swagger/codegen/DefaultGeneratorTest.java | 4 ++-- .../java/io/swagger/codegen/ExampleGeneratorTest.java | 1 + .../java/io/swagger/codegen/InlineModelResolverTest.java | 1 + .../test/java/io/swagger/codegen/SwaggerMigratorTest.java | 1 + .../swagger/codegen/config/CodegenConfiguratorTest.java | 8 ++++++-- .../io/swagger/codegen/flash/FlashClienOptionsTest.java | 2 -- .../codegen/typescriptnode/TypeScriptNodeModelTest.java | 1 + .../src/main/java/io/swagger/generator/util/ZipUtil.java | 4 +--- .../generator/online/OnlineGeneratorOptionsTest.java | 6 +++--- 16 files changed, 26 insertions(+), 18 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 9100143a236..c118a6325ef 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -89,13 +89,13 @@ org.testng testng - ${testng-version} + test org.jmockit jmockit - ${jmockit-version} + test diff --git a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java index 650f05d58e6..480631c913c 100644 --- a/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java +++ b/modules/swagger-codegen-cli/src/test/java/io/swagger/codegen/cmd/utils/OptionUtilsTest.java @@ -10,6 +10,7 @@ import java.util.List; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +@SuppressWarnings("static-method") public class OptionUtilsTest { @Test @@ -30,7 +31,7 @@ public class OptionUtilsTest { doTupleListTest(null, new ArrayList>()); } - private void doTupleListTest(String input, List> expectedResults) { + private static void doTupleListTest(String input, List> expectedResults) { final List> result = OptionUtils.parseCommaSeparatedTuples(input); assertNotNull(result); assertEquals(result.size(), expectedResults.size()); diff --git a/modules/swagger-codegen-maven-plugin/pom.xml b/modules/swagger-codegen-maven-plugin/pom.xml index 850ac735534..52cf252d309 100644 --- a/modules/swagger-codegen-maven-plugin/pom.xml +++ b/modules/swagger-codegen-maven-plugin/pom.xml @@ -51,7 +51,7 @@ junit junit - 4.12 + test diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java index 002e4ba8f29..ede3feb50b4 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/AbstractOptionsTest.java @@ -22,6 +22,7 @@ public abstract class AbstractOptionsTest { this.optionsProvider = optionsProvider; } + @SuppressWarnings("unused") @Test public void checkOptionsProcessing() { getCodegenConfig().additionalProperties().putAll(optionsProvider.createOptions()); @@ -49,7 +50,7 @@ public abstract class AbstractOptionsTest { } } - private Function getCliOptionTransformer() { + private static Function getCliOptionTransformer() { return new Function() { @Override public String apply(CliOption option) { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java index 59552bba148..490affe0764 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ClientAuthInputTest.java @@ -7,6 +7,7 @@ import org.testng.annotations.Test; import java.util.List; +@SuppressWarnings("static-method") public class ClientAuthInputTest { @Test(description = "read a file upload param from a 2.0 spec") diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java index b91e506a4f9..cf4e4a201fb 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenConfigLoaderTest.java @@ -11,6 +11,7 @@ import java.util.Set; import static org.testng.Assert.assertEquals; +@SuppressWarnings("static-method") public class CodegenConfigLoaderTest { @DataProvider(name = "codegenConfig") diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java index 68c2b4b170b..91a1240ced8 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java @@ -189,7 +189,7 @@ public class CodegenTest { } - private Swagger parseAndPrepareSwagger(String path) { + private static Swagger parseAndPrepareSwagger(String path) { Swagger swagger = new SwaggerParser().read(path); // resolve inline models new InlineModelResolver().flatten(swagger); diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java index ed83c89c8f0..8cd04c932f9 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java @@ -200,13 +200,13 @@ public class DefaultGeneratorTest { } } - private void changeContent(File file) throws IOException { + private static void changeContent(File file) throws IOException { Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8)); out.write(TEST_SKIP_OVERWRITE); out.close(); } - private CodegenOperation findCodegenOperationByOperationId(Map> paths, String operationId) { + private static CodegenOperation findCodegenOperationByOperationId(Map> paths, String operationId) { for (List ops : paths.values()) { for (CodegenOperation co : ops) { if (operationId.equals(co.operationId)) { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java index 339b77badbd..d4c22b88aad 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/ExampleGeneratorTest.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +@SuppressWarnings("static-method") public class ExampleGeneratorTest { @Test(description = "check handling of recursive models") diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java index f972711138b..9102f06908f 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java @@ -12,6 +12,7 @@ import java.util.Map; import static org.testng.AssertJUnit.*; +@SuppressWarnings("static-method") public class InlineModelResolverTest { @Test public void resolveInlineModelTest() throws Exception { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java index 2a7e9ec532a..cf19c2058c4 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/SwaggerMigratorTest.java @@ -5,6 +5,7 @@ import io.swagger.parser.SwaggerParser; import org.testng.annotations.Test; +@SuppressWarnings("static-method") public class SwaggerMigratorTest { @Test(description = "read a 1.2 spec") diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java index 8108d206f3a..6f39eb1af99 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/config/CodegenConfiguratorTest.java @@ -25,6 +25,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +@SuppressWarnings("static-method") public class CodegenConfiguratorTest { @Mocked @@ -76,6 +77,7 @@ public class CodegenConfiguratorTest { assertValueInMap(clientOptInput.getConfig().additionalProperties(), CodegenConstants.TEMPLATE_DIR, toAbsolutePathDir(templateDir)); } + @SuppressWarnings("unused") @Test public void testSystemProperties() throws Exception { @@ -287,6 +289,7 @@ public class CodegenConfiguratorTest { assertValueInMap(configurator.getDynamicProperties(), CodegenConstants.LOCAL_VARIABLE_PREFIX, "_"); } + @SuppressWarnings("unused") private ClientOptInput setupAndRunGenericTest(CodegenConfigurator configurator) { final String spec = "swagger.yaml"; @@ -316,10 +319,11 @@ public class CodegenConfiguratorTest { return result; } - private String toAbsolutePathDir(String outputDir) { + private static String toAbsolutePathDir(String outputDir) { return Paths.get(outputDir).toAbsolutePath().toAbsolutePath().toString(); } + @SuppressWarnings("unused") private void setupStandardExpectations(final String spec, final String languageName, final String auth, final CodegenConfig config) { new StrictExpectations() {{ @@ -340,7 +344,7 @@ public class CodegenConfiguratorTest { }}; } - private void assertValueInMap(Map map, String propertyKey, String expectedPropertyValue) { + private static void assertValueInMap(Map map, String propertyKey, String expectedPropertyValue) { assertTrue(map.containsKey(propertyKey)); assertEquals(map.get(propertyKey), expectedPropertyValue); } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java index 97f4036c4d9..d3debf29579 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/flash/FlashClienOptionsTest.java @@ -8,8 +8,6 @@ import io.swagger.codegen.options.FlashClienOptionsProvider; import mockit.Expectations; import mockit.Tested; -import java.util.Map; - public class FlashClienOptionsTest extends AbstractOptionsTest { @Tested diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java index a932ac2b5ae..95398b155cf 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/typescriptnode/TypeScriptNodeModelTest.java @@ -17,6 +17,7 @@ import com.google.common.collect.Sets; import org.testng.Assert; import org.testng.annotations.Test; +@SuppressWarnings("static-method") public class TypeScriptNodeModelTest { @Test(description = "convert a simple TypeScript Node model") diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java index c63f161b702..3295be5d898 100644 --- a/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java +++ b/modules/swagger-generator/src/main/java/io/swagger/generator/util/ZipUtil.java @@ -103,20 +103,18 @@ public class ZipUtil { * @throws FileNotFoundException * @throws IOException */ - private void addFileToZip(File file, ZipOutputStream zos) + private static void addFileToZip(File file, ZipOutputStream zos) throws FileNotFoundException, IOException { zos.putNextEntry(new ZipEntry(file.getName())); BufferedInputStream bis = new BufferedInputStream(new FileInputStream( file)); - long bytesRead = 0; byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = bis.read(bytesIn)) != -1) { zos.write(bytesIn, 0, read); - bytesRead += read; } zos.closeEntry(); diff --git a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java index ca5ea43412f..626255519bf 100644 --- a/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java +++ b/modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java @@ -159,7 +159,7 @@ public class OnlineGeneratorOptionsTest { public static void getOptionsTest(OptionsProvider provider) throws ApiException { final Map opts = Generator.getOptions(provider.getLanguage()); - final Function cliOptionWrapper = new Function() { + final Function cliOptionWrapper = new Function() { @Nullable @Override public CliOptionProxy apply(@Nullable CliOption option) { @@ -167,13 +167,13 @@ public class OnlineGeneratorOptionsTest { } }; - final List actual = Lists.transform(new ArrayList(opts.values()), cliOptionWrapper); + final List actual = Lists.transform(new ArrayList(opts.values()), cliOptionWrapper); final List expected = Lists.transform( CodegenConfigLoader.forName(provider.getLanguage()).cliOptions(), cliOptionWrapper); assertEquals(actual, expected); } - private static class CliOptionProxy { + protected static class CliOptionProxy { private final CliOption wrapped; public CliOptionProxy(CliOption wrapped){