### Question:
OrderServiceImpl implements OrderService { @Override @Transactional public OrderDTO cancel(OrderDTO orderDTO) { OrderMaster orderMaster = new OrderMaster(); if(!orderDTO.getOrderStatus().equals(OrderStatusEnum.NEW_PAYED.getCode())){ log.error("【取消订单】 订单状态不正确 , orderId={} , orderStatus={}" , orderDTO.getOrderId() , orderDTO.getOrderStatus()); throw new SellException(ResultEnum.ORDER_STATUS_ERROR); } orderDTO.setOrderStatus(OrderStatusEnum.CANCEL.getCode()); orderDTO.setPayStatus(PayStatusEnum.REBACK_MONEY.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.getOrderStatus().equals(OrderStatusEnum.NEW_PAYED)){ 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 Page<OrderDTO> findList(Pageable pageable); @Override Page<OrderDTO> findOrderMastersByCreateTimeDesc(Pageable pageable); @Override List<OrderDTO> findListStats(String buyerOpenid, Integer orderStatus); @Override @Transactional OrderDTO cancel(OrderDTO orderDTO); @Override @Transactional OrderDTO finish(OrderDTO orderDTO); @Override @Transactional OrderDTO paid(OrderDTO orderDTO);  }### Answer:
@Test public void cancel() { OrderDTO orderDTO = orderService.findOne(ORDER_ID); OrderDTO result = orderService.cancel(orderDTO); Assert.assertEquals(OrderStatusEnum.CANCEL.getCode() , result.getOrderStatus()); }