RoutingHandler extends ActionHandler { @Override public void handleAction(ActionParameters params) throws ActionException { RouteParams routeparams = new RouteParams(); routeparams.setFrom(params.getRequiredParamDouble(PARAM_FROM_LON), params.getRequiredParamDouble(PARAM_FROM_LAT)); routeparams.setTo(params.getRequiredParamDouble(PARAM_TO_LON), params.getRequiredParamDouble(PARAM_TO_LAT)); final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd"); final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH:mm"); final SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm"); final String dateTime = params.getHttpParam(PARAM_DATE, dateFormatter.format(new Date())) + params.getHttpParam(PARAM_TIME, timeFormatter.format(new Date())); try { final Date date = sdf.parse(dateTime); routeparams.setDate(date); } catch (ParseException e) { throw new ActionParamsException("Couldn't parse date"); } routeparams.setIsArriveBy("true".equals(params.getHttpParam(PARAM_ARRIVEBY))); routeparams.setIsWheelChair("true".equals(params.getHttpParam(PARAM_WHEELCHAIR))); routeparams.setIsShowIntermediateStops("true".equals(params.getHttpParam(PARAM_SHOW_INTERMEDIATE_STOPS))); routeparams.setSrs(params.getHttpParam(PARAM_SRS)); routeparams.setLang(params.getHttpParam(PARAM_LANGUAGE)); routeparams.setMaxWalkDistance(ConversionHelper.getLong(params.getHttpParam(PARAM_MAX_WALK_DISTANCE, PropertyUtil.get("routing.default.maxwalkdistance")), 1000000)); routeparams.setMode(params.getHttpParam(PARAM_MODE, PropertyUtil.get("routing.default.mode"))); RouteResponse result = service.getRoute(routeparams); JSONObject response = result.toJSON(); if(params.getUser().isAdmin()) { JSONHelper.putValue(response, "otpUrl", result.getRequestUrl()); } ResponseHelper.writeResponse(params, response); }  @Override void handleAction(ActionParameters params); static final String PARAM_SHOW_INTERMEDIATE_STOPS; }
@Test public void testHandleAction() throws Exception { final Map<String, String> parameters = new HashMap<String, String>(); PropertyUtil.addProperty("routing.url", ""); PropertyUtil.addProperty("routing.user", ""); PropertyUtil.addProperty("routing.password", ""); PropertyUtil.addProperty("routing.srs", ""); System.setProperty("http.proxyHost", ""); System.setProperty("https.proxyHost", ""); System.setProperty("http.proxyPort", ""); System.setProperty("https.proxyPort", ""); parameters.put("fromlon", "381210"); parameters.put("fromlat", "6679422"); parameters.put("tolat", "6671022"); parameters.put("tolon", "385010"); parameters.put(PARAM_SRS, "EPSG:3067"); final ActionParameters params = createActionParams(parameters, getLoggedInUser()); routingHandler.handleAction(params); System.out.println(getResponseString()); }