### Question:
OrderServiceImpl implements OrderService { @Override @Transactional public OrderDTO cancel(OrderDTO orderDTO) { OrderMaster orderMaster = new OrderMaster(); if (!orderDTO.getOrderStatus().equals(OrderStatusEnum.NEW.getCode())) { log.error("【取消订单】订单状态不正确, orderId={}, orderStatus={}", orderDTO.getOrderId(), orderDTO.getOrderStatus()); throw new SellException(ResultEnum.ORDER_STATUS_ERROR); } orderDTO.setOrderStatus(OrderStatusEnum.CANCEL.getCode()); BeanUtils.copyProperties(orderDTO, orderMaster); OrderMaster updateResult = orderMasterRepository.save(orderMaster); if (updateResult == null) { log.error("【取消订单】更新失败, orderMaster={}", orderMaster); throw new SellException(ResultEnum.ORDER_UPDATE_FAIL); } if (CollectionUtils.isEmpty(orderDTO.getOrderDetailList())) { log.error("【取消订单】订单中无商品详情, orderDTO={}", orderDTO); throw new SellException(ResultEnum.ORDER_DETAIL_EMPTY); } List<CartDTO> cartDTOList = orderDTO.getOrderDetailList().stream() .map(e -> new CartDTO(e.getProductId(), e.getProductQuantity())) .collect(Collectors.toList()); productService.increaseStock(cartDTOList); if (orderDTO.getPayStatus().equals(PayStatusEnum.SUCCESS.getCode())) { payService.refund(orderDTO); } return orderDTO; }  @Override @Transactional OrderDTO create(OrderDTO orderDTO); @Override OrderDTO findOne(String orderId); @Override Page<OrderDTO> findList(String buyerOpenid, Pageable pageable); @Override @Transactional OrderDTO cancel(OrderDTO orderDTO); @Override @Transactional OrderDTO finish(OrderDTO orderDTO); @Override @Transactional OrderDTO paid(OrderDTO orderDTO); @Override Page<OrderDTO> findList(Pageable pageable);  }### Answer:
@Test public void cancel() throws Exception { OrderDTO orderDTO = orderService.findOne(ORDER_ID); OrderDTO result = orderService.cancel(orderDTO); Assert.assertEquals(OrderStatusEnum.CANCEL.getCode(), result.getOrderStatus()); }