Skip to content

Commit

Permalink
beta index test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Oct 7, 2024
1 parent 65dc9fe commit f0a727e
Showing 1 changed file with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public void alphaIndex() {
RulesExecutor rulesExecutor = RulesExecutorFactory.createFromJson(JSON_ALPHA_INDEX);

// incoming event.mera.headers is a map, not a string
List<Match> matchedRules = rulesExecutor.processEvents("{ \"meta\": {\"headers\": {\"Content-Length\": \"36\"}} } }").join();
List<Match> matchedRules = rulesExecutor.processEvents("{ \"meta\": {\"headers\": {\"Content-Length\": \"36\" } } }").join();
// When alpha index is effective (= more than 3 Equals for the same property with literal values), constraint is not evaluated, so no error log. Just don't match.
assertNumberOfErrorLogs(0);
assertEquals(0, matchedRules.size());
Expand All @@ -438,18 +438,28 @@ public void alphaIndex() {
"Rule": {
"name": "r1",
"condition": {
"AllCondition": [
{
"EqualsExpression": {
"lhs": {
"Event": "meta.headers"
},
"rhs": {
"Event": "mydata"
}
}
}
]
"AllCondition": [
{
"EqualsExpression": {
"lhs": {
"Event": "mydata"
},
"rhs": {
"String": "AAA"
}
}
},
{
"EqualsExpression": {
"lhs": {
"Event": "meta.headers"
},
"rhs": {
"Events": "m_0.mydata"
}
}
}
]
},
"actions": [
{
Expand All @@ -471,7 +481,9 @@ public void betaIndex() {
RulesExecutor rulesExecutor = RulesExecutorFactory.createFromJson(JSON_BETA_INDEX);

// incoming event.mera.headers is a map, not a string
List<Match> matchedRules = rulesExecutor.processEvents("{ \"meta\": {\"headers\": {\"Content-Length\": \"36\"}} }, \"mydata\": \"AAA\" }").join();
rulesExecutor.processEvents("{ \"mydata\": \"AAA\" }").join();
List<Match> matchedRules = rulesExecutor.processEvents("{ \"meta\": {\"headers\": {\"Content-Length\": \"36\" } } }").join();

// When beta index is effective (= comparing 2 event properties with Equals), constraint is not evaluated, so no error log. Just doesn't match.
assertNumberOfErrorLogs(0);
assertEquals(0, matchedRules.size());
Expand Down

0 comments on commit f0a727e

Please sign in to comment.