File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed
integration-tests/hibernate-orm-panache/src
java/io/quarkus/it/panache
test/java/io/quarkus/it/panache/custompu Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .quarkus .it .panache .custompu ;
2+
3+ import jakarta .persistence .Entity ;
4+
5+ import io .quarkus .hibernate .orm .panache .PanacheEntity ;
6+
7+ @ Entity
8+ public class CustomPuEntity extends PanacheEntity {
9+ public String string ;
10+ }
Original file line number Diff line number Diff line change 1+ package io .quarkus .it .panache .resources ;
2+
3+ import java .util .List ;
4+
5+ import jakarta .transaction .Transactional ;
6+ import jakarta .ws .rs .PATCH ;
7+ import jakarta .ws .rs .POST ;
8+ import jakarta .ws .rs .Path ;
9+ import jakarta .ws .rs .PathParam ;
10+
11+ import io .quarkus .it .panache .custompu .CustomPuEntity ;
12+
13+ @ Path ("/custom-pu" )
14+ public class CustomPuResource {
15+
16+ @ Transactional
17+ @ POST
18+ @ Path ("/{string}" )
19+ public CustomPuEntity create (@ PathParam ("string" ) String string ) {
20+ CustomPuEntity entity = new CustomPuEntity ();
21+ entity .string = string ;
22+ entity .persist ();
23+ return entity ;
24+ }
25+
26+ @ Transactional
27+ @ PATCH
28+ @ Path ("/{string}" )
29+ public List <CustomPuEntity > updateAll (@ PathParam ("string" ) String string ) {
30+ CustomPuEntity .update ("set string = ?1 where 1 = 1" , string );
31+ return CustomPuEntity .findAll ().list ();
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -7,3 +7,12 @@ quarkus.hibernate-orm.database.generation=drop-and-create
77
88quarkus.hibernate-orm.statistics =true
99quarkus.hibernate-orm.metrics.enabled =true
10+
11+ quarkus.datasource." custom" .db-kind =h2
12+ quarkus.datasource." custom" .jdbc.url =jdbc:h2:tcp://localhost/mem:test
13+ quarkus.datasource." custom" .jdbc.max-size =8
14+
15+ quarkus.hibernate-orm." custom" .datasource =custom
16+ quarkus.hibernate-orm." custom" .packages =io.quarkus.it.panache.custompu
17+ quarkus.hibernate-orm." custom" .database.generation =drop-and-create
18+ quarkus.hibernate-orm." custom" .database.generation.create-schemas =true
Original file line number Diff line number Diff line change 1+ package io .quarkus .it .panache .custompu ;
2+
3+ import static org .hamcrest .Matchers .containsString ;
4+
5+ import org .junit .jupiter .api .Test ;
6+
7+ import io .quarkus .test .junit .QuarkusTest ;
8+ import io .restassured .RestAssured ;
9+
10+ @ QuarkusTest
11+ class SmokeTest {
12+
13+ @ Test
14+ void testPanacheFunctionality () throws Exception {
15+ RestAssured .when ().post ("/custom-pu/someValue" ).then ().body (containsString ("someValue" ));
16+ RestAssured .when ().patch ("/custom-pu/someUpdatedValue" ).then ().body (containsString ("someUpdatedValue" ));
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments