package com.ruoyi.system.mapper;

import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.session.Configuration;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertTrue;

class PosFoodMapperSqlTest {

    @Test
    void storeCardFoodsExcludeOffShelfFoodsWithoutReducingAvailableLimit() {
        Configuration configuration = new Configuration();
        configuration.addMapper(PosFoodMapper.class);

        Map<String, Object> parameters = new HashMap<>();
        parameters.put("storeIds", List.of(10L));
        parameters.put("language", "3");
        parameters.put("limitPerStore", 6);

        BoundSql boundSql = configuration
                .getMappedStatement("com.ruoyi.system.mapper.PosFoodMapper.selectFoodsByStoreIdsWithLimit")
                .getBoundSql(parameters);
        String sql = boundSql.getSql().replaceAll("\\s+", " ").toUpperCase(Locale.ROOT);

        assertTrue(sql.contains("F.STACKING_UP <> '1'"));
        assertTrue(sql.contains("F2.STACKING_UP <> '1'"));
    }
}
