| | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.ruoyi.account.api.feignClient.ChargingCardClient; |
| | | import com.ruoyi.account.api.feignClient.CompanyAllocateRecordClient; |
| | | import com.ruoyi.account.api.vo.ChargingCardDeductVO; |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.BillingTemplateClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import com.ruoyi.order.service.TCardChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.service.TVinAccountingStrategyDetailOrderService; |
| | | import com.ruoyi.order.service.TVinChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.support.ChargeAccountSupport; |
| | | import com.ruoyi.order.util.mongodb.service.UploadRealTimeMonitoringDataService; |
| | | import com.ruoyi.other.api.feignClient.CompanyPreferentialClient; |
| | | import com.ruoyi.other.api.feignClient.GroupCompanyClient; |
| | | import org.apache.ibatis.builder.MapperBuilderAssistant; |
| | | import org.junit.jupiter.api.BeforeAll; |
| | | import org.junit.jupiter.api.Test; |
| | |
| | | TableInfoHelper.initTableInfo(assistant, TVinChargingOrder.class); |
| | | } |
| | | |
| | | /** |
| | | * 账户支持组件(与生产同源):企业/授权/优惠/分配流水等公共逻辑已抽取到该组件。 |
| | | * 纯单测不启 Spring 容器,此处内联装配,远程依赖以宽松 mock 兜底(内部均有判空与兜底)。 |
| | | */ |
| | | private ChargeAccountSupport newChargeAccountSupport() { |
| | | ChargeAccountSupport support = new ChargeAccountSupport(); |
| | | ReflectionTestUtils.setField(support, "accountingStrategyDetailClient", mock(AccountingStrategyDetailClient.class)); |
| | | ReflectionTestUtils.setField(support, "groupCompanyClient", mock(GroupCompanyClient.class)); |
| | | ReflectionTestUtils.setField(support, "companyPreferentialClient", mock(CompanyPreferentialClient.class)); |
| | | ReflectionTestUtils.setField(support, "billingTemplateClient", mock(BillingTemplateClient.class)); |
| | | ReflectionTestUtils.setField(support, "companyAllocateRecordClient", mock(CompanyAllocateRecordClient.class)); |
| | | return support; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private R<Boolean> okBoolean() { |
| | | R<Boolean> result = mock(R.class); |
| | |
| | | @Test |
| | | void closesCardTimeoutStartingOrderWithCardUnlockAndGunReset() { |
| | | TCardChargingOrderServiceImpl service = new TCardChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TCardChargingOrderMapper mapper = mock(TCardChargingOrderMapper.class); |
| | | ChargingCardClient cardClient = mock(ChargingCardClient.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | |
| | | @Test |
| | | void ignoresLateCardStartReplyAfterOrderClosed() { |
| | | TCardChargingOrderServiceImpl service = new TCardChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TCardChargingOrderMapper mapper = mock(TCardChargingOrderMapper.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | |
| | | @Test |
| | | void returnsOkWithoutTouchingOrderWhenSettleLockBusy() throws InterruptedException { |
| | | TCardChargingOrderServiceImpl service = new TCardChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TCardChargingOrderMapper mapper = mock(TCardChargingOrderMapper.class); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | | ReflectionTestUtils.setField(service, "redissonClient", mockedRedisson(mockedLock(false))); |
| | |
| | | @Test |
| | | void skipsCardSettlementWhenOrderAlreadyFinished() throws InterruptedException { |
| | | TCardChargingOrderServiceImpl service = new TCardChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TCardChargingOrderMapper mapper = mock(TCardChargingOrderMapper.class); |
| | | ChargingCardClient cardClient = mock(ChargingCardClient.class); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | |
| | | @Test |
| | | void closesVinTimeoutStartingOrderWithGunReset() { |
| | | TVinChargingOrderServiceImpl service = new TVinChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TVinChargingOrderMapper mapper = mock(TVinChargingOrderMapper.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | |
| | | @Test |
| | | void ignoresLateVinStartReplyAfterOrderClosed() { |
| | | TVinChargingOrderServiceImpl service = new TVinChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TVinChargingOrderMapper mapper = mock(TVinChargingOrderMapper.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | |
| | | @Test |
| | | void skipsVinSettlementWhenOrderAlreadyFinished() throws InterruptedException { |
| | | TVinChargingOrderServiceImpl service = new TVinChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TVinChargingOrderMapper mapper = mock(TVinChargingOrderMapper.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | | UploadRealTimeMonitoringDataService monitoringDataService = mock(UploadRealTimeMonitoringDataService.class); |
| | |
| | | @SuppressWarnings("unchecked") |
| | | void fillsVinSettlementDetailStrategyIdAndCreateTime() throws InterruptedException { |
| | | TVinChargingOrderServiceImpl service = new TVinChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TVinChargingOrderMapper mapper = mock(TVinChargingOrderMapper.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |
| | | TVinAccountingStrategyDetailOrderService detailOrderService = mock(TVinAccountingStrategyDetailOrderService.class); |
| | |
| | | @SuppressWarnings("unchecked") |
| | | void fillsCardSettlementDetailStrategyIdAndCreateTime() throws InterruptedException { |
| | | TCardChargingOrderServiceImpl service = new TCardChargingOrderServiceImpl(); |
| | | ReflectionTestUtils.setField(service, "chargeAccountSupport", newChargeAccountSupport()); |
| | | TCardChargingOrderMapper mapper = mock(TCardChargingOrderMapper.class); |
| | | ChargingCardClient cardClient = mock(ChargingCardClient.class); |
| | | ChargingGunClient gunClient = mock(ChargingGunClient.class); |