use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class RowExpanderTests method testRowExpansionWithValuesListAndColumnExpansionDisabledAndDefaultValues.
@Test
@SuppressWarnings("serial")
public void testRowExpansionWithValuesListAndColumnExpansionDisabledAndDefaultValues() {
GuidedDecisionTable52 model = new GuidedDecisionTable52();
final ModuleDataModelOracle projectLoader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addFact("Driver").addField(new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER)).addField(new ModelField("name", String.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING)).addField(new ModelField("dateOfBirth", Boolean.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_DATE)).end().build();
// Emulate server-to-client conversions
final AsyncPackageDataModelOracle oracle = getOracle();
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
dataModel.setModelFields(projectLoader.getModuleModelFields());
populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
Pattern52 p1 = new Pattern52();
p1.setBoundName("c1");
p1.setFactType("Driver");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setOperator("==");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setValueList("c1a,c1b");
p1.getChildColumns().add(c1);
model.getConditions().add(p1);
Pattern52 p2 = new Pattern52();
p2.setBoundName("c2");
p2.setFactType("Driver");
ConditionCol52 c2 = new ConditionCol52();
c2.setFactField("age");
c2.setOperator("==");
c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c2.setValueList("c2a,c2b");
c2.setDefaultValue(new DTCellValue52("c2default"));
p2.getChildColumns().add(c2);
model.getConditions().add(p2);
Pattern52 p3 = new Pattern52();
p3.setBoundName("c3");
p3.setFactType("Driver");
ConditionCol52 c3 = new ConditionCol52();
c3.setFactField("dateOfBirth");
c3.setOperator("==");
c3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c3.setValueList("c3a,c3b");
p3.getChildColumns().add(c3);
model.getConditions().add(p3);
RowExpander re = new RowExpander(model, oracle);
re.setExpandColumn(c2, false);
assertEquals(5, re.getColumns().size());
RowExpander.RowIterator i = re.iterator();
List<List<DTCellValue52>> rows = new ArrayList<List<DTCellValue52>>();
while (i.hasNext()) {
List<DTCellValue52> row = i.next();
rows.add(row);
}
assertEquals(4, rows.size());
assertEquals("", rows.get(0).get(0).getStringValue());
assertEquals("", rows.get(0).get(1).getStringValue());
assertEquals("c1a", rows.get(0).get(2).getStringValue());
assertEquals("c2default", rows.get(0).get(3).getStringValue());
assertEquals("c3a", rows.get(0).get(4).getStringValue());
assertEquals("", rows.get(1).get(0).getStringValue());
assertEquals("", rows.get(1).get(1).getStringValue());
assertEquals("c1a", rows.get(1).get(2).getStringValue());
assertEquals("c2default", rows.get(1).get(3).getStringValue());
assertEquals("c3b", rows.get(1).get(4).getStringValue());
assertEquals("", rows.get(2).get(0).getStringValue());
assertEquals("", rows.get(2).get(1).getStringValue());
assertEquals("c1b", rows.get(2).get(2).getStringValue());
assertEquals("c2default", rows.get(2).get(3).getStringValue());
assertEquals("c3a", rows.get(2).get(4).getStringValue());
assertEquals("", rows.get(3).get(0).getStringValue());
assertEquals("", rows.get(3).get(1).getStringValue());
assertEquals("c1b", rows.get(3).get(2).getStringValue());
assertEquals("c2default", rows.get(3).get(3).getStringValue());
assertEquals("c3b", rows.get(3).get(4).getStringValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenterTest method setup.
@Before
public void setup() {
super.setup();
// Adding rows affects the HashCode so store the original
originalHashCode = model.hashCode();
dtPresenter.onAppendRow();
dtPresenter.onAppendRow();
dtPresenter.onAppendRow();
model1 = new GuidedDecisionTable52();
model2 = new GuidedDecisionTable52();
model3 = new GuidedDecisionTable52();
uiModel1Columns = mock(List.class);
uiModel2Columns = mock(List.class);
uiModel3Columns = mock(List.class);
uiModel1MockColumn = mock(GridColumn.class);
uiModel2MockColumn = mock(GridColumn.class);
uiModel3MockColumn = mock(GridColumn.class);
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter_AuditLogTest method setupPresenter.
private void setupPresenter() {
dtPresenter = new GuidedDecisionTablePresenter(identity, null, null, null, null, null, refreshAttributesPanelEvent, refreshMetaDataPanelEvent, refreshConditionsPanelEvent, refreshActionsPanelEvent, refreshMenusEvent, null, null, gridWidgetColumnFactory, oracleFactory, synchronizer, beanManager, lockManager, null, null, decisionTableAnalyzerProvider, enumLoaderUtilities, pluginHandler, authorizationManager, sessionInfo) {
@Override
void initialiseLockManager() {
// Do nothing for tests
}
@Override
GuidedDecisionTableView makeView(final Set<PortableWorkDefinition> workItemDefinitions) {
return view;
}
@Override
void initialiseModels() {
// Do nothing for tests
}
};
final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
final PackageDataModelOracleBaselinePayload dmoBaseline = mock(PackageDataModelOracleBaselinePayload.class);
final Set<PortableWorkDefinition> workItemDefinitions = Collections.emptySet();
final Overview overview = mock(Overview.class);
dtContent = new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dmoBaseline);
when(oracleFactory.makeAsyncPackageDataModelOracle(any(Path.class), any(GuidedDecisionTable52.class), eq(dmoBaseline))).thenReturn(dmo);
dtPresenter.setContent(null, mock(PlaceRequest.class), dtContent, modellerPresenter, false);
when(view.getLayer()).thenReturn(mock(Layer.class));
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTableViewImplTest method setup.
@Before
public void setup() {
when(renderer.getTheme()).thenReturn(theme);
when(theme.getBodyGridLine()).thenReturn(border);
when(theme.getHeaderText()).thenReturn(caption);
when(theme.getBaseRectangle(any(GuidedDecisionTableTheme.ModelColumnType.class))).thenReturn(rectangle);
GwtMockito.useProviderForType(Group.class, clazz -> container);
this.uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
this.model = new GuidedDecisionTable52();
this.view = new TestGuidedDecisionTableViewImpl(uiModel, renderer, presenter, model, notificationEvent) {
};
this.allColumns = Arrays.asList(uiRowNumberColumn, uiDescriptionColumn, uiColumn1, uiColumn2);
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class ConditionColumnPlugin method makeBRLRuleModel.
BRLRuleModel makeBRLRuleModel() {
final GuidedDecisionTable52 model = getPresenter().getModel();
final BRLRuleModel brlRuleModel = new BRLRuleModel(model);
final FactPattern pat = patternWrapper().makeFactPattern();
brlRuleModel.addLhsItem(pat);
return brlRuleModel;
}
Aggregations