-
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.
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
bd8a4ff
commit 9aab9fb
Showing
5 changed files
with
117 additions
and
21 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
91 changes: 91 additions & 0 deletions
91
...te-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/HibernateOrmDevUITest.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,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<JsonNode> persistenceUnitsIterator = persistenceUnits.elements(); | ||
while (persistenceUnitsIterator.hasNext()) { | ||
JsonNode defaultPersistenceUnit = persistenceUnitsIterator.next(); | ||
JsonNode name = defaultPersistenceUnit.get("name"); | ||
Assertions.assertEquals("<default>", name.asText()); | ||
|
||
JsonNode managedEntities = defaultPersistenceUnit.get("managedEntities"); | ||
Assertions.assertNotNull(managedEntities); | ||
Assertions.assertTrue(managedEntities.isArray()); | ||
|
||
Iterator<JsonNode> 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"; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...sions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/MyEntity.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,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; | ||
|
||
} |
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