-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX DateTime and geo:json support in custom notifications using ngsi …
…patching
- Loading branch information
Showing
8 changed files
with
272 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
255 changes: 255 additions & 0 deletions
255
...nalTest/cases/4435_ngsi_patching_special_attr_types/ngsi_patching_special_attr_types.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,255 @@ | ||
# Copyright 2023 Telefonica Investigacion y Desarrollo, S.A.U | ||
# | ||
# This file is part of Orion Context Broker. | ||
# | ||
# Orion Context Broker is free software: you can redistribute it and/or | ||
# modify it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# Orion Context Broker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. | ||
# | ||
# For those usages not covered by this license please contact with | ||
# iot_support at tid dot es | ||
|
||
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh | ||
|
||
--NAME-- | ||
Custom notification NGSI patching special attr types | ||
|
||
--SHELL-INIT-- | ||
dbInit CB | ||
brokerStart CB 0-255 | ||
|
||
--SHELL-- | ||
|
||
# | ||
# 01. Create custom subscription with ngsi patching with DateTime and geo:json | ||
# 02. Get subscription | ||
# 03. Update custom subscription with ngsi patching with DateTime and geo:json | ||
# 04. Get subscription | ||
# | ||
|
||
echo "01. Create custom subscription with ngsi patching with DateTime and geo:json" | ||
echo "============================================================================" | ||
payload='{ | ||
"description": "DateTime test", | ||
"status": "active", | ||
"subject": { | ||
"entities": [ | ||
{ | ||
"idPattern": ".*", | ||
"type": "NoiseLevelObserved" | ||
} | ||
], | ||
"condition": { | ||
"attrs": [ | ||
"TimeInstant" | ||
], | ||
"notifyOnMetadataChange": true | ||
} | ||
}, | ||
"notification": { | ||
"attrs": [ | ||
"dateobservedto", | ||
"location" | ||
], | ||
"onlyChangedAttrs": false, | ||
"attrsFormat": "normalized", | ||
"httpCustom": { | ||
"url": "http://127.0.0.1:'${LISTENER_PORT}'/notify", | ||
"ngsi": { | ||
"dateobservedto": { | ||
"type": "DateTime", | ||
"value": "${TimeInstant}" | ||
}, | ||
"mylocation": { | ||
"type": "geo:json", | ||
"value": "${location}" | ||
} | ||
} | ||
} | ||
} | ||
}' | ||
orionCurl --url /v2/subscriptions --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") | ||
|
||
|
||
echo "02. Get subscriptions" | ||
echo "=====================" | ||
orionCurl --url /v2/subscriptions/$SUB_ID | ||
echo | ||
echo | ||
|
||
|
||
echo "03. Update custom subscription with ngsi patching with DateTime and geo:json" | ||
echo "============================================================================" | ||
payload='{ | ||
"notification": { | ||
"attrs": [ | ||
"dateobservedto", | ||
"location" | ||
], | ||
"onlyChangedAttrs": false, | ||
"attrsFormat": "normalized", | ||
"httpCustom": { | ||
"url": "http://127.0.0.1:'${LISTENER_PORT}'/notify", | ||
"ngsi": { | ||
"dateobservedto2": { | ||
"type": "DateTime", | ||
"value": "${TimeInstant}" | ||
}, | ||
"mylocation2": { | ||
"type": "geo:json", | ||
"value": "${location}" | ||
} | ||
} | ||
} | ||
} | ||
}' | ||
orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "04. Get subscriptions" | ||
echo "=====================" | ||
orionCurl --url /v2/subscriptions/$SUB_ID | ||
echo | ||
echo | ||
|
||
|
||
--REGEXPECT-- | ||
01. Create custom subscription with ngsi patching with DateTime and geo:json | ||
============================================================================ | ||
HTTP/1.1 201 Created | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Location: /v2/subscriptions/REGEX([0-9a-f]{24}) | ||
Content-Length: 0 | ||
|
||
|
||
|
||
02. Get subscriptions | ||
===================== | ||
HTTP/1.1 200 OK | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Content-Type: application/json | ||
Content-Length: 522 | ||
|
||
{ | ||
"description": "DateTime test", | ||
"id": "REGEX([0-9a-f]{24})", | ||
"notification": { | ||
"attrs": [ | ||
"dateobservedto", | ||
"location" | ||
], | ||
"attrsFormat": "normalized", | ||
"covered": false, | ||
"httpCustom": { | ||
"ngsi": { | ||
"dateobservedto": { | ||
"type": "DateTime", | ||
"value": "${TimeInstant}" | ||
}, | ||
"mylocation": { | ||
"type": "geo:json", | ||
"value": "${location}" | ||
} | ||
}, | ||
"url": "http://127.0.0.1:9997/notify" | ||
}, | ||
"onlyChangedAttrs": false | ||
}, | ||
"status": "active", | ||
"subject": { | ||
"condition": { | ||
"attrs": [ | ||
"TimeInstant" | ||
], | ||
"notifyOnMetadataChange": true | ||
}, | ||
"entities": [ | ||
{ | ||
"idPattern": ".*", | ||
"type": "NoiseLevelObserved" | ||
} | ||
] | ||
} | ||
} | ||
|
||
|
||
03. Update custom subscription with ngsi patching with DateTime and geo:json | ||
============================================================================ | ||
HTTP/1.1 204 No Content | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
|
||
|
||
|
||
04. Get subscriptions | ||
===================== | ||
HTTP/1.1 200 OK | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Content-Type: application/json | ||
Content-Length: 524 | ||
|
||
{ | ||
"description": "DateTime test", | ||
"id": "REGEX([0-9a-f]{24})", | ||
"notification": { | ||
"attrs": [ | ||
"dateobservedto", | ||
"location" | ||
], | ||
"attrsFormat": "normalized", | ||
"covered": false, | ||
"httpCustom": { | ||
"ngsi": { | ||
"dateobservedto2": { | ||
"type": "DateTime", | ||
"value": "${TimeInstant}" | ||
}, | ||
"mylocation2": { | ||
"type": "geo:json", | ||
"value": "${location}" | ||
} | ||
}, | ||
"url": "http://127.0.0.1:9997/notify" | ||
}, | ||
"onlyChangedAttrs": false | ||
}, | ||
"status": "active", | ||
"subject": { | ||
"condition": { | ||
"attrs": [ | ||
"TimeInstant" | ||
], | ||
"notifyOnMetadataChange": true | ||
}, | ||
"entities": [ | ||
{ | ||
"idPattern": ".*", | ||
"type": "NoiseLevelObserved" | ||
} | ||
] | ||
} | ||
} | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |