forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenAPI: ignore build-time excluded classes from annotation scan
Fixes quarkusio#16218 Signed-off-by: Michael Edgar <[email protected]>
- Loading branch information
1 parent
01cafae
commit f69f728
Showing
2 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
...st/java/io/quarkus/smallrye/openapi/test/jaxrs/OpenApiBuildTimeExcludedClassTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import static org.hamcrest.Matchers.aMapWithSize; | ||
import static org.hamcrest.Matchers.hasKey; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.profile.IfBuildProfile; | ||
import io.quarkus.arc.profile.UnlessBuildProfile; | ||
import io.quarkus.arc.properties.IfBuildProperty; | ||
import io.quarkus.arc.properties.UnlessBuildProperty; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
class OpenApiBuildTimeExcludedClassTestCase { | ||
|
||
static String quarkusProfile; | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(IfBuildProfileTest.class, | ||
IfBuildProfileBar.class, | ||
IfBuildPropertyBarBazIsTrue.class, | ||
IfBuildProperyFooBarIsTrue.class, | ||
UnlessBuildProfileBar.class, | ||
UnlessBuildProfileTest.class, | ||
UnlessBuildPropertyBarBazIsFalse.class, | ||
UnlessBuildProperyFooBarIsFalse.class) | ||
.addAsResource( | ||
new StringAsset("%test.foobar=true\n" | ||
+ "%test.barbaz=false\n" | ||
+ "foobar=false\n" | ||
+ "barbaz=true\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
void testAutoSecurityRequirement() { | ||
RestAssured.given() | ||
.header("Accept", "application/json") | ||
.when() | ||
.get("/q/openapi") | ||
.then() | ||
.log().body() | ||
.body("paths", aMapWithSize(4)) | ||
|
||
.body("paths", hasKey("/test-profile-enabled")) | ||
.body("paths", not(hasKey("/test-profile-not-enabled"))) | ||
.body("paths", hasKey("/bar-profile-not-enabled")) | ||
.body("paths", not(hasKey("/bar-profile-enabled"))) | ||
|
||
.body("paths", hasKey("/foobar-property-true")) | ||
.body("paths", hasKey("/foobar-property-not-false")) | ||
.body("paths", not(hasKey("/barbaz-property-true"))) | ||
.body("paths", not(hasKey("/barbaz-property-not-false"))); | ||
} | ||
|
||
@Path("/test-profile-enabled") | ||
@IfBuildProfile("test") | ||
public static class IfBuildProfileTest { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/bar-profile-enabled") | ||
@IfBuildProfile("bar") | ||
public static class IfBuildProfileBar { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/test-profile-not-enabled") | ||
@UnlessBuildProfile("test") | ||
public static class UnlessBuildProfileTest { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/bar-profile-not-enabled") | ||
@UnlessBuildProfile("bar") | ||
public static class UnlessBuildProfileBar { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/foobar-property-true") | ||
@IfBuildProperty(name = "foobar", stringValue = "true", enableIfMissing = false) | ||
public static class IfBuildProperyFooBarIsTrue { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/barbaz-property-true") | ||
@IfBuildProperty(name = "barbaz", stringValue = "true", enableIfMissing = false) | ||
public static class IfBuildPropertyBarBazIsTrue { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/foobar-property-not-false") | ||
@UnlessBuildProperty(name = "foobar", stringValue = "false", enableIfMissing = false) | ||
public static class UnlessBuildProperyFooBarIsFalse { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
@Path("/barbaz-property-not-false") | ||
@UnlessBuildProperty(name = "barbaz", stringValue = "false", enableIfMissing = false) | ||
public static class UnlessBuildPropertyBarBazIsFalse { | ||
@GET | ||
public String endpoint() { | ||
return ""; | ||
} | ||
} | ||
|
||
} |