@izara_project/izara-testing-shared 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/TestingLib.js +251 -227
package/package.json
CHANGED
package/src/TestingLib.js
CHANGED
|
@@ -48,9 +48,9 @@ function checkOutputEventOneLevel(
|
|
|
48
48
|
propertyNotPass = []
|
|
49
49
|
) {
|
|
50
50
|
_izContext.logger.debug("Lib checkOutputEventOneLevel:", {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
testEventConfigOneLevel,
|
|
52
|
+
eventForTestingOneLevel,
|
|
53
|
+
level,
|
|
54
54
|
// notPassPrefix,
|
|
55
55
|
propertyNotPass
|
|
56
56
|
});
|
|
@@ -90,8 +90,9 @@ function checkOutputEventOneLevel(
|
|
|
90
90
|
return
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
} else if (testEventConfigOneLevel.hasOwnProperty('properties')
|
|
94
|
-
&& typeof testEventConfigOneLevel === 'object') {
|
|
93
|
+
} else if ((testEventConfigOneLevel.hasOwnProperty('properties')
|
|
94
|
+
&& typeof testEventConfigOneLevel === 'object')) {
|
|
95
|
+
|
|
95
96
|
_izContext.logger.debug("Case: properties", {
|
|
96
97
|
"testEventConfigOneLevel.properties": testEventConfigOneLevel.properties,
|
|
97
98
|
"eventForTestingOneLevel": eventForTestingOneLevel
|
|
@@ -100,165 +101,160 @@ function checkOutputEventOneLevel(
|
|
|
100
101
|
for (const [propertyName, propertyConfig] of Object.entries(testEventConfigOneLevel.properties)) {
|
|
101
102
|
_izContext.logger.debug('Loop testEventConfigOneLevel:', { propertyName, propertyConfig });
|
|
102
103
|
_izContext.logger.debug('find propertyName in eventForTestingOneLevel', eventForTestingOneLevel[propertyName]);
|
|
103
|
-
|
|
104
|
+
if (propertyConfig.hasOwnProperty('testValueMatches') && propertyConfig.testValueMatches == false) {
|
|
105
|
+
_izContext.logger.debug("**not test value matches,continue**", propertyName);
|
|
106
|
+
continue
|
|
107
|
+
};
|
|
104
108
|
// 0 , false, == falsy
|
|
105
109
|
if (eventForTestingOneLevel[propertyName]
|
|
106
110
|
|| (typeof eventForTestingOneLevel[propertyName] == 'number' && eventForTestingOneLevel[propertyName] == 0)
|
|
107
111
|
|| (typeof eventForTestingOneLevel[propertyName] == 'boolean' && eventForTestingOneLevel[propertyName] == false)
|
|
108
112
|
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
&& propertyConfig.forStageMatching === true)) {
|
|
120
|
-
|
|
121
|
-
_izContext.logger.debug("case forStageMatching is true", propertyConfig);
|
|
122
|
-
if (propertyConfig.stringified) {
|
|
123
|
-
_izContext.logger.debug('stringified::::', propertyConfig.stringified);
|
|
124
|
-
eventForTestingOneLevel[propertyName] = JSON.parse(eventForTestingOneLevel[propertyName]);
|
|
125
|
-
};
|
|
113
|
+
) {
|
|
114
|
+
|
|
115
|
+
if (propertyConfig.stringified) {
|
|
116
|
+
_izContext.logger.debug('stringified::::', propertyConfig.stringified);
|
|
117
|
+
eventForTestingOneLevel[propertyName] = JSON.parse(eventForTestingOneLevel[propertyName]);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
//== check config matching to massege.
|
|
121
|
+
if (!eventForTestingOneLevel.hasOwnProperty(propertyName)) {
|
|
122
|
+
_izContext.logger.debug("eventForTestingOneLevel not have propertyName:", propertyName);
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
// propertyNotPass.push(notPassPrefix + `${propertyName}: ${JSON.stringify(propertyConfig)}`)
|
|
125
|
+
propertyNotPass.push({
|
|
126
|
+
prefix: notPassPrefix,
|
|
127
|
+
expectedValue: `(NO propertyName SET IN CONFIG)`,
|
|
128
|
+
receivedValue: eventForTestingOneLevel[propertyName],
|
|
129
|
+
propertyName: propertyName,
|
|
130
|
+
propertyConfig: propertyConfig
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
else if (propertyConfig.eventValue) {
|
|
134
|
+
_izContext.logger.debug('eventValue::::', propertyConfig.eventValue);
|
|
135
|
+
//calling recursive function again.
|
|
136
|
+
this.checkOutputEventOneLevel(
|
|
137
|
+
_izContext,
|
|
138
|
+
propertyConfig,
|
|
139
|
+
eventForTestingOneLevel[propertyName],
|
|
140
|
+
level + 1,
|
|
141
|
+
notPassPrefix,
|
|
142
|
+
propertyNotPass
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
else if (propertyConfig.properties) {
|
|
146
|
+
_izContext.logger.debug("properties::::", propertyConfig.properties);
|
|
147
|
+
|
|
148
|
+
if (
|
|
149
|
+
(typeof (propertyConfig.properties.value) == 'object'
|
|
150
|
+
&& (Object.keys(propertyConfig.properties.value).length === 0))
|
|
151
|
+
&& (typeof (eventForTestingOneLevel[propertyName]) == 'object'
|
|
152
|
+
&& Object.keys(eventForTestingOneLevel[propertyName]).length === 0)
|
|
153
|
+
) {
|
|
154
|
+
// match empty object
|
|
155
|
+
_izContext.logger.debug("match empty object", propertyConfig.properties.value, eventForTestingOneLevel[propertyName])
|
|
156
|
+
} else {
|
|
157
|
+
//calling recursive function again.
|
|
158
|
+
this.checkOutputEventOneLevel(
|
|
159
|
+
_izContext,
|
|
160
|
+
propertyConfig,
|
|
161
|
+
eventForTestingOneLevel[propertyName],
|
|
162
|
+
level + 1,
|
|
163
|
+
notPassPrefix,
|
|
164
|
+
propertyNotPass
|
|
165
|
+
)
|
|
130
166
|
|
|
131
|
-
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
// if config not have value the test is not valid, test fails and note in the result
|
|
170
|
+
if (propertyConfig.hasOwnProperty("value")) {
|
|
171
|
+
// console.log("am value");
|
|
172
|
+
if (isObject(eventForTestingOneLevel[propertyName]) && isObject(propertyConfig.value)) {
|
|
173
|
+
_izContext.logger.debug("check Object")
|
|
174
|
+
if (Object.keys(eventForTestingOneLevel[propertyName]).length > 0 && Object.keys(propertyConfig.value).length > 0) {
|
|
175
|
+
// console.log("invalid object should be set propertise inside for recuresive value in object");
|
|
132
176
|
propertyNotPass.push({
|
|
133
177
|
prefix: notPassPrefix,
|
|
134
|
-
expectedValue: `
|
|
178
|
+
expectedValue: `invalid check object much be set 'propertise' inside for recuresive value in object(${propertyConfig.value})`,
|
|
135
179
|
receivedValue: eventForTestingOneLevel[propertyName],
|
|
136
180
|
propertyName: propertyName,
|
|
137
181
|
propertyConfig: propertyConfig
|
|
138
182
|
})
|
|
139
|
-
}
|
|
140
|
-
else if (propertyConfig.eventValue) {
|
|
141
|
-
_izContext.logger.debug('eventValue::::', propertyConfig.eventValue);
|
|
142
|
-
//calling recursive function again.
|
|
143
|
-
this.checkOutputEventOneLevel(
|
|
144
|
-
_izContext,
|
|
145
|
-
propertyConfig,
|
|
146
|
-
eventForTestingOneLevel[propertyName],
|
|
147
|
-
level + 1,
|
|
148
|
-
notPassPrefix,
|
|
149
|
-
propertyNotPass
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
else if (propertyConfig.properties) {
|
|
153
|
-
_izContext.logger.debug("properties::::", propertyConfig.properties);
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
(typeof (propertyConfig.properties.value) == 'object'
|
|
157
|
-
&& (Object.keys(propertyConfig.properties.value).length === 0))
|
|
158
|
-
&& (typeof (eventForTestingOneLevel[propertyName]) == 'object'
|
|
159
|
-
&& Object.keys(eventForTestingOneLevel[propertyName]).length === 0)
|
|
160
|
-
) {
|
|
161
|
-
// match empty object
|
|
162
|
-
_izContext.logger.debug("match empty object", propertyConfig.properties.value, eventForTestingOneLevel[propertyName])
|
|
163
|
-
} else {
|
|
164
|
-
//calling recursive function again.
|
|
165
|
-
this.checkOutputEventOneLevel(
|
|
166
|
-
_izContext,
|
|
167
|
-
propertyConfig,
|
|
168
|
-
eventForTestingOneLevel[propertyName],
|
|
169
|
-
level + 1,
|
|
170
|
-
notPassPrefix,
|
|
171
|
-
propertyNotPass
|
|
172
|
-
)
|
|
173
183
|
|
|
174
|
-
};
|
|
175
184
|
} else {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
} else {
|
|
192
|
-
_izContext.logger.debug("object is empty");
|
|
193
|
-
};
|
|
194
|
-
} else {
|
|
195
|
-
if (eventForTestingOneLevel[propertyName] !== propertyConfig.value) {
|
|
196
|
-
_izContext.logger.debug("miss match v",
|
|
197
|
-
{
|
|
198
|
-
eventForTestingOneLevel: eventForTestingOneLevel,
|
|
199
|
-
event: eventForTestingOneLevel[propertyName].value,
|
|
200
|
-
config: propertyConfig.value
|
|
201
|
-
}
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
propertyNotPass.push({
|
|
205
|
-
prefix: notPassPrefix,
|
|
206
|
-
expectedValue: propertyConfig.value,
|
|
207
|
-
receivedValue: eventForTestingOneLevel[propertyName],
|
|
208
|
-
propertyName: propertyName,
|
|
209
|
-
propertyConfig: propertyConfig
|
|
210
|
-
});
|
|
211
|
-
}
|
|
185
|
+
_izContext.logger.debug("object is empty");
|
|
186
|
+
};
|
|
187
|
+
} else {
|
|
188
|
+
_izContext.logger.debug("-----check value-----", {
|
|
189
|
+
propertyName: propertyName,
|
|
190
|
+
eventForTestingOneLevel: eventForTestingOneLevel[propertyName],
|
|
191
|
+
propertyConfig: propertyConfig.value
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
if (eventForTestingOneLevel[propertyName] !== propertyConfig.value) {
|
|
195
|
+
_izContext.logger.debug("miss match v",
|
|
196
|
+
{
|
|
197
|
+
eventForTestingOneLevel: eventForTestingOneLevel,
|
|
198
|
+
event: eventForTestingOneLevel[propertyName].value,
|
|
199
|
+
config: propertyConfig.value
|
|
212
200
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
});
|
|
223
|
-
_izContext.logger.debug("Message attribute is miss match!");
|
|
224
|
-
propertyNotPass.push({
|
|
225
|
-
prefix: notPassPrefix,
|
|
226
|
-
expectedValue: propertyConfig.Value,
|
|
227
|
-
receivedValue: eventForTestingOneLevel[propertyName],
|
|
228
|
-
propertyName: propertyName,
|
|
229
|
-
propertyConfig: propertyConfig
|
|
230
|
-
});
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
};
|
|
234
|
-
} else {
|
|
235
|
-
_izContext.logger.debug("NO 'VALUE' SET IN CONFIG", { notPassPrefix, propertyConfig })
|
|
236
|
-
propertyNotPass.push({
|
|
237
|
-
prefix: notPassPrefix,
|
|
238
|
-
expectedValue: "(NO 'VALUE' SET IN CONFIG)",
|
|
239
|
-
receivedValue: eventForTestingOneLevel[propertyName],
|
|
240
|
-
propertyName: propertyName,
|
|
241
|
-
propertyConfig: propertyConfig
|
|
242
|
-
})
|
|
243
|
-
};
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
propertyNotPass.push({
|
|
204
|
+
prefix: notPassPrefix,
|
|
205
|
+
expectedValue: propertyConfig.value,
|
|
206
|
+
receivedValue: eventForTestingOneLevel[propertyName],
|
|
207
|
+
propertyName: propertyName,
|
|
208
|
+
propertyConfig: propertyConfig
|
|
209
|
+
});
|
|
244
210
|
}
|
|
245
|
-
} else {
|
|
246
|
-
_izContext.logger.debug(`propertyName: ${propertyName} not test testValueMatches.`);
|
|
247
|
-
continue
|
|
248
211
|
}
|
|
249
|
-
} else {
|
|
212
|
+
} else if (propertyConfig.hasOwnProperty("Value")) {
|
|
213
|
+
// console.log("am Value");
|
|
214
|
+
if (eventForTestingOneLevel[propertyName].hasOwnProperty("Type")
|
|
215
|
+
&& eventForTestingOneLevel[propertyName].hasOwnProperty("Value")) {
|
|
216
|
+
|
|
217
|
+
if (eventForTestingOneLevel[propertyName].Value !== propertyConfig.Value) {
|
|
218
|
+
_izContext.logger.debug("miss match VV", {
|
|
219
|
+
event: eventForTestingOneLevel[propertyName].Value,
|
|
220
|
+
config: propertyConfig.Value
|
|
221
|
+
});
|
|
222
|
+
_izContext.logger.debug("Message attribute is miss match!");
|
|
223
|
+
propertyNotPass.push({
|
|
224
|
+
prefix: notPassPrefix,
|
|
225
|
+
expectedValue: propertyConfig.Value,
|
|
226
|
+
receivedValue: eventForTestingOneLevel[propertyName],
|
|
227
|
+
propertyName: propertyName,
|
|
228
|
+
propertyConfig: propertyConfig
|
|
229
|
+
});
|
|
230
|
+
};
|
|
250
231
|
|
|
251
|
-
|
|
232
|
+
};
|
|
233
|
+
} else {
|
|
234
|
+
_izContext.logger.debug("NO 'VALUE' SET IN CONFIG", { notPassPrefix, propertyConfig })
|
|
252
235
|
propertyNotPass.push({
|
|
253
236
|
prefix: notPassPrefix,
|
|
254
|
-
|
|
255
|
-
receivedValue: eventForTestingOneLevel,
|
|
256
|
-
|
|
237
|
+
expectedValue: "(NO 'VALUE' SET IN CONFIG)",
|
|
238
|
+
receivedValue: eventForTestingOneLevel[propertyName],
|
|
239
|
+
propertyName: propertyName,
|
|
240
|
+
propertyConfig: propertyConfig
|
|
257
241
|
})
|
|
258
|
-
|
|
259
242
|
};
|
|
260
243
|
}
|
|
261
244
|
|
|
245
|
+
} else {
|
|
246
|
+
|
|
247
|
+
// // mismatch eventForTestingOneLevel
|
|
248
|
+
propertyNotPass.push({
|
|
249
|
+
prefix: notPassPrefix,
|
|
250
|
+
error: `message event is not mach test config`,
|
|
251
|
+
receivedValue: eventForTestingOneLevel,
|
|
252
|
+
expectedValue: testEventConfigOneLevel
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
// };
|
|
256
|
+
// }
|
|
257
|
+
}
|
|
262
258
|
}// end for loop check test
|
|
263
259
|
}
|
|
264
260
|
if (propertyNotPass.length == 0) {
|
|
@@ -305,19 +301,19 @@ function matchingEventOneLevel(
|
|
|
305
301
|
|
|
306
302
|
if (testEventConfigOneLevel.hasOwnProperty('eventValue')) {
|
|
307
303
|
if (testEventConfigOneLevel.hasOwnProperty('forStageMatching') && testEventConfigOneLevel.forStageMatching === true) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
304
|
+
_izContext.logger.debug("Check array")// index in array is isEqual.
|
|
305
|
+
if (isEqual(eventForTestingOneLevel, testEventConfigOneLevel.eventValue) == false) {
|
|
306
|
+
_izContext.logger.debug('test array isEqual failed');
|
|
307
|
+
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
308
|
+
return false;
|
|
309
|
+
} else {
|
|
310
|
+
_izContext.logger.debug('test array isEqual true');
|
|
315
311
|
|
|
316
|
-
}
|
|
317
312
|
}
|
|
313
|
+
|
|
318
314
|
} else {
|
|
319
315
|
// continue to next property if property(ex.requestParams) has set forStageMatching: false.
|
|
320
|
-
_izContext.logger.debug(`forStageMatching set not
|
|
316
|
+
_izContext.logger.debug(`forStageMatching set not matching or default is false.`);
|
|
321
317
|
}
|
|
322
318
|
} else { // check if have properties
|
|
323
319
|
|
|
@@ -339,99 +335,127 @@ function matchingEventOneLevel(
|
|
|
339
335
|
_izContext.logger.debug("[matching]Iterate testEventConfigOneLevel.properties:", { propertyName, propertyConfig });
|
|
340
336
|
_izContext.logger.debug('eventForTestingOneLevel[propertyName]', eventForTestingOneLevel[propertyName])
|
|
341
337
|
|
|
342
|
-
// continue to test property if set forStageMatching to false
|
|
343
|
-
if (propertyConfig.hasOwnProperty('forStageMatching') && propertyConfig.forStageMatching === true) {
|
|
344
338
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
propertyConfig: propertyConfig
|
|
348
|
-
});
|
|
339
|
+
if ((!propertyConfig.hasOwnProperty('testValueMatches') || propertyConfig.testValueMatches !== false)
|
|
340
|
+
|| (propertyConfig.hasOwnProperty('forStageMatching') && propertyConfig.forStageMatching === true)) {
|
|
349
341
|
|
|
350
|
-
if (propertyConfig.stringified) {
|
|
351
|
-
eventForTestingOneLevel[propertyName] = JSON.parse(eventForTestingOneLevel[propertyName]);
|
|
352
|
-
}
|
|
353
|
-
//== check config matching to massege.
|
|
354
342
|
|
|
355
|
-
if (
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
propertyConfig
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
|
|
343
|
+
if (eventForTestingOneLevel[propertyName]
|
|
344
|
+
|| (typeof eventForTestingOneLevel[propertyName] == 'number' && eventForTestingOneLevel[propertyName] == 0)
|
|
345
|
+
|| (typeof eventForTestingOneLevel[propertyName] == 'boolean' && eventForTestingOneLevel[propertyName] == false)
|
|
346
|
+
|
|
347
|
+
) {
|
|
348
|
+
// continue to test property if set forStageMatching to false
|
|
349
|
+
// if ((!propertyConfig.hasOwnProperty('testValueMatches')
|
|
350
|
+
// || propertyConfig.testValueMatches !== false)
|
|
351
|
+
// || (propertyConfig.hasOwnProperty('forStageMatching')
|
|
352
|
+
// && propertyConfig.forStageMatching === true)) {
|
|
353
|
+
|
|
354
|
+
_izContext.logger.debug("[matching] forStageMatching is true compare value", {
|
|
355
|
+
"eventForTestingOneLevel[propertyName]": eventForTestingOneLevel[propertyName],
|
|
356
|
+
propertyConfig: propertyConfig
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
if (propertyConfig.stringified) {
|
|
360
|
+
eventForTestingOneLevel[propertyName] = JSON.parse(eventForTestingOneLevel[propertyName]);
|
|
373
361
|
}
|
|
374
|
-
|
|
375
|
-
else if (propertyConfig.hasOwnProperty("properties")) {
|
|
376
|
-
_izContext.logger.debug("[matchingEventOneLevel]propertyConfig.properties");
|
|
362
|
+
//== check config matching to massege.
|
|
377
363
|
|
|
378
|
-
|
|
379
|
-
_izContext
|
|
380
|
-
propertyConfig,
|
|
381
|
-
eventForTestingOneLevel[propertyName],
|
|
382
|
-
level + 1
|
|
383
|
-
)
|
|
384
|
-
if (checkMatched == false) {
|
|
364
|
+
if (!eventForTestingOneLevel.hasOwnProperty(propertyName)) {
|
|
365
|
+
_izContext.logger.debug(`${eventForTestingOneLevel} not have properties: ${propertyName} for matching.`);
|
|
385
366
|
return false;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
//
|
|
390
|
-
if (
|
|
391
|
-
_izContext.logger.debug(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
367
|
+
}
|
|
368
|
+
// NOT SURE - was setting all eventValue properties to also set isObject: true, try this to see if works so not need to add isObject, but seem to remember this
|
|
369
|
+
// causes problems too.. might have to return to using isObject
|
|
370
|
+
// else if (propertyConfig.isObject) { // send to recursion again if set isObject both properties and eventValue
|
|
371
|
+
else if (propertyConfig.eventValue) { // send to recursion again if set isObject both properties and eventValue
|
|
372
|
+
_izContext.logger.debug('propertyConfig.eventValue', propertyConfig.eventValue);
|
|
373
|
+
//calling recursive function again.
|
|
374
|
+
// [notsure] want to checkEventvalue is match, so match only propertyName is exist in config is enough, not re
|
|
375
|
+
let checkMatched = matchingEventOneLevel(
|
|
376
|
+
_izContext,
|
|
377
|
+
propertyConfig,
|
|
378
|
+
eventForTestingOneLevel[propertyName],
|
|
379
|
+
level + 1
|
|
380
|
+
);
|
|
381
|
+
if (checkMatched == false) {
|
|
382
|
+
return false;
|
|
397
383
|
}
|
|
398
|
-
} else {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
384
|
+
} else if (propertyConfig.hasOwnProperty("properties")) {
|
|
385
|
+
_izContext.logger.debug("[matchingEventOneLevel]propertyConfig.properties");
|
|
386
|
+
|
|
387
|
+
let checkMatched = matchingEventOneLevel(
|
|
388
|
+
_izContext,
|
|
389
|
+
propertyConfig,
|
|
390
|
+
eventForTestingOneLevel[propertyName],
|
|
391
|
+
level + 1
|
|
392
|
+
)
|
|
393
|
+
if (checkMatched == false) {
|
|
394
|
+
return false;
|
|
395
|
+
};
|
|
396
|
+
} else { // new ------------------------
|
|
397
|
+
// suport empty Object
|
|
398
|
+
if (isObject(eventForTestingOneLevel[propertyName]) && isObject(propertyConfig.value)) {
|
|
399
|
+
_izContext.logger.debug("check Object", eventForTestingOneLevel[propertyName], propertyConfig.value);
|
|
400
|
+
if ((typeof (propertyConfig.properties.value) == 'object'
|
|
401
|
+
&& (Object.keys(propertyConfig.properties.value).length === 0))
|
|
402
|
+
&& (typeof (eventForTestingOneLevel[propertyName]) == 'object'
|
|
403
|
+
&& Object.keys(eventForTestingOneLevel[propertyName]).length === 0)) {
|
|
404
|
+
console.log("invalid object should be set propertise inside for recuresive value in object");
|
|
403
405
|
return false
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
406
|
+
} else {
|
|
407
|
+
|
|
408
|
+
let checkMatched = matchingEventOneLevel(
|
|
409
|
+
_izContext,
|
|
410
|
+
propertyConfig,
|
|
411
|
+
eventForTestingOneLevel[propertyName],
|
|
412
|
+
level + 1
|
|
413
|
+
);
|
|
414
|
+
if (checkMatched == false) {
|
|
415
|
+
return false;
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
// check value
|
|
420
|
+
if (propertyConfig.hasOwnProperty("value")) {
|
|
421
|
+
if (eventForTestingOneLevel[propertyName] !== propertyConfig.value) {
|
|
422
|
+
_izContext.logger.debug("event is miss match!", { event: eventForTestingOneLevel[propertyName], testConfig: propertyConfig.value });
|
|
417
423
|
return false
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
424
|
+
};
|
|
425
|
+
} else if (propertyConfig.hasOwnProperty("Value")) {
|
|
426
|
+
_izContext.logger.debug("check Value of Attribute");
|
|
427
|
+
if (eventForTestingOneLevel[propertyName].hasOwnProperty("Type")
|
|
428
|
+
&& eventForTestingOneLevel[propertyName].hasOwnProperty("Value")) {
|
|
429
|
+
_izContext.logger.debug("messageAttTestConfig:", propertyConfig.Value);
|
|
430
|
+
_izContext.logger.debug("messageAttEvent:", eventForTestingOneLevel[propertyName].Value);
|
|
431
|
+
|
|
432
|
+
if (eventForTestingOneLevel[propertyName].Value !== propertyConfig.Value) {
|
|
433
|
+
_izContext.logger.debug("Message attribute is miss match!", {
|
|
434
|
+
event: eventForTestingOneLevel[propertyName].Value,
|
|
435
|
+
testConfig: propertyConfig.Value
|
|
436
|
+
});
|
|
437
|
+
return false
|
|
438
|
+
} else {
|
|
439
|
+
_izContext.logger.debug("Message attribute is match!");
|
|
440
|
+
}
|
|
441
|
+
};
|
|
421
442
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
};
|
|
443
|
+
// if (eventForTestingOneLevel[propertyName] !== propertyConfig.value) {
|
|
444
|
+
// console.log("misMatch data::::", { valueEvent: eventForTestingOneLevel[propertyName], valueConfig: propertyConfig.value });
|
|
445
|
+
// return false;
|
|
446
|
+
// }
|
|
447
|
+
}
|
|
448
|
+
};
|
|
429
449
|
|
|
450
|
+
} else {
|
|
451
|
+
_izContext.logger.debug("propertyName not exist ineventForTestingOneLevel", eventForTestingOneLevel[propertyName], { propertyName, eventForTestingOneLevel });
|
|
452
|
+
return false
|
|
453
|
+
}
|
|
430
454
|
} else {
|
|
431
455
|
// continue to next property if property(ex.requestParams) has set forStageMatching: false.
|
|
432
|
-
_izContext.logger.debug(
|
|
456
|
+
_izContext.logger.debug("continute matchEventOneLevel", propertyName);
|
|
433
457
|
continue
|
|
434
|
-
}
|
|
458
|
+
};// end for loop check test
|
|
435
459
|
}// end for loop check test
|
|
436
460
|
}
|
|
437
461
|
}
|