Skip to content

Commit eb697e7

Browse files
author
Senthil Nathan
committed
Changes done for v1.0.9.
1 parent 3a6d0ae commit eb697e7

File tree

6 files changed

+388
-70
lines changed

6 files changed

+388
-70
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.0.9
4+
* June/01/2021
5+
* Added two new operational verbs: in and inCI.
6+
37
## v1.0.8
48
* May/23/2021
59
* Added more commentary and fixed a few typos.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ This toolkit came into existence for a specific need with which a large enterpri
113113

114114
2. This new eval_predicate function allows the user defined rule expression to access nested tuple attributes.
115115

116-
3. This new eval_predicate function allows the user defined rule expression to have operation verbs such as contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE.
116+
3. This new eval_predicate function allows the user defined rule expression to have operation verbs such as contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE.
117117

118118
4. This new eval_predicate function supports the following operations inside the rule.
119119

@@ -123,7 +123,7 @@ This toolkit came into existence for a specific need with which a large enterpri
123123

124124
c. It supports these arithmetic operations: +, -, *, /, %
125125

126-
d. It supports these special operations for rstring, set, list and map: contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
126+
d. It supports these special operations for rstring, set, list and map: contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
127127

128128
e. No bitwise operations are supported at this time.
129129

com.ibm.streamsx.eval_predicate/EvalPredicateExample.spl

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
==================================================================
1010
First created on: Mar/05/2021
11-
Last modified on: Apr/25/2021
11+
Last modified on: June/01/2021
1212

1313
This is an example application that shows how to use the
1414
eval_predicate function to evaluate an SPL expression a.k.a
@@ -35,23 +35,23 @@ given expression (rule) to access nested tuple attributes.
3535

3636
3) This new eval_predicate function allows the user
3737
given expression (rule) to have operational verbs such as
38-
contains, startsWith, endsWith, notContains, notStartsWith,
39-
notEndsWith. For case insensitive (CI) string operations, these
40-
operational verbs can be used: containsCI, startsWithCI,
41-
endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI
38+
contains, startsWith, endsWith, notContains, notStartsWith,
39+
notEndsWith, in. For case insensitive (CI) string operations, these
40+
operational verbs can be used: containsCI, startsWithCI,
41+
endsWithCI, notContainsCI, notStartsWithCI, notEndsWithCI, inCI
4242
For checking the size of the set, list and map, these
43-
operational verbs can be used: sizeEQ, sizeNE, sizeLT,
43+
operational verbs can be used: sizeEQ, sizeNE, sizeLT,
4444
sizeLE, sizeGT, sizeGE
4545

4646
4) This new eval_predicate function supports the following operations.
4747
--> It supports these relational operations: ==, !=, <, <=, >, >=
4848
--> It supports these logical operations: ||, &&
4949
--> It supports these arithmetic operations: +, -, *, /, %
5050
--> It supports these special operations for rstring, set, list and map:
51-
contains, startsWith, endsWith, notContains, notStartsWith,
52-
notEndsWith, containsCI, startsWithCI, endsWithCI, notContainsCI,
53-
notStartsWithCI, notEndsWithCI, sizeEQ, sizeNE, sizeLT, sizeLE,
54-
sizeGT, sizeGE
51+
contains, startsWith, endsWith, notContains, notStartsWith,
52+
notEndsWith, in, containsCI, startsWithCI, endsWithCI, notContainsCI,
53+
notStartsWithCI, notEndsWithCI, inCI, sizeEQ, sizeNE, sizeLT,
54+
sizeLE, sizeGT, sizeGE
5555
--> No bitwise operations are supported at this time.
5656

5757
5) Following are the data types currently allowed in an expression (rule).
@@ -857,6 +857,42 @@ composite EvalPredicateExample {
857857
} else {
858858
printStringLn("Testcase 4.4: Tuple attribute value was not fetched successfully. Error=" + (rstring)error);
859859
}
860+
861+
// ============== TESTCASE GROUP 5 ==============
862+
type Role_t = rstring role, int32 x, float64 y;
863+
mutable Role_t myRole = {};
864+
myRole.role = "Admin";
865+
866+
//
867+
// 5.1
868+
// Usage of in
869+
// It does case sensitive membership test using a list literal string.
870+
rule = 'role in ["Developer", "Tester", "Admin", "Manager"]';
871+
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);
872+
873+
if(result == true) {
874+
printStringLn("Testcase 5.1: Evaluation criteria is met.");
875+
} else if(result == false && error == 0) {
876+
printStringLn("Testcase 5.1: Evaluation criteria is not met.");
877+
} else {
878+
printStringLn("Testcase 5.1: Evaluation execution failed. Error=" + (rstring)error);
879+
}
880+
881+
//
882+
// 5.2
883+
// Usage of inCI
884+
// It does case insensitive membership test using a list literal string.
885+
myRole.role = "mAnAgEr";
886+
rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';
887+
result = eval_predicate(rule, myRole, error, $EVAL_PREDICATE_TRACING);
888+
889+
if(result == true) {
890+
printStringLn("Testcase 5.2: Evaluation criteria is met.");
891+
} else if(result == false && error == 0) {
892+
printStringLn("Testcase 5.2: Evaluation criteria is not met.");
893+
} else {
894+
printStringLn("Testcase 5.2: Evaluation execution failed. Error=" + (rstring)error);
895+
}
860896
} // End of onTuple S
861897
} // End of the Custom operator.
862898
} // End of the main composite.

com.ibm.streamsx.eval_predicate/FunctionalTests.spl

Lines changed: 88 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: Apr/25/2021
11+
Last modified on: June/01/2021
1212

1313
This application is meant for doing several hundred
1414
functional tests to provide as much coverage as possible to
@@ -6767,6 +6767,39 @@ composite FunctionalTests {
67676767
printStringLn("Testcase A53.2: Evaluation execution failed. Error=" + (rstring)error);
67686768
}
67696769
// -------------------------
6770+
6771+
// A54.1 (Use of in for membership test.)
6772+
// It does case sensitive membership test using a list literal string.
6773+
type Role_t = rstring role, int32 x, float64 y;
6774+
mutable Role_t myRole = {};
6775+
myRole.role = "Admin";
6776+
6777+
_rule = 'role in ["Developer", "Tester", "Admin", "Manager"]';
6778+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6779+
6780+
if(result == true) {
6781+
printStringLn("Testcase A54.1: Evaluation criteria is met.");
6782+
} else if(result == false && error == 0) {
6783+
printStringLn("Testcase A54.1: Evaluation criteria is not met.");
6784+
} else {
6785+
printStringLn("Testcase A54.1: Evaluation execution failed. Error=" + (rstring)error);
6786+
}
6787+
6788+
// A54.2 (Use of inCI for membership test.)
6789+
// It does case insensitive membership test using a list literal string.
6790+
myRole.role = "mAnAgEr";
6791+
_rule = 'role inCI ["Developer", "Tester", "Admin", "Manager"]';
6792+
6793+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
6794+
6795+
if(result == true) {
6796+
printStringLn("Testcase A54.2: Evaluation criteria is met.");
6797+
} else if(result == false && error == 0) {
6798+
printStringLn("Testcase A54.2: Evaluation criteria is not met.");
6799+
} else {
6800+
printStringLn("Testcase A54.2: Evaluation execution failed. Error=" + (rstring)error);
6801+
}
6802+
// -------------------------
67706803
} // End of onTuple MTD.
67716804
} // End of the HappyPathSink operator.
67726805

@@ -7955,6 +7988,7 @@ composite FunctionalTests {
79557988
} else {
79567989
printStringLn("Testcase B80.1: Evaluation execution failed. Error=" + (rstring)error);
79577990
}
7991+
// -------------------------
79587992

79597993
// B81.1 (SPACE_NOT_FOUND_AFTER_SPECIAL_OPERATION_VERB 122)
79607994
// Possible choices: sizeEQ, sizeNE, sizeLT, sizeLE, sizeGT, sizeGE
@@ -8072,6 +8106,59 @@ composite FunctionalTests {
80728106
printStringLn("Testcase B81.9: Evaluation execution failed. Error=" + (rstring)error);
80738107
}
80748108
// -------------------------
8109+
8110+
// B82.1 (INCOMPATIBLE_IN_OPERATION_FOR_LHS_ATTRIB_TYPE 146)
8111+
type Role2_t = rstring role, int32 x, float64 y;
8112+
mutable Role2_t myRole = {};
8113+
myRole.role = "Tester";
8114+
_rule = 'x in ["Developer", "Tester", "Admin", "Manager"]';
8115+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
8116+
8117+
if(result == true) {
8118+
printStringLn("Testcase B82.1: Evaluation criteria is met.");
8119+
} else if(result == false && error == 0) {
8120+
printStringLn("Testcase B82.1: Evaluation criteria is not met.");
8121+
} else {
8122+
printStringLn("Testcase B82.1: Evaluation execution failed. Error=" + (rstring)error);
8123+
}
8124+
8125+
// B82.2 (INCOMPATIBLE_IN_CI_OPERATION_FOR_LHS_ATTRIB_TYPE 147)
8126+
_rule = 'x inCI ["Developer", "Tester", "Admin", "Manager"]';
8127+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
8128+
8129+
if(result == true) {
8130+
printStringLn("Testcase B82.2: Evaluation criteria is met.");
8131+
} else if(result == false && error == 0) {
8132+
printStringLn("Testcase B82.2: Evaluation criteria is not met.");
8133+
} else {
8134+
printStringLn("Testcase B82.2: Evaluation execution failed. Error=" + (rstring)error);
8135+
}
8136+
8137+
// B82.3 (RHS_VALUE_WITH_MISSING_OPEN_BRACKET_NO_MATCH_FOR_IN_OR_IN_CI_OPVERB 149)
8138+
_rule = 'role in "Developer", "Tester", "Admin", "Manager"';
8139+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
8140+
8141+
if(result == true) {
8142+
printStringLn("Testcase B82.3: Evaluation criteria is met.");
8143+
} else if(result == false && error == 0) {
8144+
printStringLn("Testcase B82.3: Evaluation criteria is not met.");
8145+
} else {
8146+
printStringLn("Testcase B82.3: Evaluation execution failed. Error=" + (rstring)error);
8147+
}
8148+
8149+
// B82.4 (INVALID_RHS_LIST_LITERAL_STRING_FOUND_FOR_IN_OR_IN_CI_OPVERB 151)
8150+
// It has a missing double quote for a list literal string member.
8151+
_rule = 'role in ["Developer", "Tester", "Admin", "Manager]';
8152+
result = eval_predicate(_rule, myRole, error, $EVAL_PREDICATE_TRACING);
8153+
8154+
if(result == true) {
8155+
printStringLn("Testcase B82.4: Evaluation criteria is met.");
8156+
} else if(result == false && error == 0) {
8157+
printStringLn("Testcase B82.4: Evaluation criteria is not met.");
8158+
} else {
8159+
printStringLn("Testcase B82.4: Evaluation execution failed. Error=" + (rstring)error);
8160+
}
8161+
// -------------------------
80758162
} // End of onTuple MTD.
80768163
} // End of the UnhappyPathSink operator.
80778164

0 commit comments

Comments
 (0)