Skip to content

Commit

Permalink
Merge pull request #4217 from telefonicaid/bug/4216
Browse files Browse the repository at this point in the history
  • Loading branch information
mapedraza authored Sep 28, 2022
2 parents 2817fd7 + 6219dba commit 7b45e6e
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- Add: json field in httpCustom and mqttCustom subscriptions (#2560)
- Add: ${service}, ${servicePath} and ${authToken} macros in custom notifications (#4159)
- Fix: conditions.alterationTypes not working properly when conditions.attributes is used in entityUpdate case (#1494, reopened)
- Fix: GET /v2/types and GET /v2/types/{type} wrong attribute types result (#4216)
- Upgrade Debian version from 11.2 to 11.3 in Dockerfile
- Deprecated: GET /v2 operation
- Remove: RPM package stuff
2 changes: 1 addition & 1 deletion src/lib/mongoBackend/mongoQueryTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void getAttributeTypes
{
orion::BSONObjBuilder bob;

if (entityType.empty())
if (!entityType.empty())
{
std::string idType = std::string("_id.") + ENT_ENTITY_TYPE;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Copyright 2022 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--
GET Entity Type misses attribute types

--SHELL-INIT--
dbInit CB
brokerStart CB 100

--SHELL--

#
# 01. Create E11/ET1/A-AT1
# 02. Create E12/ET1/A-AT2
# 03. Create E21/ET2/A-AT3
# 04. Create E22/ET2/A-AT4
# 05. GET /v2/types and get AT1 and AT2 attribute types in ET1 and AT3 and AT4 in ET2
# 06. GET /v2/types/ET1 and get AT3 and AT4 attribute types
#

echo "01. Create E11/ET1/A-AT1"
echo "========================"
payload='{
"type": "ET1",
"id": "E11",
"A": { "type": "AT1", "value": "irrelevant" }
}'
orionCurl --url /v2/entities --payload "$payload"
echo
echo


echo "02. Create E12/ET1/A-AT2"
echo "========================"
payload='{
"type": "ET1",
"id": "E12",
"A": { "type": "AT2", "value": "irrelevant" }
}'
orionCurl --url /v2/entities --payload "$payload"
echo
echo


echo "03. Create E21/ET2/A-AT3"
echo "========================"
payload='{
"type": "ET2",
"id": "E21",
"A": { "type": "AT3", "value": "irrelevant" }
}'
orionCurl --url /v2/entities --payload "$payload"
echo
echo


echo "04. Create E22/ET2/A-AT4"
echo "======================="
payload='{
"type": "ET2",
"id": "E22",
"A": { "type": "AT4", "value": "irrelevant" }
}'
orionCurl --url /v2/entities --payload "$payload"
echo
echo


echo "05. GET /v2/types and get AT1 and AT2 attribute types in ET1 and AT3 and AT4 in ET2"
echo "==================================================================================="
orionCurl --url /v2/types
echo
echo


echo "06. GET /v2/types/ET1 and get AT1 and AT2 attribute types"
echo "========================================================="
orionCurl --url /v2/types/ET1
echo
echo


--REGEXPECT--
01. Create E11/ET1/A-AT1
========================
HTTP/1.1 201 Created
Content-Length: 0
Location: /v2/entities/E11?type=ET1
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)



02. Create E12/ET1/A-AT2
========================
HTTP/1.1 201 Created
Content-Length: 0
Location: /v2/entities/E12?type=ET1
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)



03. Create E21/ET2/A-AT3
========================
HTTP/1.1 201 Created
Content-Length: 0
Location: /v2/entities/E21?type=ET2
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)



04. Create E22/ET2/A-AT4
=======================
HTTP/1.1 201 Created
Content-Length: 0
Location: /v2/entities/E22?type=ET2
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)



05. GET /v2/types and get AT1 and AT2 attribute types in ET1 and AT3 and AT4 in ET2
===================================================================================
HTTP/1.1 200 OK
Content-Length: 127
Content-Type: application/json
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

[
{
"attrs": {
"A": {
"types": [
"AT1",
"AT2"
]
}
},
"count": 2,
"type": "ET1"
},
{
"attrs": {
"A": {
"types": [
"AT3",
"AT4"
]
}
},
"count": 2,
"type": "ET2"
}
]


06. GET /v2/types/ET1 and get AT1 and AT2 attribute types
=========================================================
HTTP/1.1 200 OK
Content-Length: 49
Content-Type: application/json
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"attrs": {
"A": {
"types": [
"AT1",
"AT2"
]
}
},
"count": 2
}


--TEARDOWN--
brokerStop CB
dbDrop CB

0 comments on commit 7b45e6e

Please sign in to comment.