PlaceHistoryHandler { public void registerCloseDock(@Observes UberfireDocksInteractionEvent event) { if (event.getType() == UberfireDocksInteractionEvent.InteractionType.CLOSED) { currentBookmarkableURLStatus = BookmarkableUrlHelper.registerClosedDock(currentBookmarkableURLStatus, event.getTargetDock()); updateHistoryBar(); } } PlaceHistoryHandler(); void handleCurrentHistory(); HandlerRegistration initialize(final PlaceManager placeManager,
                                          final EventBus eventBus,
                                          final PlaceRequest defaultPlaceRequest); String getCurrentBookmarkableURLStatus(); PlaceRequest getPerspectiveFromPlace(final PlaceRequest place); void registerOpen(Activity activity,
                             PlaceRequest place); void registerClose(Activity activity,
                              PlaceRequest place); void flush(); String getToken(); void registerOpenDock(@Observes UberfireDocksInteractionEvent event); void registerCloseDock(@Observes UberfireDocksInteractionEvent event);  }
@Test public void testRegisterCloseDock() { final String dockName = "testDock"; final String placeRequestName = "testPlacerequest"; PlaceRequest place = new DefaultPlaceRequest(placeRequestName); placeHistoryHandler.registerOpen(screenActivity, place); PlaceRequest dockPlace = new DefaultPlaceRequest(dockName); UberfireDocksInteractionEvent openEvent = mock(UberfireDocksInteractionEvent.class); UberfireDocksInteractionEvent closeEvent = mock(UberfireDocksInteractionEvent.class); UberfireDock dock = mock(UberfireDock.class); when(dock.getDockPosition()).thenReturn(UberfireDockPosition.WEST); when(dock.getIdentifier()).thenReturn(dockName); when(dock.getIconType()).thenReturn("iconType"); when(dock.getPlaceRequest()).thenReturn(dockPlace); when(openEvent.getType()).thenReturn(UberfireDocksInteractionEvent.InteractionType.OPENED); when(openEvent.getTargetDock()).thenReturn(dock); when(closeEvent.getType()).thenReturn(UberfireDocksInteractionEvent.InteractionType.CLOSED); when(closeEvent.getTargetDock()).thenReturn(dock); placeHistoryHandler.registerOpenDock(openEvent); placeHistoryHandler.registerCloseDock(closeEvent); StringBuilder expected = new StringBuilder(placeRequestName); expected.append(BookmarkableUrlHelper.DOCK_BEGIN_SEP); expected.append(BookmarkableUrlHelper.CLOSED_DOCK_PREFIX); expected.append("W"); expected.append(dockName); expected.append(BookmarkableUrlHelper.SEPARATOR); expected.append(BookmarkableUrlHelper.DOCK_CLOSE_SEP); assertEquals(expected.toString(), placeHistoryHandler.getCurrentBookmarkableURLStatus()); }