| | |
| | | private TChargingOrderServiceImpl service; |
| | | private TChargingOrderMapper mapper; |
| | | private List<Integer> siteIds; |
| | | private LocalDate sixBefore; |
| | | |
| | | @BeforeEach |
| | | void setUp() { |
| | |
| | | siteIds = new ArrayList<>(); |
| | | siteIds.add(122); |
| | | siteIds.add(123); |
| | | sixBefore = LocalDate.of(2026, 1, 1); |
| | | ReflectionTestUtils.setField(service, "baseMapper", mapper); |
| | | } |
| | | |
| | |
| | | void platformViewAddsSuccessfulPartnerShareAmount() { |
| | | Map<String, Object> totals = new HashMap<>(); |
| | | totals.put("electrovalence", new BigDecimal("100.00")); |
| | | when(mapper.countAll(siteIds, false)).thenReturn(totals); |
| | | when(mapper.sumSuccessfulShareAmount(siteIds)).thenReturn(new BigDecimal("12.34")); |
| | | when(mapper.countAll(siteIds, false, sixBefore)).thenReturn(totals); |
| | | when(mapper.sumSuccessfulShareAmount(siteIds, sixBefore)).thenReturn(new BigDecimal("12.34")); |
| | | |
| | | Map<String, Object> result = service.countAll(siteIds, false); |
| | | Map<String, Object> result = service.countAll(siteIds, false, sixBefore); |
| | | |
| | | assertSame(totals, result); |
| | | assertEquals(new BigDecimal("12.34"), result.get("commission_amount")); |
| | | verify(mapper).sumSuccessfulShareAmount(siteIds); |
| | | verify(mapper).sumSuccessfulShareAmount(siteIds, sixBefore); |
| | | } |
| | | |
| | | @Test |
| | | void partnerViewUsesShareRecordTotalsWithoutASecondQuery() { |
| | | Map<String, Object> totals = new HashMap<>(); |
| | | totals.put("commission_amount", new BigDecimal("8.90")); |
| | | when(mapper.countAll(siteIds, true)).thenReturn(totals); |
| | | when(mapper.countAll(siteIds, true, sixBefore)).thenReturn(totals); |
| | | |
| | | Map<String, Object> result = service.countAll(siteIds, true); |
| | | Map<String, Object> result = service.countAll(siteIds, true, sixBefore); |
| | | |
| | | assertSame(totals, result); |
| | | assertEquals(new BigDecimal("8.90"), result.get("commission_amount")); |
| | | verify(mapper, never()).sumSuccessfulShareAmount(siteIds); |
| | | verify(mapper, never()).sumSuccessfulShareAmount(siteIds, sixBefore); |
| | | } |
| | | |
| | | @Test |