From 383e668c4d5e17f0826a3f34f29f2f71fdac405c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 12 Aug 2024 19:49:30 +0200 Subject: [PATCH] REMOVE NotifyConditionVector, NotifyCondition, ConditionValueList, RestrictionString, AttributeExpression and ContextRegistrationVector --- src/lib/cache/subCache.h | 1 - src/lib/mongoBackend/MongoGlobal.cpp | 33 ----- src/lib/mongoBackend/MongoGlobal.h | 2 - src/lib/mongoBackend/mongoQueryContext.cpp | 6 - src/lib/mongoBackend/mongoUpdateContext.cpp | 1 - src/lib/ngsi/AttributeExpression.cpp | 102 ------------- src/lib/ngsi/AttributeExpression.h | 51 ------- src/lib/ngsi/CMakeLists.txt | 12 -- src/lib/ngsi/ConditionValueList.cpp | 115 --------------- src/lib/ngsi/ConditionValueList.h | 56 ------- src/lib/ngsi/ContextRegistrationVector.cpp | 113 -------------- src/lib/ngsi/ContextRegistrationVector.h | 55 ------- src/lib/ngsi/NotifyCondition.cpp | 110 -------------- src/lib/ngsi/NotifyCondition.h | 58 -------- src/lib/ngsi/NotifyConditionVector.cpp | 138 ------------------ src/lib/ngsi/NotifyConditionVector.h | 58 -------- src/lib/ngsi/ParseData.h | 1 - src/lib/ngsi/Restriction.cpp | 9 +- src/lib/ngsi/Restriction.h | 2 - src/lib/ngsi/RestrictionString.cpp | 87 ----------- src/lib/ngsi/RestrictionString.h | 50 ------- test/unittests/CMakeLists.txt | 5 - .../cache/SubscriptionCache_test.cpp | 1 - .../mongoSubscribeContext_test.cpp | 1 - .../mongoUpdateContextSubscription_test.cpp | 1 - .../ngsi/AttributeExpression_test.cpp | 51 ------- .../ngsi/ConditionValueList_test.cpp | 53 ------- .../ngsi/NotifyConditionVector_test.cpp | 100 ------------- test/unittests/ngsi/NotifyCondition_test.cpp | 73 --------- .../unittests/ngsi/RestrictionString_test.cpp | 94 ------------ 30 files changed, 2 insertions(+), 1437 deletions(-) delete mode 100644 src/lib/ngsi/AttributeExpression.cpp delete mode 100644 src/lib/ngsi/AttributeExpression.h delete mode 100644 src/lib/ngsi/ConditionValueList.cpp delete mode 100644 src/lib/ngsi/ConditionValueList.h delete mode 100644 src/lib/ngsi/ContextRegistrationVector.cpp delete mode 100644 src/lib/ngsi/ContextRegistrationVector.h delete mode 100644 src/lib/ngsi/NotifyCondition.cpp delete mode 100644 src/lib/ngsi/NotifyCondition.h delete mode 100644 src/lib/ngsi/NotifyConditionVector.cpp delete mode 100644 src/lib/ngsi/NotifyConditionVector.h delete mode 100644 src/lib/ngsi/RestrictionString.cpp delete mode 100644 src/lib/ngsi/RestrictionString.h delete mode 100644 test/unittests/ngsi/AttributeExpression_test.cpp delete mode 100644 test/unittests/ngsi/ConditionValueList_test.cpp delete mode 100644 test/unittests/ngsi/NotifyConditionVector_test.cpp delete mode 100644 test/unittests/ngsi/NotifyCondition_test.cpp delete mode 100644 test/unittests/ngsi/RestrictionString_test.cpp diff --git a/src/lib/cache/subCache.h b/src/lib/cache/subCache.h index d64d51eaf3..2fbff68fff 100644 --- a/src/lib/cache/subCache.h +++ b/src/lib/cache/subCache.h @@ -30,7 +30,6 @@ #include #include "common/RenderFormat.h" -#include "ngsi/NotifyConditionVector.h" #include "ngsi/EntityIdVector.h" #include "ngsi/StringList.h" #include "apiTypesV2/HttpInfo.h" diff --git a/src/lib/mongoBackend/MongoGlobal.cpp b/src/lib/mongoBackend/MongoGlobal.cpp index 9bea81b2fe..38db362801 100644 --- a/src/lib/mongoBackend/MongoGlobal.cpp +++ b/src/lib/mongoBackend/MongoGlobal.cpp @@ -2153,39 +2153,6 @@ bool registrationsQuery -/* **************************************************************************** -* -* isCondValueInContextElementResponse - -*/ -bool isCondValueInContextElementResponse(ConditionValueList* condValues, ContextElementResponseVector* cerV) -{ - /* Empty conValue means that any attribute matches (aka ONANYCHANGE) */ - if (condValues->size() == 0) - { - return true; - } - - for (unsigned int cvlx = 0; cvlx < condValues->size(); ++cvlx) - { - for (unsigned int aclx = 0; aclx < cerV->size(); ++aclx) - { - ContextAttributeVector caV = (*cerV)[aclx]->entity.attributeVector; - - for (unsigned int kx = 0; kx < caV.size(); ++kx) - { - if (caV[kx]->name == (*condValues)[cvlx]) - { - return true; - } - } - } - } - - return false; -} - - - /* **************************************************************************** * * condValueAttrMatch - diff --git a/src/lib/mongoBackend/MongoGlobal.h b/src/lib/mongoBackend/MongoGlobal.h index 0dd0deb015..e6c2b687f2 100644 --- a/src/lib/mongoBackend/MongoGlobal.h +++ b/src/lib/mongoBackend/MongoGlobal.h @@ -41,9 +41,7 @@ #include "ngsi/StringList.h" #include "ngsi/ContextElementResponseVector.h" #include "ngsi/ContextRegistrationResponseVector.h" -#include "ngsi/ConditionValueList.h" #include "ngsi/Restriction.h" -#include "ngsi/NotifyConditionVector.h" #include "ngsi10/UpdateContextResponse.h" #include "ngsiNotify/Notifier.h" #include "rest/uriParamNames.h" diff --git a/src/lib/mongoBackend/mongoQueryContext.cpp b/src/lib/mongoBackend/mongoQueryContext.cpp index 74496732b4..f85ec7a00a 100644 --- a/src/lib/mongoBackend/mongoQueryContext.cpp +++ b/src/lib/mongoBackend/mongoQueryContext.cpp @@ -342,12 +342,6 @@ HttpStatusCode mongoQueryContext LM_T(LmtMongo, ("QueryContext Request")); LM_T(LmtPagination, ("Offset: %d, Limit: %d, Count: %s", offset, limit, (countP != NULL)? "true" : "false")); - /* FIXME: restriction not supported for the moment */ - if (!requestP->restriction.attributeExpression.isEmpty()) - { - alarmMgr.badInput(clientIp, "restriction found, but restrictions are not supported by mongo backend"); - } - std::string err; bool ok; bool limitReached = false; diff --git a/src/lib/mongoBackend/mongoUpdateContext.cpp b/src/lib/mongoBackend/mongoUpdateContext.cpp index a6480dbeed..b05b892e7c 100644 --- a/src/lib/mongoBackend/mongoUpdateContext.cpp +++ b/src/lib/mongoBackend/mongoUpdateContext.cpp @@ -36,7 +36,6 @@ #include "alarmMgr/alarmMgr.h" #include "ngsi10/UpdateContextRequest.h" #include "ngsi10/UpdateContextResponse.h" -#include "ngsi/NotifyCondition.h" #include "rest/HttpStatusCode.h" #include "ngsiNotify/QueueNotifier.h" diff --git a/src/lib/ngsi/AttributeExpression.cpp b/src/lib/ngsi/AttributeExpression.cpp deleted file mode 100644 index 1149e6392b..0000000000 --- a/src/lib/ngsi/AttributeExpression.cpp +++ /dev/null @@ -1,102 +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 "ngsi/Request.h" -#include "ngsi/AttributeExpression.h" - - -/* **************************************************************************** -* -* AttributeExpression::check - -*/ -std::string AttributeExpression::check(void) -{ - return "OK"; -} - - - -/* **************************************************************************** -* -* AttributeExpression::isEmpty - -*/ -bool AttributeExpression::isEmpty(void) -{ - if (string.empty()) - { - return true; - } - - return false; -} - - - -/* **************************************************************************** -* -* AttributeExpression::set - -*/ -void AttributeExpression::set(const std::string& value) -{ - string = value; -} - - - -/* **************************************************************************** -* -* AttributeExpression::get - -*/ -std::string AttributeExpression::get(void) -{ - return string; -} - - - -/* **************************************************************************** -* -* AttributeExpression::c_str - -*/ -const char* AttributeExpression::c_str(void) -{ - return string.c_str(); -} - - - -/* **************************************************************************** -* -* AttributeExpression::release - -*/ -void AttributeExpression::release(void) -{ - /* This method is included for the sake of homogeneity */ -} diff --git a/src/lib/ngsi/AttributeExpression.h b/src/lib/ngsi/AttributeExpression.h deleted file mode 100644 index 1e38924fde..0000000000 --- a/src/lib/ngsi/AttributeExpression.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SRC_LIB_NGSI_ATTRIBUTEEXPRESSION_H_ -#define SRC_LIB_NGSI_ATTRIBUTEEXPRESSION_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/Request.h" - - - -/* **************************************************************************** -* -* AttributeExpression - -*/ -typedef struct AttributeExpression -{ - std::string string; - - void set(const std::string& value); - std::string get(void); - bool isEmpty(void); - const char* c_str(); - void release(void); - - std::string check(void); -} AttributeExpression; - -#endif // SRC_LIB_NGSI_ATTRIBUTEEXPRESSION_H_ diff --git a/src/lib/ngsi/CMakeLists.txt b/src/lib/ngsi/CMakeLists.txt index b626f11bf5..951407f005 100644 --- a/src/lib/ngsi/CMakeLists.txt +++ b/src/lib/ngsi/CMakeLists.txt @@ -21,14 +21,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) SET (SOURCES - AttributeExpression.cpp - ConditionValueList.cpp ContextAttribute.cpp ContextAttributeVector.cpp ContextElementResponse.cpp ContextElementResponseVector.cpp ContextRegistration.cpp - ContextRegistrationVector.cpp ContextRegistrationAttribute.cpp ContextRegistrationAttributeVector.cpp ContextRegistrationResponse.cpp @@ -37,12 +34,9 @@ SET (SOURCES EntityIdVector.cpp Metadata.cpp MetadataVector.cpp - NotifyCondition.cpp - NotifyConditionVector.cpp ProvidingApplication.cpp Request.cpp Restriction.cpp - RestrictionString.cpp Scope.cpp ScopeVector.cpp StatusCode.cpp @@ -50,8 +44,6 @@ SET (SOURCES ) SET (HEADERS - AttributeExpression.h - ConditionValueList.h ContextAttribute.h ContextAttributeVector.h ContextElementResponse.h @@ -59,18 +51,14 @@ SET (HEADERS ContextRegistrationAttribute.h ContextRegistrationAttributeVector.h ContextRegistration.h - ContextRegistrationVector.h ContextRegistrationResponse.h ContextRegistrationResponseVector.h EntityId.h EntityIdVector.h Metadata.h MetadataVector.h - NotifyCondition.h - NotifyConditionVector.h ProvidingApplication.h Restriction.h - RestrictionString.h Scope.h StatusCode.h StringList.h diff --git a/src/lib/ngsi/ConditionValueList.cpp b/src/lib/ngsi/ConditionValueList.cpp deleted file mode 100644 index 5c725348ef..0000000000 --- a/src/lib/ngsi/ConditionValueList.cpp +++ /dev/null @@ -1,115 +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 -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "ngsi/ConditionValueList.h" - - - -/* **************************************************************************** -* -* ConditionValueList::check - -*/ -std::string ConditionValueList::check(void) -{ - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - if (vec[ix].empty()) - { - return "empty condValue name"; - } - } - - return "OK"; -} - - - -/* **************************************************************************** -* -* ConditionValueList::release - -*/ -void ConditionValueList::release(void) -{ - vec.clear(); -} - - - -/* **************************************************************************** -* -* push_back - -*/ -void ConditionValueList::push_back(const std::string& attributeName) -{ - vec.push_back(attributeName); -} - - - -/* **************************************************************************** -* -* ConditionValueList::size - -*/ -unsigned int ConditionValueList::size(void) -{ - return vec.size(); -} - - - -/* **************************************************************************** -* -* ConditionValueList::operator -*/ -std::string ConditionValueList::operator[] (unsigned int ix) const -{ - if (ix < vec.size()) - { - return vec[ix]; - } - - return ""; -} - - - -/* **************************************************************************** -* -* ConditionValueList::fill - -*/ -void ConditionValueList::fill(ConditionValueList& list) -{ - for (unsigned int cvIx = 0; cvIx < list.size(); ++cvIx) - { - push_back(list[cvIx]); - } -} diff --git a/src/lib/ngsi/ConditionValueList.h b/src/lib/ngsi/ConditionValueList.h deleted file mode 100644 index 97b2cd92f1..0000000000 --- a/src/lib/ngsi/ConditionValueList.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef SRC_LIB_NGSI_CONDITIONVALUELIST_H_ -#define SRC_LIB_NGSI_CONDITIONVALUELIST_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/Metadata.h" -#include "ngsi/Request.h" - - - -/* **************************************************************************** -* -* ConditionValueList - -*/ -typedef struct ConditionValueList -{ - std::vector vec; - - void release(void); - void push_back(const std::string& attributeName); - unsigned int size(void); - void fill(ConditionValueList& cvlP); - - std::string check(void); - - std::string operator[] (unsigned int ix) const; - - -} ConditionValueList; - -#endif // SRC_LIB_NGSI_CONDITIONVALUELIST_H_ diff --git a/src/lib/ngsi/ContextRegistrationVector.cpp b/src/lib/ngsi/ContextRegistrationVector.cpp deleted file mode 100644 index 9e5d1307bf..0000000000 --- a/src/lib/ngsi/ContextRegistrationVector.cpp +++ /dev/null @@ -1,113 +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 - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "ngsi/ContextRegistrationVector.h" - - - -/* **************************************************************************** -* -* ContextRegistrationVector::push_back - -*/ -void ContextRegistrationVector::push_back(ContextRegistration* item) -{ - vec.push_back(item); -} - - - -/* **************************************************************************** -* -* ContextRegistrationVector::release - -*/ -void ContextRegistrationVector::release(void) -{ - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - vec[ix]->release(); - delete(vec[ix]); - } - - vec.clear(); -} - - - -/* **************************************************************************** -* -* ContextRegistrationVector::operator[] - -*/ -ContextRegistration* ContextRegistrationVector::operator[](unsigned int ix) const -{ - if (ix < vec.size()) - { - return vec[ix]; - } - return NULL; -} - - - - -/* **************************************************************************** -* -* ContextRegistrationVector::size - -*/ -unsigned int ContextRegistrationVector::size(void) -{ - return vec.size(); -} - - - -/* **************************************************************************** -* -* ContextRegistrationVector::check - -*/ -std::string ContextRegistrationVector::check -( - RequestType requestType, - const std::string& predetectedError, - int counter -) -{ - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - std::string res; - - if ((res = vec[ix]->check(requestType, predetectedError, counter)) != "OK") - { - return res; - } - } - - return "OK"; -} diff --git a/src/lib/ngsi/ContextRegistrationVector.h b/src/lib/ngsi/ContextRegistrationVector.h deleted file mode 100644 index 13e814af45..0000000000 --- a/src/lib/ngsi/ContextRegistrationVector.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SRC_LIB_NGSI_CONTEXTREGISTRATIONVECTOR_H_ -#define SRC_LIB_NGSI_CONTEXTREGISTRATIONVECTOR_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/ContextRegistration.h" - - - -/* **************************************************************************** -* -* ContextRegistrationVector - -*/ -typedef struct ContextRegistrationVector -{ - std::vector vec; - - void push_back(ContextRegistration* item); - unsigned int size(void); - void release(void); - - std::string check(RequestType requestType, - const std::string& predetectedError, - int counter); - - ContextRegistration* operator[](unsigned int ix) const; - -} ContextRegistrationVector; - -#endif // SRC_LIB_NGSI_CONTEXTREGISTRATIONVECTOR_H_ diff --git a/src/lib/ngsi/NotifyCondition.cpp b/src/lib/ngsi/NotifyCondition.cpp deleted file mode 100644 index cb9f4823c0..0000000000 --- a/src/lib/ngsi/NotifyCondition.cpp +++ /dev/null @@ -1,110 +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 -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "ngsi/Request.h" -#include "ngsi/NotifyCondition.h" - - - -/* **************************************************************************** -* -* NotifyCondition::NotifyCondition - -*/ -NotifyCondition::NotifyCondition() -{ -} - - - -/* **************************************************************************** -* -* NotifyCondition::NotifyCondition - -*/ -NotifyCondition::NotifyCondition(NotifyCondition* ncP) -{ - type = ncP->type; - condValueList.fill(ncP->condValueList); - restriction.set(ncP->restriction.get()); -} - - - -/* **************************************************************************** -* -* NotifyCondition::check - -* -* FIXME: P5 - in case of errors a formated result string should be returned ... ? -*/ -std::string NotifyCondition::check -( - RequestType requestType, - const std::string& predetectedError, - int counter -) -{ - std::string res; - - if (type.empty()) - { - return "empty type for NotifyCondition"; - } - else if (strcasecmp(type.c_str(), ON_CHANGE_CONDITION) == 0) - { - } - else - { - return std::string("invalid notify condition type: /") + type + "/"; - } - - if ((res = condValueList.check()) != "OK") - { - return res; - } - - if ((res = restriction.check()) != "OK") - { - return res; - } - - return "OK"; -} - - - -/* **************************************************************************** -* -* NotifyCondition::release - -*/ -void NotifyCondition::release(void) -{ - condValueList.release(); -} diff --git a/src/lib/ngsi/NotifyCondition.h b/src/lib/ngsi/NotifyCondition.h deleted file mode 100644 index 8c762907f5..0000000000 --- a/src/lib/ngsi/NotifyCondition.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef SRC_LIB_NGSI_NOTIFYCONDITION_H_ -#define SRC_LIB_NGSI_NOTIFYCONDITION_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/Request.h" -#include "ngsi/RestrictionString.h" -#include "ngsi/ConditionValueList.h" - -#define ON_CHANGE_CONDITION "ONCHANGE" - - - -/* **************************************************************************** -* -* NotifyCondition - -*/ -typedef struct NotifyCondition -{ - std::string type; // Mandatory - ConditionValueList condValueList; // Optional - RestrictionString restriction; // Optional - - NotifyCondition(); - NotifyCondition(NotifyCondition* ncP); - - void release(void); - - std::string check(RequestType requestType, - const std::string& predetectedError, - int counter); -} NotifyCondition; - -#endif // SRC_LIB_NGSI_NOTIFYCONDITION_H_ diff --git a/src/lib/ngsi/NotifyConditionVector.cpp b/src/lib/ngsi/NotifyConditionVector.cpp deleted file mode 100644 index 1cb9f159b4..0000000000 --- a/src/lib/ngsi/NotifyConditionVector.cpp +++ /dev/null @@ -1,138 +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 -#include - -#include "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "common/globals.h" -#include "ngsi/NotifyConditionVector.h" - - - -/* **************************************************************************** -* -* NotifyConditionVector::NotifyConditionVector - -*/ -NotifyConditionVector::NotifyConditionVector() -{ -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::check - -*/ -std::string NotifyConditionVector::check -( - RequestType requestType, - const std::string& predetectedError, - int counter -) -{ - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - std::string res; - - if ((res = vec[ix]->check(requestType, predetectedError, counter)) != "OK") - { - return res; - } - } - - return "OK"; -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::push_back - -*/ -void NotifyConditionVector::push_back(NotifyCondition* item) -{ - vec.push_back(item); -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::operator[] - -*/ -NotifyCondition* NotifyConditionVector::operator[] (unsigned int ix) const -{ - if (ix < vec.size()) - { - return vec[ix]; - } - return NULL; -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::size - -*/ -unsigned int NotifyConditionVector::size(void) const -{ - return vec.size(); -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::release - -*/ -void NotifyConditionVector::release(void) -{ - for (unsigned int ix = 0; ix < vec.size(); ++ix) - { - vec[ix]->release(); - delete vec[ix]; - } - - vec.clear(); -} - - - -/* **************************************************************************** -* -* NotifyConditionVector::fill - -*/ -void NotifyConditionVector::fill(const NotifyConditionVector& nv) -{ - for (unsigned int ncIx = 0; ncIx < nv.size(); ++ncIx) - { - NotifyCondition* ncP = new NotifyCondition(nv[ncIx]); - push_back(ncP); - } -} diff --git a/src/lib/ngsi/NotifyConditionVector.h b/src/lib/ngsi/NotifyConditionVector.h deleted file mode 100644 index 8e4489ddec..0000000000 --- a/src/lib/ngsi/NotifyConditionVector.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef SRC_LIB_NGSI_NOTIFYCONDITIONVECTOR_H_ -#define SRC_LIB_NGSI_NOTIFYCONDITIONVECTOR_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/NotifyCondition.h" - - - -/* **************************************************************************** -* -* NotifyConditionVector - -*/ -typedef struct NotifyConditionVector -{ - std::vector vec; - - NotifyConditionVector(); - - void push_back(NotifyCondition* item); - unsigned int size(void) const; - void release(void); - void fill(const NotifyConditionVector& nv); - - std::string check(RequestType requestType, - const std::string& predetectedError, - int counter); - - NotifyCondition* operator[] (unsigned int ix) const; - -} NotifyConditionVector; - -#endif // SRC_LIB_NGSI_NOTIFYCONDITIONVECTOR_H_ diff --git a/src/lib/ngsi/ParseData.h b/src/lib/ngsi/ParseData.h index e7f518101c..23f624fbca 100644 --- a/src/lib/ngsi/ParseData.h +++ b/src/lib/ngsi/ParseData.h @@ -32,7 +32,6 @@ #include "ngsi/ContextRegistrationAttribute.h" #include "ngsi/ContextElementResponse.h" #include "ngsi/Metadata.h" -#include "ngsi/NotifyCondition.h" #include "ngsi10/QueryContextRequest.h" #include "ngsi10/QueryContextResponse.h" #include "ngsi10/UpdateContextRequest.h" diff --git a/src/lib/ngsi/Restriction.cpp b/src/lib/ngsi/Restriction.cpp index dce18e66b3..4ffd80ebca 100644 --- a/src/lib/ngsi/Restriction.cpp +++ b/src/lib/ngsi/Restriction.cpp @@ -49,14 +49,13 @@ std::string Restriction::check(int counter) return "OK"; } - if ((scopeVector.size() == 0) && (attributeExpression.isEmpty())) + if (scopeVector.size() == 0) { alarmMgr.badInput(clientIp, "empty restriction"); return "empty restriction"; } - if (((res = scopeVector.check()) != "OK") || - ((res = attributeExpression.check()) != "OK")) + if ((res = scopeVector.check()) != "OK") { LM_T(LmtRestriction, ("Restriction::check returns '%s'", res.c_str())); alarmMgr.badInput(clientIp, res); @@ -76,7 +75,6 @@ std::string Restriction::check(int counter) */ void Restriction::release(void) { - attributeExpression.release(); scopeVector.release(); } @@ -88,9 +86,6 @@ void Restriction::release(void) */ void Restriction::fill(Restriction* rP) { - const std::string ae = rP->attributeExpression.get(); - attributeExpression.set(ae); - 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 index cef97233ee..ddf4398d12 100644 --- a/src/lib/ngsi/Restriction.h +++ b/src/lib/ngsi/Restriction.h @@ -29,7 +29,6 @@ #include #include "ngsi/Request.h" -#include "ngsi/AttributeExpression.h" #include "ngsi/ScopeVector.h" @@ -40,7 +39,6 @@ */ typedef struct Restriction { - AttributeExpression attributeExpression; // Optional (FI-WARE changes - MANDATORY in OMA spec) ScopeVector scopeVector; // Optional void release(); diff --git a/src/lib/ngsi/RestrictionString.cpp b/src/lib/ngsi/RestrictionString.cpp deleted file mode 100644 index 6cc7c03886..0000000000 --- a/src/lib/ngsi/RestrictionString.cpp +++ /dev/null @@ -1,87 +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 "ngsi/Request.h" -#include "ngsi/RestrictionString.h" - - - -/* **************************************************************************** -* -* RestrictionString::check - -*/ -std::string RestrictionString::check(void) -{ - return "OK"; -} - - - -/* **************************************************************************** -* -* RestrictionString::isEmpty - -*/ -bool RestrictionString::isEmpty(void) -{ - return (string.empty())? true : false; -} - - - -/* **************************************************************************** -* -* RestrictionString::set - -*/ -void RestrictionString::set(const std::string& value) -{ - string = value; -} - - - -/* **************************************************************************** -* -* RestrictionString::get - -*/ -std::string RestrictionString::get(void) -{ - return string; -} - - - -/* **************************************************************************** -* -* RestrictionString::c_str - -*/ -const char* RestrictionString::c_str(void) -{ - return string.c_str(); -} diff --git a/src/lib/ngsi/RestrictionString.h b/src/lib/ngsi/RestrictionString.h deleted file mode 100644 index f5c5fd3005..0000000000 --- a/src/lib/ngsi/RestrictionString.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SRC_LIB_NGSI_RESTRICTIONSTRING_H_ -#define SRC_LIB_NGSI_RESTRICTIONSTRING_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/Request.h" - - - -/* **************************************************************************** -* -* RestrictionString - -*/ -typedef struct RestrictionString -{ - std::string string; - - void set(const std::string& value); - std::string get(void); - bool isEmpty(void); - const char* c_str(); - - std::string check(void); -} RestrictionString; - -#endif // SRC_LIB_NGSI_RESTRICTIONSTRING_H_ diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index 2a32f1bcae..d27a6525c4 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -87,22 +87,17 @@ SET (SOURCES ngsi10/NotifyContextRequest_test.cpp ngsi/ContextAttribute_test.cpp - ngsi/NotifyCondition_test.cpp ngsi/AttributeList_test.cpp - ngsi/ConditionValueList_test.cpp ngsi/ContextElementResponse_test.cpp ngsi/ContextElementResponseVector_test.cpp ngsi/ProvidingApplication_test.cpp - ngsi/AttributeExpression_test.cpp ngsi/ContextRegistrationResponse_test.cpp ngsi/ContextRegistrationResponseVector_test.cpp ngsi/EntityId_test.cpp ngsi/Metadata_test.cpp ngsi/MetadataVector_test.cpp - ngsi/NotifyConditionVector_test.cpp ngsi/Restriction_test.cpp ngsi/Request_test.cpp - ngsi/RestrictionString_test.cpp ngsi/Scope_test.cpp ngsi/ScopeVector_test.cpp ngsi/StatusCode_test.cpp diff --git a/test/unittests/cache/SubscriptionCache_test.cpp b/test/unittests/cache/SubscriptionCache_test.cpp index 11a2777836..15a2e91599 100644 --- a/test/unittests/cache/SubscriptionCache_test.cpp +++ b/test/unittests/cache/SubscriptionCache_test.cpp @@ -29,7 +29,6 @@ #include "ngsi/Restriction.h" #include "ngsi/Reference.h" -#include "ngsi/NotifyConditionVector.h" #include "ngsi/EntityId.h" #include "ngsi/ContextAttribute.h" #include "cache/SubscriptionCache.h" diff --git a/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp b/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp index 314969b4d3..cdefab9e58 100644 --- a/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp +++ b/test/unittests/mongoBackend/mongoSubscribeContext_test.cpp @@ -36,7 +36,6 @@ #include "ngsi10/SubscribeContextResponse.h" #include "ngsi/EntityId.h" -#include "ngsi/NotifyCondition.h" #include "apiTypesV2/HttpInfo.h" #include "mongo/client/dbclient.h" diff --git a/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp b/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp index 6e26762847..6fa0421dfb 100644 --- a/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp +++ b/test/unittests/mongoBackend/mongoUpdateContextSubscription_test.cpp @@ -37,7 +37,6 @@ #include "ngsi10/UpdateContextSubscriptionRequest.h" #include "ngsi10/UpdateContextSubscriptionResponse.h" #include "ngsi/EntityId.h" -#include "ngsi/NotifyCondition.h" #include "unittests/testInit.h" #include "unittests/unittest.h" diff --git a/test/unittests/ngsi/AttributeExpression_test.cpp b/test/unittests/ngsi/AttributeExpression_test.cpp deleted file mode 100644 index 48a99fe5fe..0000000000 --- a/test/unittests/ngsi/AttributeExpression_test.cpp +++ /dev/null @@ -1,51 +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 "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/AttributeExpression.h" - -#include "unittest.h" - - - -/* **************************************************************************** -* -* ok - -*/ -TEST(AttributeExpression, ok) -{ - AttributeExpression ae; - std::string out; - - utInit(); - - ae.set("AE"); - EXPECT_STREQ("AE", ae.get().c_str()); - - EXPECT_STREQ("AE", ae.c_str()); - - utExit(); -} diff --git a/test/unittests/ngsi/ConditionValueList_test.cpp b/test/unittests/ngsi/ConditionValueList_test.cpp deleted file mode 100644 index 7f7dcd6c13..0000000000 --- a/test/unittests/ngsi/ConditionValueList_test.cpp +++ /dev/null @@ -1,53 +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 "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" -#include "ngsi/ConditionValueList.h" - -#include "unittest.h" - - - -/* **************************************************************************** -* -* ok - -*/ -TEST(ConditionValueList, ok) -{ - ConditionValueList cvList; - std::string out; - - cvList.push_back("cv1"); - - out = cvList.check(); - EXPECT_STREQ("OK", out.c_str()); - - cvList.push_back(""); - out = cvList.check(); - EXPECT_STREQ("empty condValue name", out.c_str()); - - cvList.release(); - EXPECT_EQ(0, cvList.size()); -} diff --git a/test/unittests/ngsi/NotifyConditionVector_test.cpp b/test/unittests/ngsi/NotifyConditionVector_test.cpp deleted file mode 100644 index 4612f4eabe..0000000000 --- a/test/unittests/ngsi/NotifyConditionVector_test.cpp +++ /dev/null @@ -1,100 +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 "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/NotifyConditionVector.h" - -#include "unittest.h" - - - -/* **************************************************************************** -* -* check - -*/ -TEST(NotifyConditionVector, check) -{ - NotifyCondition nc; - NotifyConditionVector ncV; - std::string checked; - std::string expected2 = "invalid notify condition type: /Type/"; - std::string expected3 = "empty type for NotifyCondition"; - - utInit(); - - checked = ncV.check(BatchUpdateRequest, "", 0); - EXPECT_STREQ("OK", checked.c_str()); - - nc.type = "Type"; - ncV.push_back(&nc); - - checked = ncV.check(BatchUpdateRequest, "", 0); - EXPECT_STREQ(expected2.c_str(), checked.c_str()); - - nc.type = ""; - checked = ncV.check(BatchUpdateRequest, "", 0); - EXPECT_STREQ(expected3.c_str(), checked.c_str()); - - utExit(); -} - - - -/* **************************************************************************** -* -* get - -*/ -TEST(NotifyConditionVector, get) -{ - NotifyCondition nc0; - NotifyCondition nc1; - NotifyCondition nc2; - NotifyConditionVector ncV; - NotifyCondition* ncP; - - utInit(); - - nc0.type = "Type0"; - nc1.type = "Type1"; - nc2.type = "Type2"; - - ncV.push_back(&nc0); - ncV.push_back(&nc1); - ncV.push_back(&nc2); - - ncP = ncV[0]; - EXPECT_STREQ("Type0", ncP->type.c_str()); - - ncP = ncV[1]; - EXPECT_STREQ("Type1", ncP->type.c_str()); - - ncP = ncV[2]; - EXPECT_STREQ("Type2", ncP->type.c_str()); - - EXPECT_EQ(3, ncV.size()); - - utExit(); -} diff --git a/test/unittests/ngsi/NotifyCondition_test.cpp b/test/unittests/ngsi/NotifyCondition_test.cpp deleted file mode 100644 index 14b7d8b079..0000000000 --- a/test/unittests/ngsi/NotifyCondition_test.cpp +++ /dev/null @@ -1,73 +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 "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/NotifyCondition.h" - -#include "unittest.h" - - - -/* **************************************************************************** -* -* Creation - -*/ -TEST(NotifyCondition, Creation) -{ - NotifyCondition nc; - - utInit(); - - nc.restriction.set("Hola"); - EXPECT_TRUE(nc.restriction.get() == "Hola"); - - utExit(); -} - - - -/* **************************************************************************** -* -* check - -*/ -TEST(NotifyCondition, check) -{ - NotifyCondition nc; - std::string checked; - - utInit(); - - checked = nc.check(BatchUpdateRequest, "", 0); - EXPECT_STREQ("empty type for NotifyCondition", checked.c_str()); - - nc.type = "XXX"; - checked = nc.check(BatchUpdateRequest, "", 0); - EXPECT_STREQ("invalid notify condition type: /XXX/", checked.c_str()); - - nc.release(); - - utExit(); -} diff --git a/test/unittests/ngsi/RestrictionString_test.cpp b/test/unittests/ngsi/RestrictionString_test.cpp deleted file mode 100644 index 86a4c4923a..0000000000 --- a/test/unittests/ngsi/RestrictionString_test.cpp +++ /dev/null @@ -1,94 +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 "logMsg/logMsg.h" -#include "logMsg/traceLevels.h" - -#include "ngsi/RestrictionString.h" - -#include "unittest.h" - - -/* **************************************************************************** -* -* check - should RestrictionString::check always return "OK"? -*/ -TEST(RestrictionString, check) -{ - RestrictionString restrictionString; - std::string checked; - - utInit(); - - checked = restrictionString.check(); - EXPECT_STREQ("OK", checked.c_str()); - - restrictionString.string = "String"; - - checked = restrictionString.check(); - EXPECT_STREQ("OK", checked.c_str()); - - utExit(); -} - - - -/* **************************************************************************** -* -* isEmptSetAndGet - -*/ -TEST(RestrictionString, isEmptySetAndGet) -{ - RestrictionString restrictionString; - - utInit(); - - restrictionString.string = ""; - EXPECT_TRUE(restrictionString.isEmpty()); - - restrictionString.set("STR"); - EXPECT_FALSE(restrictionString.isEmpty()); - - EXPECT_STREQ("STR", restrictionString.get().c_str()); - - utExit(); -} - - - -/* **************************************************************************** -* -* c_str - -*/ -TEST(RestrictionString, c_str) -{ - RestrictionString restrictionString; - - utInit(); - - restrictionString.set("STR"); - EXPECT_STREQ("STR", restrictionString.c_str()); - - utExit(); -}