Skip to content

Commit

Permalink
Refactor the test disabled by quarkusio/quarkus#41292
Browse files Browse the repository at this point in the history
The original test was based on serialization, which is no longer possible out of bot.
In quarkusio/quarkus#41292 was suggested use this modification to make the original code work.
Now we checking if retunred json, pageable item contains specific values.

For more info see quarkusio/quarkus#41292 (comment)
  • Loading branch information
jedla97 committed Dec 12, 2024
1 parent a54dbd6 commit 4d42397
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.ts.spring.data.primitivetypes;

import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;

import org.springframework.data.domain.Page;
Expand All @@ -12,6 +14,7 @@
@ApplicationScoped
public class BookStore implements PanacheRepository<Book> {
public Page<Book> findPaged(Pageable pageable) {
return new PageImpl<>(this.findAll().page(pageable.getPageNumber(), pageable.getPageSize()).list());
List<Book> list = this.findAll().list();
return new PageImpl<>(list, pageable, list.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.quarkus.test.scenarios.QuarkusScenario;
Expand Down Expand Up @@ -98,18 +97,21 @@ void testJpaFieldsMapping() {
}

@Test
@Tag("QUARKUS-1521")
@Disabled("https://github.com/quarkusio/quarkus/issues/41292")
void ensureFieldPageableIsSerialized() {
void ensureFieldPageableContainsInfoAboutPage() {
int size = 2;
int page = 1;
Response response = app.given()
.accept("application/json")
.queryParam("size", "2")
.queryParam("page", "1")
.queryParam("size", size)
.queryParam("page", page)
.when().get("/book/paged");
Assertions.assertEquals(200, response.statusCode());
String pageable = response.body().jsonPath().get("pageable");
Assertions.assertNotNull(pageable,
"Field 'pageable' of org.springframework.data.domain.PageImpl was not serialized");
LinkedHashMap<String, Object> pageable = response.body().jsonPath().get("pageable");
Assertions.assertNotNull(pageable, "Field 'pageable' should not be null");
Assertions.assertEquals(true, pageable.get("paged"),
"The part of pageable response should contain paged equals to true");
Assertions.assertEquals(size, pageable.get("pageSize"), "Element pageSize should be " + size);
Assertions.assertEquals(page, pageable.get("pageNumber"), "Element pageNumber should be " + page);
}

private Book updateBook(Book book) {
Expand Down

0 comments on commit 4d42397

Please sign in to comment.