From b984341e4db28fdb27ab4f3c6ef3949ca86581b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Tue, 13 Aug 2024 12:27:26 +0200 Subject: [PATCH] REMOVE Restriction class --- src/lib/apiTypesV2/Subscription.cpp | 8 +- src/lib/apiTypesV2/Subscription.h | 4 +- src/lib/jsonParseV2/parseSubscription.cpp | 2 +- src/lib/mongoBackend/MongoGlobal.cpp | 7 +- src/lib/mongoBackend/MongoGlobal.h | 3 +- .../mongoBackend/mongoCreateSubscription.cpp | 12 +-- src/lib/mongoBackend/mongoQueryContext.cpp | 2 +- .../mongoBackend/mongoUpdateSubscription.cpp | 12 +-- src/lib/ngsi/CMakeLists.txt | 2 - src/lib/ngsi/ResponseData.h | 50 ---------- src/lib/ngsi/Restriction.cpp | 93 ------------------- src/lib/ngsi/Restriction.h | 50 ---------- src/lib/ngsi10/QueryContextRequest.cpp | 16 +--- src/lib/ngsi10/QueryContextRequest.h | 6 +- src/lib/rest/RestService.cpp | 40 +++----- src/lib/serviceRoutinesV2/getEntities.cpp | 6 +- test/unittests/CMakeLists.txt | 1 - .../cache/SubscriptionCache_test.cpp | 1 - test/unittests/ngsi/Restriction_test.cpp | 62 ------------- 19 files changed, 48 insertions(+), 329 deletions(-) delete mode 100644 src/lib/ngsi/ResponseData.h delete mode 100644 src/lib/ngsi/Restriction.cpp delete mode 100644 src/lib/ngsi/Restriction.h delete mode 100644 test/unittests/ngsi/Restriction_test.cpp diff --git a/src/lib/apiTypesV2/Subscription.cpp b/src/lib/apiTypesV2/Subscription.cpp index c5bdbe9fc8..38d6ba2768 100644 --- a/src/lib/apiTypesV2/Subscription.cpp +++ b/src/lib/apiTypesV2/Subscription.cpp @@ -103,16 +103,16 @@ namespace ngsiv2 */ Subscription::~Subscription() { - unsigned int sz = restriction.scopeVector.size(); + unsigned int sz = scopeVector.size(); if (sz > 0) { for (unsigned i = 0; i != sz; i++ ) { - restriction.scopeVector[i]->release(); - delete restriction.scopeVector[i]; + scopeVector[i]->release(); + delete scopeVector[i]; } - restriction.scopeVector.vec.clear(); + scopeVector.vec.clear(); } } diff --git a/src/lib/apiTypesV2/Subscription.h b/src/lib/apiTypesV2/Subscription.h index f84ae04573..8bd25dfee0 100644 --- a/src/lib/apiTypesV2/Subscription.h +++ b/src/lib/apiTypesV2/Subscription.h @@ -32,7 +32,7 @@ #include "apiTypesV2/HttpInfo.h" #include "apiTypesV2/MqttInfo.h" #include "apiTypesV2/SubscriptionExpression.h" -#include "ngsi/Restriction.h" +#include "ngsi/ScopeVector.h" #include "common/RenderFormat.h" namespace ngsiv2 @@ -159,7 +159,7 @@ class Subscription Notification notification; long long throttling; RenderFormat attrsFormat; - Restriction restriction; + ScopeVector scopeVector; std::string toJson(); void release(); diff --git a/src/lib/jsonParseV2/parseSubscription.cpp b/src/lib/jsonParseV2/parseSubscription.cpp index 77269af0aa..4d5f807000 100644 --- a/src/lib/jsonParseV2/parseSubscription.cpp +++ b/src/lib/jsonParseV2/parseSubscription.cpp @@ -1330,7 +1330,7 @@ static std::string parseNotifyConditionVector // Expression if (condition.HasMember("expression")) { - std::string r = parseExpression(condition["expression"], &subsP->restriction.scopeVector, subsP); + std::string r = parseExpression(condition["expression"], &subsP->scopeVector, subsP); if (r != "OK") { diff --git a/src/lib/mongoBackend/MongoGlobal.cpp b/src/lib/mongoBackend/MongoGlobal.cpp index 0fa56dfb02..d55b548eb7 100644 --- a/src/lib/mongoBackend/MongoGlobal.cpp +++ b/src/lib/mongoBackend/MongoGlobal.cpp @@ -49,7 +49,6 @@ #include "ngsi/EntityIdVector.h" #include "ngsi/StringList.h" #include "ngsi/ContextElementResponseVector.h" -#include "ngsi/Restriction.h" #include "ngsiNotify/Notifier.h" #include "rest/StringFilter.h" #include "apiTypesV2/Subscription.h" @@ -1252,7 +1251,7 @@ bool entitiesQuery ( const EntityIdVector& enV, const StringList& attrL, - const Restriction& res, + const ScopeVector& spV, ContextElementResponseVector* cerV, std::string* err, const std::string& tenant, @@ -1350,9 +1349,9 @@ bool entitiesQuery std::vector filters; unsigned int geoScopes = 0; - for (unsigned int ix = 0; ix < res.scopeVector.size(); ++ix) + for (unsigned int ix = 0; ix < spV.size(); ++ix) { - const Scope* scopeP = res.scopeVector[ix]; + const Scope* scopeP = spV[ix]; if (scopeP->type.find(SCOPE_FILTER) == 0) { diff --git a/src/lib/mongoBackend/MongoGlobal.h b/src/lib/mongoBackend/MongoGlobal.h index e6c2b687f2..be3fcf147e 100644 --- a/src/lib/mongoBackend/MongoGlobal.h +++ b/src/lib/mongoBackend/MongoGlobal.h @@ -41,7 +41,6 @@ #include "ngsi/StringList.h" #include "ngsi/ContextElementResponseVector.h" #include "ngsi/ContextRegistrationResponseVector.h" -#include "ngsi/Restriction.h" #include "ngsi10/UpdateContextResponse.h" #include "ngsiNotify/Notifier.h" #include "rest/uriParamNames.h" @@ -215,7 +214,7 @@ extern bool entitiesQuery ( const EntityIdVector& enV, const StringList& attrL, - const Restriction& res, + const ScopeVector& spV, ContextElementResponseVector* cerV, std::string* err, const std::string& tenant, diff --git a/src/lib/mongoBackend/mongoCreateSubscription.cpp b/src/lib/mongoBackend/mongoCreateSubscription.cpp index d5579884bb..24951d65be 100644 --- a/src/lib/mongoBackend/mongoCreateSubscription.cpp +++ b/src/lib/mongoBackend/mongoCreateSubscription.cpp @@ -68,22 +68,22 @@ static void insertInCache // // StringFilter in Scope? // - // Any Scope of type SCOPE_TYPE_SIMPLE_QUERY sub.restriction.scopeVector? + // Any Scope of type SCOPE_TYPE_SIMPLE_QUERY sub.scopeVector? // If so, set it as string filter to the sub-cache item // StringFilter* stringFilterP = NULL; StringFilter* mdStringFilterP = NULL; - for (unsigned int ix = 0; ix < sub.restriction.scopeVector.size(); ++ix) + for (unsigned int ix = 0; ix < sub.scopeVector.size(); ++ix) { - if (sub.restriction.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY) + if (sub.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY) { - stringFilterP = sub.restriction.scopeVector[ix]->stringFilterP; + stringFilterP = sub.scopeVector[ix]->stringFilterP; } - if (sub.restriction.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY_MD) + if (sub.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY_MD) { - mdStringFilterP = sub.restriction.scopeVector[ix]->mdStringFilterP; + mdStringFilterP = sub.scopeVector[ix]->mdStringFilterP; } } diff --git a/src/lib/mongoBackend/mongoQueryContext.cpp b/src/lib/mongoBackend/mongoQueryContext.cpp index f85ec7a00a..3843932334 100644 --- a/src/lib/mongoBackend/mongoQueryContext.cpp +++ b/src/lib/mongoBackend/mongoQueryContext.cpp @@ -352,7 +352,7 @@ HttpStatusCode mongoQueryContext ok = entitiesQuery(requestP->entityIdVector, requestP->attributeList, - requestP->restriction, + requestP->scopeVector, &rawCerV, &err, tenant, diff --git a/src/lib/mongoBackend/mongoUpdateSubscription.cpp b/src/lib/mongoBackend/mongoUpdateSubscription.cpp index 134a9910e4..15c40b7a45 100644 --- a/src/lib/mongoBackend/mongoUpdateSubscription.cpp +++ b/src/lib/mongoBackend/mongoUpdateSubscription.cpp @@ -149,22 +149,22 @@ static void updateInCache // // StringFilter in Scope? // - // Any Scope of type SCOPE_TYPE_SIMPLE_QUERY in subUp.restriction.scopeVector? + // Any Scope of type SCOPE_TYPE_SIMPLE_QUERY in subUp.scopeVector? // If so, set it as string filter to the sub-cache item // StringFilter* stringFilterP = NULL; StringFilter* mdStringFilterP = NULL; - for (unsigned int ix = 0; ix < subUp.restriction.scopeVector.size(); ++ix) + for (unsigned int ix = 0; ix < subUp.scopeVector.size(); ++ix) { - if (subUp.restriction.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY) + if (subUp.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY) { - stringFilterP = subUp.restriction.scopeVector[ix]->stringFilterP; + stringFilterP = subUp.scopeVector[ix]->stringFilterP; } - if (subUp.restriction.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY_MD) + if (subUp.scopeVector[ix]->type == SCOPE_TYPE_SIMPLE_QUERY_MD) { - mdStringFilterP = subUp.restriction.scopeVector[ix]->mdStringFilterP; + mdStringFilterP = subUp.scopeVector[ix]->mdStringFilterP; } } diff --git a/src/lib/ngsi/CMakeLists.txt b/src/lib/ngsi/CMakeLists.txt index 951407f005..12147c28b7 100644 --- a/src/lib/ngsi/CMakeLists.txt +++ b/src/lib/ngsi/CMakeLists.txt @@ -36,7 +36,6 @@ SET (SOURCES MetadataVector.cpp ProvidingApplication.cpp Request.cpp - Restriction.cpp Scope.cpp ScopeVector.cpp StatusCode.cpp @@ -58,7 +57,6 @@ SET (HEADERS Metadata.h MetadataVector.h ProvidingApplication.h - Restriction.h Scope.h StatusCode.h StringList.h diff --git a/src/lib/ngsi/ResponseData.h b/src/lib/ngsi/ResponseData.h deleted file mode 100644 index 11ded6afaf..0000000000 --- a/src/lib/ngsi/ResponseData.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SRC_LIB_NGSI_RESPONSEDATA_H_ -#define SRC_LIB_NGSI_RESPONSEDATA_H_ - -/* -* -* Copyright 2013 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 -* -* Author: Ken Zangelin -*/ -#include - -#include "ngsi/EntityId.h" -#include "ngsi/ContextRegistrationAttribute.h" -#include "ngsi/Metadata.h" - -#include "ngsi10/SubscribeContextResponse.h" -#include "ngsi10/QueryContextResponse.h" -#include "ngsi10/UpdateContextResponse.h" - - - -/* **************************************************************************** -* -* ResponseData - -*/ -typedef struct ResponseData -{ - QueryContextResponse qcr; - UpdateContextResponse upcr; -} ResponseData; - -#endif // SRC_LIB_NGSI_RESPONSEDATA_H_ diff --git a/src/lib/ngsi/Restriction.cpp b/src/lib/ngsi/Restriction.cpp deleted file mode 100644 index 4ffd80ebca..0000000000 --- a/src/lib/ngsi/Restriction.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -* -* Copyright 2013 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 -* -* Author: Ken Zangelin -*/ -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "alarmMgr/alarmMgr.h" -#include "ngsi/Request.h" -#include "ngsi/Restriction.h" - - - -/* **************************************************************************** -* -* Restriction::check - -*/ -std::string Restriction::check(int counter) -{ - std::string res; - - LM_T(LmtRestriction, ("In Restriction::check")); - if (counter == 0) // Restriction is always optional - { - LM_T(LmtRestriction, ("Restriction::check returns OK (counter == 0)")); - return "OK"; - } - - if (scopeVector.size() == 0) - { - alarmMgr.badInput(clientIp, "empty restriction"); - return "empty restriction"; - } - - if ((res = scopeVector.check()) != "OK") - { - LM_T(LmtRestriction, ("Restriction::check returns '%s'", res.c_str())); - alarmMgr.badInput(clientIp, res); - - return res; - } - - LM_T(LmtRestriction, ("Restriction::check returns OK (2)")); - return "OK"; -} - - - -/* **************************************************************************** -* -* Restriction::release - -*/ -void Restriction::release(void) -{ - scopeVector.release(); -} - - - -/* **************************************************************************** -* -* Restriction::fill - -*/ -void Restriction::fill(Restriction* rP) -{ - for (unsigned int ix = 0; ix < rP->scopeVector.size(); ++ix) - { - scopeVector.push_back(new Scope(rP->scopeVector[ix]->type, rP->scopeVector[ix]->value, rP->scopeVector[ix]->oper)); - } -} diff --git a/src/lib/ngsi/Restriction.h b/src/lib/ngsi/Restriction.h deleted file mode 100644 index ddf4398d12..0000000000 --- a/src/lib/ngsi/Restriction.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SRC_LIB_NGSI_RESTRICTION_H_ -#define SRC_LIB_NGSI_RESTRICTION_H_ - -/* -* -* Copyright 2013 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 -* -* Author: Ken Zangelin -*/ -#include -#include - -#include "ngsi/Request.h" -#include "ngsi/ScopeVector.h" - - - -/* **************************************************************************** -* -* Restriction - -*/ -typedef struct Restriction -{ - ScopeVector scopeVector; // Optional - - void release(); - void fill(Restriction* rP); - - std::string check(int counter); -} Restriction; - -#endif // SRC_LIB_NGSI_RESTRICTION_H_ diff --git a/src/lib/ngsi10/QueryContextRequest.cpp b/src/lib/ngsi10/QueryContextRequest.cpp index 173b41a4a0..6d4d3dbba4 100644 --- a/src/lib/ngsi10/QueryContextRequest.cpp +++ b/src/lib/ngsi10/QueryContextRequest.cpp @@ -32,7 +32,6 @@ #include "ngsi/Request.h" #include "ngsi/StringList.h" #include "ngsi/EntityIdVector.h" -#include "ngsi/Restriction.h" #include "ngsi10/QueryContextResponse.h" #include "ngsi10/QueryContextRequest.h" #include "rest/EntityTypeInfo.h" @@ -44,12 +43,9 @@ * * QueryContextRequest::QueryContextRequest * -* Explicit constructor needed to initialize primitive types so they don't get -* random values from the stack */ QueryContextRequest::QueryContextRequest() { - restrictions = 0; } @@ -69,8 +65,6 @@ QueryContextRequest::QueryContextRequest(const std::string& _contextProvider, En { attributeList.push_back(attributeName); } - - restrictions = 0; } @@ -87,8 +81,6 @@ QueryContextRequest::QueryContextRequest(const std::string& _contextProvider, En entityIdVector.push_back(new EntityId(eP)); attributeList.clone(_attributeList); - - restrictions = 0; } @@ -169,7 +161,7 @@ std::string QueryContextRequest::toJsonV1(void) void QueryContextRequest::release(void) { entityIdVector.release(); - restriction.release(); + scopeVector.release(); } @@ -215,7 +207,7 @@ void QueryContextRequest::fill scopeP->oper = (typeInfo == EntityTypeEmpty)? SCOPE_OPERATOR_NOT : ""; - restriction.scopeVector.push_back(scopeP); + scopeVector.push_back(scopeP); } if (!attributeName.empty()) @@ -251,6 +243,6 @@ void QueryContextRequest::fill(BatchQuery* bqP) attributeList.fill(bqP->attributeV.stringV); // attributeV is deprecated attrsList.fill(bqP->attrsV.stringV); metadataList.fill(bqP->metadataV.stringV); - restriction.scopeVector.fill(bqP->scopeV, false); // false: DO NOT ALLOCATE NEW scopes - reference the 'old' ones - bqP->scopeV.vec.clear(); // QueryContextRequest::restriction.scopeVector has taken over the Scopes from bqP + scopeVector.fill(bqP->scopeV, false); // false: DO NOT ALLOCATE NEW scopes - reference the 'old' ones + bqP->scopeV.vec.clear(); // QueryContextRequest::scopeVector has taken over the Scopes from bqP } diff --git a/src/lib/ngsi10/QueryContextRequest.h b/src/lib/ngsi10/QueryContextRequest.h index 737151c40d..2e960eff42 100644 --- a/src/lib/ngsi10/QueryContextRequest.h +++ b/src/lib/ngsi10/QueryContextRequest.h @@ -30,7 +30,7 @@ #include "ngsi/Request.h" #include "ngsi/StringList.h" #include "ngsi/EntityIdVector.h" -#include "ngsi/Restriction.h" +#include "ngsi/ScopeVector.h" #include "rest/EntityTypeInfo.h" @@ -54,9 +54,9 @@ typedef struct QueryContextRequest EntityIdVector entityIdVector; // Mandatory StringList attributeList; // Optional StringList attrsList; // Used by the NGSIv2 forwarding logic, to avoid over-querying attributes (see pruneContextElements) - Restriction restriction; // Optional + ScopeVector scopeVector; // Optional - int restrictions; + //int restrictions; StringList metadataList; // From URI param 'metadata' std::string contextProvider; // Not part of the payload - used internally only ProviderFormat providerFormat; // Not part of the payload - used internally only diff --git a/src/lib/rest/RestService.cpp b/src/lib/rest/RestService.cpp index 16c0227797..a86f44be7f 100644 --- a/src/lib/rest/RestService.cpp +++ b/src/lib/rest/RestService.cpp @@ -264,11 +264,11 @@ static void commonFilters // if (ciP->uriParam[URI_PARAM_NOT_EXIST] == SCOPE_VALUE_ENTITY_TYPE) { - Restriction* restrictionP = &parseDataP->qcr.res.restriction; + ScopeVector* scopeVectorP = &parseDataP->qcr.res.scopeVector; - if (restrictionP == NULL) + if (scopeVectorP == NULL) { - // The restrictionP-lookup is MISSING (not implemented + // The scopeVectorP-lookup is MISSING (not implemented // We just silently return. // return; @@ -276,7 +276,7 @@ static void commonFilters Scope* scopeP = new Scope(SCOPE_FILTER_EXISTENCE, SCOPE_VALUE_ENTITY_TYPE); scopeP->oper = SCOPE_OPERATOR_NOT; - restrictionP->scopeVector.push_back(scopeP); + scopeVectorP->push_back(scopeP); } @@ -286,11 +286,11 @@ static void commonFilters // if (ciP->uriParam[URI_PARAM_EXIST] == SCOPE_VALUE_ENTITY_TYPE) { - Restriction* restrictionP = &parseDataP->qcr.res.restriction; + ScopeVector* scopeVectorP = &parseDataP->qcr.res.scopeVector; - if (restrictionP == NULL) + if (scopeVectorP == NULL) { - // The restrictionP-lookup is MISSING (not implemented) + // The scopeVectorP-lookup is MISSING (not implemented) // We just silently return. // return; @@ -298,7 +298,7 @@ static void commonFilters Scope* scopeP = new Scope(SCOPE_FILTER_EXISTENCE, SCOPE_VALUE_ENTITY_TYPE); scopeP->oper = ""; - restrictionP->scopeVector.push_back(scopeP); + scopeVectorP->push_back(scopeP); } } @@ -315,11 +315,11 @@ static void scopeFilter RestService* serviceP ) { - Restriction* restrictionP = &parseDataP->qcr.res.restriction; + ScopeVector* scopeVectorP = &parseDataP->qcr.res.scopeVector; - for (unsigned int ix = 0; ix < restrictionP->scopeVector.size(); ++ix) + for (unsigned int ix = 0; ix < scopeVectorP->size(); ++ix) { - Scope* scopeP = restrictionP->scopeVector[ix]; + Scope* scopeP = (*scopeVectorP)[ix]; if (scopeP->type == SCOPE_FILTER_NOT_EXISTENCE) { @@ -337,23 +337,11 @@ static void scopeFilter */ static void filterRelease(ParseData* parseDataP, RequestType request) { - Restriction* restrictionP = NULL; + ScopeVector* scopeVectorP = &parseDataP->qcr.res.scopeVector; -#if 0 - if (request == EntityTypes) + if (scopeVectorP != NULL) { - restrictionP = &parseDataP->qcr.res.restriction; - } - else if (request == AllContextEntities) - { - restrictionP = &parseDataP->qcr.res.restriction; - } -#endif - restrictionP = &parseDataP->qcr.res.restriction; - - if (restrictionP != NULL) - { - restrictionP->release(); + scopeVectorP->release(); } } diff --git a/src/lib/serviceRoutinesV2/getEntities.cpp b/src/lib/serviceRoutinesV2/getEntities.cpp index 7bd1f1cc22..11e0149052 100644 --- a/src/lib/serviceRoutinesV2/getEntities.cpp +++ b/src/lib/serviceRoutinesV2/getEntities.cpp @@ -197,7 +197,7 @@ std::string getEntities return out; } - parseDataP->qcr.res.restriction.scopeVector.push_back(scopeP); + parseDataP->qcr.res.scopeVector.push_back(scopeP); } @@ -227,7 +227,7 @@ std::string getEntities return out; } - parseDataP->qcr.res.restriction.scopeVector.push_back(scopeP); + parseDataP->qcr.res.scopeVector.push_back(scopeP); } @@ -256,7 +256,7 @@ std::string getEntities return out; } - parseDataP->qcr.res.restriction.scopeVector.push_back(scopeP); + parseDataP->qcr.res.scopeVector.push_back(scopeP); } diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index d27a6525c4..b8227369e6 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -96,7 +96,6 @@ SET (SOURCES ngsi/EntityId_test.cpp ngsi/Metadata_test.cpp ngsi/MetadataVector_test.cpp - ngsi/Restriction_test.cpp ngsi/Request_test.cpp ngsi/Scope_test.cpp ngsi/ScopeVector_test.cpp diff --git a/test/unittests/cache/SubscriptionCache_test.cpp b/test/unittests/cache/SubscriptionCache_test.cpp index 15a2e91599..42092f539a 100644 --- a/test/unittests/cache/SubscriptionCache_test.cpp +++ b/test/unittests/cache/SubscriptionCache_test.cpp @@ -27,7 +27,6 @@ #include "gtest/gtest.h" -#include "ngsi/Restriction.h" #include "ngsi/Reference.h" #include "ngsi/EntityId.h" #include "ngsi/ContextAttribute.h" diff --git a/test/unittests/ngsi/Restriction_test.cpp b/test/unittests/ngsi/Restriction_test.cpp deleted file mode 100644 index fbb7da599c..0000000000 --- a/test/unittests/ngsi/Restriction_test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -* -* Copyright 2013 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 -* -* Author: Ken Zangelin -*/ -#include "gtest/gtest.h" - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/Restriction.h" -#include "ngsi/Scope.h" - - - -/* **************************************************************************** -* -* check - should Restriction::check always return "OK"? -*/ -TEST(Restriction, check) -{ - Restriction restriction; - std::string checked; - std::string expected0 = "OK"; - std::string expected1 = "empty restriction"; - std::string expected2 = "Empty type in restriction scope"; - std::string expected3 = "OK"; - Scope* scopeP = new Scope("", "Value"); - - checked = restriction.check(0); - EXPECT_EQ(expected0, checked); - - checked = restriction.check(1); - EXPECT_EQ(expected1, checked); - - restriction.scopeVector.push_back(scopeP); - checked = restriction.check(1); - EXPECT_EQ(expected2, checked); - - scopeP->type = "Type"; - checked = restriction.check(1); - EXPECT_EQ(expected3, checked); -} \ No newline at end of file