### Question:
OrderOtherServiceImpl implements OrderOtherService { @Override public Response getSoldTickets(Seat seatRequest, HttpHeaders headers) { ArrayList<Order> list = orderOtherRepository.findByTravelDateAndTrainNumber(seatRequest.getTravelDate(), seatRequest.getTrainNumber()); if (list != null && !list.isEmpty()) { Set ticketSet = new HashSet(); for (Order tempOrder : list) { Ticket ticket = new Ticket(); ticket.setSeatNo(Integer.parseInt(tempOrder.getSeatNumber())); ticket.setStartStation(tempOrder.getFrom()); ticket.setDestStation(tempOrder.getTo()); ticketSet.add(ticket); } LeftTicketInfo leftTicketInfo = new LeftTicketInfo(); leftTicketInfo.setSoldTickets(ticketSet); OrderOtherServiceImpl.LOGGER.info("Left ticket info is: {}", leftTicketInfo.toString()); return new Response<>(1, success, leftTicketInfo); } else { return new Response<>(0, "Seat is Null.", 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 testGetSoldTickets1() { Seat seatRequest = new Seat(); ArrayList<Order> list = new ArrayList<>(); list.add(new Order()); Mockito.when(orderOtherRepository.findByTravelDateAndTrainNumber(Mockito.any(Date.class), Mockito.anyString())).thenReturn(list); Response result = orderOtherServiceImpl.getSoldTickets(seatRequest, headers); Assert.assertEquals("Success", result.getMsg()); }
@Test public void testGetSoldTickets2() { Seat seatRequest = new Seat(); Mockito.when(orderOtherRepository.findByTravelDateAndTrainNumber(Mockito.any(Date.class), Mockito.anyString())).thenReturn(null); Response result = orderOtherServiceImpl.getSoldTickets(seatRequest, headers); Assert.assertEquals(new Response<>(0, "Seat is Null.", null), result); }