Skip to content

Commit

Permalink
FIX null behaviour in custom notification payload field
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed May 27, 2024
1 parent 42c3a9a commit fcb9304
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/lib/ngsiNotify/Notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static bool setPayload
}
else
{
if (!macroSubstitute(payloadP, notifPayload, exprContextObjectP, "", true))
if (!macroSubstitute(payloadP, notifPayload, exprContextObjectP, "null", true))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])
PUT http://127.0.0.1:REGEX(\d+)/notify?a1=true&id=E1&type=T1
Fiware-Servicepath: /
Entity-Id: E1
Content-Length: 36
Content-Length: 44
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Expand All @@ -292,8 +292,8 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])

{
"A1": "true",
"A2": "",
"A3": ""
"A2": "null",
"A3": "null"
}
#SORT_END
#SORT_START
Expand Down Expand Up @@ -351,7 +351,7 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])
PUT http://127.0.0.1:REGEX(\d+)/notify?id=E1&type=T2
Fiware-Servicepath: /
Entity-Id: E1
Content-Length: 32
Content-Length: 44
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Expand All @@ -361,9 +361,9 @@ Content-Type: text/plain; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])

{
"A1": "",
"A2": "",
"A3": ""
"A1": "null",
"A2": "null",
"A3": "null"
}
#SORT_END
#SORT_START
Expand Down Expand Up @@ -422,7 +422,7 @@ PUT http://127.0.0.1:REGEX(\d+)/notify?a3=3&id=E1&type=T3
Fiware-Servicepath: /
A3: 3
Entity-Id: E1
Content-Length: 33
Content-Length: 41
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Expand All @@ -432,8 +432,8 @@ Content-Type: text/plain; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])

{
"A1": "",
"A2": "",
"A1": "null",
"A2": "null",
"A3": "3"
}
=======================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ accumulatorStart
# 03. Create E1 with attribute A1=1
# 04. Dump & reset, see notifications A1=1 and A2=null in custom payload
# 05. Create E2 with attribute A1=1
# 06. Dump & reset, see notifications A1=1 and A2=<empty> in custom payload (invalid JSON)
# 06. Dump & reset, see notifications A1=1 and A2=null in custom payload
#

echo "01. Create covered custom subscriptions for E1 covering attributes A1 and A2"
Expand Down Expand Up @@ -131,8 +131,8 @@ echo
echo


echo "06. Dump & reset, see notifications A1=1 and A2=<empty> in custom payload (invalid JSON)"
echo "========================================================================================"
echo "06. Dump & reset, see notifications A1=1 and A2=null in custom payload"
echo "======================================================================"
accumulatorDump
accumulatorReset
echo
Expand Down Expand Up @@ -174,15 +174,15 @@ Content-Length: 0
======================================================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 31
Content-Length: 35
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1

{ "A1-value": 1, "A2-value": }=======================================
{ "A1-value": 1, "A2-value": null }=======================================


05. Create E2 with attribute A1=1
Expand All @@ -195,19 +195,19 @@ Content-Length: 0



06. Dump & reset, see notifications A1=1 and A2=<empty> in custom payload (invalid JSON)
========================================================================================
06. Dump & reset, see notifications A1=1 and A2=null in custom payload
======================================================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 31
Content-Length: 35
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1

{ "A1-value": 1, "A2-value": }=======================================
{ "A1-value": 1, "A2-value": null }=======================================


--TEARDOWN--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ accumulatorStart
# 03. Create custom sub using json: "${A|patata}" and "X:${A|patata}:Y"
# 04. Create custom sub using ngsi: "${A|patata}" and "X:${A|patata}:Y"
# 05. Create entity E1 with A=1
# 06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
# 06. Dump & reset accumulator and see 4 notifications
#


Expand Down Expand Up @@ -167,8 +167,8 @@ echo
echo


echo "06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)"
echo "==========================================================================================="
echo "06. Dump & reset accumulator and see 4 notifications"
echo "===================================================="
accumulatorDump
accumulatorReset
echo
Expand Down Expand Up @@ -226,8 +226,9 @@ Content-Length: 0



06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
===========================================================================================
06. Dump & reset accumulator and see 4 notifications
====================================================
#SORT_START
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 4
Expand All @@ -238,7 +239,18 @@ Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X::Y=======================================
null=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 8
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X:null:Y=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 27
Expand All @@ -261,6 +273,7 @@ Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

{"subscriptionId":"REGEX([0-9a-f]{24})","data":[{"id":"E1","type":"T","B1":{"type":"Calculated","value":null,"metadata":{}},"B2":{"type":"Calculated","value":"X:null:Y","metadata":{}}}]}=======================================
#SORT_END


--TEARDOWN--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ accumulatorStart
# 03. Create custom sub with covered using json: "${A|patata}" and "X:${A|patata}:Y"
# 04. Create custom sub with covered using ngsi: "${A|patata}" and "X:${A|patata}:Y"
# 05. Create entity E1 with A=1
# 06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
# 06. Dump & reset accumulator and see 4 notifications
#


Expand Down Expand Up @@ -174,8 +174,8 @@ echo
echo


echo "06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)"
echo "==========================================================================================="
echo "06. Dump & reset accumulator and see 4 notifications"
echo "===================================================="
accumulatorDump
accumulatorReset
echo
Expand Down Expand Up @@ -233,8 +233,9 @@ Content-Length: 0



06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
===========================================================================================
06. Dump & reset accumulator and see 4 notifications
====================================================
#SORT_START
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 4
Expand All @@ -245,7 +246,18 @@ Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X::Y=======================================
null=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 8
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X:null:Y=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 27
Expand All @@ -268,6 +280,7 @@ Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

{"subscriptionId":"REGEX([0-9a-f]{24})","data":[{"id":"E1","type":"T","B1":{"type":"Calculated","value":null,"metadata":{}},"B2":{"type":"Calculated","value":"X:null:Y","metadata":{}}}]}=======================================
#SORT_END


--TEARDOWN--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ accumulatorStart
# 03. Create custom sub using json: "${A}" and "X:${A}:Y"
# 04. Create custom sub using ngsi: "${A}" and "X:${A}:Y"
# 05. Create entity E1 with A=null
# 06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
# 06. Dump & reset accumulator and see 4 notifications
# 07. Create entity E2 without A
# 08. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
# 08. Dump & reset accumulator and see 4 notifications
#


Expand Down Expand Up @@ -168,8 +168,8 @@ echo
echo


echo "06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)"
echo "==========================================================================================="
echo "06. Dump & reset accumulator and see 4 notifications"
echo "===================================================="
accumulatorDump
accumulatorReset
echo
Expand All @@ -191,8 +191,8 @@ echo
echo


echo "08. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)"
echo "==========================================================================================="
echo "08. Dump & reset accumulator and see 4 notifications"
echo "===================================================="
accumulatorDump
accumulatorReset
echo
Expand Down Expand Up @@ -250,8 +250,9 @@ Content-Length: 0



06. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
===========================================================================================
06. Dump & reset accumulator and see 4 notifications
====================================================
#SORT_START
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 4
Expand All @@ -262,7 +263,18 @@ Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X::Y=======================================
null=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 8
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X:null:Y=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 27
Expand All @@ -285,6 +297,7 @@ Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

{"subscriptionId":"REGEX([0-9a-f]{24})","data":[{"id":"E1","type":"T","B1":{"type":"Calculated","value":null,"metadata":{}},"B2":{"type":"Calculated","value":"X:null:Y","metadata":{}}}]}=======================================
#SORT_END


07. Create entity E2 without A
Expand All @@ -297,8 +310,9 @@ Content-Length: 0



08. Dump & reset accumulator and see 3 notifications (first sub lead to empty notification)
===========================================================================================
08. Dump & reset accumulator and see 4 notifications
====================================================
#SORT_START
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 4
Expand All @@ -309,7 +323,18 @@ Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X::Y=======================================
null=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 8
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: custom
Host: 127.0.0.1:REGEX(\d+)
Accept: application/json
Content-Type: text/plain
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

X:null:Y=======================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 27
Expand All @@ -332,6 +357,7 @@ Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[1234])

{"subscriptionId":"REGEX([0-9a-f]{24})","data":[{"id":"E2","type":"T","B1":{"type":"Calculated","value":null,"metadata":{}},"B2":{"type":"Calculated","value":"X:null:Y","metadata":{}}}]}=======================================
#SORT_END


--TEARDOWN--
Expand Down
Loading

0 comments on commit fcb9304

Please sign in to comment.