| | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import static org.junit.jupiter.api.Assertions.assertTrue; |
| | | import static org.mockito.ArgumentMatchers.anyList; |
| | | import static org.mockito.ArgumentMatchers.anyLong; |
| | | import static org.mockito.ArgumentMatchers.eq; |
| | | import static org.mockito.Mockito.never; |
| | | import static org.mockito.Mockito.verify; |
| | |
| | | loginUser.setUserId(88L); |
| | | when(tokenService.getLoginUserApplet()).thenReturn(loginUser); |
| | | when(vinManagementClient.getVinIdsByAppUserId(88L)).thenReturn(R.ok(Arrays.asList(11L, 22L))); |
| | | when(mapper.countAppletOrders(Arrays.asList(11L, 22L))).thenReturn(1L); |
| | | when(mapper.countAppletOrders(88L, Arrays.asList(11L, 22L))).thenReturn(1L); |
| | | MyVinChargingOrderList order = new MyVinChargingOrderList(); |
| | | order.setId(1001L); |
| | | when(mapper.pageAppletOrders(Arrays.asList(11L, 22L), 10L, 10L)) |
| | | when(mapper.pageAppletOrders(88L, Arrays.asList(11L, 22L), 10L, 10L)) |
| | | .thenReturn(Collections.singletonList(order)); |
| | | |
| | | PageInfo<MyVinChargingOrderList> result = service.pageAppletOrders(2, 10); |
| | |
| | | assertEquals(1L, result.getTotal()); |
| | | assertEquals(1001L, result.getRecords().get(0).getId()); |
| | | verify(vinManagementClient).getVinIdsByAppUserId(88L); |
| | | verify(mapper).pageAppletOrders(Arrays.asList(11L, 22L), 10L, 10L); |
| | | verify(mapper).countAppletOrders(88L, Arrays.asList(11L, 22L)); |
| | | verify(mapper).pageAppletOrders(88L, Arrays.asList(11L, 22L), 10L, 10L); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | assertEquals(0L, result.getTotal()); |
| | | assertEquals(0, result.getRecords().size()); |
| | | verify(mapper, never()).countAppletOrders(anyList()); |
| | | verify(mapper, never()).pageAppletOrders(anyList(), eq(0L), eq(10L)); |
| | | verify(mapper, never()).countAppletOrders(anyLong(), anyList()); |
| | | verify(mapper, never()).pageAppletOrders(anyLong(), anyList(), eq(0L), eq(10L)); |
| | | } |
| | | |
| | | @Test |
| | |
| | | TVinChargingOrder order = new TVinChargingOrder(); |
| | | order.setId(1001L); |
| | | order.setVinId(11L); |
| | | order.setAppUserId(88L); |
| | | order.setCode("VD_1001"); |
| | | order.setOrderAmount(new BigDecimal("18.50")); |
| | | order.setElectrovalence(new BigDecimal("12.30")); |
| | |
| | | assertTrue(service.appletDetail(1001L).isEmpty()); |
| | | verify(mapper, never()).accountingStrategyList(1001L); |
| | | } |
| | | |
| | | @Test |
| | | void returnsEmptyDetailWhenVinReboundAndOrderBelongsToPreviousUser() { |
| | | LoginUserApplet loginUser = new LoginUserApplet(); |
| | | loginUser.setUserId(88L); |
| | | when(tokenService.getLoginUserApplet()).thenReturn(loginUser); |
| | | // VIN 11 当前绑定用户 88,但该订单是换绑前用户 99 下单的,不能查看 |
| | | when(vinManagementClient.getVinIdsByAppUserId(88L)).thenReturn(R.ok(Collections.singletonList(11L))); |
| | | TVinChargingOrder order = new TVinChargingOrder(); |
| | | order.setId(1001L); |
| | | order.setVinId(11L); |
| | | order.setAppUserId(99L); |
| | | when(mapper.selectById(1001L)).thenReturn(order); |
| | | |
| | | assertTrue(service.appletDetail(1001L).isEmpty()); |
| | | verify(mapper, never()).accountingStrategyList(1001L); |
| | | } |
| | | } |