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));
}
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)));
}
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);
}
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());
}
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);
}
Aggregations