@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()); }
@Override protected GuidedDecisionTableEditorGraphContent constructContent(final Path path, final Overview overview) { final GuidedDecisionTableEditorGraphModel model = load(path); //Signal opening to interested parties resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo)); return new GuidedDecisionTableEditorGraphContent(model, overview); }
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 void saveDocumentGraph(final Path editorPath) { final GuidedDecisionTableEditorGraphModel model = buildModelFromEditor(); graphService.call(new RemoteCallback<Path>() { @Override public void callback(final Path path) { editorView.hideBusyIndicator(); versionRecordManager.reloadVersions(path); originalGraphHash = model.hashCode(); concurrentUpdateSessionInfo = null; notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemSavedSuccessfully())); } }, new HasBusyIndicatorDefaultErrorCallback(view)).save(editorPath, model, content.getOverview().getMetadata(), commitMessage); }
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 void saveDocumentGraph(final Path editorPath) { final GuidedDecisionTableEditorGraphModel model = buildModelFromEditor(); graphService.call(new RemoteCallback<Path>() { @Override public void callback(final Path path) { editorView.hideBusyIndicator(); versionRecordManager.reloadVersions(path); originalGraphHash = model.hashCode(); concurrentUpdateSessionInfo = null; notificationEvent.fire(new NotificationEvent(CommonConstants.INSTANCE.ItemSavedSuccessfully())); } }, new HasBusyIndicatorDefaultErrorCallback(view)).save(editorPath, model, content.getOverview().getMetadata(), commitMessage); }
@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(); }
dtGraphContent.getOverview(), dmo, imports, onFocusCommandCaptor.capture()); verify(overviewWidget, times(2)).setContent(eq(dtGraphContent.getOverview()), any(ObservablePath.class));
protected GuidedDecisionTableEditorGraphContent makeDecisionTableGraphContent(final int hashCode) { final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel() { @Override public int hashCode() { return hashCode; } @Override public boolean equals(Object o) { return super.equals(o); } }; return new GuidedDecisionTableEditorGraphContent(model, mock(Overview.class)); }
@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); }
@Override protected void initialiseKieEditorTabs(final GuidedDecisionTableView.Presenter document, final Overview overview, final AsyncPackageDataModelOracle dmo, final Imports imports, final boolean isReadOnly) { kieEditorWrapperView.clear(); kieEditorWrapperView.addMainEditorPage(editorView); kieEditorWrapperView.addOverviewPage(overviewWidget, () -> overviewWidget.refresh(versionRecordManager.getVersion())); kieEditorWrapperView.addSourcePage(sourceWidget); kieEditorWrapperView.addImportsTab(importsWidget); overviewWidget.setContent(content.getOverview(), versionRecordManager.getPathToLatest()); importsWidget.setContent(dmo, imports, isReadOnly); }
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
@Override protected void initialiseKieEditorTabs(final GuidedDecisionTableView.Presenter document, final Overview overview, final AsyncPackageDataModelOracle dmo, final Imports imports, final boolean isReadOnly) { kieEditorWrapperView.clear(); kieEditorWrapperView.addMainEditorPage(editorView); kieEditorWrapperView.addOverviewPage(overviewWidget, () -> overviewWidget.refresh(versionRecordManager.getVersion())); kieEditorWrapperView.addSourcePage(sourceWidget); kieEditorWrapperView.addImportsTab(importsWidget); overviewWidget.setContent(content.getOverview(), versionRecordManager.getPathToLatest()); importsWidget.setContent(dmo, imports, isReadOnly); }
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
void initialiseEditorTabsWhenNoDocuments() { getEditMenuItem().setEnabled(false); getViewMenuItem().setEnabled(false); getInsertMenuItem().setEnabled(false); getRadarMenuItem().setEnabled(false); enableMenuItem(false, MenuItems.VALIDATE); kieEditorWrapperView.clear(); kieEditorWrapperView.addMainEditorPage(editorView); kieEditorWrapperView.addOverviewPage(overviewWidget, () -> overviewWidget.refresh(versionRecordManager.getVersion())); overviewWidget.setContent(content.getOverview(), versionRecordManager.getPathToLatest()); }
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
void initialiseEditorTabsWhenNoDocuments() { getEditMenuItem().setEnabled(false); getViewMenuItem().setEnabled(false); getInsertMenuItem().setEnabled(false); getRadarMenuItem().setEnabled(false); enableMenuItem(false, MenuItems.VALIDATE); kieEditorWrapperView.clear(); kieEditorWrapperView.addMainEditorPage(editorView); kieEditorWrapperView.addOverviewPage(overviewWidget, () -> overviewWidget.refresh(versionRecordManager.getVersion())); overviewWidget.setContent(content.getOverview(), versionRecordManager.getPathToLatest()); }