forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reproducer issue as integration test
- Loading branch information
1 parent
01fb703
commit 8847019
Showing
10 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ion-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/Child.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,32 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import java.util.Objects; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
import org.hibernate.Hibernate; | ||
|
||
@Entity | ||
public class Child extends ChildBase { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) | ||
return false; | ||
Child that = (Child) o; | ||
return id != null && Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getClass().hashCode(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/ChildBase.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,9 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import jakarta.persistence.MappedSuperclass; | ||
|
||
@MappedSuperclass | ||
public class ChildBase { | ||
String name; | ||
String detail; | ||
} |
32 changes: 32 additions & 0 deletions
32
...on-tests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/Father.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,32 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import java.util.Objects; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
import org.hibernate.Hibernate; | ||
|
||
@Entity | ||
public class Father extends FatherBase<Child> { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) | ||
return false; | ||
Father that = (Father) o; | ||
return id != null && Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getClass().hashCode(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ests/spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/FatherBase.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,17 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.MappedSuperclass; | ||
import jakarta.persistence.OneToMany; | ||
|
||
@MappedSuperclass | ||
public class FatherBase<T extends ChildBase> { | ||
String name; | ||
String detail; | ||
int age; | ||
float test; | ||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<T> children; | ||
} |
9 changes: 9 additions & 0 deletions
9
...g-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/FatherBaseRepository.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,9 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.repository.NoRepositoryBean; | ||
|
||
@NoRepositoryBean | ||
public interface FatherBaseRepository<T extends FatherBase<?>> extends JpaRepository<T, Long> { | ||
long countParentsByChildren_Name(String name); | ||
} |
4 changes: 4 additions & 0 deletions
4
...pring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/FatherRepository.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,4 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
public interface FatherRepository extends FatherBaseRepository<Father> { | ||
} |
27 changes: 27 additions & 0 deletions
27
.../spring-data-jpa/src/main/java/io/quarkus/it/spring/data/jpa/generics/FatherResource.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,27 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/rest/fathers") | ||
@ApplicationScoped | ||
public class FatherResource { | ||
private final FatherBaseRepository<Father> fatherRepository; | ||
|
||
public FatherResource(FatherBaseRepository<Father> fatherRepository) { | ||
this.fatherRepository = fatherRepository; | ||
} | ||
|
||
@GET | ||
@Path("/{childName}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public long getParents(@PathParam("childName") String childName) { | ||
long nameFathers = fatherRepository.countParentsByChildren_Name(childName); | ||
return nameFathers; | ||
} | ||
|
||
} |
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
8 changes: 8 additions & 0 deletions
8
...pring-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/generics/FatherResourceIT.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,8 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class FatherResourceIT extends FatherResourceTest { | ||
// Execute the same tests but in packaged mode. | ||
} |
21 changes: 21 additions & 0 deletions
21
...ing-data-jpa/src/test/java/io/quarkus/it/spring/data/jpa/generics/FatherResourceTest.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,21 @@ | ||
package io.quarkus.it.spring.data.jpa.generics; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class FatherResourceTest { | ||
|
||
@Test | ||
public void shouldReturnEveParents() { | ||
given() | ||
.when().get("/rest/fathers/Eve") | ||
.then() | ||
.statusCode(200).body(containsString("3")); | ||
} | ||
|
||
} |