Skip to content

Commit 12378a4

Browse files
Ignacio-Vidalclaude
andcommitted
[jaxrs-spec][quarkus] Test useQuarkusSecurityAnnotations CLI option registration
Covers: option registered with default false, readable as true for quarkus library, and not processed for non-quarkus libraries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f4de345 commit 12378a4

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,4 +1545,45 @@ public void generateQuarkusConcreteClassDoesNotAddResponseStatusAnnotation() thr
15451545
"@ResponseStatus",
15461546
"import org.jboss.resteasy.reactive.ResponseStatus");
15471547
}
1548+
1549+
@Test
1550+
public void useQuarkusSecurityAnnotationsIsRegisteredWithDefaultFalse() {
1551+
final JavaJAXRSSpecServerCodegen codegen = new JavaJAXRSSpecServerCodegen();
1552+
Assert.assertTrue(
1553+
codegen.cliOptions().stream()
1554+
.anyMatch(opt -> USE_QUARKUS_SECURITY_ANNOTATIONS.equals(opt.getOpt()) && "false".equals(opt.getDefault())),
1555+
"useQuarkusSecurityAnnotations should be a registered CLI option defaulting to false"
1556+
);
1557+
}
1558+
1559+
@Test
1560+
public void useQuarkusSecurityAnnotationsDefaultsToFalseForQuarkusLibrary() {
1561+
codegen.setLibrary(QUARKUS_LIBRARY);
1562+
codegen.processOpts();
1563+
1564+
Assert.assertFalse(
1565+
(boolean) codegen.additionalProperties().getOrDefault(USE_QUARKUS_SECURITY_ANNOTATIONS, false)
1566+
);
1567+
}
1568+
1569+
@Test
1570+
public void useQuarkusSecurityAnnotationsCanBeEnabledForQuarkusLibrary() {
1571+
codegen.setLibrary(QUARKUS_LIBRARY);
1572+
codegen.additionalProperties().put(USE_QUARKUS_SECURITY_ANNOTATIONS, true);
1573+
codegen.processOpts();
1574+
1575+
new ConfigAssert(codegen.additionalProperties())
1576+
.assertValue(USE_QUARKUS_SECURITY_ANNOTATIONS, true);
1577+
}
1578+
1579+
@Test
1580+
public void useQuarkusSecurityAnnotationsNotProcessedForNonQuarkusLibrary() {
1581+
// flag is only consumed when library=quarkus; for other libraries the block is skipped
1582+
codegen.additionalProperties().put(USE_QUARKUS_SECURITY_ANNOTATIONS, true);
1583+
codegen.processOpts();
1584+
1585+
// convertPropertyToBooleanAndWriteBack was never called, so the value was never
1586+
// written back as a boolean — the key holds the raw Object we put in, not false
1587+
Assert.assertNotEquals(false, codegen.additionalProperties().get(USE_QUARKUS_SECURITY_ANNOTATIONS));
1588+
}
15481589
}

0 commit comments

Comments
 (0)