@Test public void testToPlaceRequestEmptyRoute() { PlaceRequest placeRequest10 = tokenFormatter.toPlaceRequest("/"); PlaceRequest placeRequest11 = tokenFormatter.toPlaceRequest("/?a=valueA&b=valueB"); PlaceRequest placeRequest12 = tokenFormatter.toPlaceRequest(""); PlaceRequest placeRequest13 = tokenFormatter.toPlaceRequest("?a=valueA&b=valueB"); assertEquals("/", placeRequest10.getNameToken()); assertEquals(0, placeRequest10.getParameterNames().size()); assertEquals("/", placeRequest11.getNameToken()); assertEquals(2, placeRequest11.getParameterNames().size()); assertEquals("valueA", placeRequest11.getParameter("a", null)); assertEquals("valueB", placeRequest11.getParameter("b", null)); assertEquals("/", placeRequest12.getNameToken()); assertEquals(0, placeRequest12.getParameterNames().size()); assertEquals("/", placeRequest13.getNameToken()); assertEquals(2, placeRequest13.getParameterNames().size()); assertEquals("valueA", placeRequest13.getParameter("a", null)); assertEquals("valueB", placeRequest13.getParameter("b", null)); }
@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);  }