Search in sources :

Example 1 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools 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));
}
Also used : ObjectField(org.drools.verifier.core.index.model.ObjectField) Field(org.drools.verifier.core.index.model.Field) FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ConditionsInspectorMultiMap(org.drools.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap) Column(org.drools.verifier.core.index.model.Column) ObjectField(org.drools.verifier.core.index.model.ObjectField) Test(org.junit.Test)

Example 2 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools 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));
}
Also used : FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ConditionsInspectorMultiMap(org.drools.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap) Column(org.drools.verifier.core.index.model.Column) Test(org.junit.Test)

Example 3 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools 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;
}
Also used : Condition(org.drools.verifier.core.index.model.Condition) FieldCondition(org.drools.verifier.core.index.model.FieldCondition) FieldCondition(org.drools.verifier.core.index.model.FieldCondition) Column(org.drools.verifier.core.index.model.Column) Values(org.drools.verifier.core.index.keys.Values) ArrayList(java.util.ArrayList) Conditions(org.drools.verifier.core.index.model.Conditions)

Example 4 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools 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));
}
Also used : FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ObjectField(org.drools.verifier.core.index.model.ObjectField) Field(org.drools.verifier.core.index.model.Field) ConditionsInspectorMultiMap(org.drools.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap) Column(org.drools.verifier.core.index.model.Column) Test(org.junit.Test)

Example 5 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools by kiegroup.

the class ConditionsListenerTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final Condition condition = new FieldCondition(new Field(mock(ObjectField.class), "Person", "String", "name", configuration), new Column(1, configuration), "==", new Values<>(10), configuration);
    conditions.add(condition);
    reset(allListener);
    condition.setValue(new Values<>(20));
    verify(allListener).onAllChanged(anyCollection());
}
Also used : Condition(org.drools.verifier.core.index.model.Condition) FieldCondition(org.drools.verifier.core.index.model.FieldCondition) FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ObjectField(org.drools.verifier.core.index.model.ObjectField) Field(org.drools.verifier.core.index.model.Field) Column(org.drools.verifier.core.index.model.Column) Test(org.junit.Test)

Aggregations

FieldCondition (org.drools.verifier.core.index.model.FieldCondition)7 Column (org.drools.verifier.core.index.model.Column)6 Test (org.junit.Test)5 Field (org.drools.verifier.core.index.model.Field)4 ObjectField (org.drools.verifier.core.index.model.ObjectField)4 ConditionsInspectorMultiMap (org.drools.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap)3 Values (org.drools.verifier.core.index.keys.Values)3 Condition (org.drools.verifier.core.index.model.Condition)2 ArrayList (java.util.ArrayList)1 Conditions (org.drools.verifier.core.index.model.Conditions)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1