| | |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import static org.junit.jupiter.api.Assertions.assertNull; |
| | | import static org.junit.jupiter.api.Assertions.assertThrows; |
| | | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | |
| | | assertEquals(null, result.getFleetId()); |
| | | } |
| | | |
| | | // ---------------- 白名单账户可用余额解析(充电页余额显示) ---------------- |
| | | |
| | | @Test |
| | | void resolveWhitelistAccountBalanceReturnsCompanyBalanceForSharedMode() { |
| | | TGroupCompany company = new TGroupCompany(); |
| | | company.setAccountMode(1); |
| | | company.setAvailableBalance(new BigDecimal("500.50")); |
| | | when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company)); |
| | | |
| | | AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO(); |
| | | match.setMatched(true); |
| | | match.setCompanyId(12); |
| | | match.setBalance(new BigDecimal("100.00")); |
| | | |
| | | BigDecimal result = service.resolveWhitelistAccountBalance(match); |
| | | |
| | | assertEquals(new BigDecimal("500.50"), result); |
| | | } |
| | | |
| | | @Test |
| | | void resolveWhitelistAccountBalanceReturnsWhitelistBalanceForAllocationMode() { |
| | | TGroupCompany company = new TGroupCompany(); |
| | | company.setAccountMode(2); |
| | | company.setAvailableBalance(new BigDecimal("500.50")); |
| | | when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company)); |
| | | |
| | | AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO(); |
| | | match.setMatched(true); |
| | | match.setCompanyId(12); |
| | | match.setBalance(new BigDecimal("100.00")); |
| | | |
| | | BigDecimal result = service.resolveWhitelistAccountBalance(match); |
| | | |
| | | assertEquals(new BigDecimal("100.00"), result); |
| | | } |
| | | |
| | | @Test |
| | | void resolveWhitelistAccountBalanceTreatsNullAccountModeAsShared() { |
| | | TGroupCompany company = new TGroupCompany(); |
| | | company.setAccountMode(null); |
| | | company.setAvailableBalance(new BigDecimal("500.50")); |
| | | when(groupCompanyClient.getCompanyById(12)).thenReturn(R.ok(company)); |
| | | |
| | | AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO(); |
| | | match.setMatched(true); |
| | | match.setCompanyId(12); |
| | | match.setBalance(new BigDecimal("100.00")); |
| | | |
| | | BigDecimal result = service.resolveWhitelistAccountBalance(match); |
| | | |
| | | assertEquals(new BigDecimal("500.50"), result); |
| | | } |
| | | |
| | | @Test |
| | | void resolveWhitelistAccountBalanceReturnsNullWhenCompanyQueryFails() { |
| | | when(groupCompanyClient.getCompanyById(12)).thenReturn(R.fail("公司信息查询失败")); |
| | | |
| | | AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO(); |
| | | match.setMatched(true); |
| | | match.setCompanyId(12); |
| | | match.setBalance(new BigDecimal("100.00")); |
| | | |
| | | BigDecimal result = service.resolveWhitelistAccountBalance(match); |
| | | |
| | | assertNull(result); |
| | | } |
| | | |
| | | @Test |
| | | void resolveWhitelistAccountBalanceReturnsNullWhenNotMatched() { |
| | | AppUserWhitelistMatchVO match = new AppUserWhitelistMatchVO(); |
| | | match.setMatched(false); |
| | | |
| | | BigDecimal result = service.resolveWhitelistAccountBalance(match); |
| | | |
| | | assertNull(result); |
| | | } |
| | | |
| | | // ---------------- 额度分配 ---------------- |
| | | |
| | | @Test |