use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl in project drools-wb by kiegroup.
the class ConstraintValueEditorHelperTest method testEvents_BoundTypeIsEvent.
@Test
public void testEvents_BoundTypeIsEvent() throws Exception {
AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, validatorInstance);
oracle.setPackageName("org.test");
oracle.addModelFields(new HashMap<String, ModelField[]>() {
{
put("org.test.Event1", new ModelField[] { modelField("this", "org.test.Event1") });
put("org.test.Event2", new ModelField[] { modelField("this", "org.test.Event2") });
}
});
oracle.addEventTypes(new HashMap<String, Boolean>() {
{
put("org.test.Event1", true);
put("org.test.Event2", false);
}
});
oracle.addSuperTypes(new HashMap<String, List<String>>() {
{
put("org.test.Event1", Collections.EMPTY_LIST);
put("org.test.Event2", Collections.EMPTY_LIST);
}
});
oracle.filter();
FactPattern pattern1 = new FactPattern();
pattern1.setFactType("Event1");
pattern1.setBoundName("$e");
SingleFieldConstraint constraint = new SingleFieldConstraint();
constraint.setFactType("Event1");
constraint.setFieldName("this");
constraint.setFieldType("Event1");
constraint.setOperator(OperatorsOracle.SIMPLE_CEP_OPERATORS[0]);
pattern1.addConstraint(constraint);
model.addLhsItem(pattern1);
ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "Event2", "this", constraint, "Event2", new DropDownData());
helper.isApplicableBindingsInScope("$e", new Callback<Boolean>() {
@Override
public void callback(Boolean result) {
assertFalse(result);
}
});
}
use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidgetTest method setUp.
@Before
public void setUp() throws Exception {
// listBox is used for verification fo added available fact types into UI
GwtMockito.useProviderForType(ListBox.class, aClass -> listBox);
// Mock partially the AsyncPackageDataModelOracle
validatorInstance = new MockInstanceImpl<>();
oracle = spy(new AsyncPackageDataModelOracleImpl(new CallerMock<>(incrementalDataModelService), validatorInstance));
// Mock partially the AsyncPackageDataModelOracleFactory and ensure oracle will contain data form payload below
doReturn(syncBeanDef).when(syncBeanManager).lookupBean(AsyncPackageDataModelOracle.class);
doReturn(oracle).when(syncBeanDef).getInstance();
doReturn(oracle).when(ruleModeller).getDataModelOracle();
// Prepare base payload that simulates two Facts in the package, Person and Car
dataModelPayload = new PackageDataModelOracleBaselinePayload();
dataModelPayload.setModelFields(new HashMap<String, ModelField[]>() {
{
final String fqnPerson = REDHAT_PACKAGE + "." + FACT_TYPE_PERSON;
final String fqnCar = REDHAT_PACKAGE + "." + FACT_TYPE_CAR;
final String fqnNumber = Number.class.getName();
put(fqnPerson, new ModelField[] { modelField(DataType.TYPE_THIS, fqnPerson) });
put(fqnCar, new ModelField[] { modelField(DataType.TYPE_THIS, fqnCar) });
put(fqnNumber, new ModelField[] { modelField(DataType.TYPE_THIS, fqnNumber) });
}
});
// Prevent NPE in FromAccumulateCompositeFactPatternWidget constructor
when(pattern.useFunctionOrCode()).thenReturn(FromAccumulateCompositeFactPattern.USE_FUNCTION);
fromAccumulateWidget = new FromAccumulateCompositeFactPatternWidget(ruleModeller, eventBus, pattern);
ruleModelWithImportedNumber = new RuleModel() {
{
setImports(new Imports() {
{
addImport(new Import(Number.class));
}
});
}
};
}
Aggregations