BookmarkableUrlHelper { public static String registerOpenedDock(String currentBookmarkableURLStatus, UberfireDock targetDock) { if (targetDock == null) { return currentBookmarkableURLStatus; } final String id = getDockId(targetDock); final String closed = CLOSED_DOCK_PREFIX.concat(id); if (currentBookmarkableURLStatus.contains(DOCK_CLOSE_SEP)) { String result = null; if (!currentBookmarkableURLStatus.contains(id)) { result = currentBookmarkableURLStatus.replace(DOCK_CLOSE_SEP, (id + DOCK_CLOSE_SEP)); } else if (currentBookmarkableURLStatus.contains(closed)) { result = currentBookmarkableURLStatus.replace(closed, id); } else { result = currentBookmarkableURLStatus; } return result; } else { return currentBookmarkableURLStatus + DOCK_BEGIN_SEP + (getDockId(targetDock) + DOCK_CLOSE_SEP); } }  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 testRegisterOpenDock() { final String screens = "screen1"; final String dockName = "dockedScreen"; final String perspectiveName = "perspectiveName"; String url = perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat(screens); final UberfireDock dock1 = createUberfireDockForTest(dockName, perspectiveName); final UberfireDock dock2 = createUberfireDockForTest(dockName.concat("New"), perspectiveName); url = BookmarkableUrlHelper.registerOpenedDock(url, dock1); assertEquals(perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[WdockedScreen,]"), url); url = BookmarkableUrlHelper.registerOpenedDock(url, dock2); assertEquals(perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[WdockedScreen,WdockedScreenNew,]"), url); url = perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[!WdockedScreen,]"); String expected = perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[WdockedScreen,]"); url = BookmarkableUrlHelper.registerOpenedDock(url, dock1); assertEquals(expected, url); expected = BookmarkableUrlHelper.registerOpenedDock(url, null); assertNotNull(expected); assertEquals(expected, url); url = " "; expected = BookmarkableUrlHelper.registerOpenedDock(url, null); assertNotNull(expected); assertEquals(expected, url); }
@Test public void testDoubleRegisterOpenDock() { final String screens = "screen1"; final String dockName = "dockedScreen"; final String perspectiveName = "perspectiveName"; String url = perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat(screens); final UberfireDock dock1 = createUberfireDockForTest(dockName, perspectiveName); final UberfireDock dock2 = createUberfireDockForTest(dockName.concat("New"), perspectiveName); url = BookmarkableUrlHelper.registerOpenedDock(url, dock1); url = BookmarkableUrlHelper.registerOpenedDock(url, dock1); assertEquals(perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[WdockedScreen,]"), url); url = BookmarkableUrlHelper.registerOpenedDock(url, dock2); url = BookmarkableUrlHelper.registerOpenedDock(url, dock2); assertEquals(perspectiveName .concat(BookmarkableUrlHelper.PERSPECTIVE_SEP) .concat("screen1[WdockedScreen,WdockedScreenNew,]"), url); }
@Test public void testOpenADockWithEmptyBookmark() { UberfireDock dock1 = createUberfireDockForTest("dock", "perspective"); String url = BookmarkableUrlHelper.registerOpenedDock("", dock1); assertEquals("[Wdock,]", url); }