Skip to content

Commit

Permalink
FIX value not given processing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Feb 14, 2024
1 parent 8a6c762 commit 7231ad4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/lib/common/macroSubstitute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::string smartStringValue(const std::string stringValue, JexlContext* jexlCon
std::string macroName = stringValue.substr(2, stringValue.size() - 3);

JexlResult r = jexlMgr.evaluate(jexlContextP, macroName);
if (r.valueType == orion::ValueTypeNull)
if (r.valueType == orion::ValueTypeNotGiven)
{
return notFoundDefault;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ static std::string stringValueOrNothing(JexlContext* jexlContextP, const std::st
{
JexlResult r = jexlMgr.evaluate(jexlContextP, key);

if (r.valueType == orion::ValueTypeNull)
if (r.valueType == orion::ValueTypeNotGiven)
{
return notFoundDefault;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/jexl/JexlManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ JexlResult JexlManager::evaluate(JexlContext* jexlContextP, const std::string& _

JexlResult r;

// If nothing changes, the returned value would be null (failsafe)
r.valueType = orion::ValueTypeNull;
// If nothing changes, the returned value would be ValueTypeNotGiven
r.valueType = orion::ValueTypeNotGiven;

PyObject* expression = Py_BuildValue("s", _expression.c_str());
if (expression == NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,25 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])
"subscriptionId": "REGEX([0-9a-f]{24})"
}
=======================================
PUT http://127.0.0.1:REGEX(\d+)/notify?a1=true&id=E1&type=T1
PUT http://127.0.0.1:REGEX(\d+)/notify?a1=true&a2=null&a3=null&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+)
Accept: application/json
A1: true
A2: null
A3: null
Entity-Type: T1
Content-Type: text/plain; charset=utf-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 @@ -348,22 +350,25 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])
"subscriptionId": "REGEX([0-9a-f]{24})"
}
=======================================
PUT http://127.0.0.1:REGEX(\d+)/notify?id=E1&type=T2
PUT http://127.0.0.1:REGEX(\d+)/notify?a1=null&a2=null&a3=null&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+)
Accept: application/json
A1: null
A2: null
A3: null
Entity-Type: T2
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 @@ -418,11 +423,13 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}; cbnotif=[123])
"subscriptionId": "REGEX([0-9a-f]{24})"
}
=======================================
PUT http://127.0.0.1:REGEX(\d+)/notify?a3=3&id=E1&type=T3
PUT http://127.0.0.1:REGEX(\d+)/notify?a1=null&a2=null&a3=3&id=E1&type=T3
Fiware-Servicepath: /
A1: null
A2: null
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 +439,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 @@ -199,15 +199,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 }=======================================


--TEARDOWN--
Expand Down

0 comments on commit 7231ad4

Please sign in to comment.