-
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.
Hibernate reactive panache - validation of interceptor bindings
- the build only fails if any of [WithSession, WithTransaction, WithSessionOnDemand] is declared on a method that does not return Uni - if declared on a class then the methods that do not return Uni are effectively ignored
- Loading branch information
Showing
10 changed files
with
139 additions
and
31 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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
...a/io/quarkus/hibernate/reactive/panache/test/WithTransactionClassLevelValidationTest.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,41 @@ | ||
package io.quarkus.hibernate.reactive.panache.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
import io.quarkus.hibernate.reactive.panache.common.WithTransaction; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class WithTransactionClassLevelValidationTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot(root -> root | ||
.addClasses(Bean.class)); | ||
|
||
@Inject | ||
Bean bean; | ||
|
||
@Test | ||
public void testBindingIgnored() { | ||
assertEquals("ok", bean.ping()); | ||
} | ||
|
||
@WithTransaction | ||
@Unremovable | ||
@ApplicationScoped | ||
static class Bean { | ||
|
||
// this method is just ignored by the interceptor | ||
String ping() { | ||
return "ok"; | ||
} | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../io/quarkus/hibernate/reactive/panache/test/WithTransactionMethodLevelValidationTest.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,36 @@ | ||
package io.quarkus.hibernate.reactive.panache.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
import io.quarkus.hibernate.reactive.panache.common.WithTransaction; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class WithTransactionMethodLevelValidationTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setExpectedException(IllegalStateException.class) | ||
.withApplicationRoot(root -> root | ||
.addClasses(Bean.class)); | ||
|
||
@Test | ||
public void testValidationFailed() { | ||
fail(); | ||
} | ||
|
||
@Unremovable | ||
@ApplicationScoped | ||
static class Bean { | ||
|
||
@WithTransaction | ||
void ping() { | ||
} | ||
|
||
} | ||
} |