RuntimeScreen { public void goToIndex(List<LayoutTemplate> templates) { if (templates.size() == 1) { placeManager.goTo(templates.get(0).getName()); } else { templates.stream() .map(LayoutTemplate::getName) .filter(INDEX_PAGE_NAME::equals) .findFirst() .ifPresent(placeManager::goTo); } }  @WorkbenchPartTitle String getScreenTitle(); @WorkbenchPartView View workbenchPart(); void loadDashboards(RuntimeModel runtimeModel); void goToIndex(List<LayoutTemplate> templates); static final String ID; static final String INDEX_PAGE_NAME; }
@Test public void testGoToIndexWithIndexPage() { String randomPage = "randomPage"; List<LayoutTemplate> templates = Arrays.asList(new LayoutTemplate(randomPage), new LayoutTemplate(RuntimeScreen.INDEX_PAGE_NAME)); runtimeScreen.goToIndex(templates); verify(placeManager).goTo(RuntimeScreen.INDEX_PAGE_NAME); verify(placeManager, times(0)).goTo(randomPage); }
@Test public void testGoToIndexWithSinglePage() { String randomPage = "randomPage"; List<LayoutTemplate> templates = Arrays.asList(new LayoutTemplate(randomPage)); runtimeScreen.goToIndex(templates); verify(placeManager).goTo(randomPage); }
@Test public void testGoToIndexWithoutIndex() { List<LayoutTemplate> templates = Arrays.asList(new LayoutTemplate("page1"), new LayoutTemplate("page2")); runtimeScreen.goToIndex(templates); verify(placeManager, times(0)).goTo(anyString()); }