### Question:
RouteServiceImpl implements RouteService { @Override public Response createAndModify(RouteInfo info, HttpHeaders headers) { RouteServiceImpl.LOGGER.info("Create And Modify Start: {} End: {}", info.getStartStation(), info.getEndStation()); String[] stations = info.getStationList().split(","); String[] distances = info.getDistanceList().split(","); List<String> stationList = new ArrayList<>(); List<Integer> distanceList = new ArrayList<>(); if (stations.length != distances.length) { RouteServiceImpl.LOGGER.info("Station Number Not Equal To Distance Number"); return new Response<>(0, "Station Number Not Equal To Distance Number", null); } for (int i = 0; i < stations.length; i++) { stationList.add(stations[i]); distanceList.add(Integer.parseInt(distances[i])); } int maxIdArrayLen = 10; if (info.getId() == null || info.getId().length() < maxIdArrayLen) { Route route = new Route(); route.setId(UUID.randomUUID().toString()); route.setStartStationId(info.getStartStation()); route.setTerminalStationId(info.getEndStation()); route.setStations(stationList); route.setDistances(distanceList); routeRepository.save(route); RouteServiceImpl.LOGGER.info("Save success"); return new Response<>(1, "Save Success", route); } else { Route route = routeRepository.findById(info.getId()); if (route == null) { route = new Route(); route.setId(info.getId()); } route.setStartStationId(info.getStartStation()); route.setTerminalStationId(info.getEndStation()); route.setStations(stationList); route.setDistances(distanceList); routeRepository.save(route); RouteServiceImpl.LOGGER.info("Modify success"); return new Response<>(1, "Modify success", route); } }  @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 testCreateAndModify1() { RouteInfo info = new RouteInfo("id", "start_station", "end_station", "shanghai", "5,10"); Response result = routeServiceImpl.createAndModify(info, headers); Assert.assertEquals(new Response<>(0, "Station Number Not Equal To Distance Number", null), result); }
@Test public void testCreateAndModify2() { RouteInfo info = new RouteInfo("id", "start_station", "end_station", "shanghai", "5"); Mockito.when(routeRepository.save(Mockito.any(Route.class))).thenReturn(null); Response result = routeServiceImpl.createAndModify(info, headers); Assert.assertEquals("Save Success", result.getMsg()); }
@Test public void testCreateAndModify3() { RouteInfo info = new RouteInfo("id123456789", "start_station", "end_station", "shanghai", "5"); Mockito.when(routeRepository.findById(Mockito.anyString())).thenReturn(null); Mockito.when(routeRepository.save(Mockito.any(Route.class))).thenReturn(null); Response result = routeServiceImpl.createAndModify(info, headers); Assert.assertEquals("Modify success", result.getMsg()); }