RouteModel implements Serializable { Map<String, RouteParameterData> getParameters(String template) { Map<String, RouteParameterData> result = new HashMap<>(); this.root.matchSegmentTemplates(template, segment -> { if (segment.isParameter()) { result.put(segment.getName(), new RouteParameterData(segment.getTemplate(), segment.getRegex().orElse(null))); } }, null); return result; } private  RouteModel(boolean mutable); private  RouteModel(RouteSegment root, boolean mutable);   }
@Test public void route_model_provides_parameters() { RouteModel root = getRouteModel(); final String template = "trunk/branch/:id(" + RouteParameterRegex.INTEGER + ")/:list*(" + RouteParameterRegex.LONG + ")"; final Map<String, RouteParameterData> parameters = root .getParameters(template); Assert.assertEquals("Incorrect parameters size", 2, parameters.size()); Assert.assertTrue("Missing parameter", parameters.containsKey("id")); Assert.assertTrue("Missing parameter", parameters.containsKey("list")); Assert.assertEquals("Wrong parameter data", ":id(" + RouteParameterRegex.INTEGER + ")", parameters.get("id").getTemplate()); Assert.assertEquals("Wrong parameter data", ":list*(" + RouteParameterRegex.LONG + ")", parameters.get("list").getTemplate()); }