forked from loafle/openapi-generator-original
Change/reintroduce junit5 (#18790)
* Revert "Revert back to junit4 (#18786)" This reverts commit 2471ba2d2e96261941d21eb10648f3d70e969423. * Make junit engine execute TestNG test cases * Fix failing test and use tempDir's for test code generation * Make test fail with helpful info in case generator throws exception * Suppress error output from TestUtils * Remove transitive junit4 dependency * Sync guava-testlib version with guava version * Add hint regarding alternative for guava-testlib's FakeTicker
This commit is contained in:
parent
368110a631
commit
6a6f39d6f4
@ -19,7 +19,7 @@
|
||||
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version>
|
||||
<jodatime-version>2.7</jodatime-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.13.2</junit-version>
|
||||
<junit-version>5.10.2</junit-version>
|
||||
<http-signature-version>1.4</http-signature-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -59,8 +59,8 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
package org.openapitools.codegen.plugin;
|
||||
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
@ -127,8 +127,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -1,14 +1,14 @@
|
||||
package org.openapitools.codegen.online.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.openapitools.codegen.online.model.ResponseCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
@ -18,7 +18,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@WebMvcTest(GenApiController.class)
|
||||
public class GenApiControllerTest {
|
||||
|
||||
|
@ -327,14 +327,20 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tngtech.archunit</groupId>
|
||||
<artifactId>archunit-junit4</artifactId>
|
||||
<artifactId>archunit-junit5</artifactId>
|
||||
<version>${archunit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng.version}</version>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.support</groupId>
|
||||
<artifactId>testng-engine</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -427,7 +433,13 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-testlib</artifactId>
|
||||
<version>31.1-jre</version>
|
||||
<version>${guava.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,6 +1,6 @@
|
||||
package {{generatorPackage}};
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
@ -33,4 +33,4 @@ public class {{generatorClass}}Test {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.opts(clientOptInput).generate();
|
||||
}
|
||||
}
|
||||
}
|
@ -41,7 +41,6 @@
|
||||
</systemPropertyVariables>
|
||||
<argLine>-Xms512m -Xmx1500m</argLine>
|
||||
<parallel>methods</parallel>
|
||||
<forkMode>pertest</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -114,8 +113,8 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@ -124,6 +123,6 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<openapi-generator-version>{{openapiGeneratorVersion}}</openapi-generator-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.13.2</junit-version>
|
||||
<junit-version>5.10.2</junit-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -30,26 +30,26 @@ public class AllGeneratorsTest {
|
||||
@Test
|
||||
public void testEachWithPetstore() throws IOException {
|
||||
for (final CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName(codegenConfig.getName())
|
||||
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
List<File> files = List.of();
|
||||
try {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName(codegenConfig.getName())
|
||||
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
// Main intention of this test is to check that nothing crashes. Besides, we check here that
|
||||
// at least 1 file is generated, besides the common ".openapi-generator-ignore", "FILES" and "VERSION" files.
|
||||
Assert.assertTrue(files.size() >= 4);
|
||||
files = generator.opts(clientOptInput).generate();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to run " + codegenConfig.getName() + " with petstore.yaml: " + e.getMessage());
|
||||
Assert.fail("Generator " + codegenConfig.getName() + " threw an exception (generating " + codegenConfig.getInputSpec() + "): " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
// Main intention of this test is to check that nothing crashes. Besides, we check here that
|
||||
// at least 1 file is generated, besides the common ".openapi-generator-ignore", "FILES" and "VERSION" files.
|
||||
Assert.assertTrue(files.size() >= 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.tngtech.archunit.core.domain.JavaClasses;
|
||||
import com.tngtech.archunit.core.domain.JavaModifier;
|
||||
import com.tngtech.archunit.core.importer.ClassFileImporter;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
|
||||
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
|
||||
package org.openapitools.codegen.csharpnetcore;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
|
@ -32,8 +32,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
|
||||
public class CSharpClientDeepObjectTest {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.java;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileNotContains;
|
||||
import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
|
||||
@ -67,7 +67,6 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import lombok.SneakyThrows;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@ -109,9 +108,9 @@ public class JavaClientCodegenTest {
|
||||
"application/json",
|
||||
new MediaType().schema(new ArraySchema().items(new StringSchema()))));
|
||||
CodegenParameter codegenParameter1 = codegen.fromRequestBody(body1, new HashSet<String>(), null);
|
||||
Assert.assertEquals(codegenParameter1.description, "A list of ids");
|
||||
Assert.assertEquals(codegenParameter1.dataType, "List<String>");
|
||||
Assert.assertEquals(codegenParameter1.baseType, "String");
|
||||
Assertions.assertEquals(codegenParameter1.description, "A list of ids");
|
||||
Assertions.assertEquals(codegenParameter1.dataType, "List<String>");
|
||||
Assertions.assertEquals(codegenParameter1.baseType, "String");
|
||||
|
||||
RequestBody body2 = new RequestBody();
|
||||
body2.setDescription("A list of list of values");
|
||||
@ -123,9 +122,9 @@ public class JavaClientCodegenTest {
|
||||
.schema(
|
||||
new ArraySchema().items(new ArraySchema().items(new IntegerSchema())))));
|
||||
CodegenParameter codegenParameter2 = codegen.fromRequestBody(body2, new HashSet<String>(), null);
|
||||
Assert.assertEquals(codegenParameter2.description, "A list of list of values");
|
||||
Assert.assertEquals(codegenParameter2.dataType, "List<List<Integer>>");
|
||||
Assert.assertEquals(codegenParameter2.baseType, "List");
|
||||
Assertions.assertEquals(codegenParameter2.description, "A list of list of values");
|
||||
Assertions.assertEquals(codegenParameter2.dataType, "List<List<Integer>>");
|
||||
Assertions.assertEquals(codegenParameter2.baseType, "List");
|
||||
|
||||
RequestBody body3 = new RequestBody();
|
||||
body3.setDescription("A list of points");
|
||||
@ -142,9 +141,9 @@ public class JavaClientCodegenTest {
|
||||
point.addProperty("x", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
point.addProperty("y", new IntegerSchema().format(SchemaTypeUtil.INTEGER32_FORMAT));
|
||||
CodegenParameter codegenParameter3 = codegen.fromRequestBody(body3, new HashSet<String>(), null);
|
||||
Assert.assertEquals(codegenParameter3.description, "A list of points");
|
||||
Assert.assertEquals(codegenParameter3.dataType, "List<Point>");
|
||||
Assert.assertEquals(codegenParameter3.baseType, "Point");
|
||||
Assertions.assertEquals(codegenParameter3.description, "A list of points");
|
||||
Assertions.assertEquals(codegenParameter3.dataType, "List<Point>");
|
||||
Assertions.assertEquals(codegenParameter3.baseType, "Point");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -153,7 +152,7 @@ public class JavaClientCodegenTest {
|
||||
ComposedSchema schema = new ComposedSchema();
|
||||
CodegenModel result = codegen.fromModel("CompSche",
|
||||
schema);
|
||||
Assert.assertEquals(result.name, "CompSche");
|
||||
Assertions.assertEquals(result.name, "CompSche");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -177,7 +176,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
javaClientCodegen.postProcessOperationsWithModels(objs, Collections.emptyList());
|
||||
|
||||
Assert.assertEquals(Arrays.asList(pathParam1, pathParam2, queryParamRequired, queryParamOptional), codegenOperation.allParams);
|
||||
Assertions.assertEquals(Arrays.asList(pathParam1, pathParam2, queryParamRequired, queryParamOptional), codegenOperation.allParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -185,22 +184,22 @@ public class JavaClientCodegenTest {
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
||||
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
||||
Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
|
||||
Assertions.assertFalse(codegen.isHideGenerationTimestamp());
|
||||
|
||||
Assert.assertEquals(codegen.modelPackage(), "org.openapitools.client.model");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.modelPackage(), "org.openapitools.client.model");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE),
|
||||
"org.openapitools.client.model");
|
||||
Assert.assertEquals(codegen.apiPackage(), "org.openapitools.client.api");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.apiPackage(), "org.openapitools.client.api");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.API_PACKAGE),
|
||||
"org.openapitools.client.api");
|
||||
Assert.assertEquals(codegen.getInvokerPackage(), "org.openapitools.client");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.getInvokerPackage(), "org.openapitools.client");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE),
|
||||
"org.openapitools.client");
|
||||
Assert.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_GSON);
|
||||
Assertions.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_GSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -213,20 +212,20 @@ public class JavaClientCodegenTest {
|
||||
codegen.setSerializationLibrary("JACKSON");
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
Assert.assertTrue(codegen.isHideGenerationTimestamp());
|
||||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.model");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
Assertions.assertTrue(codegen.isHideGenerationTimestamp());
|
||||
Assertions.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.model");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.model");
|
||||
Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.api");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.api");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "xyz.yyyyy.zzzzzzz.api");
|
||||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.invoker");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.invoker");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.invoker");
|
||||
Assert.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_GSON); // the library JavaClientCodegen.OKHTTP_GSON only supports GSON
|
||||
Assertions.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_GSON); // the library JavaClientCodegen.OKHTTP_GSON only supports GSON
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -244,21 +243,21 @@ public class JavaClientCodegenTest {
|
||||
codegen.additionalProperties().put(CodegenConstants.LIBRARY, JavaClientCodegen.JERSEY2);
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
Assert.assertTrue(codegen.isHideGenerationTimestamp());
|
||||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
Assertions.assertTrue(codegen.isHideGenerationTimestamp());
|
||||
Assertions.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.API_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.iiii.invoker");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.iiii.invoker");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.iiii.invoker");
|
||||
Assert.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON);
|
||||
Assertions.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -321,7 +320,7 @@ public class JavaClientCodegenTest {
|
||||
codegen.additionalProperties().put(CodegenConstants.LIBRARY, JavaClientCodegen.JERSEY3);
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertTrue(codegen.getFeatureSet().getSecurityFeatures().contains(SecurityFeature.SignatureAuth));
|
||||
Assertions.assertTrue(codegen.getFeatureSet().getSecurityFeatures().contains(SecurityFeature.SignatureAuth));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -333,16 +332,16 @@ public class JavaClientCodegenTest {
|
||||
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.apiPackage(), "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.API_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.aaaaa");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.aaaaa");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.aaaaa");
|
||||
}
|
||||
@ -355,16 +354,16 @@ public class JavaClientCodegenTest {
|
||||
.put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.modelPackage(), "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||
Assert.assertEquals(codegen.apiPackage(), "org.openapitools.client.api");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.apiPackage(), "org.openapitools.client.api");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.API_PACKAGE),
|
||||
"org.openapitools.client.api");
|
||||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.mmmmm");
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.zzzzzzz.mmmmm");
|
||||
Assertions.assertEquals(
|
||||
codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE),
|
||||
"xyz.yyyyy.zzzzzzz.mmmmm");
|
||||
}
|
||||
@ -377,8 +376,8 @@ public class JavaClientCodegenTest {
|
||||
|
||||
Operation operation = openAPI.getPaths().get("/ping").getPost();
|
||||
CodegenOperation co = codegen.fromOperation("/ping", "POST", operation, null);
|
||||
Assert.assertEquals(co.allParams.size(), 1);
|
||||
Assert.assertEquals(co.allParams.get(0).baseType, "MessageEventCoreWithTimeListEntries");
|
||||
Assertions.assertEquals(co.allParams.size(), 1);
|
||||
Assertions.assertEquals(co.allParams.get(0).baseType, "MessageEventCoreWithTimeListEntries");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -390,11 +389,11 @@ public class JavaClientCodegenTest {
|
||||
|
||||
List<Map<String, String>> enumVars =
|
||||
(List<Map<String, String>>) array.getItems().getAllowableValues().get("enumVars");
|
||||
Assert.assertNotNull(enumVars);
|
||||
Assertions.assertNotNull(enumVars);
|
||||
Map<String, String> testedEnumVar = enumVars.get(0);
|
||||
Assert.assertNotNull(testedEnumVar);
|
||||
Assert.assertEquals(testedEnumVar.getOrDefault("name", ""), "NUMBER_1");
|
||||
Assert.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||
Assertions.assertNotNull(testedEnumVar);
|
||||
Assertions.assertEquals(testedEnumVar.getOrDefault("name", ""), "NUMBER_1");
|
||||
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -410,11 +409,11 @@ public class JavaClientCodegenTest {
|
||||
|
||||
List<Map<String, String>> enumVars =
|
||||
(List<Map<String, String>>) array.getItems().getAllowableValues().get("enumVars");
|
||||
Assert.assertNotNull(enumVars);
|
||||
Assertions.assertNotNull(enumVars);
|
||||
Map<String, String> testedEnumVar = enumVars.get(0);
|
||||
Assert.assertNotNull(testedEnumVar);
|
||||
Assert.assertEquals(testedEnumVar.getOrDefault("name", ""), "ONE");
|
||||
Assert.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||
Assertions.assertNotNull(testedEnumVar);
|
||||
Assertions.assertEquals(testedEnumVar.getOrDefault("name", ""), "ONE");
|
||||
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -435,7 +434,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 40);
|
||||
Assertions.assertEquals(files.size(), 40);
|
||||
TestUtils.ensureContainsFile(files, output, ".gitignore");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
|
||||
@ -511,7 +510,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 43);
|
||||
Assertions.assertEquals(files.size(), 43);
|
||||
TestUtils.ensureContainsFile(files, output, ".gitignore");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
|
||||
@ -599,7 +598,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 32);
|
||||
Assertions.assertEquals(files.size(), 32);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(
|
||||
@ -668,7 +667,7 @@ public class JavaClientCodegenTest {
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 153);
|
||||
Assertions.assertEquals(files.size(), 153);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/xyz/abcdef/model/Dog.java"),
|
||||
@ -695,7 +694,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 35);
|
||||
Assertions.assertEquals(files.size(), 35);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
Path defaultApi = Paths.get(output + "/src/main/java/xyz/abcdef/api/PingApi.java");
|
||||
@ -722,10 +721,10 @@ public class JavaClientCodegenTest {
|
||||
ApiResponse ok_200 = openAPI.getComponents().getResponses().get("OK_200");
|
||||
CodegenResponse response = codegen.fromResponse("200", ok_200);
|
||||
|
||||
Assert.assertEquals(response.headers.size(), 1);
|
||||
Assertions.assertEquals(response.headers.size(), 1);
|
||||
CodegenProperty header = response.headers.get(0);
|
||||
Assert.assertEquals(header.dataType, "UUID");
|
||||
Assert.assertEquals(header.baseName, "Request");
|
||||
Assertions.assertEquals(header.dataType, "UUID");
|
||||
Assertions.assertEquals(header.baseName, "Request");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -791,7 +790,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
Assert.assertEquals(files.size(), 1);
|
||||
Assertions.assertEquals(files.size(), 1);
|
||||
files.forEach(File::deleteOnExit);
|
||||
}
|
||||
|
||||
@ -820,7 +819,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
Assert.assertEquals(files.size(), 9);
|
||||
Assertions.assertEquals(files.size(), 9);
|
||||
files.forEach(File::deleteOnExit);
|
||||
}
|
||||
|
||||
@ -851,7 +850,7 @@ public class JavaClientCodegenTest {
|
||||
File apiClient = files.stream()
|
||||
.filter(f -> f.getName().equals("ApiClient.java"))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new AssertionFailedError(
|
||||
.orElseThrow(() -> new AssertionError(
|
||||
"ApiClient.java not found"));
|
||||
|
||||
Stream<String> contents = Arrays.stream(Files.readString(apiClient.toPath(),
|
||||
@ -899,29 +898,29 @@ public class JavaClientCodegenTest {
|
||||
Schema test1 = openAPI.getComponents().getSchemas().get("MapTest1");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm1 = codegen.fromModel("MapTest1", test1);
|
||||
Assert.assertEquals(cm1.getDataType(), "Map");
|
||||
Assert.assertEquals(cm1.getParent(), "HashMap<String, Object>");
|
||||
Assert.assertEquals(cm1.getClassname(), "MapTest1");
|
||||
Assertions.assertEquals(cm1.getDataType(), "Map");
|
||||
Assertions.assertEquals(cm1.getParent(), "HashMap<String, Object>");
|
||||
Assertions.assertEquals(cm1.getClassname(), "MapTest1");
|
||||
|
||||
Schema test2 = openAPI.getComponents().getSchemas().get("MapTest2");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm2 = codegen.fromModel("MapTest2", test2);
|
||||
Assert.assertEquals(cm2.getDataType(), "Map");
|
||||
Assert.assertEquals(cm2.getParent(), "HashMap<String, Object>");
|
||||
Assert.assertEquals(cm2.getClassname(), "MapTest2");
|
||||
Assertions.assertEquals(cm2.getDataType(), "Map");
|
||||
Assertions.assertEquals(cm2.getParent(), "HashMap<String, Object>");
|
||||
Assertions.assertEquals(cm2.getClassname(), "MapTest2");
|
||||
|
||||
Schema test3 = openAPI.getComponents().getSchemas().get("MapTest3");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm3 = codegen.fromModel("MapTest3", test3);
|
||||
Assert.assertEquals(cm3.getDataType(), "Map");
|
||||
Assert.assertEquals(cm3.getParent(), "HashMap<String, Object>");
|
||||
Assert.assertEquals(cm3.getClassname(), "MapTest3");
|
||||
Assertions.assertEquals(cm3.getDataType(), "Map");
|
||||
Assertions.assertEquals(cm3.getParent(), "HashMap<String, Object>");
|
||||
Assertions.assertEquals(cm3.getClassname(), "MapTest3");
|
||||
|
||||
Schema other = openAPI.getComponents().getSchemas().get("OtherObj");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm = codegen.fromModel("OtherObj", other);
|
||||
Assert.assertEquals(cm.getDataType(), "Object");
|
||||
Assert.assertEquals(cm.getClassname(), "OtherObj");
|
||||
Assertions.assertEquals(cm.getDataType(), "Object");
|
||||
Assertions.assertEquals(cm.getClassname(), "OtherObj");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -949,7 +948,7 @@ public class JavaClientCodegenTest {
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
Assert.assertEquals(
|
||||
Assertions.assertEquals(
|
||||
clientOptInput.getConfig().schemaMapping().get("TypeAlias"), "foo.bar.TypeAlias");
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
@ -964,7 +963,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
Assert.assertEquals(files.size(), 1);
|
||||
Assertions.assertEquals(files.size(), 1);
|
||||
TestUtils.ensureContainsFile(
|
||||
files, output, "src/main/java/org/openapitools/client/model/ParentType.java");
|
||||
|
||||
@ -979,11 +978,11 @@ public class JavaClientCodegenTest {
|
||||
|
||||
final Pattern FIELD_PATTERN = Pattern.compile(".* private (.*?) typeAlias;.*", Pattern.DOTALL);
|
||||
Matcher fieldMatcher = FIELD_PATTERN.matcher(parentTypeContents);
|
||||
Assert.assertTrue(fieldMatcher.matches());
|
||||
Assertions.assertTrue(fieldMatcher.matches());
|
||||
|
||||
// this is the type of the field 'typeAlias'. With a working schemaMapping it should
|
||||
// be 'foo.bar.TypeAlias' or just 'TypeAlias'
|
||||
Assert.assertEquals(fieldMatcher.group(1), "foo.bar.TypeAlias");
|
||||
Assertions.assertEquals(fieldMatcher.group(1), "foo.bar.TypeAlias");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -993,10 +992,10 @@ public class JavaClientCodegenTest {
|
||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
|
||||
List<CodegenSecurity> security = codegen.fromSecurity(openAPI.getComponents().getSecuritySchemes());
|
||||
Assert.assertEquals(security.size(), 1);
|
||||
Assert.assertEquals(security.get(0).isBasic, Boolean.TRUE);
|
||||
Assert.assertEquals(security.get(0).isBasicBasic, Boolean.FALSE);
|
||||
Assert.assertEquals(security.get(0).isBasicBearer, Boolean.TRUE);
|
||||
Assertions.assertEquals(security.size(), 1);
|
||||
Assertions.assertEquals(security.get(0).isBasic, Boolean.TRUE);
|
||||
Assertions.assertEquals(security.get(0).isBasicBasic, Boolean.FALSE);
|
||||
Assertions.assertEquals(security.get(0).isBasicBearer, Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1082,135 +1081,135 @@ public class JavaClientCodegenTest {
|
||||
Schema test1 = openAPI.getComponents().getSchemas().get("AnyValueModel");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm1 = codegen.fromModel("AnyValueModel", test1);
|
||||
Assert.assertEquals(cm1.getClassname(), "AnyValueModel");
|
||||
Assertions.assertEquals(cm1.getClassname(), "AnyValueModel");
|
||||
|
||||
final CodegenProperty property1 = cm1.allVars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "any_value");
|
||||
Assert.assertEquals(property1.dataType, "Object");
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
Assert.assertFalse(property1.isFreeFormObject);
|
||||
Assert.assertTrue(property1.isAnyType);
|
||||
Assertions.assertEquals(property1.baseName, "any_value");
|
||||
Assertions.assertEquals(property1.dataType, "Object");
|
||||
Assertions.assertTrue(property1.isPrimitiveType);
|
||||
Assertions.assertFalse(property1.isContainer);
|
||||
Assertions.assertFalse(property1.isFreeFormObject);
|
||||
Assertions.assertTrue(property1.isAnyType);
|
||||
|
||||
final CodegenProperty property2 = cm1.allVars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "any_value_with_desc");
|
||||
Assert.assertEquals(property2.dataType, "Object");
|
||||
Assert.assertFalse(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertFalse(property2.isContainer);
|
||||
Assert.assertFalse(property2.isFreeFormObject);
|
||||
Assert.assertTrue(property2.isAnyType);
|
||||
Assertions.assertEquals(property2.baseName, "any_value_with_desc");
|
||||
Assertions.assertEquals(property2.dataType, "Object");
|
||||
Assertions.assertFalse(property2.required);
|
||||
Assertions.assertTrue(property2.isPrimitiveType);
|
||||
Assertions.assertFalse(property2.isContainer);
|
||||
Assertions.assertFalse(property2.isFreeFormObject);
|
||||
Assertions.assertTrue(property2.isAnyType);
|
||||
|
||||
final CodegenProperty property3 = cm1.allVars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "any_value_nullable");
|
||||
Assert.assertEquals(property3.dataType, "Object");
|
||||
Assert.assertFalse(property3.required);
|
||||
Assert.assertTrue(property3.isPrimitiveType);
|
||||
Assert.assertFalse(property3.isContainer);
|
||||
Assert.assertFalse(property3.isFreeFormObject);
|
||||
Assert.assertTrue(property3.isAnyType);
|
||||
Assertions.assertEquals(property3.baseName, "any_value_nullable");
|
||||
Assertions.assertEquals(property3.dataType, "Object");
|
||||
Assertions.assertFalse(property3.required);
|
||||
Assertions.assertTrue(property3.isPrimitiveType);
|
||||
Assertions.assertFalse(property3.isContainer);
|
||||
Assertions.assertFalse(property3.isFreeFormObject);
|
||||
Assertions.assertTrue(property3.isAnyType);
|
||||
|
||||
Schema test2 = openAPI.getComponents().getSchemas().get("AnyValueModelInline");
|
||||
codegen.setOpenAPI(openAPI);
|
||||
CodegenModel cm2 = codegen.fromModel("AnyValueModelInline", test2);
|
||||
Assert.assertEquals(cm2.getClassname(), "AnyValueModelInline");
|
||||
Assertions.assertEquals(cm2.getClassname(), "AnyValueModelInline");
|
||||
|
||||
final CodegenProperty cp1 = cm2.vars.get(0);
|
||||
Assert.assertEquals(cp1.baseName, "any_value");
|
||||
Assert.assertEquals(cp1.dataType, "Object");
|
||||
Assert.assertFalse(cp1.required);
|
||||
Assert.assertTrue(cp1.isPrimitiveType);
|
||||
Assert.assertFalse(cp1.isContainer);
|
||||
Assert.assertFalse(cp1.isFreeFormObject);
|
||||
Assert.assertTrue(cp1.isAnyType);
|
||||
Assertions.assertEquals(cp1.baseName, "any_value");
|
||||
Assertions.assertEquals(cp1.dataType, "Object");
|
||||
Assertions.assertFalse(cp1.required);
|
||||
Assertions.assertTrue(cp1.isPrimitiveType);
|
||||
Assertions.assertFalse(cp1.isContainer);
|
||||
Assertions.assertFalse(cp1.isFreeFormObject);
|
||||
Assertions.assertTrue(cp1.isAnyType);
|
||||
|
||||
final CodegenProperty cp2 = cm2.vars.get(1);
|
||||
Assert.assertEquals(cp2.baseName, "any_value_with_desc");
|
||||
Assert.assertEquals(cp2.dataType, "Object");
|
||||
Assert.assertFalse(cp2.required);
|
||||
Assert.assertTrue(cp2.isPrimitiveType);
|
||||
Assert.assertFalse(cp2.isContainer);
|
||||
Assert.assertFalse(cp2.isFreeFormObject);
|
||||
Assert.assertTrue(cp2.isAnyType);
|
||||
Assertions.assertEquals(cp2.baseName, "any_value_with_desc");
|
||||
Assertions.assertEquals(cp2.dataType, "Object");
|
||||
Assertions.assertFalse(cp2.required);
|
||||
Assertions.assertTrue(cp2.isPrimitiveType);
|
||||
Assertions.assertFalse(cp2.isContainer);
|
||||
Assertions.assertFalse(cp2.isFreeFormObject);
|
||||
Assertions.assertTrue(cp2.isAnyType);
|
||||
|
||||
final CodegenProperty cp3 = cm2.vars.get(2);
|
||||
Assert.assertEquals(cp3.baseName, "any_value_nullable");
|
||||
Assert.assertEquals(cp3.dataType, "Object");
|
||||
Assert.assertFalse(cp3.required);
|
||||
Assert.assertTrue(cp3.isPrimitiveType);
|
||||
Assert.assertFalse(cp3.isContainer);
|
||||
Assert.assertFalse(cp3.isFreeFormObject);
|
||||
Assert.assertTrue(cp3.isAnyType);
|
||||
Assertions.assertEquals(cp3.baseName, "any_value_nullable");
|
||||
Assertions.assertEquals(cp3.dataType, "Object");
|
||||
Assertions.assertFalse(cp3.required);
|
||||
Assertions.assertTrue(cp3.isPrimitiveType);
|
||||
Assertions.assertFalse(cp3.isContainer);
|
||||
Assertions.assertFalse(cp3.isFreeFormObject);
|
||||
Assertions.assertTrue(cp3.isAnyType);
|
||||
|
||||
// map
|
||||
// Should allow in any type including map, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp4 = cm2.vars.get(3);
|
||||
Assert.assertEquals(cp4.baseName, "map_free_form_object");
|
||||
Assert.assertEquals(cp4.dataType, "Map<String, Object>");
|
||||
Assert.assertFalse(cp4.required);
|
||||
Assert.assertTrue(cp4.isPrimitiveType);
|
||||
Assert.assertTrue(cp4.isContainer);
|
||||
Assert.assertTrue(cp4.isMap);
|
||||
Assert.assertTrue(cp4.isFreeFormObject);
|
||||
Assert.assertFalse(cp4.isAnyType);
|
||||
Assert.assertFalse(cp4.isModel);
|
||||
Assertions.assertEquals(cp4.baseName, "map_free_form_object");
|
||||
Assertions.assertEquals(cp4.dataType, "Map<String, Object>");
|
||||
Assertions.assertFalse(cp4.required);
|
||||
Assertions.assertTrue(cp4.isPrimitiveType);
|
||||
Assertions.assertTrue(cp4.isContainer);
|
||||
Assertions.assertTrue(cp4.isMap);
|
||||
Assertions.assertTrue(cp4.isFreeFormObject);
|
||||
Assertions.assertFalse(cp4.isAnyType);
|
||||
Assertions.assertFalse(cp4.isModel);
|
||||
|
||||
// Should allow in any type including map, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp5 = cm2.vars.get(4);
|
||||
Assert.assertEquals(cp5.baseName, "map_any_value_with_desc");
|
||||
Assert.assertEquals(cp5.dataType, "Map<String, Object>");
|
||||
Assert.assertFalse(cp5.required);
|
||||
Assert.assertTrue(cp5.isPrimitiveType);
|
||||
Assert.assertTrue(cp5.isContainer);
|
||||
Assert.assertTrue(cp5.isMap);
|
||||
Assert.assertTrue(cp5.isFreeFormObject);
|
||||
Assert.assertFalse(cp5.isAnyType);
|
||||
Assert.assertFalse(cp5.isModel);
|
||||
Assertions.assertEquals(cp5.baseName, "map_any_value_with_desc");
|
||||
Assertions.assertEquals(cp5.dataType, "Map<String, Object>");
|
||||
Assertions.assertFalse(cp5.required);
|
||||
Assertions.assertTrue(cp5.isPrimitiveType);
|
||||
Assertions.assertTrue(cp5.isContainer);
|
||||
Assertions.assertTrue(cp5.isMap);
|
||||
Assertions.assertTrue(cp5.isFreeFormObject);
|
||||
Assertions.assertFalse(cp5.isAnyType);
|
||||
Assertions.assertFalse(cp5.isModel);
|
||||
|
||||
// Should allow in any type including map, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp6 = cm2.vars.get(5);
|
||||
Assert.assertEquals(cp6.baseName, "map_any_value_nullable");
|
||||
Assert.assertEquals(cp6.dataType, "Map<String, Object>");
|
||||
Assert.assertFalse(cp6.required);
|
||||
Assert.assertTrue(cp6.isPrimitiveType);
|
||||
Assert.assertTrue(cp6.isContainer);
|
||||
Assert.assertTrue(cp6.isMap);
|
||||
Assert.assertTrue(cp6.isFreeFormObject);
|
||||
Assert.assertFalse(cp6.isAnyType);
|
||||
Assertions.assertEquals(cp6.baseName, "map_any_value_nullable");
|
||||
Assertions.assertEquals(cp6.dataType, "Map<String, Object>");
|
||||
Assertions.assertFalse(cp6.required);
|
||||
Assertions.assertTrue(cp6.isPrimitiveType);
|
||||
Assertions.assertTrue(cp6.isContainer);
|
||||
Assertions.assertTrue(cp6.isMap);
|
||||
Assertions.assertTrue(cp6.isFreeFormObject);
|
||||
Assertions.assertFalse(cp6.isAnyType);
|
||||
|
||||
// array
|
||||
// Should allow in any type including array, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp7 = cm2.vars.get(6);
|
||||
Assert.assertEquals(cp7.baseName, "array_any_value");
|
||||
Assert.assertEquals(cp7.dataType, "List<Object>");
|
||||
Assert.assertFalse(cp7.required);
|
||||
Assert.assertTrue(cp7.isPrimitiveType);
|
||||
Assert.assertTrue(cp7.isContainer);
|
||||
Assert.assertTrue(cp7.isArray);
|
||||
Assert.assertFalse(cp7.isFreeFormObject);
|
||||
Assert.assertFalse(cp7.isAnyType);
|
||||
Assertions.assertEquals(cp7.baseName, "array_any_value");
|
||||
Assertions.assertEquals(cp7.dataType, "List<Object>");
|
||||
Assertions.assertFalse(cp7.required);
|
||||
Assertions.assertTrue(cp7.isPrimitiveType);
|
||||
Assertions.assertTrue(cp7.isContainer);
|
||||
Assertions.assertTrue(cp7.isArray);
|
||||
Assertions.assertFalse(cp7.isFreeFormObject);
|
||||
Assertions.assertFalse(cp7.isAnyType);
|
||||
|
||||
// Should allow in any type including array, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp8 = cm2.vars.get(7);
|
||||
Assert.assertEquals(cp8.baseName, "array_any_value_with_desc");
|
||||
Assert.assertEquals(cp8.dataType, "List<Object>");
|
||||
Assert.assertFalse(cp8.required);
|
||||
Assert.assertTrue(cp8.isPrimitiveType);
|
||||
Assert.assertTrue(cp8.isContainer);
|
||||
Assert.assertTrue(cp8.isArray);
|
||||
Assert.assertFalse(cp8.isFreeFormObject);
|
||||
Assert.assertFalse(cp8.isAnyType);
|
||||
Assertions.assertEquals(cp8.baseName, "array_any_value_with_desc");
|
||||
Assertions.assertEquals(cp8.dataType, "List<Object>");
|
||||
Assertions.assertFalse(cp8.required);
|
||||
Assertions.assertTrue(cp8.isPrimitiveType);
|
||||
Assertions.assertTrue(cp8.isContainer);
|
||||
Assertions.assertTrue(cp8.isArray);
|
||||
Assertions.assertFalse(cp8.isFreeFormObject);
|
||||
Assertions.assertFalse(cp8.isAnyType);
|
||||
|
||||
// Should allow in any type including array, https://github.com/swagger-api/swagger-parser/issues/1603
|
||||
final CodegenProperty cp9 = cm2.vars.get(8);
|
||||
Assert.assertEquals(cp9.baseName, "array_any_value_nullable");
|
||||
Assert.assertEquals(cp9.dataType, "List<Object>");
|
||||
Assert.assertFalse(cp9.required);
|
||||
Assert.assertTrue(cp9.isPrimitiveType);
|
||||
Assert.assertTrue(cp9.isContainer);
|
||||
Assert.assertTrue(cp9.isArray);
|
||||
Assert.assertFalse(cp9.isFreeFormObject);
|
||||
Assert.assertFalse(cp9.isAnyType);
|
||||
Assertions.assertEquals(cp9.baseName, "array_any_value_nullable");
|
||||
Assertions.assertEquals(cp9.dataType, "List<Object>");
|
||||
Assertions.assertFalse(cp9.required);
|
||||
Assertions.assertTrue(cp9.isPrimitiveType);
|
||||
Assertions.assertTrue(cp9.isContainer);
|
||||
Assertions.assertTrue(cp9.isArray);
|
||||
Assertions.assertFalse(cp9.isFreeFormObject);
|
||||
Assertions.assertFalse(cp9.isAnyType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1362,7 +1361,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 49);
|
||||
Assertions.assertEquals(files.size(), 49);
|
||||
TestUtils.ensureContainsFile(
|
||||
files, output, "src/main/java/org/openapitools/client/model/RealCommand.java");
|
||||
TestUtils.ensureContainsFile(
|
||||
@ -1657,7 +1656,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 35);
|
||||
Assertions.assertEquals(files.size(), 35);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(
|
||||
@ -1688,7 +1687,7 @@ public class JavaClientCodegenTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 38);
|
||||
Assertions.assertEquals(files.size(), 38);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(
|
||||
@ -2159,7 +2158,7 @@ public class JavaClientCodegenTest {
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
Assert.assertEquals(files.size(), 27);
|
||||
Assertions.assertEquals(files.size(), 27);
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
TestUtils.assertFileContains(
|
||||
@ -2497,12 +2496,12 @@ public class JavaClientCodegenTest {
|
||||
CodegenModel cm1 = codegen.fromModel("Cat", test1);
|
||||
|
||||
CodegenProperty cp0 = cm1.getAllVars().get(0);
|
||||
Assert.assertEquals(cp0.getName(), "petType");
|
||||
Assert.assertEquals(cp0.isOverridden, true);
|
||||
Assertions.assertEquals(cp0.getName(), "petType");
|
||||
Assertions.assertEquals(cp0.isOverridden, true);
|
||||
|
||||
CodegenProperty cp1 = cm1.getAllVars().get(1);
|
||||
Assert.assertEquals(cp1.getName(), "name");
|
||||
Assert.assertEquals(cp1.isOverridden, false);
|
||||
Assertions.assertEquals(cp1.getName(), "name");
|
||||
Assertions.assertEquals(cp1.isOverridden, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -3030,7 +3029,7 @@ public class JavaClientCodegenTest {
|
||||
|
||||
File apiFile = files.get("HelloExampleApi.java");
|
||||
|
||||
Assert.assertNotNull(apiFile);
|
||||
Assertions.assertNotNull(apiFile);
|
||||
JavaFileAssert.assertThat(apiFile)
|
||||
.assertMethod("helloCall", "String", "ApiCallback")
|
||||
.bodyContainsLines(
|
||||
@ -3154,12 +3153,12 @@ public class JavaClientCodegenTest {
|
||||
|
||||
// enum
|
||||
File modelFile = files.get("Metadata.java");
|
||||
Assert.assertNotNull(modelFile);
|
||||
Assertions.assertNotNull(modelFile);
|
||||
JavaFileAssert.assertThat(modelFile).fileContains(expectedEnumLines);
|
||||
|
||||
// Inner enum
|
||||
File apiFile = files.get("V1SchemasGetDefaultResponse.java");
|
||||
Assert.assertNotNull(apiFile);
|
||||
Assertions.assertNotNull(apiFile);
|
||||
JavaFileAssert.assertThat(apiFile).fileContains(expectedInnerEnumLines);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@ -76,18 +76,16 @@ public class JavaHelidonCommonCodegenPackagePrefixTest {
|
||||
String explicitPrefix,
|
||||
String generatorName,
|
||||
String libraryName) {
|
||||
IllegalArgumentException e = Assert.assertThrows("Run invalid combo: " + assertMsg(explicitHelidonVersion,
|
||||
explicitPrefix,
|
||||
generatorName,
|
||||
libraryName),
|
||||
IllegalArgumentException.class,
|
||||
() -> runTest(explicitHelidonVersion, explicitPrefix, generatorName, libraryName));
|
||||
Assert.assertTrue("Exception message for " + assertMsg(explicitHelidonVersion,
|
||||
explicitPrefix,
|
||||
generatorName,
|
||||
libraryName)
|
||||
+ "'" + e.getMessage() + "' containing '" + EXCEPTION_MESSAGE_FRAGMENT + "'",
|
||||
e.getMessage().contains(EXCEPTION_MESSAGE_FRAGMENT));
|
||||
IllegalArgumentException e = Assert.expectThrows(
|
||||
"Run invalid combo: " + assertMsg(explicitHelidonVersion, explicitPrefix, generatorName, libraryName),
|
||||
IllegalArgumentException.class,
|
||||
() -> runTest(explicitHelidonVersion, explicitPrefix, generatorName, libraryName)
|
||||
);
|
||||
Assert.assertTrue(
|
||||
e.getMessage().contains(EXCEPTION_MESSAGE_FRAGMENT),
|
||||
"Exception message for " + assertMsg(explicitHelidonVersion, explicitPrefix, generatorName, libraryName)
|
||||
+ "'" + e.getMessage() + "' containing '" + EXCEPTION_MESSAGE_FRAGMENT + "'"
|
||||
);
|
||||
}
|
||||
|
||||
private static String assertMsg(String explicitHelidonVersion, String explicitPrefix, String generatorName, String libraryName) {
|
||||
|
@ -26,12 +26,12 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.languages.JavaHelidonCommonCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -97,7 +97,7 @@ public class JavaHelidonCommonCodegenTest {
|
||||
|
||||
@Test
|
||||
public void bothNotEqualsVersionTest() {
|
||||
IllegalArgumentException e = Assert.assertThrows(IllegalArgumentException.class,() -> runServerVersionTest("1.0.0", "2.0.0"));
|
||||
IllegalArgumentException e = Assert.expectThrows(IllegalArgumentException.class, () -> runServerVersionTest("1.0.0", "2.0.0"));
|
||||
Assert.assertEquals(
|
||||
"Both parentVersion and helidonVersion properties were set with different value.",
|
||||
e.getMessage());
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.openapitools.codegen.jetbrains.http.client;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.languages.JetbrainsHttpClientClientCodegen;
|
||||
@ -403,7 +403,7 @@ public class JetbrainsHttpClientClientCodegenTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // For some reason this test fails during Docker image generation. Investigate one day.
|
||||
@Disabled // For some reason this test fails during Docker image generation. Investigate one day.
|
||||
public void testBasicGenerationMultipleRequests() throws IOException {
|
||||
// Checking that each request example is present in the output file
|
||||
File output = Files.createTempDirectory("jetbrainstest_").toFile();
|
||||
|
@ -8,6 +8,7 @@ import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.KotlinClientCodegen;
|
||||
import org.openapitools.codegen.languages.KotlinSpringServerCodegen;
|
||||
import org.openapitools.codegen.utils.StringUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -22,7 +23,11 @@ import static org.testng.Assert.assertEquals;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class KotlinReservedWordsTest {
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/kotlin/reserved_words.yaml");
|
||||
OpenAPI openAPI;
|
||||
|
||||
@BeforeTest void loadOpenApi() {
|
||||
openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/kotlin/reserved_words.yaml");
|
||||
}
|
||||
|
||||
@DataProvider(name = "reservedWords")
|
||||
static Object[][] reservedWords() {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package org.openapitools.codegen.kotlin.spring;
|
||||
|
||||
import com.google.common.collect.testing.Helpers;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
@ -225,7 +225,7 @@ public class KotlinSpringServerCodegenTest {
|
||||
)
|
||||
.generate();
|
||||
|
||||
Helpers.assertContainsAllOf(files,
|
||||
Assertions.assertThat(files).contains(
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiController.kt"),
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"),
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV2ApiController.kt"),
|
||||
@ -250,7 +250,7 @@ public class KotlinSpringServerCodegenTest {
|
||||
)
|
||||
.generate();
|
||||
|
||||
Helpers.assertContainsAllOf(files,
|
||||
Assertions.assertThat(files).contains(
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1Api.kt"),
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiController.kt"),
|
||||
new File(output, "src/main/kotlin/org/openapitools/api/TestV1ApiDelegate.kt"),
|
||||
|
@ -18,7 +18,7 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
// This test class is in this package, not org.openapitools.codegen.java.helidon, so it can refer to elements of
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.openapitools.codegen.n4js;
|
||||
|
||||
import static java.lang.Boolean.parseBoolean;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.openapitools.codegen.CodegenConstants.API_NAME_PREFIX;
|
||||
import static org.openapitools.codegen.CodegenConstants.API_PACKAGE;
|
||||
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.models.tags.Tag;
|
||||
import org.junit.Assert;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.languages.PostmanCollectionCodegen;
|
||||
@ -22,10 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.openapitools.codegen.TestUtils.*;
|
||||
|
||||
public class PostmanCollectionCodegenTest {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.python;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
@ -31,7 +31,6 @@ import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||
import static org.openapitools.codegen.TestUtils.assertFileExists;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.java.assertions.JavaFileAssert;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import java.io.File;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.openapitools.codegen.templating.mustache;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -7,11 +7,14 @@ import org.openapitools.codegen.Generator;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
@ -21,28 +24,33 @@ import static org.openapitools.codegen.typescript.TypeScriptGroups.*;
|
||||
|
||||
@Test(groups = {TYPESCRIPT})
|
||||
public class SharedTypeScriptTest {
|
||||
|
||||
@Test
|
||||
public void typesInImportsAreSplitTest() throws IOException {
|
||||
Path output = Files.createTempDirectory("test");
|
||||
output.toFile().deleteOnExit();
|
||||
|
||||
CodegenConfigurator config =
|
||||
new CodegenConfigurator()
|
||||
.setInputSpec("src/test/resources/split-import.json")
|
||||
.setModelPackage("model")
|
||||
.setApiPackage("api")
|
||||
.setOutputDir("src/test/resources/typesInImportsAreSplittedTest")
|
||||
.setOutputDir(output.toString())
|
||||
.addAdditionalProperty(
|
||||
TypeScriptAxiosClientCodegen.SEPARATE_MODELS_AND_API, true);
|
||||
|
||||
config.setGeneratorName("typescript-axios");
|
||||
// TODO uncomment/fix the test below
|
||||
//checkAPIFile(getGenerator(config).generate(), "default-api.ts");
|
||||
getGenerator(config).generate();
|
||||
final String apiFileContent = Files.readString(output.resolve("api/default-api.ts"), StandardCharsets.UTF_8);
|
||||
Assert.assertFalse(apiFileContent.contains("import { GetCustomer200Response | PersonWrapper }"));
|
||||
Assert.assertEquals(StringUtils.countMatches(apiFileContent,"import type { PersonWrapper }"),1);
|
||||
Assert.assertEquals(StringUtils.countMatches(apiFileContent,"import type { GetCustomer200Response }"),1);
|
||||
|
||||
config.setGeneratorName("typescript-node");
|
||||
checkAPIFile(getGenerator(config).generate(), "defaultApi.ts");
|
||||
|
||||
config.setGeneratorName("typescript-angular");
|
||||
checkAPIFile(getGenerator(config).generate(), "default.service.ts");
|
||||
|
||||
FileUtils.deleteDirectory(new File("src/test/resources/typesInImportsAreSplittedTest"));
|
||||
}
|
||||
|
||||
private Generator getGenerator(CodegenConfigurator config) {
|
||||
@ -52,19 +60,22 @@ public class SharedTypeScriptTest {
|
||||
private void checkAPIFile(List<File> files, String apiFileName) throws IOException {
|
||||
File apiFile = files.stream().filter(file->file.getName().contains(apiFileName)).findFirst().get();
|
||||
String apiFileContent = FileUtils.readFileToString(apiFile, StandardCharsets.UTF_8);
|
||||
Assert.assertTrue(!apiFileContent.contains("import { GetCustomer200Response | PersonWrapper }"));
|
||||
Assert.assertFalse(apiFileContent.contains("import { GetCustomer200Response | PersonWrapper }"));
|
||||
Assert.assertEquals(StringUtils.countMatches(apiFileContent,"import { PersonWrapper }"),1);
|
||||
Assert.assertEquals(StringUtils.countMatches(apiFileContent,"import { GetCustomer200Response }"),1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oldImportsStillPresentTest() throws IOException {
|
||||
Path output = Files.createTempDirectory("test");
|
||||
output.toFile().deleteOnExit();
|
||||
|
||||
CodegenConfigurator config =
|
||||
new CodegenConfigurator()
|
||||
.setInputSpec("petstore.json")
|
||||
.setModelPackage("model")
|
||||
.setApiPackage("api")
|
||||
.setOutputDir("src/test/resources/oldImportsStillPresentTest/")
|
||||
.setOutputDir(output.toString())
|
||||
.addAdditionalProperty(
|
||||
TypeScriptAxiosClientCodegen.SEPARATE_MODELS_AND_API, true);
|
||||
|
||||
|
@ -20,6 +20,8 @@ import static org.testng.Assert.*;
|
||||
@SuppressWarnings({"SameParameterValue", "UnstableApiUsage"})
|
||||
public class OnceLoggerTest {
|
||||
private Logger mockLogger = Mockito.mock(Logger.class);
|
||||
|
||||
// TODO if we find a replacement for FakeTicker, we can drop the guava-testlib dependency altogether
|
||||
private FakeTicker ticker = new FakeTicker();
|
||||
|
||||
@BeforeTest
|
||||
|
9
pom.xml
9
pom.xml
@ -1186,10 +1186,11 @@
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
@ -1234,7 +1235,7 @@
|
||||
<jackson.version>2.16.2</jackson.version>
|
||||
<jacoco.version>0.8.10</jacoco.version>
|
||||
<jmustache.version>1.15</jmustache.version>
|
||||
<junit.version>4.13.2</junit.version>
|
||||
<junit.version>5.10.2</junit.version>
|
||||
<kotlin.version>1.6.21</kotlin.version>
|
||||
<kotlin-compiler-embeddable.version>1.6.21</kotlin-compiler-embeddable.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
|
@ -41,7 +41,6 @@
|
||||
</systemPropertyVariables>
|
||||
<argLine>-Xms512m -Xmx1500m</argLine>
|
||||
<parallel>methods</parallel>
|
||||
<forkMode>pertest</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -114,8 +113,8 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@ -124,6 +123,6 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<openapi-generator-version>7.7.0-SNAPSHOT</openapi-generator-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.13.2</junit-version>
|
||||
<junit-version>5.10.2</junit-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.my.company.codegen;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
@ -33,4 +33,4 @@ public class MyclientcodegenGeneratorTest {
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.opts(clientOptInput).generate();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user