Search in sources :

Example 1 with ObjectType

use of org.drools.verifier.core.index.model.ObjectType in project drools-wb by kiegroup.

the class PatternResolver method resolveObjectType.

private ObjectType resolveObjectType(final String factType) {
    final ObjectType first = index.getObjectTypes().where(ObjectType.type().is(factType)).select().first();
    if (first == null) {
        final ObjectType objectType = new ObjectType(factType, configuration);
        index.getObjectTypes().add(objectType);
        return objectType;
    } else {
        return first;
    }
}
Also used : ObjectType(org.drools.verifier.core.index.model.ObjectType)

Example 2 with ObjectType

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

the class QueryableIndexTest method makeSureFirstAndLastObjectTypesAreTheSame.

@Test
public void makeSureFirstAndLastObjectTypesAreTheSame() throws Exception {
    queryableIndex.getObjectTypes().where(ObjectType.type().is("Person")).select().first(objectTypeQueryCallback);
    verify(objectTypeQueryCallback).callback(objectTypeArgumentCaptor.capture());
    final ObjectType first = objectTypeArgumentCaptor.getValue();
    reset(objectTypeQueryCallback);
    queryableIndex.getObjectTypes().where(ObjectType.type().is("Person")).select().last(objectTypeQueryCallback);
    verify(objectTypeQueryCallback).callback(objectTypeArgumentCaptor.capture());
    final ObjectType last = objectTypeArgumentCaptor.getValue();
    assertEquals("Person", first.getType());
    assertEquals(first, last);
}
Also used : ObjectType(org.drools.verifier.core.index.model.ObjectType) Test(org.junit.Test)

Example 3 with ObjectType

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

the class PatternInspectorTest method testSubsumpt02.

@Test
public void testSubsumpt02() throws Exception {
    final PatternInspector x = new PatternInspector(new Pattern("x", new ObjectType("org.Address", configurationMock), configurationMock), mock(RuleInspectorUpdater.class), mock(AnalyzerConfiguration.class));
    assertFalse(x.subsumes(b));
    assertFalse(b.subsumes(x));
}
Also used : Pattern(org.drools.verifier.core.index.model.Pattern) ObjectType(org.drools.verifier.core.index.model.ObjectType) AnalyzerConfiguration(org.drools.verifier.core.configuration.AnalyzerConfiguration) Test(org.junit.Test)

Example 4 with ObjectType

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

the class PatternInspectorTest method testRedundancy02.

@Test
public void testRedundancy02() throws Exception {
    final PatternInspector x = new PatternInspector(new Pattern("x", new ObjectType("org.Address", configurationMock), configurationMock), mock(RuleInspectorUpdater.class), mock(AnalyzerConfiguration.class));
    assertFalse(x.isRedundant(b));
    assertFalse(b.isRedundant(x));
}
Also used : Pattern(org.drools.verifier.core.index.model.Pattern) ObjectType(org.drools.verifier.core.index.model.ObjectType) AnalyzerConfiguration(org.drools.verifier.core.configuration.AnalyzerConfiguration) Test(org.junit.Test)

Example 5 with ObjectType

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

the class PatternInspectorTest method setUp.

@Before
public void setUp() throws Exception {
    configurationMock = new AnalyzerConfigurationMock();
    a = new PatternInspector(new Pattern("a", new ObjectType("org.Person", configurationMock), configurationMock), mock(RuleInspectorUpdater.class), mock(AnalyzerConfiguration.class));
    b = new PatternInspector(new Pattern("b", new ObjectType("org.Person", configurationMock), configurationMock), mock(RuleInspectorUpdater.class), mock(AnalyzerConfiguration.class));
}
Also used : Pattern(org.drools.verifier.core.index.model.Pattern) ObjectType(org.drools.verifier.core.index.model.ObjectType) AnalyzerConfigurationMock(org.drools.verifier.core.AnalyzerConfigurationMock) Before(org.junit.Before)

Aggregations

ObjectType (org.drools.verifier.core.index.model.ObjectType)6 Pattern (org.drools.verifier.core.index.model.Pattern)3 Test (org.junit.Test)3 AnalyzerConfigurationMock (org.drools.verifier.core.AnalyzerConfigurationMock)2 AnalyzerConfiguration (org.drools.verifier.core.configuration.AnalyzerConfiguration)2 Before (org.junit.Before)2 Column (org.drools.verifier.core.index.model.Column)1 Columns (org.drools.verifier.core.index.model.Columns)1 ObjectTypes (org.drools.verifier.core.index.model.ObjectTypes)1 Rule (org.drools.verifier.core.index.model.Rule)1 Rules (org.drools.verifier.core.index.model.Rules)1