-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…implementations - Fixes quarkusio#35169
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.quarkus.hibernate.orm.rest.data.panache.deployment.entity; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.ForbiddenException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.rest.data.panache.RestDataResourceMethodListener; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class PanacheEntityResourceMethodListenerExceptionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Collection.class, CollectionsResource.class, AbstractEntity.class, AbstractItem.class, | ||
Item.class, ItemsResource.class, WebApplicationExceptionResourceMethodListener.class) | ||
.addAsResource("application.properties") | ||
.addAsResource("import.sql")); | ||
|
||
@Test | ||
void shouldReceiveWebApplicationException() { | ||
given().accept("application/json") | ||
.and().contentType("application/json") | ||
.and().body("{\"name\": \"test-simple\", \"collection\": {\"id\": \"full\"}}") | ||
.when().post("/items") | ||
.then() | ||
.statusCode(403); | ||
} | ||
|
||
@ApplicationScoped | ||
public static class WebApplicationExceptionResourceMethodListener implements RestDataResourceMethodListener<Item> { | ||
|
||
@Override | ||
public void onBeforeAdd(Item item) { | ||
throw new ForbiddenException("You shall not pass"); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.quarkus.hibernate.reactive.rest.data.panache.deployment.entity; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.ForbiddenException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.reactive.rest.data.panache.RestDataResourceMethodListener; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class PanacheEntityResourceMethodListenerExceptionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Collection.class, CollectionsResource.class, AbstractEntity.class, AbstractItem.class, | ||
Item.class, ItemsResource.class, WebApplicationExceptionResourceMethodListener.class) | ||
.addAsResource("application.properties") | ||
.addAsResource("import.sql")); | ||
|
||
@Test | ||
void shouldReceiveWebApplicationException() { | ||
given().accept("application/json") | ||
.and().contentType("application/json") | ||
.and().body("{\"name\": \"test-simple\", \"collection\": {\"id\": \"full\"}}") | ||
.when().post("/items") | ||
.then() | ||
.statusCode(403); | ||
Check failure on line 31 in extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/entity/PanacheEntityResourceMethodListenerExceptionTest.java GitHub Actions / Build summary for 8740e13006d91240c7c8d0d0c8cfde0a06c7c613JVM Tests - JDK 11
Raw output
Check failure on line 31 in extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/entity/PanacheEntityResourceMethodListenerExceptionTest.java GitHub Actions / Build summary for 8740e13006d91240c7c8d0d0c8cfde0a06c7c613JVM Tests - JDK 17
Raw output
Check failure on line 31 in extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/entity/PanacheEntityResourceMethodListenerExceptionTest.java GitHub Actions / Build summary for 8740e13006d91240c7c8d0d0c8cfde0a06c7c613JVM Tests - JDK 20
Raw output
|
||
} | ||
|
||
@ApplicationScoped | ||
public static class WebApplicationExceptionResourceMethodListener implements RestDataResourceMethodListener<Item> { | ||
|
||
@Override | ||
public void onBeforeAdd(Item item) { | ||
throw new ForbiddenException("You shall not pass"); | ||
} | ||
} | ||
|
||
} |