package com.ruoyi.order.mapper;
|
|
import org.junit.jupiter.api.Test;
|
|
import java.io.BufferedReader;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.io.InputStreamReader;
|
import java.nio.charset.StandardCharsets;
|
import java.util.stream.Collectors;
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
class ChargingPeriodPaginationMapperTest {
|
|
@Test
|
void pagesOrdersBeforeLoadingAccountingSummaries() throws IOException {
|
InputStream input = getClass().getClassLoader()
|
.getResourceAsStream("mapper/order/TChargingOrderMapper.xml");
|
assertNotNull(input);
|
|
String mapper;
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
|
mapper = reader.lines().collect(Collectors.joining("\n"));
|
}
|
|
String pageQuery = mapper.substring(
|
mapper.indexOf("<select id=\"chargingList1\""),
|
mapper.indexOf("<select id=\"chargingListAccountingSummary\""));
|
assertTrue(pageQuery.contains("from t_charging_order b"));
|
assertFalse(pageQuery.contains("t_charging_order_accounting_strategy"));
|
assertFalse(pageQuery.contains("group by charging_order_id"));
|
|
int summaryStart = mapper.indexOf("<select id=\"chargingListAccountingSummary\"");
|
assertTrue(summaryStart >= 0);
|
String accountingQuery = mapper.substring(summaryStart, mapper.indexOf("<select id=\"chargingListSum\""));
|
assertTrue(accountingQuery.contains("from t_charging_order_accounting_strategy"));
|
assertTrue(accountingQuery.contains("where charging_order_id in"));
|
assertTrue(accountingQuery.contains("group by charging_order_id"));
|
}
|
}
|