package ch.difty.scipamato.core.persistence.paper.slim;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import ch.difty.scipamato.common.persistence.paging.PaginationContext;
import ch.difty.scipamato.common.persistence.paging.PaginationRequest;
import ch.difty.scipamato.core.entity.projection.PaperSlim;
import ch.difty.scipamato.core.entity.search.SearchCondition;
import ch.difty.scipamato.core.entity.search.SearchOrder;
import ch.difty.scipamato.core.persistence.JooqBaseIntegrationTest;

class JooqPaperSlimBySearchOrderRepoIntegrationTest extends JooqBaseIntegrationTest {

    @Autowired
    private JooqPaperSlimBySearchOrderRepo repo;

    @Test
    void finding() {
        SearchOrder so = new SearchOrder();
        so.setGlobal(true);

        List<PaperSlim> papers = repo.findBySearchOrder(so);
        assertThat(papers).isNotNull();
    }

    @Test
    void findingPaged_withNonMatchingCondition_findsNoRecords() {
        SearchOrder so = new SearchOrder();
        so.setGlobal(true);

        PaginationContext pc = new PaginationRequest(0, 10);
        List<PaperSlim> papers = repo.findPageBySearchOrder(so, pc);

        assertThat(papers).isEmpty();
    }

    @Test
    void findingPaged_withMatchingSearchCondition() {
        SearchOrder so = new SearchOrder();
        SearchCondition sc = new SearchCondition();
        sc.setAuthors("Turner");
        so.add(sc);

        PaginationContext pc = new PaginationRequest(0, 10);
        List<PaperSlim> papers = repo.findPageBySearchOrder(so, pc);

        assertThat(papers).isNotEmpty();
    }

    @Test
    void counting() {
        SearchOrder so = new SearchOrder();
        so.setGlobal(true);

        int count = repo.countBySearchOrder(so);
        assertThat(count).isGreaterThanOrEqualTo(0);
    }

}

@@ -1919,10 +1919,1604 @@
 %0A    %7D%0A%0A
+    @Test%0A    void findingPaged_withSearchConditionUsingIdRange() %7B%0A        SearchOrder so = new SearchOrder();%0A        SearchCondition sc = new SearchCondition();%0A        sc.setId(%2210-15%22);%0A        so.add(sc);%0A%0A        PaginationContext pc = new PaginationRequest(0, 10);%0A        List%3CPaperSlim%3E papers = repo.findPageBySearchOrder(so, pc);%0A%0A        assertThat(papers).hasSize(6);%0A    %7D%0A%0A    @Test%0A    void findingPaged_withSearchConditionUsingIdLessThan() %7B%0A        SearchOrder so = new SearchOrder();%0A        SearchCondition sc = new SearchCondition();%0A        sc.setId(%22%3C11%22);%0A        so.add(sc);%0A%0A        PaginationContext pc = new PaginationRequest(0, 10);%0A        List%3CPaperSlim%3E papers = repo.findPageBySearchOrder(so, pc);%0A%0A        assertThat(papers).hasSize(5);%0A    %7D%0A%0A    @Test%0A    void findingPaged_withSearchConditionUsingNumberGreaterThan() %7B%0A        SearchOrder so = new SearchOrder();%0A        SearchCondition sc = new SearchCondition();%0A        sc.setNumber(%2223%22);%0A        so.add(sc);%0A%0A        PaginationContext pc = new PaginationRequest(0, 10);%0A        List%3CPaperSlim%3E papers = repo.findPageBySearchOrder(so, pc);%0A%0A        assertThat(papers).hasSize(1);%0A    %7D%0A%0A    @Test%0A    void findingPaged_withSearchConditionUsingPublicationYearRange() %7B%0A        SearchOrder so = new SearchOrder();%0A        SearchCondition sc = new SearchCondition();%0A        sc.setPublicationYear(%22%3C2015%22);%0A        so.add(sc);%0A%0A        PaginationContext pc = new PaginationRequest(0, 10);%0A        List%3CPaperSlim%3E papers = repo.findPageBySearchOrder(so, pc);%0A%0A        assertThat(papers).hasSize(6);%0A    %7D%0A%0A
 %7D%0A

Add some integration tests capturing the id issue