Search in sources :

Example 26 with AnnotationDescr

use of org.drools.drl.ast.descr.AnnotationDescr in project drools by kiegroup.

the class RuleParserTest method testMultiValueAnnotationsBackwardCompatibility.

@Test
public void testMultiValueAnnotationsBackwardCompatibility() throws Exception {
    // multiple values with no keys are parsed as a single value
    final String text = "rule X @ann1( val1, val2 ) @ann2( \"val1\", \"val2\" ) when then end";
    RuleDescr rule = (RuleDescr) parse("rule", text);
    AnnotationDescr ann = rule.getAnnotation("ann1");
    assertNotNull(ann);
    assertEquals("val1, val2", ann.getValue());
    ann = rule.getAnnotation("ann2");
    assertNotNull(ann);
    assertEquals("\"val1\", \"val2\"", ann.getValue());
}
Also used : RuleDescr(org.drools.drl.ast.descr.RuleDescr) AnnotationDescr(org.drools.drl.ast.descr.AnnotationDescr) Test(org.junit.Test)

Aggregations

AnnotationDescr (org.drools.drl.ast.descr.AnnotationDescr)26 BaseDescr (org.drools.drl.ast.descr.BaseDescr)8 ConstraintConnectiveDescr (org.drools.drl.ast.descr.ConstraintConnectiveDescr)8 AnnotationDefinition (org.drools.core.factmodel.AnnotationDefinition)5 ArrayList (java.util.ArrayList)3 TypeDeclarationError (org.drools.compiler.compiler.TypeDeclarationError)3 TypeDeclarationDescr (org.drools.drl.ast.descr.TypeDeclarationDescr)3 TypeFieldDescr (org.drools.drl.ast.descr.TypeFieldDescr)3 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 AnnotationDeclarationError (org.drools.compiler.compiler.AnnotationDeclarationError)2 FieldDefinition (org.drools.core.factmodel.FieldDefinition)2 QualifiedName (org.drools.drl.ast.descr.QualifiedName)2 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)1 IOException (java.io.IOException)1 Annotation (java.lang.annotation.Annotation)1 Arrays (java.util.Arrays)1 BitSet (java.util.BitSet)1