### Question:
AdminOrderServiceImpl implements AdminOrderService { @Override public Response getAllOrders(HttpHeaders headers) { AdminOrderServiceImpl.LOGGER.info("[Admin Order Service][Get All Orders]"); ArrayList<Order> orders = new ArrayList<>(); HttpEntity requestEntity = new HttpEntity(headers); ResponseEntity<Response<ArrayList<Order>>> re = restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { }); Response<ArrayList<Order>> result = re.getBody(); if (result.getStatus() == 1) { AdminOrderServiceImpl.LOGGER.info("[Admin Order Service][Get Orders From ts-order-service successfully!]"); ArrayList<Order> orders1 = result.getData(); orders.addAll(orders1); } else { AdminOrderServiceImpl.LOGGER.info("[Admin Order Service][Get Orders From ts-order-service fail!]"); } HttpEntity requestEntity2 = new HttpEntity(headers); ResponseEntity<Response<ArrayList<Order>>> re2 = restTemplate.exchange( "http: HttpMethod.GET, requestEntity2, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { }); result = re2.getBody(); if (result.getStatus() == 1) { AdminOrderServiceImpl.LOGGER.info("[Admin Order Service][Get Orders From ts-order-other-service successfully!]"); ArrayList<Order> orders1 = (ArrayList<Order>) result.getData(); orders.addAll(orders1); } else { AdminOrderServiceImpl.LOGGER.info("[Admin Order Service][Get Orders From ts-order-other-service fail!]"); } return new Response<>(1, "Get the orders successfully!", orders); }  @Override Response getAllOrders(HttpHeaders headers); @Override Response deleteOrder(String orderId, String trainNumber, HttpHeaders headers); @Override Response updateOrder(Order request, HttpHeaders headers); @Override Response addOrder(Order request, HttpHeaders headers);  }### Answer:
@Test public void testGetAllOrders1() { Response<ArrayList<Order>> response = new Response<>(0, null, null); ResponseEntity<Response<ArrayList<Order>>> re = new ResponseEntity<>(response, HttpStatus.OK); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { })).thenReturn(re); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { })).thenReturn(re); Response result = adminOrderService.getAllOrders(headers); Assert.assertEquals(new Response<>(1, "Get the orders successfully!", new ArrayList<>()), result); }
@Test public void testGetAllOrders2() { ArrayList<Order> orders = new ArrayList<>(); orders.add(new Order()); Response<ArrayList<Order>> response = new Response<>(1, null, orders); ResponseEntity<Response<ArrayList<Order>>> re = new ResponseEntity<>(response, HttpStatus.OK); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { })).thenReturn(re); Mockito.when(restTemplate.exchange( "http: HttpMethod.GET, requestEntity, new ParameterizedTypeReference<Response<ArrayList<Order>>>() { })).thenReturn(re); Response result = adminOrderService.getAllOrders(headers); Assert.assertNotNull(result); }