Skip to content

Commit dbd3755

Browse files
author
Senthil Nathan
committed
Changes done for v1.1.8.
1 parent 806c1d6 commit dbd3755

File tree

5 files changed

+195
-43
lines changed

5 files changed

+195
-43
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## v1.1.8
4+
* Oct/11/2023
5+
* Made a fix to correctly evaluate new multi-level nested expression patterns as shown in the test cases A51.22 to A51.24 in FunctionalTests.spl.
6+
37
## v1.1.7
48
* Sep/27/2023
59
* Made a fix to correctly evaluate a new multi-level nested expression pattern as shown in the test case A51.21 in FunctionalTests.spl.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ This toolkit came into existence for a specific need with which a large enterpri
281281
(a.transport.plane.airliner equalsCI 'bOeInG' && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari' || (testId equalsCI 'Happy Path' || a.rack.hw.vendor equalsCI 'Intel2'))) && ((testId equalsCI 'Happy Path' && a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.plane.airliner equalsCI 'bOeInG2' || testId equalsCI 'Happy Path') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG')) || (testId equalsCI 'Happy Path' && testId equalsCI 'Happy Path') || (testId equalsCI 'Happy Path7' && testId equalsCI 'Happy Path')) && (testId equalsCI 'Happy Path')
282282

283283
(a.transport.plane.airliner equalsCI 'bOeInG') && (a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && ((testId equalsCI 'Happy Path') && ((a.rack.hw.vendor equalsCI 'Intel') || ((a.transport.cars.autoMaker equalsCI 'Enzo Ferrari') && (a.transport.plane.airliner equalsCI 'bOeInG'))))
284+
285+
(Value.Status.Event equalsCI 'PATCHING') && ((Value.Status.UserName containsCI 'EWR') || (Value.Status.EntityState equalsCI 'ENGINEERING') || ((Value.Properties.OwnedBy containsCI 'FER') && ((Value.Status.Availability equalsCI 'Up') || ((Value.Status.Availability equalsCI 'Down') && (Value.Status.StatusCategory3 containsCI 'StatusCategory3'))))) && (Value.Status.StatusCategory4 equalsCI 'StatusCategory4')
284286

285287
## Source code
286288
The complete C++ logic for the **eval_predicate** function is available in the [eval_predicate.h](impl/include/eval_predicate.h) file of this repository.

com.ibm.streamsx.eval_predicate/FunctionalTests.spl

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/28/2021
11-
Last modified on: Sep/27/2023
11+
Last modified on: Oct/11/2023
1212

1313
This application is meant for doing several hundred
1414
functional tests to provide as much coverage as possible to
@@ -6961,6 +6961,97 @@ composite FunctionalTests {
69616961
} else {
69626962
printStringLn("Testcase A51.21: Evaluation execution failed. Error=" + (rstring)error);
69636963
}
6964+
6965+
// A51.22 (Nested expression pattern 22)
6966+
// The following is a rule used in a real-world use case at
6967+
// one of the best IBM Streams customers. It has the first and
6968+
// third subexpressions as self-enclosed. It then has the second
6969+
// subexpression with four levels of multi-level nested SEs.
6970+
// In that second SE, it evaluates certain conditions such that
6971+
// they will collectively contribute to returning a final false result.
6972+
//
6973+
// Tuple schema needed for this rule's data.
6974+
type NodeProperties_T = rstring ParentTool, rstring MES_CEID, rstring REV_CEID,
6975+
rstring EquipmentGroup, rstring FunctionalArea, rstring EntityType,
6976+
rstring Cluster, list<rstring> Processes, list<rstring> VirtualLines,
6977+
rstring OwnedBy, rstring Location, rstring CurrentSite, list<rstring> ToolGroups;
6978+
6979+
type NodeStatus_T = list<rstring> Lots, rstring Availability, rstring Comments,
6980+
rstring EntityState, rstring Event, rstring StatusCategory1,
6981+
rstring StatusCategory2, rstring StatusCategory3, rstring StatusCategory4,
6982+
map<rstring,rstring> AttributesMap, rstring StatusCategory5,
6983+
rstring StatusCategory6,rstring StatusCategory7, rstring StatusCategory8,
6984+
rstring StatusCategory9, rstring UserName;
6985+
6986+
type NodeV_T = NodeProperties_T Properties, NodeStatus_T Status,
6987+
timestamp PublishTime, rstring MWTimestamp;
6988+
6989+
type Node_T = rstring Key, NodeV_T Value;
6990+
6991+
// Variable declaration that uses the tuple schema defined above.
6992+
mutable Node_T myNode = (Node_T){};
6993+
myNode.Value.Status.Event = "PATCHING";
6994+
myNode.Value.Status.UserName = "";
6995+
myNode.Value.Status.EntityState = "";
6996+
myNode.Value.Properties.OwnedBy = 'SAD';
6997+
myNode.Value.Status.Availability = "Down";
6998+
myNode.Value.Status.StatusCategory2 = 'StatusCategory2';
6999+
myNode.Value.Status.StatusCategory3 = 'StatusCategory3';
7000+
myNode.Value.Status.StatusCategory4 = 'StatusCategory4';
7001+
7002+
_rule = "(Value.Status.Event equalsCI 'PATCHING') && ((Value.Status.UserName containsCI 'EWR') || (Value.Status.EntityState equalsCI 'ENGINEERING') || ((Value.Properties.OwnedBy containsCI 'FER') && ((Value.Status.Availability equalsCI 'Up') || ((Value.Status.Availability equalsCI 'Down') && (Value.Status.StatusCategory3 containsCI 'StatusCategory3'))))) && (Value.Status.StatusCategory4 equalsCI 'StatusCategory4')";
7003+
result = eval_predicate(_rule, myNode, error, $EVAL_PREDICATE_TRACING);
7004+
7005+
if(result == true) {
7006+
printStringLn("Testcase A51.22: Evaluation criteria is met.");
7007+
} else if(result == false && error == 0) {
7008+
printStringLn("Testcase A51.22: Evaluation criteria is not met.");
7009+
} else {
7010+
printStringLn("Testcase A51.22: Evaluation execution failed. Error=" + (rstring)error);
7011+
}
7012+
7013+
// A51.23 (Nested expression pattern 23)
7014+
// The following rule is same as the previous one except
7015+
// it checks with a slightly different tuple attribute
7016+
// values to meet all the evaluation conditions and
7017+
// then to return true.
7018+
//
7019+
// Set these two tuple attributes to specific values.
7020+
myNode.Value.Status.UserName = "EWR";
7021+
myNode.Value.Status.EntityState = "ENGINEERING";
7022+
7023+
_rule = "(Value.Status.Event equalsCI 'PATCHING') && ((Value.Status.UserName containsCI 'EWR') || (Value.Status.EntityState equalsCI 'ENGINEERING') || ((Value.Properties.OwnedBy containsCI 'SAD') && ((Value.Status.Availability equalsCI 'Up') || ((Value.Status.Availability equalsCI 'Down') && (Value.Status.StatusCategory3 containsCI 'StatusCategory3'))))) && (Value.Status.StatusCategory4 equalsCI 'StatusCategory4')";
7024+
result = eval_predicate(_rule, myNode, error, $EVAL_PREDICATE_TRACING);
7025+
7026+
if(result == true) {
7027+
printStringLn("Testcase A51.23: Evaluation criteria is met.");
7028+
} else if(result == false && error == 0) {
7029+
printStringLn("Testcase A51.23: Evaluation criteria is not met.");
7030+
} else {
7031+
printStringLn("Testcase A51.23: Evaluation execution failed. Error=" + (rstring)error);
7032+
}
7033+
7034+
// A51.24 (Nested expression pattern 24)
7035+
// The following rule is same as the previous one except
7036+
// it checks with a slightly different tuple attribute
7037+
// values to meet all the evaluation conditions and
7038+
// then to return true.
7039+
//
7040+
// Set these three tuple attributes to specific values.
7041+
myNode.Value.Status.EntityState = "SIGNALING";
7042+
myNode.Value.Properties.OwnedBy = 'D1D';
7043+
myNode.Value.Status.Availability = "Up";
7044+
7045+
_rule = "(Value.Status.EntityState equalsCI 'SIGNALING') && ((Value.Properties.OwnedBy notStartsWithCI 'D1D') || ((Value.Properties.OwnedBy startsWithCI 'D1D') && (Value.Status.Availability equalsCI 'Up')))";
7046+
result = eval_predicate(_rule, myNode, error, $EVAL_PREDICATE_TRACING);
7047+
7048+
if(result == true) {
7049+
printStringLn("Testcase A51.24: Evaluation criteria is met.");
7050+
} else if(result == false && error == 0) {
7051+
printStringLn("Testcase A51.24: Evaluation criteria is not met.");
7052+
} else {
7053+
printStringLn("Testcase A51.24: Evaluation execution failed. Error=" + (rstring)error);
7054+
}
69647055
// -------------------------
69657056

69667057
// A52.1 (list<TUPLE>)

0 commit comments

Comments
 (0)