1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "UnitTestHelper.h"
22 #include "MaintenanceCollection.h"
23 #include "ConfigurationCollection.h"
24 #include "FactorySetCollection.h"
27 #include "ActionSet.h"
28 #include "GroupManager.h"
29 #include "ThingsConfiguration.h"
30 #include "ThingsMaintenance.h"
32 #include "OCPlatform.h"
38 #include <condition_variable>
40 #define SUCCESS_RESPONSE 0
41 constexpr int DEFAULT_WAITING_TIME_IN_MILLIS = 3000;
46 namespace PH = std::placeholders;
49 bool isSlowResponse = false;
51 std::string defaultDeviceName = "Legacy Device";
52 std::string defaultLocation = "37.256616, 127.052806";
53 std::string defaultLocationName = "Living Room";
54 std::string defaultRegion = "Won";
55 std::string defaultCurrency = "Seoul, Korea";
57 OCResourceHandle resourceHandle;
58 OCResourceHandle foundResourceHandle;
60 std::shared_ptr< OCResource > g_resource;
61 std::shared_ptr< OCResource > g_room_resource;
62 std::shared_ptr< OCResource > g_light;
63 std::shared_ptr< OCResource > configurationResource;
64 std::vector< string > lights;
65 std::vector< OCResourceHandle > resourceHandleVector;
67 GroupManager *groupMgr = new GroupManager();
68 ConfigurationResource *myConfigurationResource;
69 MaintenanceResource *myMaintenanceResource;
70 FactorySetResource *myFactorySetResource;
72 std::condition_variable cv1;
73 std::condition_variable cv2;
74 std::condition_variable cv3;
75 std::condition_variable cv4;
76 std::condition_variable cv5;
78 bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
79 OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest);
80 OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
81 OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request);
83 typedef std::function< void(OCRepresentation &) > putFunc;
84 typedef std::function< OCRepresentation(void) > getFunc;
86 void *ChangeLightRepresentation(void *param);
87 void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest);
89 /****** Light Resource [Required to gtestcases of GroupManager APIs] ******/
96 std::string m_lightUri;
97 OCResourceHandle m_resourceHandle;
98 OCRepresentation m_lightRep;
102 m_power("on"), m_lightUri("/a/light"), m_resourceHandle(0)
104 m_lightRep.setUri(m_lightUri);
105 m_lightRep.setValue("power", m_power);
108 void createResource()
110 std::string resourceURI = m_lightUri;
111 std::string resourceTypeName = "core.light";
112 std::string resourceInterface = DEFAULT_INTERFACE;
113 EntityHandler cb = std::bind(&LightResource::entityHandler, this, PH::_1);
115 OCStackResult result = OCPlatform::registerResource(m_resourceHandle, resourceURI,
116 resourceTypeName, resourceInterface, cb, OC_DISCOVERABLE | OC_OBSERVABLE);
118 if (OC_STACK_OK != result)
120 printf("\nLightResource : OC_STACK_OK != result...");
126 std::condition_variable cv;
127 std::unique_lock < std::mutex > lock(blocker);
132 OCResourceHandle getHandle()
134 return m_resourceHandle;
137 void put(OCRepresentation &rep)
142 if (rep.getValue < std::string > ("power", test))
144 cout << "\t\t\t\t" << "power: " << test << endl;
148 cout << "\t\t\t\t" << "power not found in the representation" << endl;
153 cout << e.what() << endl;
157 OCRepresentation post(OCRepresentation &rep)
163 OCRepresentation get()
165 m_lightRep.setValue("power", m_power);
170 void addType(const std::string &type) const
172 OCStackResult result = OCPlatform::bindTypeToResource(m_resourceHandle, type);
173 if (OC_STACK_OK != result)
175 cout << "Binding TypeName to Resource was unsuccessful\n";
179 void addInterface(const std::string &interface) const
181 OCStackResult result = OCPlatform::bindInterfaceToResource(m_resourceHandle, interface);
182 if (OC_STACK_OK != result)
184 cout << "Binding TypeName to Resource was unsuccessful\n";
189 OCEntityHandlerResult entityHandler(std::shared_ptr< OCResourceRequest > request)
191 cout << "\tIn Server CPP entity handler:\n";
192 OCEntityHandlerResult ehResult = OC_EH_ERROR;
195 std::string requestType = request->getRequestType();
196 int requestFlag = request->getRequestHandlerFlag();
198 if (requestFlag & RequestHandlerFlag::RequestFlag)
200 cout << "\t\trequestFlag : Request\n";
201 auto pResponse = std::make_shared< OC::OCResourceResponse >();
202 pResponse->setRequestHandle(request->getRequestHandle());
203 pResponse->setResourceHandle(request->getResourceHandle());
205 if (requestType == "GET")
207 cout << "\t\t\trequestType : GET\n";
210 static int startedThread = 0;
213 std::thread t(handleSlowResponse, (void *) this, request);
217 ehResult = OC_EH_SLOW;
221 pResponse->setErrorCode(200);
222 pResponse->setResponseResult(OC_EH_OK);
223 pResponse->setResourceRepresentation(get());
224 if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
230 else if (requestType == "PUT")
232 cout << "\t\t\trequestType : PUT\n";
233 OCRepresentation rep = request->getResourceRepresentation();
235 pResponse->setErrorCode(200);
236 pResponse->setResponseResult(OC_EH_OK);
237 pResponse->setResourceRepresentation(rep);
238 if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
243 else if (requestType == "POST")
245 cout << "\t\t\trequestType : POST\n";
247 OCRepresentation rep = request->getResourceRepresentation();
248 OCRepresentation rep_post = post(rep);
250 pResponse->setResourceRepresentation(rep_post);
251 pResponse->setErrorCode(200);
252 if (rep_post.hasAttribute("createduri"))
254 pResponse->setResponseResult(OC_EH_RESOURCE_CREATED);
255 pResponse->setNewResourceUri(
256 rep_post.getValue < std::string > ("createduri"));
259 if (OC_STACK_OK == OCPlatform::sendResponse(pResponse))
264 else if (requestType == "DELETE")
271 std::cout << "Request invalid" << std::endl;
277 void *handleSlowResponse(void *param, std::shared_ptr< OCResourceRequest > pRequest)
279 LightResource *lightPtr = (LightResource *) param;
282 auto pResponse = std::make_shared< OC::OCResourceResponse >();
283 pResponse->setRequestHandle(pRequest->getRequestHandle());
284 pResponse->setResourceHandle(pRequest->getResourceHandle());
285 pResponse->setResourceRepresentation(lightPtr->get());
286 pResponse->setErrorCode(200);
287 pResponse->setResponseResult(OC_EH_OK);
289 isSlowResponse = false;
290 OCPlatform::sendResponse(pResponse);
294 /****** Configuration Resource ******/
296 void ConfigurationResource::createResources(ResourceEntityHandler callback)
298 using namespace OC::OCPlatform;
300 if (callback == NULL)
302 std::cout << "callback should be binded\t";
306 OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
307 m_configurationTypes[0], m_configurationInterfaces[0], callback,
308 OC_DISCOVERABLE | OC_OBSERVABLE);
310 if (OC_STACK_OK != result)
312 std::cout << "Resource creation (configuration) was unsuccessful\n";
318 std::condition_variable cv;
319 std::unique_lock < std::mutex > lock(blocker);
324 void ConfigurationResource::setConfigurationRepresentation(OCRepresentation &rep)
327 if (rep.getValue("n", value))
329 m_deviceName = value;
330 std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
333 if (rep.getValue("loc", value))
336 std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
339 if (rep.getValue("locn", value))
341 m_locationName = value;
342 std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
345 if (rep.getValue("c", value))
348 std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
351 if (rep.getValue("r", value))
354 std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
358 OCRepresentation ConfigurationResource::getConfigurationRepresentation()
360 m_configurationRep.setValue("n", m_deviceName);
361 m_configurationRep.setValue("loc", m_location);
362 m_configurationRep.setValue("locn", m_locationName);
363 m_configurationRep.setValue("c", m_currency);
364 m_configurationRep.setValue("r", m_region);
366 return m_configurationRep;
369 std::string ConfigurationResource::getUri()
371 return m_configurationUri;
374 void ConfigurationResource::factoryReset()
376 m_deviceName = defaultDeviceName;
377 m_location = defaultLocation;
378 m_locationName = defaultLocationName;
379 m_currency = defaultCurrency;
380 m_region = defaultRegion;
383 /****** FactorySet Resource ******/
385 FactorySetResource::FactorySetResource()
387 m_configurationUri = "/factoryset"; // URI of the resource
388 m_configurationTypes.clear();
389 m_configurationTypes.push_back("factoryset"); // resource type name.
390 m_configurationRep.setUri(m_configurationUri);
391 m_configurationRep.setResourceTypes(m_configurationTypes);
394 FactorySetResource::~FactorySetResource()
398 void FactorySetResource::createResources(ResourceEntityHandler callback)
400 using namespace OC::OCPlatform;
402 if (callback == NULL)
404 std::cout << "callback should be binded\t";
408 OCStackResult result = registerResource(m_configurationHandle, m_configurationUri,
409 m_configurationTypes[0], m_configurationInterfaces[0], callback,
410 OC_DISCOVERABLE | OC_OBSERVABLE);
412 if (OC_STACK_OK != result)
414 std::cout << "Resource creation (configuration) was unsuccessful\n";
421 std::condition_variable cv;
422 std::unique_lock < std::mutex > lock(blocker);
427 void FactorySetResource::setFactorySetRepresentation(OCRepresentation &rep)
431 if (rep.getValue("n", value))
433 m_deviceName = value;
434 std::cout << "\t\t\t\t" << "m_deviceName: " << m_deviceName << std::endl;
437 if (rep.getValue("loc", value))
440 std::cout << "\t\t\t\t" << "m_location: " << m_location << std::endl;
443 if (rep.getValue("locn", value))
445 m_locationName = value;
446 std::cout << "\t\t\t\t" << "m_locationName: " << m_locationName << std::endl;
449 if (rep.getValue("c", value))
452 std::cout << "\t\t\t\t" << "m_currency: " << m_currency << std::endl;
455 if (rep.getValue("r", value))
458 std::cout << "\t\t\t\t" << "m_region: " << m_region << std::endl;
462 OCRepresentation FactorySetResource::getFactorySetRepresentation()
464 m_configurationRep.setValue("n", m_deviceName);
465 m_configurationRep.setValue("loc", m_location);
466 m_configurationRep.setValue("locn", m_locationName);
467 m_configurationRep.setValue("c", m_currency);
468 m_configurationRep.setValue("r", m_region);
470 return m_configurationRep;
473 std::string FactorySetResource::getUri()
475 return m_configurationUri;
478 /****** Maintenance Resource ********/
480 void MaintenanceResource::createResources(ResourceEntityHandler callback)
482 using namespace OC::OCPlatform;
484 if (callback == NULL)
486 std::cout << "callback should be binded\t";
490 OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
491 m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback,
492 OC_DISCOVERABLE | OC_OBSERVABLE);
494 if (OC_STACK_OK != result)
496 std::cout << "Resource creation (maintenance) was unsuccessful\n";
500 std::function< void(int second) >(
501 std::bind(&MaintenanceResource::maintenanceMonitor, this,
502 std::placeholders::_1)), 10);
506 std::condition_variable cv;
507 std::unique_lock < std::mutex > lock(blocker);
510 std::cout << "maintenance Resource is Created!\n";
513 void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation &rep)
517 if (rep.getValue("fr", value))
519 m_factoryReset = value;
520 std::cout << "\t\t\t\t" << "m_factoryReset: " << m_factoryReset << std::endl;
523 if (rep.getValue("rb", value))
526 std::cout << "\t\t\t\t" << "m_reboot: " << m_reboot << std::endl;
529 if (rep.getValue("ssc", value))
531 m_startStatCollection = value;
532 std::cout << "\t\t\t\t" << "m_startStatCollection: " << m_startStatCollection << std::endl;
536 OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
538 m_maintenanceRep.setValue("fr", m_factoryReset);
539 m_maintenanceRep.setValue("rb", m_reboot);
540 m_maintenanceRep.setValue("ssc", m_startStatCollection);
542 return m_maintenanceRep;
545 std::string MaintenanceResource::getUri()
547 return m_maintenanceUri;
550 void MaintenanceResource::maintenanceMonitor(int second)
556 if (m_reboot == "true")
559 std::cout << "Reboot will be soon..." << std::endl;
560 m_reboot = defaultReboot;
561 res = system("sudo reboot");
563 std::cout << "return: " << res << std::endl;
566 else if (m_factoryReset == "true")
568 std::cout << "Factory Reset will be soon..." << std::endl;
569 m_factoryReset = defaultFactoryReset;
575 getFunc getGetFunction(std::string uri)
579 if (uri == myConfigurationResource->getUri())
581 res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
582 myConfigurationResource);
584 else if (uri == myMaintenanceResource->getUri())
586 res = std::bind(&MaintenanceResource::getMaintenanceRepresentation, myMaintenanceResource);
591 putFunc getPutFunction(std::string uri)
595 if (uri == myConfigurationResource->getUri())
597 res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
598 myConfigurationResource, std::placeholders::_1);
600 else if (uri == myMaintenanceResource->getUri())
602 res = std::bind(&MaintenanceResource::setMaintenanceRepresentation, myMaintenanceResource,
603 std::placeholders::_1);
608 bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request)
610 std::cout << "\tIn Server CPP prepareResponseForResource:\n";
614 std::string requestType = request->getRequestType();
615 int requestFlag = request->getRequestHandlerFlag();
617 if (requestFlag == RequestHandlerFlag::RequestFlag)
619 std::cout << "\t\trequestFlag : Request\n";
620 if (requestType == "GET")
622 std::cout << "\t\t\trequestType : GET\n";
625 else if (requestType == "PUT")
627 std::cout << "\t\t\trequestType : PUT\n";
629 OCRepresentation rep = request->getResourceRepresentation();
631 putFunction = getPutFunction(request->getResourceUri());
635 else if (requestType == "POST")
638 else if (requestType == "DELETE")
642 else if (requestFlag == RequestHandlerFlag::ObserverFlag)
644 std::cout << "\t\trequestFlag : Observer\n";
649 std::cout << "Request invalid" << std::endl;
655 OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequest)
657 auto pResponse = std::make_shared< OC::OCResourceResponse >();
658 QueryParamsMap queryParamsMap = pRequest->getQueryParameters();
660 pResponse->setRequestHandle(pRequest->getRequestHandle());
661 pResponse->setResourceHandle(pRequest->getResourceHandle());
664 getFunction = getGetFunction(pRequest->getResourceUri());
666 OCRepresentation rep;
669 auto findRes = queryParamsMap.find("if");
671 if (findRes != queryParamsMap.end())
673 pResponse->setResourceRepresentation(rep, findRes->second);
677 pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
680 pResponse->setErrorCode(200);
681 pResponse->setResponseResult(OC_EH_OK);
683 return OCPlatform::sendResponse(pResponse);
686 OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request)
688 std::cout << "\tIn Server CPP (entityHandlerForResource) entity handler:\n";
689 OCEntityHandlerResult ehResult = OC_EH_ERROR;
691 QueryParamsMap test = request->getQueryParameters();
693 if (prepareResponseForResource(request))
695 if (OC_STACK_OK == sendResponseForResource(request))
701 std::cout << "sendResponse failed." << std::endl;
706 std::cout << "PrepareResponse failed." << std::endl;
711 /****** BootStrap Resource [Required for doBootstrap API of ThingsConfiguration class] ******/
713 class BootstrapResource
716 std::string m_bootstrapUri;
717 std::vector< std::string > m_bootstrapTypes;
718 std::vector< std::string > m_bootstrapInterfaces;
719 OCResourceHandle m_bootstrapHandle;
720 OCRepresentation m_bootstrapRep;
725 m_bootstrapUri = "/bootstrap";
726 m_bootstrapTypes.push_back("bootstrap");
727 m_bootstrapInterfaces.push_back(DEFAULT_INTERFACE);
728 m_bootstrapRep.setUri(m_bootstrapUri);
729 m_bootstrapRep.setResourceTypes(m_bootstrapTypes);
730 m_bootstrapRep.setResourceInterfaces(m_bootstrapInterfaces);
731 m_bootstrapHandle = NULL;
733 void createResources()
735 using namespace OC::OCPlatform;
736 OCStackResult result = registerResource(m_bootstrapHandle, m_bootstrapUri,
737 m_bootstrapTypes[0], m_bootstrapInterfaces[0], entityHandlerBootstrap,
738 OC_DISCOVERABLE | OC_OBSERVABLE);
740 if (OC_STACK_OK != result)
742 cout << "Resource creation (room) was unsuccessful\n";
747 std::condition_variable cv;
748 std::unique_lock < std::mutex > lock(blocker);
752 void setBootstrapRepresentation(OCRepresentation& /*rep*/)
756 OCRepresentation getBootstrapRepresentation()
758 m_bootstrapRep.setValue < std::string > ("n", defaultDeviceName);
759 m_bootstrapRep.setValue < std::string > ("loc", defaultLocation);
760 m_bootstrapRep.setValue < std::string > ("locn", defaultLocationName);
761 m_bootstrapRep.setValue < std::string > ("c", defaultCurrency);
762 m_bootstrapRep.setValue < std::string > ("r", defaultRegion);
764 return m_bootstrapRep;
768 BootstrapResource myBootstrapResource;
770 bool prepareResponse(std::shared_ptr< OCResourceRequest > request)
772 cout << "\tIn Server CPP prepareResponse:\n";
776 std::string requestType = request->getRequestType();
777 int requestFlag = request->getRequestHandlerFlag();
779 if (requestFlag == RequestHandlerFlag::RequestFlag)
781 cout << "\t\trequestFlag : Request\n";
782 if (requestType == "GET")
784 cout << "\t\t\trequestType : GET\n";
787 else if (requestType == "PUT")
789 cout << "\t\t\trequestType : PUT\n";
791 OCRepresentation rep = request->getResourceRepresentation();
792 myBootstrapResource.setBootstrapRepresentation(rep);
795 else if (requestType == "POST")
798 else if (requestType == "DELETE")
802 else if (requestFlag == RequestHandlerFlag::ObserverFlag)
804 cout << "\t\trequestFlag : Observer\n";
809 std::cout << "Request invalid" << std::endl;
815 OCStackResult sendResponse(std::shared_ptr< OCResourceRequest > pRequest)
817 auto pResponse = std::make_shared< OC::OCResourceResponse >();
818 pResponse->setRequestHandle(pRequest->getRequestHandle());
819 pResponse->setResourceHandle(pRequest->getResourceHandle());
820 pResponse->setResourceRepresentation(myBootstrapResource.getBootstrapRepresentation());
821 pResponse->setErrorCode(200);
822 pResponse->setResponseResult(OC_EH_OK);
824 return OCPlatform::sendResponse(pResponse);
827 OCEntityHandlerResult entityHandlerBootstrap(std::shared_ptr< OCResourceRequest > request)
829 cout << "\tIn Server CPP (entityHandlerBootstrap) entity handler:\n";
830 OCEntityHandlerResult ehResult = OC_EH_ERROR;
832 if (prepareResponse(request))
834 if (OC_STACK_OK == sendResponse(request))
840 std::cout << "sendResponse failed." << std::endl;
845 std::cout << "PrepareResponse failed." << std::endl;
850 /****** gtest class ******/
852 class ThingsManagerTest: public TestWithMock
860 void Wait(int waitingTime = DEFAULT_WAITING_TIME_IN_MILLIS)
862 std::unique_lock < std::mutex > lock
864 cond.wait_for(lock, std::chrono::milliseconds
871 TestWithMock::SetUp();
876 TestWithMock::TearDown();
880 std::condition_variable cond;
885 void onUpdate(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
890 void onGetBootstrapInformation(const HeaderOptions& /*headerOptions*/,
891 const OCRepresentation& /*rep*/, const int /*eCode*/)
895 void onReboot(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
900 void onFactoryReset(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
905 void onGet(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
910 void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
915 void onPost(const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
920 void foundResources(std::vector< std::shared_ptr< OC::OCResource > > listOfResource)
922 for (auto rsrc = listOfResource.begin(); rsrc != listOfResource.end(); ++rsrc)
924 std::string resourceURI = (*rsrc)->uri();
925 std::string hostAddress = (*rsrc)->host();
927 if (resourceURI == "/a/light")
929 result = OCPlatform::registerResource(foundResourceHandle, (*rsrc));
930 if (result == OC_STACK_OK)
932 OCPlatform::bindResource(resourceHandle, foundResourceHandle);
933 resourceHandleVector.push_back(foundResourceHandle);
937 cout << "\tresource Error!" << endl;
939 lights.push_back((hostAddress + resourceURI));
945 configurationResource = (*rsrc);
951 void foundGroupResource(std::shared_ptr< OCResource > resource)
953 std::string resourceURI;
954 resourceURI = resource->uri();
955 if (resourceURI == "/core/a/collection")
957 g_resource = resource;
961 g_room_resource = resource;
966 //This test case is to create the lightserver , BootstrapServer & configuration sever
967 TEST_F(ThingsManagerTest, testCreateResources)
970 { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos};
971 OCPlatform::Configure(cfg);
973 LightResource myLight;
974 std::thread t1(&LightResource::createResource, &myLight);
977 std::unique_lock < std::mutex > lock1(blocker1);
980 std::thread t2(&BootstrapResource::createResources, &myBootstrapResource);
983 std::unique_lock < std::mutex > lock2(blocker2);
986 myConfigurationResource = new ConfigurationResource();
987 std::thread t3(&ConfigurationResource::createResources, myConfigurationResource,
988 &entityHandlerForResource);
992 std::unique_lock < std::mutex > lock3(blocker3);
995 myMaintenanceResource = new MaintenanceResource();
996 std::thread t4(&MaintenanceResource::createResources, myMaintenanceResource,
997 &entityHandlerForResource);
1000 std::mutex blocker4;
1001 std::unique_lock < std::mutex > lock4(blocker4);
1004 myFactorySetResource = new FactorySetResource();
1005 std::thread t5(&FactorySetResource::createResources, myFactorySetResource,
1006 &entityHandlerForResource);
1009 std::mutex blocker5;
1010 std::unique_lock < std::mutex > lock5(blocker5);
1013 myMaintenanceResource->factoryReset = std::function < void()
1014 > (std::bind(&ConfigurationResource::factoryReset,
1015 myConfigurationResource));
1018 //Check findCandidateResources
1019 TEST_F(ThingsManagerTest, testFindCandidateResources)
1022 string resourceURI = "/core/a/collection";
1023 string resourceTypeName = "a.collection";
1024 string resourceInterface = BATCH_INTERFACE;
1026 OCStackResult res = OCPlatform::registerResource(resourceHandle, resourceURI,
1027 resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
1029 if ( res != OC_STACK_OK )
1031 cout << "Resource registeration failed." << endl;
1034 OCPlatform::bindInterfaceToResource(resourceHandle, GROUP_INTERFACE);
1035 OCPlatform::bindInterfaceToResource(resourceHandle, DEFAULT_INTERFACE);
1037 std::string query = OC_RSRVD_WELL_KNOWN_URI;
1038 query.append("?rt=");
1039 query.append(resourceTypeName);
1041 OCPlatform::findResource("", query, CT_DEFAULT, &foundGroupResource);
1043 std::mutex blocker1;
1044 std::unique_lock < std::mutex > lock1(blocker1);
1047 GroupManager *instance = new GroupManager();
1048 vector<string> types;
1049 types.push_back("core.light");
1051 result = instance->findCandidateResources(types, &foundResources);
1053 std::mutex blocker2;
1054 std::unique_lock < std::mutex > lock2(blocker2);
1058 //Find Candidate Resource when no resources are specified
1059 TEST_F(ThingsManagerTest, testFindCandidateResourcesEmptyResourceType)
1061 GroupManager *instance = new GroupManager();
1062 vector<string> types;
1063 result = instance->findCandidateResources(types, &foundResources);
1064 EXPECT_TRUE(result == OC_STACK_ERROR);
1068 //Find Candidate Resource when Callback is null
1069 TEST_F(ThingsManagerTest, testFindCandidateResourcesNullCallback)
1071 GroupManager *instance = new GroupManager();
1072 vector<string> types;
1073 types.push_back("core.light");
1074 result = instance->findCandidateResources(types, NULL);
1075 EXPECT_TRUE(result == OC_STACK_ERROR);
1079 //test bind resource to group
1080 TEST_F(ThingsManagerTest, testBindResourceToGroup)
1082 GroupManager *instance = new GroupManager();
1083 OCResourceHandle rHandle = NULL;
1085 string resourceURI = "/core/room-large";
1086 string resourceTypeName = "core.room-large";
1087 string resourceInterface = BATCH_INTERFACE;
1089 OCStackResult res = OCPlatform::registerResource(rHandle, resourceURI,
1090 resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
1092 if ( res != OC_STACK_OK )
1094 cout << "Resource registeration failed." << endl;
1097 OCPlatform::bindInterfaceToResource(rHandle, GROUP_INTERFACE);
1098 OCPlatform::bindInterfaceToResource(rHandle, DEFAULT_INTERFACE);
1100 std::string query = OC_RSRVD_WELL_KNOWN_URI;
1101 query.append("?rt=");
1102 query.append(resourceTypeName);
1104 OCPlatform::findResource("", query, CT_DEFAULT, &foundGroupResource);
1106 std::mutex blocker1;
1107 std::unique_lock < std::mutex > lock1(blocker1);
1110 result = instance->bindResourceToGroup (resourceHandle, g_room_resource, rHandle);
1112 EXPECT_TRUE(result == OC_STACK_OK);
1117 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOff)
1119 string actionsetDesc;
1120 ActionSet *allBulbOff = new ActionSet();
1121 allBulbOff->actionsetName = "AllBulbOff";
1123 mocks.ExpectCallFunc(onPut).
1124 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1125 const int /*eCode*/) { Proceed();});
1127 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1129 Action *action = new Action();
1130 action->target = (*iter);
1132 Capability *capa = new Capability();
1133 capa->capability = "power";
1134 capa->status = "off";
1136 action->listOfCapability.push_back(capa);
1137 allBulbOff->listOfAction.push_back(action);
1141 result = groupMgr->addActionSet(g_resource, allBulbOff, &onPut);
1143 EXPECT_TRUE(result == OC_STACK_OK);
1149 //Add actionset with NULL resource
1150 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOffResourceNull)
1152 string actionsetDesc;
1153 ActionSet *allBulbOff = new ActionSet();
1154 allBulbOff->actionsetName = "AllBulbOff";
1156 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1158 Action *action = new Action();
1159 action->target = (*iter);
1161 Capability *capa = new Capability();
1162 capa->capability = "power";
1163 capa->status = "off";
1165 action->listOfCapability.push_back(capa);
1166 allBulbOff->listOfAction.push_back(action);
1169 result = groupMgr->addActionSet(NULL, allBulbOff, &onPut);
1171 EXPECT_TRUE(result == OC_STACK_ERROR);
1177 //Add actionset with NULL ActionSet
1178 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOffActionsetNull)
1182 result = groupMgr->addActionSet(g_resource, NULL, &onPut);
1184 EXPECT_TRUE(result == OC_STACK_ERROR);
1190 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOn)
1192 string actionsetDesc;
1193 ActionSet *allBulbON = new ActionSet();
1194 allBulbON->actionsetName = "AllBulbOn";
1196 mocks.ExpectCallFunc(onPut).
1197 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1198 const int /*eCode*/) { Proceed();});
1200 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1202 Action *action = new Action();
1203 action->target = (*iter);
1205 Capability *capa = new Capability();
1206 capa->capability = "power";
1207 capa->status = "on";
1209 action->listOfCapability.push_back(capa);
1210 allBulbON->listOfAction.push_back(action);
1214 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1216 EXPECT_TRUE(result == OC_STACK_OK);
1222 //Add actionset with NULL Resource
1223 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnResourceNull)
1225 string actionsetDesc;
1226 ActionSet *allBulbON = new ActionSet();
1227 allBulbON->actionsetName = "AllBulbOn";
1229 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1231 Action *action = new Action();
1232 action->target = (*iter);
1234 Capability *capa = new Capability();
1235 capa->capability = "power";
1236 capa->status = "on";
1238 action->listOfCapability.push_back(capa);
1239 allBulbON->listOfAction.push_back(action);
1242 result = groupMgr->addActionSet(NULL, allBulbON, onPut);
1244 EXPECT_TRUE(result == OC_STACK_ERROR);
1250 //Add actionset with NULL ActionSet
1251 TEST_F(ThingsManagerTest, testAddActionSetAllBulbOnActionSetNull)
1255 result = groupMgr->addActionSet(g_resource, NULL, onPut);
1257 EXPECT_TRUE(result == OC_STACK_ERROR);
1263 TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOn)
1265 string actionsetDesc;
1266 ActionSet *allBulbON = new ActionSet();
1267 allBulbON->actionsetName = "AllBulbOn1";
1269 mocks.ExpectCallFunc(onPut).
1270 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1271 const int /*eCode*/) { Proceed();});
1273 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1275 Action *action = new Action();
1276 action->target = (*iter);
1278 Capability *capa = new Capability();
1279 capa->capability = "power";
1280 capa->status = "on";
1282 action->listOfCapability.push_back(capa);
1283 allBulbON->listOfAction.push_back(action);
1287 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1289 EXPECT_TRUE(result == OC_STACK_OK);
1293 mocks.ExpectCallFunc(onPost).
1294 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1295 const int /*eCode*/) { Proceed();});
1299 result = groupMgr->executeActionSet(g_resource, "AllBulbOn", &onPost);
1301 EXPECT_TRUE(result == OC_STACK_OK);
1306 //Execute actionset with NULL Resource
1307 TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOnResourceNull)
1309 result = groupMgr->executeActionSet(NULL, "AllBulbOn", &onPost);
1311 EXPECT_TRUE(result == OC_STACK_ERROR);
1316 TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOff)
1318 mocks.ExpectCallFunc(onPost).
1319 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1320 const int /*eCode*/) { Proceed();});
1324 result = groupMgr->executeActionSet(g_resource, "AllBulbOff", &onPost);
1326 EXPECT_TRUE(result == OC_STACK_OK);
1331 //Execute actionset with NULL resource
1332 TEST_F(ThingsManagerTest, testExecuteActionSetAllBulbOffResourceNull)
1334 result = groupMgr->executeActionSet(NULL, "AllBulbOff", &onPost);
1336 EXPECT_TRUE(result == OC_STACK_ERROR);
1340 //Execute actionset with Delay
1341 TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelay)
1343 string actionsetDesc;
1344 ActionSet *allBulbON = new ActionSet();
1345 allBulbON->actionsetName = "AllBulbOnDelay";
1346 allBulbON->setDelay(1);
1348 mocks.ExpectCallFunc(onPut).
1349 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1350 const int /*eCode*/) { Proceed();});
1352 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1354 Action *action = new Action();
1355 action->target = (*iter);
1357 Capability *capa = new Capability();
1358 capa->capability = "power";
1359 capa->status = "off";
1361 action->listOfCapability.push_back(capa);
1362 allBulbON->listOfAction.push_back(action);
1366 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1370 mocks.ExpectCallFunc(onPost).
1371 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1372 const int /*eCode*/) { Proceed();});
1376 result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", &onPost);
1378 EXPECT_TRUE(result == OC_STACK_OK);
1383 //Execute actionset with Delay = 0
1384 TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayEqulasZero)
1386 string actionsetDesc;
1387 ActionSet *allBulbON = new ActionSet();
1388 allBulbON->actionsetName = "AllBulbOnDelay";
1390 mocks.ExpectCallFunc(onPut).
1391 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1392 const int /*eCode*/) { Proceed();});
1394 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1396 Action *action = new Action();
1397 action->target = (*iter);
1399 Capability *capa = new Capability();
1400 capa->capability = "power";
1401 capa->status = "off";
1403 action->listOfCapability.push_back(capa);
1404 allBulbON->listOfAction.push_back(action);
1408 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1414 result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", 0, &onPost);
1416 EXPECT_TRUE(result == OC_STACK_INVALID_PARAM);
1421 //Execute actionset with invalid Delay
1422 TEST_F(ThingsManagerTest, testExcecuteActionSetWithInvalidDelay)
1424 string actionsetDesc;
1425 ActionSet *allBulbON = new ActionSet();
1426 allBulbON->actionsetName = "AllBulbOnDelay";
1428 mocks.ExpectCallFunc(onPut).
1429 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1430 const int /*eCode*/) { Proceed();});
1432 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1434 Action *action = new Action();
1435 action->target = (*iter);
1437 Capability *capa = new Capability();
1438 capa->capability = "power";
1439 capa->status = "off";
1441 action->listOfCapability.push_back(capa);
1442 allBulbON->listOfAction.push_back(action);
1446 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1452 result = groupMgr->executeActionSet(g_resource, "AllBulbOnDelay", -10, &onPost);
1454 EXPECT_TRUE(result == OC_STACK_INVALID_PARAM);
1459 //Execute actionset with delay on NULL Resource
1460 TEST_F(ThingsManagerTest, testExcecuteActionSetWithDelayWithResourceNull)
1462 string actionsetDesc;
1463 ActionSet *allBulbON = new ActionSet();
1464 allBulbON->actionsetName = "AllBulbOnDelay";
1465 allBulbON->setDelay(5);
1467 mocks.ExpectCallFunc(onPut).
1468 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1469 const int /*eCode*/) { Proceed();});
1471 for (auto iter = lights.begin(); iter != lights.end(); ++iter)
1473 Action *action = new Action();
1474 action->target = (*iter);
1476 Capability *capa = new Capability();
1477 capa->capability = "power";
1478 capa->status = "off";
1480 action->listOfCapability.push_back(capa);
1481 allBulbON->listOfAction.push_back(action);
1485 result = groupMgr->addActionSet(g_resource, allBulbON, onPut);
1488 result = groupMgr->executeActionSet(NULL, "AllBulbOnDelay", &onPost);
1489 EXPECT_TRUE(result == OC_STACK_ERROR);
1495 TEST_F(ThingsManagerTest, testCancelActionSet)
1497 mocks.ExpectCallFunc(onPost).
1498 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1499 const int /*eCode*/) { Proceed();});
1503 result = groupMgr->cancelActionSet(g_resource, "AllBulbOff", &onPost);
1505 EXPECT_TRUE(result == OC_STACK_OK);
1510 //Cancel ActionSet on NULL Resource
1511 TEST_F(ThingsManagerTest, testCancelActionSetResourceNull)
1513 result = groupMgr->cancelActionSet(NULL, "AllBulbOff", &onPost);
1515 EXPECT_TRUE(result == OC_STACK_ERROR);
1520 TEST_F(ThingsManagerTest, testDeleteActionSet)
1522 mocks.ExpectCallFunc(onPut).
1523 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1524 const int /*eCode*/) { Proceed();});
1528 result = groupMgr->deleteActionSet(g_resource, "AllBulbOff", &onPut);
1530 EXPECT_TRUE(result == OC_STACK_OK);
1535 //Delete ActionSet on NULL Resource
1536 TEST_F(ThingsManagerTest, testDeleteActionSetResourceNull)
1538 result = groupMgr->deleteActionSet(NULL, "AllBulbOff", &onPut);
1540 EXPECT_TRUE(result == OC_STACK_ERROR);
1545 TEST_F(ThingsManagerTest, testGetActionSet)
1547 mocks.ExpectCallFunc(onPost).
1548 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1549 const int /*eCode*/) { Proceed();});
1553 result = groupMgr->getActionSet(g_resource, "AllBulbOn", &onPost);
1555 EXPECT_TRUE(result == OC_STACK_OK);
1560 //Get ActionSet on NULL Resource
1561 TEST_F(ThingsManagerTest, testGetActionSetResourceNull)
1563 result = groupMgr->getActionSet(NULL, "AllBulbOn", &onPost);
1565 EXPECT_TRUE(result == OC_STACK_ERROR);
1569 //Get Configurations
1570 TEST_F(ThingsManagerTest, testGetConfigurations)
1572 ConfigurationName name = "all";
1574 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1575 std::vector< ConfigurationName > configurations;
1577 configurations.push_back(name);
1579 mocks.ExpectCallFunc(onGet).
1580 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1581 const int /*eCode*/) { Proceed();});
1583 vector<string> types;
1584 types.push_back("oic.wk.con");
1586 result = groupMgr->findCandidateResources(types, &foundResources);
1589 std::unique_lock < std::mutex > lock(blocker);
1592 if (result == OC_STACK_OK)
1594 result = g_thingsConf->getConfigurations(configurationResource, configurations, &onGet);
1596 EXPECT_TRUE(result == OC_STACK_OK);
1601 //Get Configurations with empty Configuration
1602 TEST_F(ThingsManagerTest, testGetConfigurationsEmptyConfiguration)
1604 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1605 std::vector< ConfigurationName > configurations;
1607 vector<string> types;
1608 types.push_back("oic.wk.con");
1610 result = groupMgr->findCandidateResources(types, &foundResources);
1613 std::unique_lock < std::mutex > lock(blocker);
1616 if (result == OC_STACK_OK)
1618 result = g_thingsConf->getConfigurations(configurationResource, configurations, &onGet);
1620 EXPECT_TRUE(result == OC_STACK_ERROR);
1625 //Get Configurations on NULL Resource
1626 TEST_F(ThingsManagerTest, testGetConfigurationsResourceNull)
1628 ConfigurationName name = "all";
1629 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1630 std::vector< ConfigurationName > configurations;
1632 configurations.push_back(name);
1634 result = g_thingsConf->getConfigurations(NULL, configurations, &onGet);
1636 EXPECT_TRUE(result == OC_STACK_ERROR);
1640 //Get all supported Configurations
1641 TEST_F(ThingsManagerTest, testGetallSupportedCOnfigurations)
1643 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1644 string retVal = g_thingsConf->getListOfSupportedConfigurationUnits();
1645 EXPECT_FALSE(retVal.size() == 0);
1649 TEST_F(ThingsManagerTest, testDoBootstrap)
1651 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1653 mocks.ExpectCallFunc(onGetBootstrapInformation).
1654 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1655 const int /*eCode*/) { Proceed();});
1656 result = g_thingsConf->doBootstrap(&onGetBootstrapInformation);
1658 EXPECT_TRUE(result == OC_STACK_OK);
1662 //DoBootstrap with NULL callback
1663 TEST_F(ThingsManagerTest, testDoBootstrapCallBackNull)
1665 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1667 result = g_thingsConf->doBootstrap(NULL);
1669 EXPECT_TRUE(result == OC_STACK_ERROR);
1673 //Update Configuration
1674 TEST_F(ThingsManagerTest, testUpdateConfiguration)
1676 ConfigurationName name = "r";
1677 ConfigurationValue value = "INDIA";
1679 std::map< ConfigurationName, ConfigurationValue > configurations;
1680 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1681 configurations.insert(std::make_pair(name, value));
1683 mocks.ExpectCallFunc(onUpdate).
1684 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1685 const int /*eCode*/) { Proceed();});
1687 vector<string> types;
1688 types.push_back("oic.wk.con");
1689 result = groupMgr->findCandidateResources(types, &foundResources);
1691 std::mutex blocker2;
1692 std::unique_lock < std::mutex > lock2(blocker2);
1695 if (result == OC_STACK_OK)
1697 result = g_thingsConf->updateConfigurations(configurationResource, configurations,
1700 EXPECT_TRUE(result == OC_STACK_OK);
1705 //Update Configuration with Empty Configuration
1706 TEST_F(ThingsManagerTest, testUpdateConfigurationEmptyConfiguration)
1708 std::map< ConfigurationName, ConfigurationValue > configurations;
1709 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1711 vector<string> types;
1712 types.push_back("oic.wk.con");
1713 result = groupMgr->findCandidateResources(types, &foundResources);
1715 std::mutex blocker2;
1716 std::unique_lock < std::mutex > lock2(blocker2);
1719 if (result == OC_STACK_OK)
1721 result = g_thingsConf->updateConfigurations(configurationResource, configurations,
1724 EXPECT_TRUE(result == OC_STACK_ERROR);
1729 //Update Configuration on NULL Resource
1730 TEST_F(ThingsManagerTest, testUpdateConfigurationResourceNull)
1732 ConfigurationName name = "r";
1733 ConfigurationValue value = "INDIA";
1735 std::map< ConfigurationName, ConfigurationValue > configurations;
1736 ThingsConfiguration *g_thingsConf = ThingsConfiguration::getInstance();
1738 configurations.insert(std::make_pair(name, value));
1740 result = g_thingsConf->updateConfigurations(NULL, configurations, &onUpdate);
1742 EXPECT_TRUE(result == OC_STACK_ERROR);
1747 TEST_F(ThingsManagerTest, testReboot)
1749 ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
1751 mocks.ExpectCallFunc(onReboot).
1752 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1753 const int /*eCode*/) { Proceed();});
1755 vector<string> types;
1756 types.push_back("oic.wk.mnt");
1757 result = groupMgr->findCandidateResources(types, &foundResources);
1760 std::unique_lock < std::mutex > lock(blocker);
1763 if (result == OC_STACK_OK)
1765 result = g_thingsMnt->reboot(configurationResource, &onReboot);
1767 EXPECT_TRUE(result == OC_STACK_OK);
1772 //Reboot on NULL Resource
1773 TEST_F(ThingsManagerTest, testRebootResourceNull)
1775 ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
1777 result = g_thingsMnt->reboot(NULL, &onReboot);
1779 EXPECT_TRUE(result == OC_STACK_ERROR);
1784 TEST_F(ThingsManagerTest, testFactoryReset)
1786 ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
1788 mocks.ExpectCallFunc(onFactoryReset).
1789 Do([this](const HeaderOptions& /*headerOptions*/, const OCRepresentation& /*rep*/,
1790 const int /*eCode*/) { Proceed();});
1792 vector<string> types;
1793 types.push_back("oic.wk.mnt");
1794 result = groupMgr->findCandidateResources(types, &foundResources);
1797 std::unique_lock < std::mutex > lock(blocker);
1800 if (result == OC_STACK_OK)
1802 result = g_thingsMnt->factoryReset(configurationResource, &onFactoryReset);
1804 EXPECT_TRUE(result == OC_STACK_OK);
1809 //Factory Reset on NULL Resource
1810 TEST_F(ThingsManagerTest, testFactoryResetResourceNull)
1812 ThingsMaintenance *g_thingsMnt = ThingsMaintenance::getInstance();
1814 result = g_thingsMnt->factoryReset(NULL, &onFactoryReset);
1816 EXPECT_TRUE(result == OC_STACK_ERROR);