use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class NewGuidedDecisionTableGraphHandler method create.
@Override
public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) {
busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
graphService.call(getSuccessCallback(presenter), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(pkg.getPackageMainResourcesPath(), buildFileName(baseFileName, resourceType), new GuidedDecisionTableEditorGraphModel(), "");
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkBuildModelFromEditor.
@Test
public void checkBuildModelFromEditor() {
final ObservablePath dtPath1 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest1 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent1 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter1 = makeDecisionTable(dtPath1, dtPath1, dtPlaceRequest1, dtContent1);
final ObservablePath dtPath2 = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest2 = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent2 = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter2 = makeDecisionTable(dtPath2, dtPath2, dtPlaceRequest2, dtContent2);
when(dtPresenter1.getView().getX()).thenReturn(100.0);
when(dtPresenter1.getView().getY()).thenReturn(110.0);
when(dtPresenter2.getView().getX()).thenReturn(200.0);
when(dtPresenter2.getView().getY()).thenReturn(220.0);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter1);
add(dtPresenter2);
}
});
final GuidedDecisionTableEditorGraphModel model = presenter.buildModelFromEditor();
assertNotNull(model);
assertNotNull(model.getEntries());
assertEquals(2, model.getEntries().size());
assertContains(model.getEntries(), dtPath1, 100.0, 110.0);
assertContains(model.getEntries(), dtPath2, 200.0, 220.0);
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method testLoadDocumentGraphEmptyModel.
@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);
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkSaveAndUpdateGraphEntries.
@Test
@SuppressWarnings("unchecked")
public void checkSaveAndUpdateGraphEntries() {
// Setup Decision Table
final Path path = mock(Path.class);
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
final Metadata metadata = mock(Metadata.class);
final String comment = "comment";
final String headPathUri = "file://project/src/main/resources/mypackage/dtable.gdst";
final String versionPathUri = "file://0123456789@project/src/main/resources/mypackage/dtable.gdst";
when(path.toURI()).thenReturn(headPathUri);
when(path.getFileName()).thenReturn("dtable.gdst");
// Setup Decision Table versions
final List<VersionRecord> versions = new ArrayList<>();
versions.add(new PortableVersionRecord("0123456789", "manstis", "manstis@email.com", "comment", Calendar.getInstance().getTime(), versionPathUri));
when(versionRecordService.load(any(org.uberfire.java.nio.file.Path.class))).thenReturn(versions);
// Setup Decision Table Graph
final URI dtGraphPathUri = URI.create("file://project/src/main/resources/mypackage/graph1.gdst-set");
final org.uberfire.java.nio.file.Path dtGraphPath = mock(org.uberfire.java.nio.file.Path.class);
when(dtGraphPath.toUri()).thenReturn(dtGraphPathUri);
when(dtGraphPath.getFileName()).thenReturn(dtGraphPath);
when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
final List<org.uberfire.java.nio.file.Path> dtGraphPaths = new ArrayList<>();
dtGraphPaths.add(dtGraphPath);
when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class), any(FileExtensionFilter.class))).thenReturn(new MockDirectoryStream(dtGraphPaths));
final GuidedDecisionTableEditorGraphModel dtGraphModel = new GuidedDecisionTableEditorGraphModel();
dtGraphModel.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(path, path));
when(dtableGraphService.load(any(Path.class))).thenReturn(dtGraphModel);
// Test save
service.saveAndUpdateGraphEntries(path, model, metadata, comment);
verify(ioService, times(1)).startBatch(any(FileSystem.class));
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any());
verify(ioService, times(1)).endBatch();
assertEquals("mypackage", model.getPackageName());
assertEquals(1, dtGraphModel.getEntries().size());
assertEquals(versions.get(0).uri(), dtGraphModel.getEntries().iterator().next().getPathVersion().toURI());
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkCreate.
@Test
public void checkCreate() {
final Path context = mock(Path.class);
final String fileName = "filename." + dtGraphResourceType.getSuffix();
final GuidedDecisionTableEditorGraphModel content = new GuidedDecisionTableEditorGraphModel();
final String comment = "comment";
when(context.toURI()).thenReturn("file://project/src/main/resources/mypackage");
final Path p = service.create(context, fileName, content, comment);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any());
assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtGraphResourceType.getSuffix()));
}
Aggregations