Skip to content

Commit 1bbd866

Browse files
committed
Fix test case
1 parent eab525a commit 1bbd866

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,4 +1396,58 @@ public void generateQuarkusImplWithAuthenticatedForOAuth2EmptyScopes() throws Ex
13961396
assertFileContains(defaultApi, "@io.quarkus.security.Authenticated");
13971397
}
13981398

1399+
@Test
1400+
public void generateQuarkusInterfaceWithoutAuthenticatedForOAuth2WithScopes() throws Exception {
1401+
final File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
1402+
output.deleteOnExit();
1403+
1404+
final OpenAPI openAPI = new OpenAPIParser()
1405+
.readLocation("src/test/resources/3_0/jaxrs-spec/quarkus-oauth2-with-scopes.yaml", null, new ParseOptions()).getOpenAPI();
1406+
1407+
codegen.setOutputDir(output.getAbsolutePath());
1408+
codegen.setLibrary(QUARKUS_LIBRARY);
1409+
codegen.additionalProperties().put(INTERFACE_ONLY, true);
1410+
codegen.additionalProperties().put(USE_JAKARTA_EE, true);
1411+
1412+
final ClientOptInput input = new ClientOptInput()
1413+
.openAPI(openAPI)
1414+
.config(codegen);
1415+
1416+
final DefaultGenerator generator = new DefaultGenerator();
1417+
final List<File> files = generator.opts(input).generate();
1418+
1419+
validateJavaSourceFiles(files);
1420+
1421+
final Path defaultApi = output.toPath().resolve("src/gen/java/org/openapitools/api/ItemsApi.java");
1422+
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/ItemsApi.java");
1423+
assertFileNotContains(defaultApi, "@io.quarkus.security.Authenticated");
1424+
}
1425+
1426+
@Test
1427+
public void generateQuarkusImplWithoutAuthenticatedForOAuth2WithScopes() throws Exception {
1428+
final File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
1429+
output.deleteOnExit();
1430+
1431+
final OpenAPI openAPI = new OpenAPIParser()
1432+
.readLocation("src/test/resources/3_0/jaxrs-spec/quarkus-oauth2-with-scopes.yaml", null, new ParseOptions()).getOpenAPI();
1433+
1434+
codegen.setOutputDir(output.getAbsolutePath());
1435+
codegen.setLibrary(QUARKUS_LIBRARY);
1436+
codegen.additionalProperties().put(INTERFACE_ONLY, false);
1437+
codegen.additionalProperties().put(USE_JAKARTA_EE, true);
1438+
1439+
final ClientOptInput input = new ClientOptInput()
1440+
.openAPI(openAPI)
1441+
.config(codegen);
1442+
1443+
final DefaultGenerator generator = new DefaultGenerator();
1444+
final List<File> files = generator.opts(input).generate();
1445+
1446+
validateJavaSourceFiles(files);
1447+
1448+
final Path defaultApi = output.toPath().resolve("src/gen/java/org/openapitools/api/ItemsApi.java");
1449+
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/ItemsApi.java");
1450+
assertFileNotContains(defaultApi, "@io.quarkus.security.Authenticated");
1451+
}
1452+
13991453
}

0 commit comments

Comments
 (0)