BookmarkableUrlHelper { public static PlaceRequest getPerspectiveFromPlace(PlaceRequest place) { String url = place.getFullIdentifier(); if (isPerspectiveInUrl(url)) { String perspectiveName = url.substring(0, url.indexOf(PERSPECTIVE_SEP)); PlaceRequest copy = place.clone(); copy.setIdentifier(perspectiveName); if (!place.getParameters().isEmpty()) { for (Map.Entry<String, String> elem : place.getParameters().entrySet()) { copy.addParameter(elem.getKey(), elem.getValue()); } } return copy; } return place; }  static String registerOpenedScreen(String bookmarkableUrl,
                                              final PlaceRequest placeRequest); static String registerClose(String bookmarkableUrl,
                                       final String screenName); static PlaceRequest getPerspectiveFromPlace(PlaceRequest place); static boolean isPerspectiveScreen(final String bookmarkableUrl,
                                              final String screen); static boolean isPerspectiveInUrl(final String url); static boolean urlContainsExtraPerspectiveScreen(final String bookmarkableUrl); static String getUrlToken(final String bookmarkableUrl,
                                     final String screen); static Set<String> getDockedScreensFromUrl(final String url); static Set<String> getDockedScreensFromPlace(final PlaceRequest place); static Set<String> getScreensFromPlace(final PlaceRequest place); static Set<String> getClosedScreenFromPlace(final PlaceRequest place); static Set<String> getOpenedScreenFromPlace(final PlaceRequest place); static boolean isScreenClosed(final String bookmarkableUrl,
                                         String screen); static String registerOpenedPerspective(String currentBookmarkableURLStatus,
                                                   PlaceRequest place); static String registerOpenedDock(String currentBookmarkableURLStatus,
                                            UberfireDock targetDock); static String registerClosedDock(String currentBookmarkableURLStatus,
                                            UberfireDock targetDock); static String registerCloseEditor(final String currentBookmarkableURLStatus,
                                             final PlaceRequest place); final static String PERSPECTIVE_SEP; final static String DOCK_BEGIN_SEP; final static String DOCK_CLOSE_SEP; final static String SEPARATOR; final static String OTHER_SCREEN_SEP; final static String CLOSED_PREFIX; final static String CLOSED_DOCK_PREFIX; final static int MAX_NAV_URL_SIZE; }
@Test public void testGetPerspectiveFromPlace() { final String perspectiveName = "eccePerspective"; final String bookmarkableUrl = perspectiveName .concat("|~screen1,~screen2"); final PlaceRequest req = new DefaultPlaceRequest(bookmarkableUrl); PlaceRequest place = BookmarkableUrlHelper.getPerspectiveFromPlace(req); assertNotNull(place); assertNotSame(req, place); assertEquals(perspectiveName, place.getFullIdentifier()); final PlaceRequest empty = new DefaultPlaceRequest("screenOpened,~screenClosed"); empty.addParameter("param", "value"); place = BookmarkableUrlHelper.getPerspectiveFromPlace(empty); assertNotNull(place); assertEquals(empty.getFullIdentifier(), place.getFullIdentifier()); }
@Test public void testGetPerspectiveFromPlaceWithParams() { final String perspectiveName = "eccePerspective"; final String bookmarkableUrl = perspectiveName .concat("|~screen1,~screen2"); final PlaceRequest req = new DefaultPlaceRequest(bookmarkableUrl); req.addParameter("param", "value"); PlaceRequest place = BookmarkableUrlHelper.getPerspectiveFromPlace(req); assertNotNull(place); assertNotSame(req, place); StringBuilder expected = new StringBuilder(perspectiveName); expected.append("?param=value"); assertEquals(expected.toString(), place.getFullIdentifier()); }