use of org.drools.workbench.services.verifier.api.client.index.FieldCondition in project drools-wb by kiegroup.
the class RuleInspector method isDeficient.
@Override
public boolean isDeficient(final RuleInspector other) {
if (other.atLeastOneActionHasAValue() && !getActionsInspectors().conflicts(other.getActionsInspectors())) {
return false;
}
final Collection<Condition> allConditionsFromTheOtherRule = other.rule.getConditions().where(Condition.value().any()).select().all();
if (allConditionsFromTheOtherRule.isEmpty()) {
return true;
} else {
for (final Condition condition : allConditionsFromTheOtherRule) {
if (condition.getValues() == null) {
continue;
}
if (condition instanceof FieldCondition) {
final FieldCondition fieldCondition = (FieldCondition) condition;
final Conditions conditions = rule.getPatterns().where(Pattern.name().is(fieldCondition.getField().getFactType())).select().fields().where(Field.name().is(fieldCondition.getField().getName())).select().conditions();
if (conditions.where(Condition.value().any()).select().exists()) {
return false;
}
}
}
return true;
}
}
use of org.drools.workbench.services.verifier.api.client.index.FieldCondition in project drools-wb by kiegroup.
the class ConditionsInspectorTest method testSubsume001.
@Test
public void testSubsume001() throws Exception {
final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock));
final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock));
assertTrue(a.subsumes(b));
assertTrue(b.subsumes(a));
}
use of org.drools.workbench.services.verifier.api.client.index.FieldCondition in project drools-wb by kiegroup.
the class ConditionsInspectorTest method testSubsume003.
@Test
public void testSubsume003() throws Exception {
final Field nameField = new Field(new ObjectField("Person", "String", "name", configurationMock), "Person", "String", "name", configurationMock);
final Field lastNameField = new Field(new ObjectField("Person", "String", "lastName", configurationMock), "Person", "String", "lastName", configurationMock);
final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock));
final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(12), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(lastNameField, mock(Column.class), "==", new Values<>("Rikkola"), configurationMock), configurationMock));
assertFalse(a.subsumes(b));
assertTrue(b.subsumes(a));
}
use of org.drools.workbench.services.verifier.api.client.index.FieldCondition in project drools-wb by kiegroup.
the class ConditionsInspectorTest method testSubsume002.
@Test
public void testSubsume002() throws Exception {
final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock));
final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock), new ComparableConditionInspector<Integer>(new FieldCondition(new Field(mock(ObjectField.class), "Person", "Integer", "balance", configurationMock), mock(Column.class), "==", new Values<>(111111111), configurationMock), configurationMock));
assertFalse(a.subsumes(b));
assertTrue(b.subsumes(a));
}
use of org.drools.workbench.services.verifier.api.client.index.FieldCondition in project drools-wb by kiegroup.
the class FieldInspectorUpdateTest method makeCondition.
private FieldCondition makeCondition(final Field field) {
final FieldCondition fieldAction = new FieldCondition(field, mock(Column.class), "==", new Values(11), configurationMock);
final ArrayList<Condition> actionsList = new ArrayList<>();
actionsList.add(fieldAction);
final Conditions conditions = new Conditions(actionsList);
when(field.getConditions()).thenReturn(conditions);
return fieldAction;
}
Aggregations