forked from loafle/openapi-generator-original
fixes
This commit is contained in:
parent
89ed3bdb75
commit
370a8d136f
@ -89,13 +89,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>${testng-version}</version>
|
<!-- <version>${testng-version}</version> -->
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jmockit</groupId>
|
<groupId>org.jmockit</groupId>
|
||||||
<artifactId>jmockit</artifactId>
|
<artifactId>jmockit</artifactId>
|
||||||
<version>${jmockit-version}</version>
|
<!-- <version>${jmockit-version}</version> -->
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class OptionUtilsTest {
|
public class OptionUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -30,7 +31,7 @@ public class OptionUtilsTest {
|
|||||||
doTupleListTest(null, new ArrayList<Pair<String, String>>());
|
doTupleListTest(null, new ArrayList<Pair<String, String>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {
|
private static void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {
|
||||||
final List<Pair<String, String>> result = OptionUtils.parseCommaSeparatedTuples(input);
|
final List<Pair<String, String>> result = OptionUtils.parseCommaSeparatedTuples(input);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals(result.size(), expectedResults.size());
|
assertEquals(result.size(), expectedResults.size());
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<!-- <version>4.12</version> -->
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -22,6 +22,7 @@ public abstract class AbstractOptionsTest {
|
|||||||
this.optionsProvider = optionsProvider;
|
this.optionsProvider = optionsProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Test
|
@Test
|
||||||
public void checkOptionsProcessing() {
|
public void checkOptionsProcessing() {
|
||||||
getCodegenConfig().additionalProperties().putAll(optionsProvider.createOptions());
|
getCodegenConfig().additionalProperties().putAll(optionsProvider.createOptions());
|
||||||
@ -49,7 +50,7 @@ public abstract class AbstractOptionsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<CliOption, String> getCliOptionTransformer() {
|
private static Function<CliOption, String> getCliOptionTransformer() {
|
||||||
return new Function<CliOption, String>() {
|
return new Function<CliOption, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(CliOption option) {
|
public String apply(CliOption option) {
|
||||||
|
@ -7,6 +7,7 @@ import org.testng.annotations.Test;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class ClientAuthInputTest {
|
public class ClientAuthInputTest {
|
||||||
|
|
||||||
@Test(description = "read a file upload param from a 2.0 spec")
|
@Test(description = "read a file upload param from a 2.0 spec")
|
||||||
|
@ -11,6 +11,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class CodegenConfigLoaderTest {
|
public class CodegenConfigLoaderTest {
|
||||||
|
|
||||||
@DataProvider(name = "codegenConfig")
|
@DataProvider(name = "codegenConfig")
|
||||||
|
@ -189,7 +189,7 @@ public class CodegenTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Swagger parseAndPrepareSwagger(String path) {
|
private static Swagger parseAndPrepareSwagger(String path) {
|
||||||
Swagger swagger = new SwaggerParser().read(path);
|
Swagger swagger = new SwaggerParser().read(path);
|
||||||
// resolve inline models
|
// resolve inline models
|
||||||
new InlineModelResolver().flatten(swagger);
|
new InlineModelResolver().flatten(swagger);
|
||||||
|
@ -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));
|
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8));
|
||||||
out.write(TEST_SKIP_OVERWRITE);
|
out.write(TEST_SKIP_OVERWRITE);
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodegenOperation findCodegenOperationByOperationId(Map<String, List<CodegenOperation>> paths, String operationId) {
|
private static CodegenOperation findCodegenOperationByOperationId(Map<String, List<CodegenOperation>> paths, String operationId) {
|
||||||
for (List<CodegenOperation> ops : paths.values()) {
|
for (List<CodegenOperation> ops : paths.values()) {
|
||||||
for (CodegenOperation co : ops) {
|
for (CodegenOperation co : ops) {
|
||||||
if (operationId.equals(co.operationId)) {
|
if (operationId.equals(co.operationId)) {
|
||||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class ExampleGeneratorTest {
|
public class ExampleGeneratorTest {
|
||||||
|
|
||||||
@Test(description = "check handling of recursive models")
|
@Test(description = "check handling of recursive models")
|
||||||
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static org.testng.AssertJUnit.*;
|
import static org.testng.AssertJUnit.*;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class InlineModelResolverTest {
|
public class InlineModelResolverTest {
|
||||||
@Test
|
@Test
|
||||||
public void resolveInlineModelTest() throws Exception {
|
public void resolveInlineModelTest() throws Exception {
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.parser.SwaggerParser;
|
|||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class SwaggerMigratorTest {
|
public class SwaggerMigratorTest {
|
||||||
|
|
||||||
@Test(description = "read a 1.2 spec")
|
@Test(description = "read a 1.2 spec")
|
||||||
|
@ -25,6 +25,7 @@ import static org.testng.Assert.assertEquals;
|
|||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class CodegenConfiguratorTest {
|
public class CodegenConfiguratorTest {
|
||||||
|
|
||||||
@Mocked
|
@Mocked
|
||||||
@ -76,6 +77,7 @@ public class CodegenConfiguratorTest {
|
|||||||
assertValueInMap(clientOptInput.getConfig().additionalProperties(), CodegenConstants.TEMPLATE_DIR, toAbsolutePathDir(templateDir));
|
assertValueInMap(clientOptInput.getConfig().additionalProperties(), CodegenConstants.TEMPLATE_DIR, toAbsolutePathDir(templateDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Test
|
@Test
|
||||||
public void testSystemProperties() throws Exception {
|
public void testSystemProperties() throws Exception {
|
||||||
|
|
||||||
@ -287,6 +289,7 @@ public class CodegenConfiguratorTest {
|
|||||||
assertValueInMap(configurator.getDynamicProperties(), CodegenConstants.LOCAL_VARIABLE_PREFIX, "_");
|
assertValueInMap(configurator.getDynamicProperties(), CodegenConstants.LOCAL_VARIABLE_PREFIX, "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private ClientOptInput setupAndRunGenericTest(CodegenConfigurator configurator) {
|
private ClientOptInput setupAndRunGenericTest(CodegenConfigurator configurator) {
|
||||||
|
|
||||||
final String spec = "swagger.yaml";
|
final String spec = "swagger.yaml";
|
||||||
@ -316,10 +319,11 @@ public class CodegenConfiguratorTest {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toAbsolutePathDir(String outputDir) {
|
private static String toAbsolutePathDir(String outputDir) {
|
||||||
return Paths.get(outputDir).toAbsolutePath().toAbsolutePath().toString();
|
return Paths.get(outputDir).toAbsolutePath().toAbsolutePath().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private void setupStandardExpectations(final String spec, final String languageName, final String auth, final CodegenConfig config) {
|
private void setupStandardExpectations(final String spec, final String languageName, final String auth, final CodegenConfig config) {
|
||||||
|
|
||||||
new StrictExpectations() {{
|
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));
|
assertTrue(map.containsKey(propertyKey));
|
||||||
assertEquals(map.get(propertyKey), expectedPropertyValue);
|
assertEquals(map.get(propertyKey), expectedPropertyValue);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import io.swagger.codegen.options.FlashClienOptionsProvider;
|
|||||||
import mockit.Expectations;
|
import mockit.Expectations;
|
||||||
import mockit.Tested;
|
import mockit.Tested;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class FlashClienOptionsTest extends AbstractOptionsTest {
|
public class FlashClienOptionsTest extends AbstractOptionsTest {
|
||||||
|
|
||||||
@Tested
|
@Tested
|
||||||
|
@ -17,6 +17,7 @@ import com.google.common.collect.Sets;
|
|||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
public class TypeScriptNodeModelTest {
|
public class TypeScriptNodeModelTest {
|
||||||
|
|
||||||
@Test(description = "convert a simple TypeScript Node model")
|
@Test(description = "convert a simple TypeScript Node model")
|
||||||
|
@ -103,20 +103,18 @@ public class ZipUtil {
|
|||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void addFileToZip(File file, ZipOutputStream zos)
|
private static void addFileToZip(File file, ZipOutputStream zos)
|
||||||
throws FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
zos.putNextEntry(new ZipEntry(file.getName()));
|
zos.putNextEntry(new ZipEntry(file.getName()));
|
||||||
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
|
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
|
||||||
file));
|
file));
|
||||||
|
|
||||||
long bytesRead = 0;
|
|
||||||
byte[] bytesIn = new byte[BUFFER_SIZE];
|
byte[] bytesIn = new byte[BUFFER_SIZE];
|
||||||
int read = 0;
|
int read = 0;
|
||||||
|
|
||||||
while ((read = bis.read(bytesIn)) != -1) {
|
while ((read = bis.read(bytesIn)) != -1) {
|
||||||
zos.write(bytesIn, 0, read);
|
zos.write(bytesIn, 0, read);
|
||||||
bytesRead += read;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
|
@ -159,7 +159,7 @@ public class OnlineGeneratorOptionsTest {
|
|||||||
public static void getOptionsTest(OptionsProvider provider) throws ApiException {
|
public static void getOptionsTest(OptionsProvider provider) throws ApiException {
|
||||||
final Map<String, CliOption> opts = Generator.getOptions(provider.getLanguage());
|
final Map<String, CliOption> opts = Generator.getOptions(provider.getLanguage());
|
||||||
|
|
||||||
final Function cliOptionWrapper = new Function<CliOption, CliOptionProxy>() {
|
final Function<CliOption, CliOptionProxy> cliOptionWrapper = new Function<CliOption, CliOptionProxy>() {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CliOptionProxy apply(@Nullable CliOption option) {
|
public CliOptionProxy apply(@Nullable CliOption option) {
|
||||||
@ -167,13 +167,13 @@ public class OnlineGeneratorOptionsTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final List<CliOptionProxy> actual = Lists.transform(new ArrayList(opts.values()), cliOptionWrapper);
|
final List<CliOptionProxy> actual = Lists.transform(new ArrayList<CliOption>(opts.values()), cliOptionWrapper);
|
||||||
final List<CliOptionProxy> expected = Lists.transform(
|
final List<CliOptionProxy> expected = Lists.transform(
|
||||||
CodegenConfigLoader.forName(provider.getLanguage()).cliOptions(), cliOptionWrapper);
|
CodegenConfigLoader.forName(provider.getLanguage()).cliOptions(), cliOptionWrapper);
|
||||||
assertEquals(actual, expected);
|
assertEquals(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CliOptionProxy {
|
protected static class CliOptionProxy {
|
||||||
private final CliOption wrapped;
|
private final CliOption wrapped;
|
||||||
|
|
||||||
public CliOptionProxy(CliOption wrapped){
|
public CliOptionProxy(CliOption wrapped){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user