Search in sources :

Example 56 with GuidedDecisionTable52

use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 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 = "default://project/src/main/resources/mypackage/dtable.gdst";
    final String versionPathUri = "default://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("default://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(CommentedOption.class));
    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) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) 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 57 with GuidedDecisionTable52

use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method testSaveAndRename.

@Test
public void testSaveAndRename() throws Exception {
    final Path path = mock(Path.class);
    final String newFileName = "newFileName";
    final Metadata metadata = mock(Metadata.class);
    final GuidedDecisionTable52 content = mock(GuidedDecisionTable52.class);
    final String comment = "comment";
    service.saveAndRename(path, newFileName, metadata, content, comment);
    verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Example 58 with GuidedDecisionTable52

use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method checkToSource.

@Test
@SuppressWarnings("unchecked")
public void checkToSource() {
    final Path path = mock(Path.class);
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    final SourceService mockSourceService = mock(SourceService.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage");
    when(mockSourceServices.getServiceFor(any(org.uberfire.java.nio.file.Path.class))).thenReturn(mockSourceService);
    service.toSource(path, model);
    verify(mockSourceServices, times(1)).getServiceFor(any(org.uberfire.java.nio.file.Path.class));
    verify(mockSourceService, times(1)).getSource(any(org.uberfire.java.nio.file.Path.class), eq(model));
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) SourceService(org.kie.workbench.common.services.backend.source.SourceService) Test(org.junit.Test)

Example 59 with GuidedDecisionTable52

use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.

the class GuidedDecisionTableFactory method makeTableWithBRLFragmentConditionColWithPredicate.

public static GuidedDecisionTable52 makeTableWithBRLFragmentConditionColWithPredicate(final String packageName, final Collection<Import> imports, final String tableName) {
    final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setPackageName(packageName);
    dt.getImports().getImports().addAll(imports);
    dt.setTableName(tableName);
    final BRLConditionColumn brl = new BRLConditionColumn();
    final FactPattern fp1 = new FactPattern();
    fp1.setFactType("Applicant");
    final SingleFieldConstraint sfc1 = new SingleFieldConstraint();
    sfc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
    sfc1.setValue("age = 45");
    fp1.addConstraint(sfc1);
    brl.getDefinition().add(fp1);
    brl.getChildColumns().add(new BRLConditionVariableColumn("f1", DataType.TYPE_BOOLEAN));
    dt.getConditions().add(brl);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { "1", "desc", true } }));
    return dt;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 60 with GuidedDecisionTable52

use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.

the class GuidedDecisionTableFactory method makeTableWithAttributeCol.

public static GuidedDecisionTable52 makeTableWithAttributeCol(final String packageName, final Collection<Import> imports, final String tableName) {
    final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setPackageName(packageName);
    dt.getImports().getImports().addAll(imports);
    dt.setTableName(tableName);
    AttributeCol52 attr = new AttributeCol52();
    attr.setAttribute("ruleflow-group");
    dt.getAttributeCols().add(attr);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "myRuleFlowGroup" } }));
    return dt;
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)

Aggregations

GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)262 Test (org.junit.Test)193 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)92 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)74 Path (org.uberfire.backend.vfs.Path)52 ArrayList (java.util.ArrayList)51 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)51 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)47 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)39 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)37 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)35 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)33 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)33 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)33 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)32 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)31 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)27 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)27 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26