### Question:
RouteServiceImpl implements RouteService { @Override public Response getRouteByStartAndTerminal(String startId, String terminalId, HttpHeaders headers) { ArrayList<Route> routes = routeRepository.findAll(); RouteServiceImpl.LOGGER.info("[Route Service] Find All: {}", routes.size()); List<Route> resultList = new ArrayList<>(); for (Route route : routes) { if (route.getStations().contains(startId) && route.getStations().contains(terminalId) && route.getStations().indexOf(startId) < route.getStations().indexOf(terminalId)) { resultList.add(route); } } if (!resultList.isEmpty()) { return new Response<>(1, success, resultList); } else { return new Response<>(0, "No routes with the startId and terminalId", null); } }  @Override Response createAndModify(RouteInfo info, HttpHeaders headers); @Override Response deleteRoute(String routeId, HttpHeaders headers); @Override Response getRouteById(String routeId, HttpHeaders headers); @Override Response getRouteByStartAndTerminal(String startId, String terminalId, HttpHeaders headers); @Override Response getAllRoutes(HttpHeaders headers);  }### Answer:
@Test public void testGetRouteByStartAndTerminal1() { List<String> stations = new ArrayList<>(); stations.add("shanghai"); stations.add("nanjing"); List<Integer> distances = new ArrayList<>(); distances.add(5); distances.add(10); Route route = new Route("id", stations, distances, "shanghai", "nanjing"); ArrayList<Route> routes = new ArrayList<>(); routes.add(route); Mockito.when(routeRepository.findAll()).thenReturn(routes); Response result = routeServiceImpl.getRouteByStartAndTerminal("shanghai", "nanjing", headers); Assert.assertEquals("Success", result.getMsg()); }
@Test public void testGetRouteByStartAndTerminal2() { ArrayList<Route> routes = new ArrayList<>(); Mockito.when(routeRepository.findAll()).thenReturn(routes); Response result = routeServiceImpl.getRouteByStartAndTerminal("shanghai", "nanjing", headers); Assert.assertEquals("No routes with the startId and terminalId", result.getMsg()); }