Search in sources :

Example 1 with GuidedDecisionTableEditorGraphModel

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(), "");
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) HasBusyIndicatorDefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.HasBusyIndicatorDefaultErrorCallback)

Example 2 with 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);
}
Also used : PathPlaceRequest(org.uberfire.mvp.impl.PathPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) OverviewWidgetPresenter(org.kie.workbench.common.widgets.metadata.client.widget.OverviewWidgetPresenter) GuidedDecisionTableEditorContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with GuidedDecisionTableEditorGraphModel

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);
}
Also used : GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTableEditorGraphContent(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) Overview(org.guvnor.common.services.shared.metadata.model.Overview) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 4 with GuidedDecisionTableEditorGraphModel

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());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ArrayList(java.util.ArrayList) URI(java.net.URI) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) FileSystem(org.uberfire.java.nio.file.FileSystem) FileExtensionFilter(org.guvnor.common.services.backend.file.FileExtensionFilter) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 5 with GuidedDecisionTableEditorGraphModel

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()));
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Test(org.junit.Test)

Aggregations

GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)22 Test (org.junit.Test)16 Path (org.uberfire.backend.vfs.Path)9 URI (java.net.URI)3 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 Map (java.util.Map)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)2 GuidedDecisionTableEditorGraphContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphContent)2 FileExtensionFilter (org.guvnor.common.services.backend.file.FileExtensionFilter)2 Overview (org.guvnor.common.services.shared.metadata.model.Overview)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 ResourceOpenedEvent (org.uberfire.workbench.events.ResourceOpenedEvent)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1