use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.
the class OperatorsBaseTest method setUp.
@Before
public void setUp() throws Exception {
ApplicationPreferences.setUp(new HashMap() {
{
put(ApplicationPreferences.DATE_FORMAT, "dd/MM/YYYY");
}
});
serviceCaller = new CallerMock<>(service);
oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, null);
final ModelField[] modelFields = new ModelField[] { modelField("street", DataType.TYPE_STRING), modelField("number", DataType.TYPE_NUMERIC_INTEGER) };
Map<String, ModelField[]> fields = new HashMap<>();
fields.put("org.Address", modelFields);
oracle.addModelFields(fields);
connectives = spy(new Connectives(modeller, eventBus, pattern, false));
doReturn(oracle).when(connectives).getDataModelOracle();
doReturn(oracle).when(modeller).getDataModelOracle();
doReturn(Stream.of(connectiveConstraint).toArray(ConnectiveConstraint[]::new)).when(singleFieldConstraint).getConnectives();
}
use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.
the class ConstraintValueEditorHelperTest method testEvents_BothTypesAreEvents.
@Test
public void testEvents_BothTypesAreEvents() 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", true);
}
});
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) {
assertTrue(result);
}
});
}
use of org.kie.soup.project.datamodel.oracle.ModelField 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.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.
the class ModelFieldUtilTest method filtering.
@Test
public void filtering() {
when(field1.getName()).thenReturn("field1");
when(field2.getName()).thenReturn("field2");
final ActionFieldList afl = new ActionInsertFact();
final ActionFieldValue afv = new ActionFieldValue();
afv.setField("field1");
afl.addFieldValue(afv);
final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[] { field1, field2 }, afl);
assertEquals(1, result.length);
assertEquals(field2, result[0]);
}
use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.
the class ModelFieldUtilTest method emptyActionFieldList.
@Test
public void emptyActionFieldList() {
final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[] { field1 }, new ActionInsertFact());
assertEquals(1, result.length);
assertEquals(field1, result[0]);
}
Aggregations