| 12345678910111213141516171819202122232425262728 |
- package com.ruoyi.system.mapper;
- import org.apache.ibatis.builder.xml.XMLMapperBuilder;
- import org.apache.ibatis.session.Configuration;
- import org.junit.jupiter.api.Test;
- import java.util.*;
- import static org.junit.jupiter.api.Assertions.*;
- class FlashLinePayMapperTest {
- private Configuration configuration(String name) throws Exception {
- String resource="mapper/flash/FlashDeliveryLine"+name+"Mapper.xml";Configuration config=new Configuration();
- try(var stream=getClass().getClassLoader().getResourceAsStream(resource)){new XMLMapperBuilder(stream,config,resource,config.getSqlFragments()).parse();}return config;
- }
- @Test void pickupQueriesEmitCurrentReads() throws Exception {
- Configuration payments=configuration("Payment"),refunds=configuration("Refund");
- String p="com.ruoyi.system.mapper.flash.FlashDeliveryLinePaymentMapper.selectLatestForUpdate";
- String r="com.ruoyi.system.mapper.flash.FlashDeliveryLineRefundMapper.selectByPaymentIdForUpdate";
- assertTrue(payments.hasStatement(p));assertTrue(refunds.hasStatement(r));
- assertTrue(payments.getMappedStatement(p).getBoundSql(Map.of("orderId",1L)).getSql().trim().endsWith("FOR UPDATE"));
- assertTrue(refunds.getMappedStatement(r).getBoundSql(Map.of("paymentId",22L)).getSql().trim().endsWith("FOR UPDATE"));
- }
- @Test void recoverySelectsOldestDueWorkBeforeId() throws Exception {
- for(String kind:List.of("Payment","Refund")){
- Configuration config=configuration(kind);
- String sql=config.getMappedStatement("com.ruoyi.system.mapper.flash.FlashDeliveryLine"+kind+"Mapper.selectDue")
- .getBoundSql(Map.of("now",new Date(),"limit",20)).getSql().replaceAll("\\s+"," ");
- assertTrue(sql.contains("ORDER BY next_reconcile_at, id LIMIT"),sql);
- }
- }
- }
|