Search in sources :

Example 76 with GuidedDecisionTable52

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

the class DecisionTableXLSToDecisionTableGuidedConverterTest method testImportGeneration.

@Test
public // https://issues.jboss.org/browse/GUVNOR-2478
void testImportGeneration() {
    final InputStream is = this.getClass().getResourceAsStream("GUVNOR-2478.xls");
    when(ioService.newInputStream(any(org.uberfire.java.nio.file.Path.class))).thenReturn(is);
    final ConversionResult result = converter.convert(path);
    assertNotNull(result);
    final ArgumentCaptor<Path> projectImportsPathArgumentCaptor = ArgumentCaptor.forClass(Path.class);
    final ArgumentCaptor<ProjectImports> projectImportsArgumentCaptor = ArgumentCaptor.forClass(ProjectImports.class);
    verify(importsService, times(1)).save(projectImportsPathArgumentCaptor.capture(), projectImportsArgumentCaptor.capture(), any(Metadata.class), any(String.class));
    assertNotNull(projectImportsPathArgumentCaptor.getValue());
    final Path actualProjectImportsPath = projectImportsPathArgumentCaptor.getValue();
    assertEquals(expectedProjectImportsPath.toURI(), actualProjectImportsPath.toURI());
    assertNotNull(projectImportsArgumentCaptor.getValue());
    final ProjectImports projectImports = projectImportsArgumentCaptor.getValue();
    assertEquals(1, projectImports.getImports().getImports().size());
    assertEquals("java.util.List", projectImports.getImports().getImports().get(0).getType());
    verify(guidedDecisionTableService, times(1)).create(any(Path.class), any(String.class), any(GuidedDecisionTable52.class), any(String.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) ConversionResult(org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) InputStream(java.io.InputStream) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) Test(org.junit.Test)

Example 77 with GuidedDecisionTable52

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

the class BRLActionColumnDefinitionBuilder method generateDefinition.

@Override
public void generateDefinition(final GuidedDecisionTableView.Presenter dtPresenter, final BaseColumn column, final Callback<String> afterGenerationCallback) {
    if (!(column instanceof BRLActionVariableColumn)) {
        return;
    }
    final GuidedDecisionTable52 existingModel = dtPresenter.getModel();
    final BRLActionVariableColumn brlVariableColumn = (BRLActionVariableColumn) column;
    final BRLActionColumn brlColumn = existingModel.getBRLColumn(brlVariableColumn);
    final GuidedDecisionTable52 partialModel = new GuidedDecisionTable52();
    final ColumnUtilities columnUtilities = new ColumnUtilities(existingModel, dtPresenter.getDataModelOracle());
    partialModel.getActionCols().add(brlColumn);
    partialModel.getData().add(makeRowData(columnUtilities, brlColumn));
    generateDefinitionOnServer(partialModel, dtPresenter.getCurrentPath(), (String drl) -> afterGenerationCallback.callback(getRHS(drl)));
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 78 with GuidedDecisionTable52

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

the class ColumnsPagePresenterTest method testRefresh.

@Test
public void testRefresh() {
    final GuidedDecisionTable52 guidedDecisionTable52 = mock(GuidedDecisionTable52.class);
    doReturn(Optional.of(guidedDecisionTable52)).when(presenter).getGuidedDecisionTable52();
    doNothing().when(presenter).refreshAttributeWidget(any());
    doNothing().when(presenter).refreshMetaDataWidget(any());
    doNothing().when(presenter).refreshConditionsWidget(any());
    doNothing().when(presenter).refreshActionsWidget(any());
    final List<AttributeCol52> attributeCol52s = new ArrayList<>();
    final List<MetadataCol52> metadataCol52s = new ArrayList<>();
    final List<CompositeColumn<? extends BaseColumn>> compositeColumns = new ArrayList<>();
    final List<ActionCol52> actionCol52s = new ArrayList<>();
    doReturn(attributeCol52s).when(guidedDecisionTable52).getAttributeCols();
    doReturn(metadataCol52s).when(guidedDecisionTable52).getAttributeCols();
    doReturn(compositeColumns).when(guidedDecisionTable52).getAttributeCols();
    doReturn(actionCol52s).when(guidedDecisionTable52).getAttributeCols();
    presenter.refresh();
    verify(presenter).refreshAttributeWidget(attributeCol52s);
    verify(presenter).refreshMetaDataWidget(metadataCol52s);
    verify(presenter).refreshConditionsWidget(compositeColumns);
    verify(presenter).refreshActionsWidget(actionCol52s);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 79 with GuidedDecisionTable52

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

the class NewGuidedDecisionTableHandlerTest method testResolvedHitPolicy.

@Test
public void testResolvedHitPolicy() throws Exception {
    final Package pkg = mock(Package.class);
    final Path resourcesPath = PathFactory.newPath("resources", "default://project/src/main/resources");
    when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
    when(options.isUsingWizard()).thenReturn(false);
    when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT);
    handler.create(pkg, "fileName", newResourcePresenter);
    final ArgumentCaptor<GuidedDecisionTable52> dtableArgumentCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
    verify(service, times(1)).create(eq(resourcesPath), eq("fileName." + resourceType.getSuffix()), dtableArgumentCaptor.capture(), any(String.class));
    final GuidedDecisionTable52 model = dtableArgumentCaptor.getValue();
    assertEquals(1, model.getMetadataCols().size());
    final MetadataCol52 metadataCol52 = model.getMetadataCols().get(0);
    assertEquals(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT_METADATA_NAME, metadataCol52.getMetadata());
}
Also used : Path(org.uberfire.backend.vfs.Path) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Package(org.guvnor.common.services.project.model.Package) Test(org.junit.Test)

Example 80 with GuidedDecisionTable52

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

the class DecisionTableAnalyzerTest method setUp.

@Before
public void setUp() throws Exception {
    actionColumns = new ArrayList<>();
    conditionColumns = new ArrayList<>();
    patterns = new ArrayList<>();
    pattern = new Pattern52();
    connection = mock(VerifierWebWorkerConnection.class);
    updateManager = mock(DTableUpdateManagerImpl.class);
    model = new GuidedDecisionTable52();
    decisionTableAnalyzer = new DecisionTableAnalyzer(model, updateManager, connection);
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Before(org.junit.Before)

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