BookmarkableUrlHelper { public static String registerClose(String bookmarkableUrl, final String screenName) { final boolean isPerspective = isPerspectiveScreen(bookmarkableUrl, screenName); final String separator = isPerspective ? PERSPECTIVE_SEP : OTHER_SCREEN_SEP; final String closedScreen = CLOSED_PREFIX.concat(screenName); final String uniqueScreenAfterDelimiter = separator.concat(screenName); final String firstScreenAfterDelimiter = uniqueScreenAfterDelimiter.concat(SEPARATOR); final String commaSeparatedScreen = screenName.concat(SEPARATOR); if (isScreenClosed(bookmarkableUrl, closedScreen)) { return bookmarkableUrl; } if (isPerspective) { bookmarkableUrl = bookmarkableUrl.replace(screenName, closedScreen); } else { if (bookmarkableUrl.contains(firstScreenAfterDelimiter)) { bookmarkableUrl = bookmarkableUrl.replace(firstScreenAfterDelimiter, separator); } else if (bookmarkableUrl.contains(uniqueScreenAfterDelimiter)) { bookmarkableUrl = bookmarkableUrl.replace(uniqueScreenAfterDelimiter, ""); } else if (bookmarkableUrl.contains(commaSeparatedScreen)) { bookmarkableUrl = bookmarkableUrl.replace(commaSeparatedScreen, ""); } } return bookmarkableUrl; }  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 testRegisterClose() { String url = "perspective|screen1,screen2$screen3,screen4"; url = BookmarkableUrlHelper.registerClose(url, "screen3"); assertEquals("perspective|screen1,screen2$screen4", url); url = BookmarkableUrlHelper.registerClose(url, "screen4"); assertEquals("perspective|screen1,screen2", url); url = BookmarkableUrlHelper.registerClose(url, "screen1"); assertEquals("perspective|~screen1,screen2", url); url = BookmarkableUrlHelper.registerClose(url, "screen2"); assertEquals("perspective|~screen1,~screen2", url); url = "perspective|screen1,~screen2$screen3"; url = BookmarkableUrlHelper.registerClose(url, "screen2"); assertEquals("perspective|screen1,~screen2$screen3", url); url = "perspective|screen1$screen2"; url = BookmarkableUrlHelper.registerClose(url, "screen2"); assertEquals("perspective|screen1", url); url = "perspective|screen1$screen2,screen3"; url = BookmarkableUrlHelper.registerClose(url, "screen2"); assertEquals("perspective|screen1$screen3", url); url = "perspective|screen1$screen2,screen3,screen4"; url = BookmarkableUrlHelper.registerClose(url, "screen3"); assertEquals("perspective|screen1$screen2,screen4", url); }