-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34999 from Sgitario/34938
Allow to exclude classes in REST Data with Panache with annotations
- Loading branch information
Showing
11 changed files
with
216 additions
and
17 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
24 changes: 24 additions & 0 deletions
24
...rnate/orm/rest/data/panache/deployment/build/BuildConditionsWithResourceDisabledTest.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,24 @@ | ||
package io.quarkus.hibernate.orm.rest.data.panache.deployment.build; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BuildConditionsWithResourceDisabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Collection.class, CollectionsResource.class)); | ||
|
||
@Test | ||
void shouldResourceNotBeFound() { | ||
given().accept("application/json") | ||
.when().get("/collections") | ||
.then().statusCode(404); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ernate/orm/rest/data/panache/deployment/build/BuildConditionsWithResourceEnabledTest.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,25 @@ | ||
package io.quarkus.hibernate.orm.rest.data.panache.deployment.build; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BuildConditionsWithResourceEnabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.overrideConfigKey("collections.enabled", "true") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Collection.class, CollectionsResource.class)); | ||
|
||
@Test | ||
void shouldResourceBeFound() { | ||
given().accept("application/json") | ||
.when().get("/collections") | ||
.then().statusCode(200); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...src/test/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/build/Collection.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,15 @@ | ||
package io.quarkus.hibernate.orm.rest.data.panache.deployment.build; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheEntityBase; | ||
|
||
@Entity | ||
public class Collection extends PanacheEntityBase { | ||
|
||
@Id | ||
public String id; | ||
|
||
public String name; | ||
} |
8 changes: 8 additions & 0 deletions
8
...java/io/quarkus/hibernate/orm/rest/data/panache/deployment/build/CollectionsResource.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,8 @@ | ||
package io.quarkus.hibernate.orm.rest.data.panache.deployment.build; | ||
|
||
import io.quarkus.arc.properties.IfBuildProperty; | ||
import io.quarkus.hibernate.orm.rest.data.panache.PanacheEntityResource; | ||
|
||
@IfBuildProperty(name = "collections.enabled", stringValue = "true") | ||
public interface CollectionsResource extends PanacheEntityResource<Collection, String> { | ||
} |
25 changes: 25 additions & 0 deletions
25
.../reactive/rest/data/panache/deployment/build/BuildConditionsWithResourceDisabledTest.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,25 @@ | ||
package io.quarkus.hibernate.reactive.rest.data.panache.deployment.build; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BuildConditionsWithResourceDisabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.overrideConfigKey("collections.endpoint", "disable") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Collection.class, CollectionsResource.class)); | ||
|
||
@Test | ||
void shouldResourceNotBeFound() { | ||
given().accept("application/json") | ||
.when().get("/collections") | ||
.then().statusCode(404); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...e/reactive/rest/data/panache/deployment/build/BuildConditionsWithResourceEnabledTest.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,25 @@ | ||
package io.quarkus.hibernate.reactive.rest.data.panache.deployment.build; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BuildConditionsWithResourceEnabledTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.overrideConfigKey("collections.endpoint", "enable") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Collection.class, CollectionsResource.class)); | ||
|
||
@Test | ||
void shouldResourceBeFound() { | ||
given().accept("application/json") | ||
.when().get("/collections") | ||
.then().statusCode(200); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...est/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/build/Collection.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,15 @@ | ||
package io.quarkus.hibernate.reactive.rest.data.panache.deployment.build; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; | ||
|
||
@Entity | ||
public class Collection extends PanacheEntityBase { | ||
|
||
@Id | ||
public String id; | ||
|
||
public String name; | ||
} |
8 changes: 8 additions & 0 deletions
8
...io/quarkus/hibernate/reactive/rest/data/panache/deployment/build/CollectionsResource.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,8 @@ | ||
package io.quarkus.hibernate.reactive.rest.data.panache.deployment.build; | ||
|
||
import io.quarkus.hibernate.reactive.rest.data.panache.PanacheEntityResource; | ||
import io.quarkus.resteasy.reactive.server.EndpointDisabled; | ||
|
||
@EndpointDisabled(name = "collections.endpoint", stringValue = "disable") | ||
public interface CollectionsResource extends PanacheEntityResource<Collection, String> { | ||
} |
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
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