### Question:
OrderOtherServiceImpl implements OrderOtherService { @Override public Response alterOrder(OrderAlterInfo oai, HttpHeaders headers) { UUID oldOrderId = oai.getPreviousOrderId(); Order oldOrder = orderOtherRepository.findById(oldOrderId); if (oldOrder == null) { OrderOtherServiceImpl.LOGGER.info("[Order Other Service][Alter Order] Fail.Order do not exist."); return new Response<>(0, "Old Order Does Not Exists", null); } oldOrder.setStatus(OrderStatus.CANCEL.getCode()); saveChanges(oldOrder, headers); Order newOrder = oai.getNewOrderInfo(); newOrder.setId(UUID.randomUUID()); Response cor = create(oai.getNewOrderInfo(), headers); if (cor.getStatus() == 1) { OrderOtherServiceImpl.LOGGER.info("[Order Other Service][Alter Order] Success."); return new Response<>(1, "Alter Order Success", newOrder); } else { return new Response<>(0, cor.getMsg(), null); } }  @Override Response getSoldTickets(Seat seatRequest, HttpHeaders headers); @Override Response findOrderById(UUID id, HttpHeaders headers); @Override Response create(Order order, HttpHeaders headers); @Override void initOrder(Order order, HttpHeaders headers); @Override Response alterOrder(OrderAlterInfo oai, HttpHeaders headers); @Override Response<ArrayList<Order>> queryOrders(QueryInfo qi, String accountId, HttpHeaders headers); @Override Response queryOrdersForRefresh(QueryInfo qi, String accountId, HttpHeaders headers); List<String> queryForStationId(List<String> ids, HttpHeaders headers); @Override Response saveChanges(Order order, HttpHeaders headers); @Override Response cancelOrder(UUID accountId, UUID orderId, HttpHeaders headers); @Override Response queryAlreadySoldOrders(Date travelDate, String trainNumber, HttpHeaders headers); @Override Response getAllOrders(HttpHeaders headers); @Override Response modifyOrder(String orderId, int status, HttpHeaders headers); @Override Response getOrderPrice(String orderId, HttpHeaders headers); @Override Response payOrder(String orderId, HttpHeaders headers); @Override Response getOrderById(String orderId, HttpHeaders headers); @Override Response checkSecurityAboutOrder(Date dateFrom, String accountId, HttpHeaders headers); @Override Response deleteOrder(String orderId, HttpHeaders headers); @Override Response addNewOrder(Order order, HttpHeaders headers); @Override Response updateOrder(Order order, HttpHeaders headers);  }### Answer:
@Test public void testAlterOrder1() { OrderAlterInfo oai = new OrderAlterInfo(); Mockito.when(orderOtherRepository.findById(Mockito.any(UUID.class))).thenReturn(null); Response result = orderOtherServiceImpl.alterOrder(oai, headers); Assert.assertEquals(new Response<>(0, "Old Order Does Not Exists", null), result); }
@Test public void testAlterOrder2() { OrderAlterInfo oai = new OrderAlterInfo(UUID.randomUUID(), UUID.randomUUID(), "login_token", new Order()); Order order = new Order(); Mockito.when(orderOtherRepository.findById(Mockito.any(UUID.class))).thenReturn(order); Mockito.when(orderOtherRepository.save(Mockito.any(Order.class))).thenReturn(null); ArrayList<Order> accountOrders = new ArrayList<>(); Mockito.when(orderOtherRepository.findByAccountId(Mockito.any(UUID.class))).thenReturn(accountOrders); Response result = orderOtherServiceImpl.alterOrder(oai, headers); Assert.assertEquals("Alter Order Success", result.getMsg()); }