<commit_before>package com.github.wz2cool.dynamic;

import com.github.wz2cool.dynamic.model.LogicPagingResult;
import com.github.wz2cool.dynamic.mybatis.db.mapper.ProductDao;
import com.github.wz2cool.dynamic.mybatis.db.model.entity.table.Product;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author Frank
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = TestApplication.class)
public class LogicPagingTest {
    @Autowired
    private ProductDao productDao;

    @Test
    public void testGetDataAscUp() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.ASC, UpDown.UP);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(3L);
        logicPagingQuery.setLastEndPageId(4L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(1).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getList().get(1).getProductId()));
    }

    @Test
    public void testGetDataAscDown() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.ASC, UpDown.DOWN);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(1L);
        logicPagingQuery.setLastEndPageId(2L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(4).equals(result.getList().get(1).getProductId()));
    }

    @Test
    public void testGetDataDescUp() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.DESC, UpDown.UP);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(2L);
        logicPagingQuery.setLastEndPageId(1L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(4).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(1).getProductId()));
    }

    @Test
    public void testGetDataDescDown() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.DESC, UpDown.DOWN);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(5L);
        logicPagingQuery.setLastEndPageId(4L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getList().get(1).getProductId()));
    }
}
<commit_msg>fix logic paging issue<commit_after>package com.github.wz2cool.dynamic;

import com.github.wz2cool.dynamic.model.LogicPagingResult;
import com.github.wz2cool.dynamic.mybatis.db.mapper.ProductDao;
import com.github.wz2cool.dynamic.mybatis.db.model.entity.table.Product;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author Frank
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = TestApplication.class)
public class LogicPagingTest {
    @Autowired
    private ProductDao productDao;

    @Test
    public void testGetDataAscUp() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.ASC, UpDown.UP);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(3L);
        logicPagingQuery.setLastEndPageId(4L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(1).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getList().get(1).getProductId()));
        Assert.assertTrue(Long.valueOf(1).equals(result.getStartPageId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getEndPageId()));
    }

    @Test
    public void testGetDataAscDown() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.ASC, UpDown.DOWN);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(1L);
        logicPagingQuery.setLastEndPageId(2L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(4).equals(result.getList().get(1).getProductId()));
        Assert.assertTrue(Long.valueOf(3).equals(result.getStartPageId()));
        Assert.assertTrue(Long.valueOf(4).equals(result.getEndPageId()));
    }

    @Test
    public void testGetDataDescUp() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.DESC, UpDown.UP);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(2L);
        logicPagingQuery.setLastEndPageId(1L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(4).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(1).getProductId()));
        Assert.assertTrue(Long.valueOf(4).equals(result.getStartPageId()));
        Assert.assertTrue(Long.valueOf(3).equals(result.getEndPageId()));
    }

    @Test
    public void testGetDataDescDown() {
        LogicPagingQuery<Product> logicPagingQuery =
                LogicPagingQuery.createQuery(Product.class, Product::getProductId, SortDirection.DESC, UpDown.DOWN);
        logicPagingQuery.setPageSize(2);
        logicPagingQuery.setLastStartPageId(5L);
        logicPagingQuery.setLastEndPageId(4L);
        LogicPagingResult<Product> result = productDao.selectByLogicPaging(logicPagingQuery);
        Assert.assertTrue(Long.valueOf(3).equals(result.getList().get(0).getProductId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getList().get(1).getProductId()));
        Assert.assertTrue(Long.valueOf(3).equals(result.getStartPageId()));
        Assert.assertTrue(Long.valueOf(2).equals(result.getEndPageId()));
    }
}

{'fraction_non_alphanumeric': 0.1222117074489658, 'fraction_numerical': 0.010274435581992699, 'mean_word_length': 4.47189349112426, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7390400', 'n_tokens_mistral': 2245, 'n_tokens_neox': 2252, 'n_words': 229}