Search in sources :

Example 36 with TypeDeclaration

use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.

the class CepEspTest method testEventExpiration.

@Test(timeout = 10000)
public void testEventExpiration() throws Exception {
    KieBase kbase = loadKnowledgeBase("test_CEP_EventExpiration.drl");
    // read in the source
    TypeDeclaration factType = ((KnowledgeBaseImpl) kbase).getTypeDeclaration(StockTick.class);
    assertEquals(TimeIntervalParser.parse("1h30m")[0], factType.getExpirationOffset());
}
Also used : KieBase(org.kie.api.KieBase) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Test(org.junit.Test)

Example 37 with TypeDeclaration

use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.

the class TypeDeclarationMergingTest method testOverrideFromDeeperParentInterface.

@Test
public void testOverrideFromDeeperParentInterface() {
    // inherits role but not typesafe
    String str = "" + "package org.drools.compiler.test \n" + "global java.util.List list \n" + "declare " + IA.class.getCanonicalName() + "\n" + "    @typesafe(true)\n" + "    @role(event)\n" + "end\n" + "declare " + DImpl.class.getCanonicalName() + "\n" + "    @typesafe(false)\n" + "end\n";
    KnowledgeBuilderImpl builder = getPackageBuilder(str);
    TypeDeclaration tdecl = builder.getTypeDeclaration(DImpl.class);
    assertEquals(false, tdecl.isTypesafe());
    assertEquals(Role.Type.EVENT, tdecl.getRole());
}
Also used : KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Test(org.junit.Test)

Example 38 with TypeDeclaration

use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.

the class TypeDeclarationMergingTest method testInheritNoneExitenceFromParentInterface.

@Test
public void testInheritNoneExitenceFromParentInterface() {
    // inherits role and typesafe
    String str = "" + "package org.drools.compiler.test \n" + "global java.util.List list \n" + "declare " + IB.class.getCanonicalName() + "\n" + "    @typesafe(true)\n" + "    @role(event)\n" + "end\n";
    KnowledgeBuilderImpl builder = getPackageBuilder(str);
    TypeDeclaration tdecl = builder.getTypeDeclaration(DImpl.class);
    assertEquals(true, tdecl.isTypesafe());
    assertEquals(Role.Type.EVENT, tdecl.getRole());
}
Also used : KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Test(org.junit.Test)

Example 39 with TypeDeclaration

use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.

the class TypeDeclarationMergingTest method testInheritNoneExitenceFromParentClass.

@Test
public void testInheritNoneExitenceFromParentClass() {
    // inherits role and typesafe
    String str = "" + "package org.drools.compiler.test \n" + "global java.util.List list \n" + "declare " + CImpl.class.getCanonicalName() + "\n" + "    @typesafe(true)\n" + "    @role(event)\n" + "end\n";
    KnowledgeBuilderImpl builder = getPackageBuilder(str);
    TypeDeclaration tdecl = builder.getTypeDeclaration(DImpl.class);
    assertEquals(true, tdecl.isTypesafe());
    assertEquals(Role.Type.EVENT, tdecl.getRole());
}
Also used : KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Test(org.junit.Test)

Example 40 with TypeDeclaration

use of org.drools.core.rule.TypeDeclaration in project drools by kiegroup.

the class TypeDeclarationMergingTest method testInheritExitenceFromParentInterface.

@Test
public void testInheritExitenceFromParentInterface() {
    // inherits role and typesafe
    String str = "" + "package org.drools.compiler.test \n" + "global java.util.List list \n" + "declare " + IB.class.getCanonicalName() + "\n" + "    @typesafe(true)\n" + "    @role(event)\n" + "end\n" + "declare " + DImpl.class.getCanonicalName() + "\n" + "end\n";
    KnowledgeBuilderImpl builder = getPackageBuilder(str);
    TypeDeclaration tdecl = builder.getTypeDeclaration(DImpl.class);
    assertEquals(true, tdecl.isTypesafe());
    assertEquals(Role.Type.EVENT, tdecl.getRole());
}
Also used : KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Test(org.junit.Test)

Aggregations

TypeDeclaration (org.drools.core.rule.TypeDeclaration)72 Test (org.junit.Test)15 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)12 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)11 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)10 ClassDefinition (org.drools.core.factmodel.ClassDefinition)9 ClassObjectType (org.drools.core.base.ClassObjectType)7 TypeDeclarationDescr (org.drools.compiler.lang.descr.TypeDeclarationDescr)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TypeDeclarationError (org.drools.compiler.compiler.TypeDeclarationError)4 AbstractClassTypeDeclarationDescr (org.drools.compiler.lang.descr.AbstractClassTypeDeclarationDescr)4 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)4 ObjectType (org.drools.core.spi.ObjectType)4 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 BindingDescr (org.drools.compiler.lang.descr.BindingDescr)3 TypeFieldDescr (org.drools.compiler.lang.descr.TypeFieldDescr)3 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)3