-
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.
Merge pull request #37458 from gsmet/move-java-17-tests
Move Java 17 records tests to their respective modules
- Loading branch information
Showing
14 changed files
with
98 additions
and
266 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...s/it/hibernate/panache/person/Person.java → ...anache/deployment/test/record/Person.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
2 changes: 1 addition & 1 deletion
2
.../hibernate/panache/person/PersonName.java → ...he/deployment/test/record/PersonName.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
72 changes: 72 additions & 0 deletions
72
...est/java/io/quarkus/hibernate/orm/panache/deployment/test/record/RecordInPanacheTest.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,72 @@ | ||
package io.quarkus.hibernate.orm.panache.deployment.test.record; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import jakarta.transaction.Transactional; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class RecordInPanacheTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addAsResource("application-test.properties", "application.properties") | ||
.addClasses(Person.class, PersonName.class, Status.class)); | ||
|
||
@Test | ||
@Transactional | ||
void testRecordInPanache() { | ||
var person1 = new Person(); | ||
person1.firstname = "Loïc"; | ||
person1.lastname = "Mathieu"; | ||
person1.status = Status.ALIVE; | ||
person1.persist(); | ||
|
||
var person2 = new Person(); | ||
person1.firstname = "Zombie"; | ||
person2.lastname = "Zombie"; | ||
person2.status = Status.DEAD; | ||
person2.persist(); | ||
|
||
assertEquals(2L, Person.count()); | ||
|
||
} | ||
|
||
@Test | ||
@Transactional | ||
void testHqlPanacheProject() { | ||
var mark = new Person(); | ||
mark.firstname = "Mark"; | ||
mark.lastname = "Mark"; | ||
mark.persistAndFlush(); | ||
|
||
var hqlWithoutSpace = """ | ||
select | ||
firstname, | ||
lastname | ||
from | ||
io.quarkus.hibernate.orm.panache.deployment.test.record.Person | ||
where | ||
firstname = ?1 | ||
"""; | ||
var persistedWithoutSpace = Person.find(hqlWithoutSpace, "Mark").project(PersonName.class).firstResult(); | ||
assertEquals("Mark", persistedWithoutSpace.firstname()); | ||
|
||
// We need to escape the whitespace in Java otherwise the compiler removes it. | ||
var hqlWithSpace = """ | ||
select\s | ||
firstname, | ||
lastname | ||
from | ||
io.quarkus.hibernate.orm.panache.deployment.test.record.Person | ||
where | ||
firstname = ?1 | ||
"""; | ||
var persistedWithSpace = Person.find(hqlWithSpace, "Mark").project(PersonName.class).firstResult(); | ||
assertEquals("Mark", persistedWithSpace.firstname()); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...s/it/hibernate/panache/person/Status.java → ...anache/deployment/test/record/Status.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
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
...on-tests/java-17/src/main/java/io/quarkus/it/hibernate/panache/person/PersonResource.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
integration-tests/java-17/src/main/resources/application.properties
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...it/mongodb/panache/person/PersonName.java → ...it/mongodb/panache/record/PersonName.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package io.quarkus.it.mongodb.panache.person; | ||
package io.quarkus.it.mongodb.panache.record; | ||
|
||
import io.quarkus.mongodb.panache.common.ProjectionFor; | ||
|
||
@ProjectionFor(Person.class) | ||
@ProjectionFor(PersonWithRecord.class) | ||
public record PersonName(String firstName, String lastName) { | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...kus/it/mongodb/panache/person/Person.java → ...godb/panache/record/PersonWithRecord.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
2 changes: 1 addition & 1 deletion
2
...kus/it/mongodb/panache/person/Status.java → ...kus/it/mongodb/panache/record/Status.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
Oops, something went wrong.