diff --git a/test/functionalTest/cases/2877_return_ServicePath_in_entity_response/servicePath_behave_with_q_and_orderBy.test b/test/functionalTest/cases/2877_return_ServicePath_in_entity_response/servicePath_behave_with_q_and_orderBy.test new file mode 100644 index 0000000000..c9444977c0 --- /dev/null +++ b/test/functionalTest/cases/2877_return_ServicePath_in_entity_response/servicePath_behave_with_q_and_orderBy.test @@ -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 +=========================================================== +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 +========================================= +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