--- /dev/null
+//******************************************************************
+//
+// Copyright 2020 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#define _POSIX_C_SOURCE 200112L
+
+#include "iotivity_config.h"
+
+#include <string.h>
+#include <gtest/gtest.h>
+
+#include "oicgroup.h"
+#include "ocpayload.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+#include "occollection.h"
+#include "ocserverrequest.h"
+#include <stdio.h>
+
+TEST(InitializeScheduleResourceListTest, InitializeScheduleResourceList)
+{
+ EXPECT_EQ(OC_STACK_OK, OCInit(NULL, 0, OC_SERVER));
+}
+TEST(TerminateScheduleResourceListTest, TerminateScheduleResourceList)
+{
+ EXPECT_EQ(OC_STACK_OK, OCInit(NULL, 0, OC_SERVER));
+ EXPECT_EQ(OC_STACK_OK, OCStop());
+}
+static OCActionSet *createAction(char *actionName)
+{
+ OCActionSet *actionSet;
+ actionSet = (OCActionSet*)OICMalloc(sizeof(OCActionSet));
+ actionSet->timesteps = 5;
+ actionSet->type = 1;
+ actionSet->actionsetName = (char*)OICMalloc(strlen(actionName)+1);
+ strncpy(actionSet->actionsetName, actionName, strlen(actionName)+1);
+ OCAction *action = (OCAction*)OICMalloc(sizeof(OCAction));
+ action->resourceUri = (char*)OICMalloc(20);
+ strncpy(action->resourceUri , "/a/light" , 9);
+ action->next = NULL;
+ OCCapability *cap=(OCCapability*)OICMalloc(sizeof(OCCapability));
+ cap->capability = (char*)OICMalloc(7);
+ strncpy(cap->capability, "switch", 7);
+ cap->status = (char*)OICMalloc(3);
+ strncpy(cap->status, "on", 3);
+ cap->next = NULL;
+ action->head = cap;
+ actionSet->head = action;
+ actionSet->next = NULL;
+ return actionSet;
+}
+TEST(BuildActionSetFromStringTest, BuildActionSetFromString)
+{
+ char temp[1024] = {0};
+ strncat(temp, "house*",6);
+ strncat(temp, "5 1", 3);
+ strncat(temp, "*uri=/a/light|switch=on*uri=/a/fan|switch=off", 45);
+ char *val = OICStrdup(temp);
+ OCActionSet *set = NULL;
+ EXPECT_EQ(OC_STACK_OK, BuildActionSetFromString(&set, val));
+}
+TEST(BuildStringFromActionSetTest, BuildStringFromActionSet)
+{
+ OCActionSet *actionSet = createAction("house");
+ char *s;
+ EXPECT_EQ(OC_STACK_OK, BuildStringFromActionSet(actionSet, &s));
+}
+TEST(FindAndDeleteActionSetTest, FindAndDeleteActionSet)
+{
+ OCResource *res;
+ res = (OCResource*)OICMalloc(sizeof(OCResource));
+ res->next = NULL;
+ OCActionSet *action = createAction("house");
+ res->actionsetHead = action;
+ char *actionsetFindName = (char*)OICMalloc(6);
+ strncpy(actionsetFindName, "house", 6);
+ EXPECT_EQ(OC_STACK_OK, FindAndDeleteActionSet(&res, actionsetFindName));
+}
+TEST(FindAndDeleteActionSetTestWithMultipleActions, FindAndDeleteActionSet)
+{
+ OCResource *res;
+ res = (OCResource*)OICMalloc(sizeof(OCResource));
+ res->next = NULL;
+ OCActionSet *action1 = createAction("house");
+ OCActionSet *action2 = createAction("kitchen");
+ action1->next = action2;
+ res->actionsetHead = action1;
+ char *actionsetFindName = (char*)OICMalloc(8);
+ strncpy(actionsetFindName, "kitchen", 8);
+ EXPECT_EQ(OC_STACK_OK, FindAndDeleteActionSet(&res, actionsetFindName));
+}
+TEST(AddActionSetTest, AddActionSet)
+{
+ OCActionSet *head = createAction("house");
+ OCActionSet *action = createAction("kitchen");
+ OCServerRequest *request;
+ EXPECT_EQ(OC_STACK_OK, AddActionSet(&head, action));
+}
+TEST(BuildCollectionGroupActionCBORResponsePutWithSameActionTest, BuildCollectionGroupActionCBORResponse)
+{
+ OCResource *res = (OCResource*)OICMalloc(sizeof(OCResource));
+ OCEntityHandlerRequest *request = (OCEntityHandlerRequest*)OICMalloc(sizeof(OCEntityHandlerRequest));
+ OCRepPayload *RepPayload = OCRepPayloadCreate();
+ char temp[1024] = {0};
+ strncat(temp, "house*",6);
+ strncat(temp, "5 1", 3);
+ strncat(temp, "*uri=/a/light|switch=on*uri=/a/fan|switch=off", 45);
+ char *val = OICStrdup(temp);
+ OCRepPayloadSetPropString(RepPayload, "ActionSet", temp);
+ request->payload = (OCPayload*)RepPayload;
+ res->actionsetHead = createAction("house");
+ EXPECT_EQ(OC_STACK_ERROR, BuildCollectionGroupActionCBORResponse(OC_REST_PUT, res, request));
+}
+TEST(BuildCollectionGroupActionCBORResponseDeleteTest, BuildCollectionGroupActionCBORResponse)
+{
+ OCResource *res = (OCResource*)OICMalloc(sizeof(OCResource));
+ OCEntityHandlerRequest *request = (OCEntityHandlerRequest*)OICMalloc(sizeof(OCEntityHandlerRequest));
+ OCRepPayload *RepPayload = OCRepPayloadCreate();
+ char temp[1024] = {0};
+ strncat(temp, "house", 5);
+ char *val = OICStrdup(temp);
+ OCRepPayloadSetPropString(RepPayload, "DelActionSet", temp);
+ request->payload = (OCPayload*)RepPayload;
+ res->actionsetHead = createAction("house");
+ EXPECT_EQ(OC_STACK_ERROR, BuildCollectionGroupActionCBORResponse(OC_REST_PUT, res, request));
+}
+TEST(BuildCollectionGroupActionCBORResponsePOSTTest, BuildCollectionGroupActionCBORResponse)
+{
+ OCResource *res = (OCResource*)OICMalloc(sizeof(OCResource));
+ OCEntityHandlerRequest *request = (OCEntityHandlerRequest*)OICMalloc(sizeof(OCEntityHandlerRequest));
+ OCRepPayload *RepPayload = OCRepPayloadCreate();
+ char temp[1024] = {0};
+ strncat(temp, "house*1", 7);
+ char *val = OICStrdup(temp);
+ OCRepPayloadSetPropString(RepPayload, "DoScheduledAction", temp);
+ request->payload = (OCPayload*)RepPayload;
+ res->actionsetHead = createAction("house");
+ res->uri = (char*)OICMalloc(9);
+ strncpy(res->uri , "/a/light" , 9);
+ EXPECT_EQ(OC_STACK_ERROR, BuildCollectionGroupActionCBORResponse(OC_REST_POST, res, request));
+}
+TEST(BuildCollectionGroupActionCBORResponseCancelActionTest, BuildCollectionGroupActionCBORResponse)
+{
+ OCResource *res = (OCResource*)OICMalloc(sizeof(OCResource));
+ OCEntityHandlerRequest *request = (OCEntityHandlerRequest*)OICMalloc(sizeof(OCEntityHandlerRequest));
+ OCRepPayload *RepPayload = OCRepPayloadCreate();
+ char temp[1024] = {0};
+ strncat(temp, "house", 5);
+ char *val = OICStrdup(temp);
+ OCRepPayloadSetPropString(RepPayload, "CancelAction", temp);
+ request->payload = (OCPayload*)RepPayload;
+ res->actionsetHead = createAction("house");
+ res->uri = (char*)OICMalloc(9);
+ strncpy(res->uri , "/a/light" , 9);
+ EXPECT_EQ(OC_STACK_ERROR, BuildCollectionGroupActionCBORResponse(OC_REST_POST, res, request));
+}
+TEST(BuildCollectionGroupActionCBORResponseGetActionTest, BuildCollectionGroupActionCBORResponse)
+{
+ OCResource *res = (OCResource*)OICMalloc(sizeof(OCResource));
+ OCEntityHandlerRequest *request = (OCEntityHandlerRequest*)OICMalloc(sizeof(OCEntityHandlerRequest));
+ OCRepPayload *RepPayload = OCRepPayloadCreate();
+ char temp[1024] = {0};
+ strncat(temp, "house", 5);
+ char *val = OICStrdup(temp);
+ OCRepPayloadSetPropString(RepPayload, "GetActionSet", temp);
+ request->payload = (OCPayload*)RepPayload;
+ res->actionsetHead = createAction("house");
+ res->uri = (char*)OICMalloc(9);
+ strncpy(res->uri , "/a/light" , 9);
+ EXPECT_EQ(OC_STACK_ERROR, BuildCollectionGroupActionCBORResponse(OC_REST_POST, res, request));
+}
+
+