private RemoteCallback<GuidedDecisionTableEditorGraphContent> getLoadGraphContentSuccessCallback() { return (content) -> { this.content = content; this.originalGraphHash = content.getModel().hashCode(); this.concurrentUpdateSessionInfo = null; final GuidedDecisionTableEditorGraphModel model = content.getModel(); final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> modelEntries = model.getEntries(); initialiseEditorTabsWhenNoDocuments(); if (modelEntries == null || modelEntries.isEmpty()) { view.hideBusyIndicator(); return; } loadGraphLatch = new LoadGraphLatch(modelEntries.size(), getSelectDecisionTableCommand(modelEntries.iterator().next().getPathHead()), () -> { originalGraphHash = buildModelFromEditor().hashCode(); modeller.getView().getGridPanel().setFocus(true); }); modelEntries.stream().forEach(loadGraphLatch::loadDocumentGraphEntry); }; }
private RemoteCallback<GuidedDecisionTableEditorGraphContent> getLoadGraphContentSuccessCallback() { return (content) -> { this.content = content; this.originalGraphHash = content.getModel().hashCode(); this.concurrentUpdateSessionInfo = null; final GuidedDecisionTableEditorGraphModel model = content.getModel(); final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> modelEntries = model.getEntries(); initialiseEditorTabsWhenNoDocuments(); if (modelEntries == null || modelEntries.isEmpty()) { view.hideBusyIndicator(); return; } loadGraphLatch = new LoadGraphLatch(modelEntries.size(), getSelectDecisionTableCommand(modelEntries.iterator().next().getPathHead()), () -> { originalGraphHash = buildModelFromEditor().hashCode(); modeller.getView().getGridPanel().setFocus(true); }); modelEntries.stream().forEach(loadGraphLatch::loadDocumentGraphEntry); }; }
@Test public void checkConstructContent() { final Path path = mock(Path.class); final Overview overview = mock(Overview.class); when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview); verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class)); assertNotNull(content.getModel()); assertEquals(overview, content.getOverview()); }
@Test public void checkConstructContent() { final Path path = mock(Path.class); final Overview overview = mock(Overview.class); when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview); verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class)); assertNotNull(content.getModel()); assertEquals(overview, content.getOverview()); }
private void checkMayClose(final int uiModelHashCode, final Command assertion) { final ObservablePath dtGraphPath = mock(ObservablePath.class); final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class); final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(0); when(dtGraphPath.toURI()).thenReturn("dtGraphPath"); when(dtGraphPath.getFileName()).thenReturn("filename"); when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent); when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath); doReturn(makeDecisionTableGraphContent(uiModelHashCode).getModel()).when(presenter).buildModelFromEditor(); presenter.onStartup(dtGraphPath, dtGraphPlaceRequest); assertion.execute(); }
@Test public void testLoadDocumentGraphEmptyModel() throws Exception { final ObservablePath documentPath = mock(ObservablePath.class); final Overview overview = mock(Overview.class); final GuidedDecisionTableEditorGraphModel graphModel = mock(GuidedDecisionTableEditorGraphModel.class); final GuidedDecisionTableEditorGraphContent graphContent = mock(GuidedDecisionTableEditorGraphContent.class); when(documentPath.getFileName()).thenReturn("GDT"); when(versionRecordManager.getCurrentPath()).thenReturn(documentPath); when(dtGraphService.loadContent(documentPath)).thenReturn(graphContent); when(versionRecordManager.getPathToLatest()).thenReturn(documentPath); when(graphContent.getOverview()).thenReturn(overview); when(graphContent.getModel()).thenReturn(graphModel); presenter.loadDocumentGraph(documentPath); verify(view).showLoading(); verify(view).hideBusyIndicator(); verify(view).refreshTitle(startsWith("GDT")); // initialise when no documents verify(editMenuItem).setEnabled(false); verify(viewMenuItem).setEnabled(false); verify(insertMenuItem).setEnabled(false); verify(radarMenuItem).setEnabled(false); verify(kieEditorWrapperView).clear(); verify(kieEditorWrapperView).addMainEditorPage(view); verify(kieEditorWrapperView).addOverviewPage(eq(overviewWidget), any(com.google.gwt.user.client.Command.class)); verify(overviewWidget).setContent(overview, documentPath); }
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);