Skip to content

Commit 7f25af0

Browse files
committed
Simplify test setup by using already available methods to configure and instantiate the generator.
This fixes the different behavior between Test and CLI seen in #17273 (comment)
1 parent 21bf477 commit 7f25af0

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,30 +4476,9 @@ public void multiLineTagDescription() throws IOException {
44764476

44774477
@Test
44784478
public void testSSEOperationSupport() throws Exception {
4479-
4480-
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
4481-
output.deleteOnExit();
4482-
4483-
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/sse.yaml");
4484-
final SpringCodegen codegen = new SpringCodegen();
4485-
codegen.setOpenAPI(openAPI);
4486-
codegen.setOutputDir(output.getAbsolutePath());
4487-
4488-
codegen.additionalProperties().put(SSE, "true");
4489-
codegen.additionalProperties().put(REACTIVE, "true");
4490-
codegen.additionalProperties().put(INTERFACE_ONLY, "false");
4491-
codegen.additionalProperties().put(DELEGATE_PATTERN, "true");
4492-
4493-
ClientOptInput input = new ClientOptInput();
4494-
input.openAPI(openAPI);
4495-
input.config(codegen);
4496-
4497-
DefaultGenerator generator = new DefaultGenerator();
4498-
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
4499-
generator.setGenerateMetadata(false);
4500-
4501-
Map<String, File> files = generator.opts(input).generate().stream()
4502-
.collect(Collectors.toMap(File::getName, Function.identity()));
4479+
Map<String, Object> additionalProperties = Map.of(SSE, true, REACTIVE, "true", INTERFACE_ONLY, "false",
4480+
DELEGATE_PATTERN, "true");
4481+
Map<String, File> files = generateFromContract("src/test/resources/3_0/sse.yaml", "spring-boot", additionalProperties);
45034482

45044483
MapAssert.assertThatMap(files).isNotEmpty();
45054484
File api = files.get("PathApi.java");

0 commit comments

Comments
 (0)