RouteTokenFormatter implements TokenFormatter { @Override public String toHistoryToken(List<PlaceRequest> placeRequestHierarchy) throws TokenFormatException { assert placeRequestHierarchy.size() == 1 : "Expected a place hierarchy with exactly one place."; return toPlaceToken(placeRequestHierarchy.get(0)); } @Inject  RouteTokenFormatter(UrlUtils urlUtils,
                        PlaceTokenRegistry tokenRegistry); @Override String toPlaceToken(PlaceRequest placeRequest); @Override String toHistoryToken(List<PlaceRequest> placeRequestHierarchy); @Override PlaceRequest toPlaceRequest(String placeToken); @Override List<PlaceRequest> toPlaceRequestHierarchy(String historyToken);  }
@Test public void testToHistoryToken() { tokenFormatter = spy(tokenFormatter); PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("token").build(); List<PlaceRequest> placeRequestHierarchy = ImmutableList.<PlaceRequest>builder().add(placeRequest).build(); tokenFormatter.toHistoryToken(placeRequestHierarchy); verify(tokenFormatter).toPlaceToken(placeRequest); }