-
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.
Migrate to latests version for Spring dependencies
- Loading branch information
1 parent
8b28b65
commit d5c451e
Showing
37 changed files
with
1,414 additions
and
691 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
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
6 changes: 6 additions & 0 deletions
6
...pa/deployment/src/test/java/io/quarkus/spring/data/deployment/BookListCrudRepository.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,6 @@ | ||
package io.quarkus.spring.data.deployment; | ||
|
||
import org.springframework.data.repository.ListCrudRepository; | ||
|
||
public interface BookListCrudRepository extends ListCrudRepository<Book, Integer> { | ||
} |
79 changes: 79 additions & 0 deletions
79
...eployment/src/test/java/io/quarkus/spring/data/deployment/BookListCrudRepositoryTest.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,79 @@ | ||
package io.quarkus.spring.data.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.transaction.Transactional; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class BookListCrudRepositoryTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest().setArchiveProducer( | ||
() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource("import_books.sql", "import.sql") | ||
.addClasses(Book.class, BookListCrudRepository.class)) | ||
.withConfigurationResource("application.properties"); | ||
|
||
@Inject | ||
BookListCrudRepository repo; | ||
|
||
@Test | ||
@Order(1) | ||
@Transactional | ||
public void shouldListAllBooks() { | ||
List<Book> all = repo.findAll(); | ||
assertThat(all).isNotEmpty(); | ||
assertThat(all).hasSize(3); | ||
assertThat(all.stream().map(Book::getName)).containsExactlyInAnyOrder("Talking to Strangers", "The Ascent of Money", | ||
"A Short History of Everything"); | ||
} | ||
|
||
@Test | ||
@Order(2) | ||
@Transactional | ||
public void shouldListBooksWithIds() { | ||
List<Integer> ids = Arrays.asList(1, 2); | ||
List<Book> all = repo.findAllById(ids); | ||
assertThat(all).isNotEmpty(); | ||
assertThat(all).hasSize(2); | ||
assertThat(all.stream().map(Book::getName)).containsExactlyInAnyOrder("Talking to Strangers", "The Ascent of Money"); | ||
} | ||
|
||
@Test | ||
@Order(3) | ||
@Transactional | ||
public void shouldSaveBooks() { | ||
Book harryPotterAndTheChamberOfSecrets = populateBook(4, "Harry Potter and the Chamber of Secrets"); | ||
Book harryPotterAndThePrisonerOfAzkaban = populateBook(5, "Harry Potter and the Prisoner of Azkaban"); | ||
Book harryPotterAndTheGlobetOfFire = populateBook(6, "Harry Potter and the Globet of Fire"); | ||
List<Book> books = Arrays.asList(harryPotterAndTheChamberOfSecrets, harryPotterAndThePrisonerOfAzkaban, | ||
harryPotterAndTheGlobetOfFire); | ||
List<Book> all = repo.saveAll(books); | ||
assertThat(all).isNotEmpty(); | ||
assertThat(all).hasSize(3); | ||
assertThat(all.stream().map(Book::getName)).containsExactlyInAnyOrder("Harry Potter and the Chamber of Secrets", | ||
"Harry Potter and the Prisoner of Azkaban", "Harry Potter and the Globet of Fire"); | ||
} | ||
|
||
private Book populateBook(Integer id, String title) { | ||
Book book = new Book(); | ||
book.setBid(id); | ||
book.setName(title); | ||
return book; | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...t/src/test/java/io/quarkus/spring/data/deployment/BookListPagingAndSortingRepository.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,6 @@ | ||
package io.quarkus.spring.data.deployment; | ||
|
||
import org.springframework.data.repository.ListPagingAndSortingRepository; | ||
|
||
public interface BookListPagingAndSortingRepository extends ListPagingAndSortingRepository<Book, Integer> { | ||
} |
111 changes: 111 additions & 0 deletions
111
...t/src/test/java/io/quarkus/spring/data/deployment/BookPagingAndSortingRepositoryTest.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,111 @@ | ||
package io.quarkus.spring.data.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.transaction.Transactional; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class BookPagingAndSortingRepositoryTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest().setArchiveProducer( | ||
() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource("import_hp_books.sql", "import.sql") | ||
.addClasses(Book.class, BookListPagingAndSortingRepository.class)) | ||
.withConfigurationResource("application.properties"); | ||
|
||
@Inject | ||
BookListPagingAndSortingRepository repo; | ||
|
||
@Test | ||
// @Order(1) | ||
@Transactional | ||
public void shouldReturnFirstPageOfTwoBooks() { | ||
Pageable pageRequest = PageRequest.of(0, 2); | ||
Page<Book> result = repo.findAll(pageRequest); | ||
|
||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(2); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(1, 2); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
public void shouldReturnSecondPageOfSizeTwoBooks() { | ||
Pageable pageRequest = PageRequest.of(1, 2); | ||
Page<Book> result = repo.findAll(pageRequest); | ||
|
||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(2); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(3, 4); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
public void shouldReturnLastPage() { | ||
Pageable pageRequest = PageRequest.of(2, 2); | ||
Page<Book> result = repo.findAll(pageRequest); | ||
|
||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(2); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(5, 6); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
void shouldReturnSortedByNameAscAndPagedResult() { | ||
Pageable pageRequest = PageRequest.of(0, 3, Sort.by("name")); | ||
|
||
Page<Book> result = repo.findAll(pageRequest); | ||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(3); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(2, 7, 4); | ||
|
||
} | ||
|
||
@Test | ||
@Transactional | ||
void shouldReturnSortedByNameDescAndPagedResult() { | ||
Pageable pageRequest = PageRequest.of(0, 5, Sort.by("name").descending()); | ||
|
||
Page<Book> result = repo.findAll(pageRequest); | ||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(5); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(3, 1, 5, 6, 4); | ||
|
||
} | ||
|
||
@Test | ||
@Transactional | ||
void shouldReturnAllBooksSortedByNameDescResult() { | ||
List<Book> result = repo.findAll(Sort.by("name").descending()); | ||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(7); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(3, 1, 5, 6, 4, 7, 2); | ||
|
||
} | ||
|
||
@Test | ||
@Transactional | ||
void shouldReturnAllBooksSortedByNameAscResult() { | ||
List<Book> result = repo.findAll(Sort.by("name")); | ||
assertThat(result).isNotEmpty(); | ||
assertThat(result).hasSize(7); | ||
assertThat(result.stream().map(Book::getBid)).containsExactly(2, 7, 4, 6, 5, 1, 3); | ||
|
||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
extensions/spring-data-jpa/deployment/src/test/resources/import_hp_books.sql
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,7 @@ | ||
INSERT INTO book(bid, name) VALUES (1, 'Harry Potter and the Philosophers Stone'); | ||
INSERT INTO book(bid, name) VALUES (2, 'Harry Potter and the Chamber of Secrets'); | ||
INSERT INTO book(bid, name) VALUES (3, 'Harry Potter and the Prisoner of Azkaban'); | ||
INSERT INTO book(bid, name) VALUES (4, 'Harry Potter and the Goblet of Fire'); | ||
INSERT INTO book(bid, name) VALUES (5, 'Harry Potter and the Order of the Phoenix'); | ||
INSERT INTO book(bid, name) VALUES (6, 'Harry Potter and the Half-Blood Prince'); | ||
INSERT INTO book(bid, name) VALUES (7, 'Harry Potter and the Deathly Hallows'); |
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
16 changes: 16 additions & 0 deletions
16
...io/quarkus/spring/data/runtime/Target_org_springframework_data_domain_Sort_TypedSort.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.spring.data.runtime; | ||
|
||
import com.oracle.svm.core.annotate.Substitute; | ||
import com.oracle.svm.core.annotate.TargetClass; | ||
import com.oracle.svm.core.annotate.TargetElement; | ||
|
||
@TargetClass(className = "org.springframework.data.domain.Sort", innerClass = "TypedSort") | ||
public final class Target_org_springframework_data_domain_Sort_TypedSort { | ||
|
||
@Substitute | ||
@TargetElement(name = TargetElement.CONSTRUCTOR_NAME) | ||
public Target_org_springframework_data_domain_Sort_TypedSort(Class<?> type) { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.