NavTreeEditor extends NavItemEditor { public void edit(NavTree navTree) { this.navTree = navTree.cloneTree(); this.currentlyEditedItem = Optional.empty(); view.setChangedFlag(false); NavGroup rootGroup = NavFactory.get().createNavGroup(navTree); rootGroup.setId(ROOT_GROUP_ID); getSettings().setNewDividerEnabled(ROOT_GROUP_ID, false); getSettings().setNewPerspectiveEnabled(ROOT_GROUP_ID, false); super.edit(rootGroup); super.expand(); } @Inject  NavTreeEditor(NavTreeEditorView view,
                         NavigationManager navigationManager,
                         SyncBeanManager beanManager,
                         PlaceManager placeManager,
                         PerspectiveTreeProvider perspectiveTreeProvider,
                         TargetPerspectiveEditor targetPerspectiveEditor,
                         PerspectivePluginManager perspectivePluginManager,
                         Event<NavItemEditStartedEvent> navItemEditStartedEvent,
                         Event<NavItemEditCancelledEvent> navItemEditCancelledEvent); void setOnSaveCommand(Command onSaveCommand); @Override String getGroupLiteral(); void setMaximized(boolean maximized); NavTree getNavTree(); void edit(NavTree navTree); NavItemEditorSettings setMaxLevels(String navItemId, int maxLevels); NavItemEditorSettings.Flags setNewGroupEnabled(String navItemId, boolean enabled); NavItemEditorSettings.Flags setNewPerspectiveEnabled(String navItemId, boolean enabled); NavItemEditorSettings.Flags setNewDividerEnabled(String navItemId, boolean enabled); NavItemEditorSettings.Flags setOnlyRuntimePerspectives(String navItemId, boolean enabled); NavItemEditorSettings.Flags setPerspectiveContextEnabled(String navItemId, boolean enabled); static final NavigationConstants i18n; static final String ROOT_GROUP_ID; }
@Test public void testNewGroup() { navTreeEditor.setOnUpdateCommand(updateCommand); navTreeEditor.edit(NAV_TREE); navTreeEditor.collapse(); assertFalse(navTreeEditor.isExpanded()); reset(view); NavItemEditor navItemEditor = navTreeEditor.newGroup(); assertEquals(((NavGroup) navTreeEditor.getNavItem()).getChildren().size(), 2); assertTrue(navTreeEditor.isExpanded()); verify(navItemEditor).startEdition(); verify(view, times(3)).addChild(any()); verify(updateCommand, never()).execute(); when(navRootNodeEditorView.getItemName()).thenReturn("A"); navItemEditor.onChangesOk(); verify(updateCommand).execute(); }
@Test public void testNewPerspective() { navTreeEditor.setOnUpdateCommand(updateCommand); navTreeEditor.edit(NAV_TREE); navTreeEditor.collapse(); assertFalse(navTreeEditor.isExpanded()); reset(view); NavItemEditor navItemEditor = navTreeEditor.newPerspective(); assertEquals(((NavGroup) navTreeEditor.getNavItem()).getChildren().size(), 2); assertTrue(navTreeEditor.isExpanded()); verify(navItemEditor).startEdition(); verify(view, times(3)).addChild(any()); verify(updateCommand, never()).execute(); }
@Test public void testNewDivider() { navTreeEditor.setOnUpdateCommand(updateCommand); navTreeEditor.edit(NAV_TREE); navTreeEditor.collapse(); assertFalse(navTreeEditor.isExpanded()); reset(view); navTreeEditor.newDivider(); assertTrue(navTreeEditor.isExpanded()); assertEquals(((NavGroup) navTreeEditor.getNavItem()).getChildren().size(), 3); verify(view, times(3)).addChild(any()); verify(updateCommand).execute(); }
@Test public void testEditIsNotInvokedTwiceAfterCancel() { navTreeEditor.edit(NAV_TREE); reset(navItemEditor); navItemEditor.startEdition(); navItemEditor.cancelEdition(); verify(navItemEditor, times(1)).edit(any()); }