package com.ruoyi.web.modules.screen.mapper;

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

import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

/**
 * Mapper XML 冒烟。
 */
@DisplayName("HomeScreenStatsMapper XML")
class HomeScreenStatsMapperXmlTest
{

    @Test
    @DisplayName("HomeScreenStatsMapper.xml 包含关键表")
    void xmlContainsTables() throws Exception
    {
        String xml = IOUtils.toString(
                getClass().getClassLoader().getResourceAsStream("mapper/screen/HomeScreenStatsMapper.xml"),
                StandardCharsets.UTF_8);
        assertTrue(xml.contains("biz_yak_asset"));
        assertTrue(xml.contains("biz_service_appointment"));
        assertTrue(xml.contains("biz_subsidy_grant_record"));
        assertTrue(xml.contains("biz_yak_herd_inventory"));
        assertTrue(xml.contains("biz_yak_outbound_report"));
        assertTrue(xml.contains("sumHerdInventoryYakTotalByStatYearMonth"));
        assertTrue(xml.contains("sumHerdInventorySpeciesByStatYearMonth"));
        assertTrue(xml.contains("sumHerdInventoryYakStructureByStatYearMonth"));
        assertTrue(xml.contains("sumOutboundReportSpeciesByStatYearMonth"));
        assertTrue(xml.contains("sumOutboundReportSelfConsumptionByStatYearMonth"));
        assertTrue(xml.contains("sumFamilyRanchFinanceByStatYearMonth"));
        assertTrue(xml.contains("sumLargeLivestockFarmerFinanceByStatYearMonth"));
        assertTrue(xml.contains("countCooperativeBusinessModelByStatYearMonth"));
        assertTrue(xml.contains("countFarmerHouseholdClassByStatYearMonth"));
        assertTrue(xml.contains("sumFarmerHouseholdSubsidyTotalByTownStatYearMonth"));
        assertTrue(xml.contains("subsidy_total"));
        assertTrue(xml.contains("selectDisposableIncomeByYearRange"));
        assertTrue(xml.contains("selectLatestDisposableIncomeStatYear"));
        assertTrue(xml.contains("biz_disposable_income"));
        assertTrue(xml.contains("rural_disposable_income"));
        assertTrue(xml.contains("business_model"));
        assertTrue(xml.contains("is_pure_herder"));
        assertTrue(xml.contains("subsidy_amount"));
        assertTrue(xml.contains("horse_mule_outbound_count"));
        assertTrue(xml.contains("self_consumption_cattle_count"));
        assertTrue(xml.contains("breeding_bull_count"));
        assertTrue(xml.contains("insured_yak_count"));
        assertTrue(xml.contains("dairy_total"));
        assertTrue(xml.contains("sheep_total"));
        assertTrue(xml.contains("selectLatestHerdInventoryStatPeriod"));
        assertTrue(xml.contains("selectLatestFarmerHouseholdStatPeriodByYear"));
        assertTrue(xml.contains("sumFarmerHouseholdCountByStatYearMonth"));
        assertTrue(xml.contains("biz_farmer_household"));
        assertTrue(xml.contains("countCooperativeDevelopmentByStatYearMonth"));
        assertTrue(xml.contains("countFamilyRanchByStatYearMonth"));
        assertTrue(xml.contains("countLargeLivestockFarmerByStatYearMonth"));
        assertTrue(xml.contains("biz_cooperative_development"));
        assertTrue(xml.contains("biz_family_ranch"));
        assertTrue(xml.contains("biz_large_livestock_farmer"));
        assertTrue(xml.contains("sumWithLivestockHouseholdCountByStatYearMonth"));
        assertTrue(xml.contains("sumFarmerHouseholdPastureContractAreaByStatYearMonth"));
        assertTrue(xml.contains("biz_livestock_ownership_household"));
        assertTrue(xml.contains("selectHerdInventoryBullCowByYearMonthRange"));
        assertTrue(xml.contains("selectOutboundReportYakCountByYearMonthRange"));
        assertTrue(xml.contains("selectOutboundReportYakCountByMonth"));
        assertTrue(xml.contains("selectTownMapMarkers"));
        assertTrue(xml.contains("selectYakInventoryOutboundList"));
        assertTrue(xml.contains("selectBreedingEntityQuantityList"));
        assertTrue(xml.contains("from biz_farmer_household"));
        assertTrue(xml.contains("union"));
        assertTrue(xml.contains("from biz_cooperative_development"));
        assertTrue(xml.contains("from biz_family_ranch"));
        assertTrue(xml.contains("from biz_large_livestock_farmer"));
        assertTrue(xml.contains("cooperative_count"));
        assertTrue(xml.contains("family_ranch_count"));
        assertTrue(xml.contains("large_farmer_count"));
        assertTrue(xml.contains("herdStatMonth"));
        assertTrue(xml.contains("outboundStatMonth"));
        assertTrue(xml.contains("status not in (2, 3)"));
    }
}
