Skip to content

Commit

Permalink
Add a test for non default pu
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta authored and gsmet committed Aug 8, 2024
1 parent 83ace0d commit e3de691
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.it.panache.custompu;

import jakarta.persistence.Entity;

import io.quarkus.hibernate.orm.panache.PanacheEntity;

@Entity
public class CustomPuEntity extends PanacheEntity {
public String string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.it.panache.resources;

import java.util.List;

import jakarta.transaction.Transactional;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;

import io.quarkus.it.panache.custompu.CustomPuEntity;

@Path("/custom-pu")
public class CustomPuResource {

@Transactional
@POST
@Path("/{string}")
public CustomPuEntity create(@PathParam("string") String string) {
CustomPuEntity entity = new CustomPuEntity();
entity.string = string;
entity.persist();
return entity;
}

@Transactional
@PATCH
@Path("/{string}")
public List<CustomPuEntity> updateAll(@PathParam("string") String string) {
CustomPuEntity.update("set string = ?1 where 1 = 1", string);
return CustomPuEntity.findAll().list();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ quarkus.hibernate-orm.database.generation=drop-and-create

quarkus.hibernate-orm.statistics=true
quarkus.hibernate-orm.metrics.enabled=true

quarkus.datasource."custom".db-kind=h2
quarkus.datasource."custom".jdbc.url=jdbc:h2:tcp://localhost/mem:test
quarkus.datasource."custom".jdbc.max-size=8

quarkus.hibernate-orm."custom".datasource=custom
quarkus.hibernate-orm."custom".packages=io.quarkus.it.panache.custompu
quarkus.hibernate-orm."custom".database.generation=drop-and-create
quarkus.hibernate-orm."custom".database.generation.create-schemas=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkus.it.panache.custompu;

import static org.hamcrest.Matchers.containsString;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;

@QuarkusTest
class SmokeTest {

@Test
void testPanacheFunctionality() throws Exception {
RestAssured.when().post("/custom-pu/someValue").then().body(containsString("someValue"));
RestAssured.when().patch("/custom-pu/someUpdatedValue").then().body(containsString("someUpdatedValue"));
}
}

0 comments on commit e3de691

Please sign in to comment.