RouterScreen { protected void route(RuntimeServiceResponse response) { this.mode = response.getMode(); Optional<RuntimeModel> runtimeModelOp = response.getRuntimeModelOp(); if (mode == DashbuilderRuntimeMode.MULTIPLE_IMPORT) { appNavBar.setDashboardListEnabled(true); appNavBar.setup(); } if (runtimeModelOp.isPresent()) { RuntimeModel runtimeModel = runtimeModelOp.get(); placeManager.goTo(RuntimePerspective.ID); runtimeScreen.loadDashboards(runtimeModel); runtimeScreen.goToIndex(runtimeModel.getLayoutTemplates()); return; } if (response.getAvailableModels().isEmpty()) { placeManager.goTo(EmptyPerspective.ID); return; } dashboardsListScreen.loadList(response.getAvailableModels()); placeManager.goTo(DashboardsListPerspective.ID); }  @WorkbenchPartTitle String title(); @WorkbenchPartView View getView(); @OnOpen void onOpen(); void doRoute(); void afterDashboardUpload(String id); void loadDashboard(String importId); void listDashboards(); static final String ID; }
@Test public void testRouteToRuntimePerspective() { RuntimeModel runtimeModel = mock(RuntimeModel.class); RuntimeServiceResponse response = new RuntimeServiceResponse(DashbuilderRuntimeMode.SINGLE_IMPORT, Optional.of(runtimeModel), Collections.emptyList()); routerScreen.route(response); verify(runtimeScreen).loadDashboards(eq(runtimeModel)); verify(placeManager).goTo(eq(RuntimePerspective.ID)); }
@Test public void testRouteToEmptyPerspective() { RuntimeServiceResponse response = new RuntimeServiceResponse(DashbuilderRuntimeMode.SINGLE_IMPORT, Optional.empty(), Collections.emptyList()); routerScreen.route(response); verify(placeManager).goTo(eq(EmptyPerspective.ID)); }
@Test public void testRouteToDashboardsListPerspective() { List<String> models = Arrays.asList("m1", "m2"); RuntimeServiceResponse response = new RuntimeServiceResponse(DashbuilderRuntimeMode.MULTIPLE_IMPORT, Optional.empty(), models); routerScreen.route(response); verify(dashboardsListScreen).loadList(eq(models)); verify(placeManager).goTo(eq(DashboardsListPerspective.ID)); }