8
8
/*
9
9
==================================================================
10
10
First created on: Mar/28/2021
11
- Last modified on: Apr/11 /2021
11
+ Last modified on: Apr/15 /2021
12
12
13
13
This application is meant for doing several hundred
14
14
functional tests to provide as much coverage as possible to
@@ -67,7 +67,11 @@ composite FunctionalTests {
67
67
Ticker_t = rstring symbol, float32 price, uint32 quantity,
68
68
boolean buyOrSell, map<boolean, int32> myMap1;
69
69
70
- // 2) A made up arbitrary schema with multilevel types and
70
+ // 2) Another simple flat schema with no nesting.
71
+ Weather_t = rstring city, float64 humidity,
72
+ map<int64, float64> hourlyTemperatureMap, boolean sunnyDay;
73
+
74
+ // 3) A made up arbitrary schema with multilevel types and
71
75
// nesting that includes primitive and collection data types such as
72
76
// sets, lists and maps. Main idea here is to have tuple types that can
73
77
// include all the SPL typed attributes needed for testing the
@@ -115,10 +119,11 @@ composite FunctionalTests {
115
119
116
120
GroupC_t = tuple<FloatWorld_t fw> reals;
117
121
118
- TestData_t = rstring testId, GroupA_t a, GroupB_t b, GroupC_t c;
122
+ TestData_t = rstring testId, GroupA_t a,
123
+ GroupB_t b, GroupC_t c, list<Weather_t> weatherList;
119
124
120
125
graph
121
- // Kickstart this application with a dummy signal.
126
+ // Start this application with a dummy signal.
122
127
(stream<boolean dummy> Signal as S) as SignalGenerator = Beacon() {
123
128
param
124
129
iterations: 1;
@@ -142,6 +147,21 @@ composite FunctionalTests {
142
147
// Send this tuple out.
143
148
submit(myTicker, MT);
144
149
// -------------------------
150
+ mutable Weather_t myWeather = {};
151
+ myWeather.city = "New York";
152
+ myWeather.humidity = 12.87;
153
+ insertM(myWeather.hourlyTemperatureMap,
154
+ 333343l, 87.355);
155
+ insertM(myWeather.hourlyTemperatureMap,
156
+ 443536l, 84.31);
157
+ insertM(myWeather.hourlyTemperatureMap,
158
+ 592311l, 85.72);
159
+ insertM(myWeather.hourlyTemperatureMap,
160
+ 693127l, 86.128);
161
+ insertM(myWeather.hourlyTemperatureMap,
162
+ 729841l, 85.853);
163
+ myWeather.sunnyDay = true;
164
+ // -------------------------
145
165
// Create the comprehensive test data tuple now.
146
166
mutable TestData_t myTestData = {};
147
167
myTestData.testId = "Happy Path";
@@ -242,6 +262,8 @@ composite FunctionalTests {
242
262
myTestData.c.reals.fw.s =
243
263
{59.09 : 60.14, 61.28 : 62.37, 63.15 : 64.65};
244
264
// -------------------------
265
+ appendM(myTestData.weatherList, myWeather);
266
+ // -------------------------
245
267
// Send this tuple out.
246
268
submit(myTestData, MTD);
247
269
} // End of onTuple S.
@@ -6067,6 +6089,19 @@ composite FunctionalTests {
6067
6089
printStringLn("Testcase A51.6: Evaluation execution failed. Error=" + (rstring)error);
6068
6090
}
6069
6091
// -------------------------
6092
+
6093
+ // A52.1 (list<TUPLE>)
6094
+ _rule = "(((b.digital.sw.productNameToGuid['You Chat'] notStartsWith '4345-8fd3-72550428159e') || (weatherList[0].city contains 'York') || (weatherList[0].humidity <= 12.87) || (c.reals.fw.s[61.28] - 2.37 == 60.00)) && ((a.transport.cars.rpmRange contains 8700) && (b.digital.sw.productNameToRevenue['Streams'] == 945438131.84) && (weatherList[0].hourlyTemperatureMap[592311] != 89.16)) && weatherList[0].sunnyDay == true)";
6095
+ result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
6096
+
6097
+ if(result == true) {
6098
+ printStringLn("Testcase A52.1: Evaluation criteria is met.");
6099
+ } else if(result == false && error == 0) {
6100
+ printStringLn("Testcase A52.1: Evaluation criteria is not met.");
6101
+ } else {
6102
+ printStringLn("Testcase A52.1: Evaluation execution failed. Error=" + (rstring)error);
6103
+ }
6104
+ // -------------------------
6070
6105
} // End of onTuple MTD.
6071
6106
} // End of the HappyPathSink operator.
6072
6107
@@ -6098,7 +6133,6 @@ composite FunctionalTests {
6098
6133
mutable boolean result = false;
6099
6134
printStringLn("");
6100
6135
printStringLn("");
6101
-
6102
6136
// Before we do anything here, we will do quick tests of
6103
6137
// the built-in evalPredicate native function available
6104
6138
// in the IBM Streams product to see where it works fine
@@ -7231,6 +7265,32 @@ composite FunctionalTests {
7231
7265
printStringLn("Testcase B78.1: Evaluation execution failed. Error=" + (rstring)error);
7232
7266
}
7233
7267
// -------------------------
7268
+
7269
+ // B79.1 (OPEN_SQUARE_BRACKET_NOT_FOUND_AFTER_LIST_OF_TUPLE 117)
7270
+ _rule = "weatherList 0.city contains 'York'";
7271
+ result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
7272
+
7273
+ if(result == true) {
7274
+ printStringLn("Testcase B79.1: Evaluation criteria is met.");
7275
+ } else if(result == false && error == 0) {
7276
+ printStringLn("Testcase B79.1: Evaluation criteria is not met.");
7277
+ } else {
7278
+ printStringLn("Testcase B79.1: Evaluation execution failed. Error=" + (rstring)error);
7279
+ }
7280
+ // -------------------------
7281
+
7282
+ // B80.1 (NO_PERIOD_FOUND_AFTER_LIST_OF_TUPLE 119)
7283
+ _rule = "(weatherList[0] hourlyTemperatureMap[592311] != 89.16)";
7284
+ result = eval_predicate(_rule, _myTestData, error, $EVAL_PREDICATE_TRACING);
7285
+
7286
+ if(result == true) {
7287
+ printStringLn("Testcase B80.1: Evaluation criteria is met.");
7288
+ } else if(result == false && error == 0) {
7289
+ printStringLn("Testcase B80.1: Evaluation criteria is not met.");
7290
+ } else {
7291
+ printStringLn("Testcase B80.1: Evaluation execution failed. Error=" + (rstring)error);
7292
+ }
7293
+ // -------------------------
7234
7294
} // End of onTuple MTD.
7235
7295
} // End of the UnhappyPathSink operator.
7236
7296
} // End of main composite.
0 commit comments