diff --git a/extensions/hibernate-orm/deployment/pom.xml b/extensions/hibernate-orm/deployment/pom.xml index 8d828fe785924..d1b1770d2f167 100644 --- a/extensions/hibernate-orm/deployment/pom.xml +++ b/extensions/hibernate-orm/deployment/pom.xml @@ -53,6 +53,11 @@ io.quarkus quarkus-vertx-http-dev-ui-spi + + io.quarkus + quarkus-vertx-http-dev-ui-tests + test + io.quarkus quarkus-junit5-internal diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/HibernateOrmDevUITest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/HibernateOrmDevUITest.java new file mode 100644 index 0000000000000..42d97197e5203 --- /dev/null +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/HibernateOrmDevUITest.java @@ -0,0 +1,91 @@ +package io.quarkus.hibernate.orm.devui; + +import java.util.Iterator; + +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import com.fasterxml.jackson.databind.JsonNode; + +import io.quarkus.devui.tests.DevUIJsonRPCTest; +import io.quarkus.test.QuarkusDevModeTest; + +public class HibernateOrmDevUITest extends DevUIJsonRPCTest { + + @RegisterExtension + static final QuarkusDevModeTest test = new QuarkusDevModeTest() + .withApplicationRoot((jar) -> jar.addAsResource( + new StringAsset("quarkus.datasource.db-kind=h2\n" + + "quarkus.datasource.jdbc.url=jdbc:h2:mem:test\n"), + "application.properties") + .addClasses(MyEntity.class)); + + @Test + public void testGetInfo() throws Exception { + JsonNode getInfoResponse = super.executeJsonRPCMethod("getInfo"); + Assertions.assertNotNull(getInfoResponse); + + JsonNode persistenceUnits = getInfoResponse.get("persistenceUnits"); + Assertions.assertNotNull(persistenceUnits); + Assertions.assertTrue(persistenceUnits.isArray()); + + Iterator persistenceUnitsIterator = persistenceUnits.elements(); + while (persistenceUnitsIterator.hasNext()) { + JsonNode defaultPersistenceUnit = persistenceUnitsIterator.next(); + JsonNode name = defaultPersistenceUnit.get("name"); + Assertions.assertEquals("", name.asText()); + + JsonNode managedEntities = defaultPersistenceUnit.get("managedEntities"); + Assertions.assertNotNull(managedEntities); + Assertions.assertTrue(managedEntities.isArray()); + + Iterator managedEntitiesIterator = managedEntities.elements(); + while (managedEntitiesIterator.hasNext()) { + JsonNode myEntity = managedEntitiesIterator.next(); + + String className = myEntity.get("className").asText(); + Assertions.assertEquals("io.quarkus.hibernate.orm.devui.MyEntity", className); + + String tableName = myEntity.get("tableName").asText(); + Assertions.assertEquals("MyEntity", tableName); + } + + JsonNode namedQueries = defaultPersistenceUnit.get("namedQueries"); + Assertions.assertNotNull(namedQueries); + Assertions.assertTrue(namedQueries.isArray()); + + } + } + + @Test + public void testGetNumberOfPersistenceUnits() throws Exception { + JsonNode getNumberOfPersistenceUnitsResponse = super.executeJsonRPCMethod("getNumberOfPersistenceUnits"); + Assertions.assertNotNull(getNumberOfPersistenceUnitsResponse); + Assertions.assertTrue(getNumberOfPersistenceUnitsResponse.isInt()); + Assertions.assertEquals(1, getNumberOfPersistenceUnitsResponse.asInt()); + } + + @Test + public void testGetNumberOfEntityTypes() throws Exception { + JsonNode getNumberOfEntityTypesResponse = super.executeJsonRPCMethod("getNumberOfEntityTypes"); + Assertions.assertNotNull(getNumberOfEntityTypesResponse); + Assertions.assertTrue(getNumberOfEntityTypesResponse.isInt()); + Assertions.assertEquals(1, getNumberOfEntityTypesResponse.asInt()); + } + + @Test + public void testGetNumberOfNamedQueries() throws Exception { + JsonNode getNumberOfNamedQueriesResponse = super.executeJsonRPCMethod("getNumberOfNamedQueries"); + Assertions.assertNotNull(getNumberOfNamedQueriesResponse); + Assertions.assertTrue(getNumberOfNamedQueriesResponse.isInt()); + Assertions.assertEquals(0, getNumberOfNamedQueriesResponse.asInt()); + } + + @Override + protected String getNamespace() { + return "io.quarkus.quarkus-hibernate-orm"; + } + +} diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/MyEntity.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/MyEntity.java new file mode 100644 index 0000000000000..622bdfa97927e --- /dev/null +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/MyEntity.java @@ -0,0 +1,16 @@ +package io.quarkus.hibernate.orm.devui; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; + +@Entity +public class MyEntity { + + @Id + Long id; + + @Column + String field; + +} diff --git a/integration-tests/devmode/pom.xml b/integration-tests/devmode/pom.xml index 6a6c2b5ce8521..f149a3b7510d3 100644 --- a/integration-tests/devmode/pom.xml +++ b/integration-tests/devmode/pom.xml @@ -14,6 +14,11 @@ + + io.quarkus + quarkus-vertx-http-dev-ui-tests + test + io.quarkus quarkus-resteasy-reactive-deployment diff --git a/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleHibernateOrmSmokeTest.java b/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleHibernateOrmSmokeTest.java index 58a8ef4b09512..542c8f0c461fd 100644 --- a/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleHibernateOrmSmokeTest.java +++ b/integration-tests/devmode/src/test/java/io/quarkus/test/devconsole/DevConsoleHibernateOrmSmokeTest.java @@ -39,25 +39,4 @@ public void testLegacyPages() { .statusCode(200) .body(Matchers.containsString("No named queries were found.")); } - - @Test - public void testPages() { - // TODO #31970 restore tests of the page's content as we used to do for the old Dev UI - - RestAssured.get("q/dev-ui/hibernate-orm/persistence-units") - .then() - .statusCode(200); - // .body(Matchers.containsString("<default>")); - - RestAssured.get("q/dev-ui/hibernate-orm/entity-types") - .then() - .statusCode(200); - // .body(Matchers.containsString("io.quarkus.test.devconsole.MyEntity")); - - RestAssured.get("q/dev-ui/hibernate-orm/named-queries") - .then() - .statusCode(200); - // .body(Matchers.containsString("No named queries were found.")); - } - }