Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return servicePath in the entity response #4329

Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
# 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--
servicepath behave with q and orderBy

--SHELL-INIT--
dbInit CB
brokerStart CB

--SHELL--

#
# 01. Create entity E1 with temperature = 35 in servicePath /Madrid/A
# 02. Create entity E2 with temperature = 25 in servicePath /Barcelona/B
# 03. Create entity E3 with temperature = 30 in servicePath /Madrid/A
# 04. Create entity E4 with temperature = 40 in servicePath /Barcelona/B
# 05. GET entities with q parameter and servicePath /Madrid/A
# 06. GET entities with orderBy servicePath
#


echo "01. Create entity E1 with temperature = 35 in servicePath /Madrid/A"
echo "==================================================================="
payload='{
"id": "E1",
"type": "T",
"temperature": {
"value":35,
"type": "Integer"
}
}'
orionCurl --url /v2/entities --payload "$payload" --servicePath /Madrid/A
echo
echo


echo "02. Create entity E2 with temperature = 25 in servicePath /Barcelona/B"
echo "======================================================================"
payload='{
"id": "E2",
"type": "T",
"temperature": {
"value": 25,
"type": "Integer"
}
}'
orionCurl --url /v2/entities --payload "$payload" --servicePath /Barcelon/B
echo
echo


echo "03. Create entity E3 with temperature = 30 in servicePath /Madrid/A"
echo "==================================================================="
payload='{
"id": "E3",
"type": "T",
"temperature": {
"value": 30,
"type": "Integer"
}
}'
orionCurl --url /v2/entities --payload "$payload" --servicePath /Madrid/A
echo
echo


echo "04. Create entity E4 with temperature = 40 in servicePath /Barcelona/B"
echo "======================================================================"
payload='{
"id": "E4",
"type": "T",
"temperature": {
"value": 40,
"type": "Integer"
}
}'
orionCurl --url /v2/entities --payload "$payload" --servicePath /Barcelona/B
echo
echo


echo "05. GET entities with q parameter and servicePath /Madrid/A"
echo "==========================================================="
orionCurl --url /v2/entities?q=servicePath:/Madrid/A
echo
echo


echo "06. GET entities with orderBy servicePath"
echo "========================================="
orionCurl --url /v2/entities?orderBy=servicePath
echo
echo


--REGEXPECT--
01. Create entity E1 with temperature = 35 in servicePath /Madrid/A
===================================================================
HTTP/1.1 201 Created
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Location: /v2/entities/E1?type=T
Content-Length: 0



02. Create entity E2 with temperature = 25 in servicePath /Barcelona/B
======================================================================
HTTP/1.1 201 Created
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Location: /v2/entities/E2?type=T
Content-Length: 0



03. Create entity E3 with temperature = 30 in servicePath /Madrid/A
===================================================================
HTTP/1.1 201 Created
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Location: /v2/entities/E3?type=T
Content-Length: 0



04. Create entity E4 with temperature = 40 in servicePath /Barcelona/B
======================================================================
HTTP/1.1 201 Created
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Location: /v2/entities/E4?type=T
Content-Length: 0



05. GET entities with q parameter and servicePath /Madrid/A
chetan-NEC marked this conversation as resolved.
Show resolved Hide resolved
===========================================================
HTTP/1.1 200 OK
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Content-Type: application/json
Content-Length: 2

[]


06. GET entities with orderBy servicePath
=========================================
chetan-NEC marked this conversation as resolved.
Show resolved Hide resolved
HTTP/1.1 200 OK
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Content-Type: application/json
Content-Length: 325

[
{
"id": "E1",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 35
},
"type": "T"
},
{
"id": "E2",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 25
},
"type": "T"
},
{
"id": "E3",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 30
},
"type": "T"
},
{
"id": "E4",
"temperature": {
"metadata": {},
"type": "Integer",
"value": 40
},
"type": "T"
}
]


--TEARDOWN--
brokerStop CB
dbDrop CB