@Test public void testToPlaceRequestNotExistingRoute() { PlaceRequest placeRequest13 = tokenFormatter.toPlaceRequest("/not/existing"); PlaceRequest placeRequest14 = tokenFormatter.toPlaceRequest("/not/existing?a=valueA&b=valueB"); PlaceRequest placeRequest15 = tokenFormatter.toPlaceRequest("not/existing"); assertEquals("/not/existing", placeRequest13.getNameToken()); assertEquals(0, placeRequest13.getParameterNames().size()); assertEquals("/not/existing", placeRequest14.getNameToken()); assertEquals(2, placeRequest14.getParameterNames().size()); assertEquals("valueA", placeRequest14.getParameter("a", null)); assertEquals("valueB", placeRequest14.getParameter("b", null)); assertEquals("/not/existing", placeRequest15.getNameToken()); assertEquals(0, placeRequest15.getParameterNames().size()); }
@Override public PlaceRequest toPlaceRequest(String placeToken) throws TokenFormatException { if (!placeTokenIsValid(placeToken)) return toPlaceRequest("/" + placeToken); int split = placeToken.indexOf('?'); String place = (split != -1) ? placeToken.substring(0, split) : placeToken; String query = (split != -1) ? placeToken.substring(split + 1) : ""; TreeSet<RouteMatch> allMatches = matchRoute(place); RouteMatch match = (!allMatches.isEmpty()) ? allMatches.last() : new RouteMatch(place, 0, emptyMap()); return PlaceRequest.of(match.route).with(parseQueryString(query, match.parameters)).build(); }
RouteTokenFormatter implements TokenFormatter { @Override public PlaceRequest toPlaceRequest(String placeToken) throws TokenFormatException { if (!placeTokenIsValid(placeToken)) return toPlaceRequest("/" + placeToken); int split = placeToken.indexOf('?'); String place = (split != -1) ? placeToken.substring(0, split) : placeToken; String query = (split != -1) ? placeToken.substring(split + 1) : ""; TreeSet<RouteMatch> allMatches = matchRoute(place); RouteMatch match = (!allMatches.isEmpty()) ? allMatches.last() : new RouteMatch(place, 0, emptyMap()); return PlaceRequest.of(match.route).with(parseQueryString(query, match.parameters)).build(); } }
RouteTokenFormatter implements TokenFormatter { @Override public PlaceRequest toPlaceRequest(String placeToken) throws TokenFormatException { if (!placeTokenIsValid(placeToken)) return toPlaceRequest("/" + placeToken); int split = placeToken.indexOf('?'); String place = (split != -1) ? placeToken.substring(0, split) : placeToken; String query = (split != -1) ? placeToken.substring(split + 1) : ""; TreeSet<RouteMatch> allMatches = matchRoute(place); RouteMatch match = (!allMatches.isEmpty()) ? allMatches.last() : new RouteMatch(place, 0, emptyMap()); return PlaceRequest.of(match.route).with(parseQueryString(query, match.parameters)).build(); } @Inject  RouteTokenFormatter(UrlUtils urlUtils, Set<Place> places); }
RouteTokenFormatter implements TokenFormatter { @Override public PlaceRequest toPlaceRequest(String placeToken) throws TokenFormatException { if (!placeTokenIsValid(placeToken)) return toPlaceRequest("/" + placeToken); int split = placeToken.indexOf('?'); String place = (split != -1) ? placeToken.substring(0, split) : placeToken; String query = (split != -1) ? placeToken.substring(split + 1) : ""; TreeSet<RouteMatch> allMatches = matchRoute(place); RouteMatch match = (!allMatches.isEmpty()) ? allMatches.last() : new RouteMatch(place, 0, emptyMap()); return PlaceRequest.of(match.route).with(parseQueryString(query, match.parameters)).build(); } @Inject  RouteTokenFormatter(UrlUtils urlUtils, Set<Place> places); @Override String toPlaceToken(PlaceRequest placeRequest); @Override PlaceRequest toPlaceRequest(String placeToken); }
RouteTokenFormatter implements TokenFormatter { @Override public PlaceRequest toPlaceRequest(String placeToken) throws TokenFormatException { if (!placeTokenIsValid(placeToken)) return toPlaceRequest("/" + placeToken); int split = placeToken.indexOf('?'); String place = (split != -1) ? placeToken.substring(0, split) : placeToken; String query = (split != -1) ? placeToken.substring(split + 1) : ""; TreeSet<RouteMatch> allMatches = matchRoute(place); RouteMatch match = (!allMatches.isEmpty()) ? allMatches.last() : new RouteMatch(place, 0, emptyMap()); return PlaceRequest.of(match.route).with(parseQueryString(query, match.parameters)).build(); } @Inject  RouteTokenFormatter(UrlUtils urlUtils, Set<Place> places); @Override String toPlaceToken(PlaceRequest placeRequest); @Override PlaceRequest toPlaceRequest(String placeToken);  }