Skip to content

Commit

Permalink
[incubator-kie-drools-5982] [new-parser] Enable alternative attribute…
Browse files Browse the repository at this point in the history
…s test (#5983)
  • Loading branch information
tkobayas authored Jun 7, 2024
1 parent 6d8f9d5 commit d03d1d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1964,9 +1964,8 @@ public void parse_Timer() throws Exception {
assertThat(at.getValue()).isEqualTo("true");
}

@Disabled("Priority : Low | Not written in docs nor other unit tests. Drop the support?")
@Test
public void parse_Attributes_alternateSyntax() throws Exception {
public void parse_Attributes_alternateSyntax() {
final RuleDescr rule = parseAndGetFirstRuleDescrFromFile(
"rule_attributes_alt.drl" );
assertThat(rule.getName()).isEqualTo("simple_rule");
Expand All @@ -1975,27 +1974,27 @@ public void parse_Attributes_alternateSyntax() throws Exception {
final Map<String, AttributeDescr> attrs = rule.getAttributes();
assertThat(attrs.size()).isEqualTo(6);

AttributeDescr at = (AttributeDescr) attrs.get( "salience" );
AttributeDescr at = attrs.get( "salience" );
assertThat(at.getName()).isEqualTo("salience");
assertThat(at.getValue()).isEqualTo("42");

at = (AttributeDescr) attrs.get( "agenda-group" );
at = attrs.get( "agenda-group" );
assertThat(at.getName()).isEqualTo("agenda-group");
assertThat(at.getValue()).isEqualTo("my_group");

at = (AttributeDescr) attrs.get( "no-loop" );
at = attrs.get( "no-loop" );
assertThat(at.getName()).isEqualTo("no-loop");
assertThat(at.getValue()).isEqualTo("true");

at = (AttributeDescr) attrs.get( "lock-on-active" );
at = attrs.get( "lock-on-active" );
assertThat(at.getName()).isEqualTo("lock-on-active");
assertThat(at.getValue()).isEqualTo("true");

at = (AttributeDescr) attrs.get( "duration" );
at = attrs.get( "duration" );
assertThat(at.getName()).isEqualTo("duration");
assertThat(at.getValue()).isEqualTo("42");

at = (AttributeDescr) attrs.get( "activation-group" );
at = attrs.get( "activation-group" );
assertThat(at.getName()).isEqualTo("activation-group");
assertThat(at.getValue()).isEqualTo("my_activation_group");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ drlKeywords returns [Token token]
| DRL_EVAL
| DRL_FORALL
| DRL_OVER
| DRL_ATTRIBUTES
| DRL_SALIENCE
| DRL_ENABLED
| DRL_NO_LOOP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ DRL_STARTED_BY : 'startedby';
DRL_WINDOW : 'window';

// attributes
DRL_ATTRIBUTES : 'attributes';
DRL_SALIENCE : 'salience';
DRL_ENABLED : 'enabled';
DRL_NO_LOOP : 'no-loop';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,14 @@ drlAnnotation
: {boolean buildState = buildDescr; buildDescr = true;} anno=fullAnnotation[null] {buildDescr = buildState;} // either standard Java annotation
| AT name=drlQualifiedName (LPAREN chunk RPAREN)? ; // or support @watch(!*, age) etc.

attributes : attribute ( COMMA? attribute )* ;
attribute : name=( 'salience' | 'enabled' ) conditionalAttributeValue #expressionAttribute
| name=( 'no-loop' | 'auto-focus' | 'lock-on-active' | 'refract' | 'direct' ) BOOL_LITERAL? #booleanAttribute
| name=( 'agenda-group' | 'activation-group' | 'ruleflow-group' | 'date-effective' | 'date-expires' | 'dialect' ) DRL_STRING_LITERAL #stringAttribute
| name='calendars' DRL_STRING_LITERAL ( COMMA DRL_STRING_LITERAL )* #stringListAttribute
| name='timer' ( DECIMAL_LITERAL | LPAREN chunk RPAREN ) #intOrChunkAttribute
| name='duration' ( DECIMAL_LITERAL | LPAREN chunk RPAREN ) #intOrChunkAttribute
// attributes := (ATTRIBUTES COLON?)? [ attribute ( COMMA? attribute )* ]
attributes : (DRL_ATTRIBUTES COLON?)? attribute ( COMMA? attribute )* ;
attribute : name=( DRL_SALIENCE | DRL_ENABLED ) conditionalAttributeValue #expressionAttribute
| name=( DRL_NO_LOOP | DRL_AUTO_FOCUS | DRL_LOCK_ON_ACTIVE | DRL_REFRACT | DRL_DIRECT ) BOOL_LITERAL? #booleanAttribute
| name=( DRL_AGENDA_GROUP | DRL_ACTIVATION_GROUP | DRL_RULEFLOW_GROUP | DRL_DATE_EFFECTIVE | DRL_DATE_EXPIRES | DRL_DIALECT ) DRL_STRING_LITERAL #stringAttribute
| name=DRL_CALENDARS DRL_STRING_LITERAL ( COMMA DRL_STRING_LITERAL )* #stringListAttribute
| name=DRL_TIMER ( DECIMAL_LITERAL | LPAREN chunk RPAREN ) #intOrChunkAttribute
| name=DRL_DURATION ( DECIMAL_LITERAL | LPAREN chunk RPAREN ) #intOrChunkAttribute
;

conditionalAttributeValue : ( LPAREN conditionalExpression RPAREN | conditionalExpression ) ;
Expand Down

0 comments on commit d03d1d8

Please sign in to comment.