PerspectivesExplorer implements IsElement { public void show() { view.clear(); view.setTitle(i18n.capitalizeFirst(i18n.getPerspectivesResourceName())); view.setNewMenuName(i18n.getContentExplorerNew()); view.setNewMenuVisible(pluginController.canCreatePerspectives()); view.setPerspectiveName(i18n.capitalizeFirst(i18n.getPerspectiveResourceName())); perspectivePluginManager.getPerspectivePlugins(perspectivePlugins -> { List<Plugin> filteredPlugins = perspectivePlugins.stream() .filter(pluginController::canRead) .sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())) .collect(Collectors.toList()); if (filteredPlugins.isEmpty()) { view.showEmpty(i18n.getNoPerspectives()); } else { filteredPlugins.forEach(p -> view.addPerspective(p.getName(), () -> onPerspectiveClick(p))); } }); this.expand(); } @Inject  PerspectivesExplorer(View view,
                                PerspectivePluginManager perspectivePluginManager,
                                PluginController pluginController,
                                NewPluginPopUp newPluginPopUp,
                                PlaceManager placeManager,
                                ContentManagerI18n i18n); @Override HTMLElement getElement(); void setOnExpandCommand(Command onExpandCommand); void show(); void onPerspectiveClick(Plugin plugin); boolean isExpanded(); void expand(); void collapse(); void expandOrCollapse(); void setMaximized(boolean maximized); void createNewPerspective(); void onPerspectivePluginsChanged(@Observes final PerspectivePluginsChangedEvent event);  }
@Test public void testPerspectiveListEmpty() { pluginList = new ArrayList<>(); perspectivesExplorer.show(); verify(viewM).clear(); verify(viewM).showEmpty(anyString()); }
@Test public void testPerspectivesAvailable() { when(pluginControllerM.canRead(any())).thenReturn(true); perspectivesExplorer.show(); InOrder inOrder = inOrder(viewM); inOrder.verify(viewM).clear(); inOrder.verify(viewM).addPerspective(eq("a"), any()); inOrder.verify(viewM).addPerspective(eq("B"), any()); inOrder.verify(viewM).addPerspective(eq("cEE"), any()); }
@Test public void testPerspectiveReadAccessDenied() { when(pluginControllerM.canRead(a)).thenReturn(true); when(pluginControllerM.canRead(b)).thenReturn(true); perspectivesExplorer.show(); InOrder inOrder = inOrder(viewM); inOrder.verify(viewM).clear(); inOrder.verify(viewM).addPerspective(eq("a"), any()); inOrder.verify(viewM).addPerspective(eq("B"), any()); inOrder.verify(viewM, never()).addPerspective(eq("cEE"), any()); }