| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.ChargingCardAuthDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardBalanceDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardDeductDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardExcelDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardQueryDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardSaveDTO; |
| | | import com.ruoyi.account.api.dto.ChargingCardStatusDTO; |
| | | import com.ruoyi.account.api.model.TChargingCard; |
| | | import com.ruoyi.account.api.vo.ChargingCardDeductVO; |
| | | import com.ruoyi.account.service.TChargingCardService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | |
| | | verify(service).importCards(any()); |
| | | } |
| | | |
| | | @Test |
| | | void innerVerifyChargingDelegatesToService() { |
| | | ChargingCardAuthDTO dto = new ChargingCardAuthDTO(); |
| | | dto.setCardNo("CARD-1"); |
| | | TChargingCard card = new TChargingCard(); |
| | | card.setId(1L); |
| | | when(service.verifyCardForCharging(dto)).thenReturn(card); |
| | | |
| | | R<TChargingCard> result = controller.verifyCharging(dto); |
| | | |
| | | assertEquals(200, result.getCode()); |
| | | assertEquals(card, result.getData()); |
| | | verify(service).verifyCardForCharging(dto); |
| | | } |
| | | |
| | | @Test |
| | | void innerLockAndUnlockDelegateToService() { |
| | | when(service.lockCardForCharging(1L, "SD20260909001")).thenReturn(true); |
| | | when(service.unlockCardForCharging(1L, "SD20260909001")).thenReturn(true); |
| | | |
| | | assertTrue(controller.lockForCharging(1L, "SD20260909001").getData()); |
| | | assertTrue(controller.unlockForCharging(1L, "SD20260909001").getData()); |
| | | verify(service).lockCardForCharging(1L, "SD20260909001"); |
| | | verify(service).unlockCardForCharging(1L, "SD20260909001"); |
| | | } |
| | | |
| | | @Test |
| | | void innerDeductChargingDelegatesToService() { |
| | | ChargingCardDeductDTO dto = new ChargingCardDeductDTO(); |
| | | dto.setCardId(1L); |
| | | dto.setOrderCode("SD20260909001"); |
| | | dto.setAmount(java.math.BigDecimal.TEN); |
| | | ChargingCardDeductVO vo = new ChargingCardDeductVO(); |
| | | vo.setDuplicated(false); |
| | | when(service.deductBalanceForCharging(dto)).thenReturn(vo); |
| | | |
| | | R<ChargingCardDeductVO> result = controller.deductForCharging(dto); |
| | | |
| | | assertEquals(200, result.getCode()); |
| | | assertEquals(vo, result.getData()); |
| | | verify(service).deductBalanceForCharging(dto); |
| | | } |
| | | |
| | | private byte[] excelBytes() throws Exception { |
| | | org.apache.poi.xssf.usermodel.XSSFWorkbook workbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(); |
| | | try { |