Eliminate result code from RCSGetResponse and RCSSetResponse.
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 18 Sep 2015 11:02:46 +0000 (04:02 -0700)
committerMadan Lanka <lanka.madan@samsung.com>
Sat, 19 Sep 2015 06:56:52 +0000 (06:56 +0000)
It turned out there is no reason for users to set the result code.
The only scenario that RCSResponses have not OK for the result is that there is an error occurred
and in that case it should be an exception on resource-encapsulation layer.

Change-Id: Icef409ea5e224f9f02e12e174231baa4e11c5a33
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2705
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceObject.cpp
service/resource-encapsulation/include/RCSResponse.h
service/resource-encapsulation/src/resourceContainer/src/ResourceContainerImpl.cpp
service/resource-encapsulation/src/serverBuilder/include/RequestHandler.h
service/resource-encapsulation/src/serverBuilder/src/RCSResponse.cpp
service/resource-encapsulation/src/serverBuilder/src/RequestHandler.cpp
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp
service/resource-encapsulation/src/serverBuilder/unittests/RCSResponseTest.cpp
service/resource-encapsulation/src/serverBuilder/unittests/RequestHandlerTest.cpp
service/resource-encapsulation/unittests/ResourceClientTest.cpp

index 34e129f..36a298d 100644 (file)
@@ -202,18 +202,17 @@ namespace
 
         if (responseAttrsObj)
         {
-            return RESPONSE::create(toNativeAttributes(env.get(), responseAttrsObj), OC_EH_OK,
-                    errorCode);
+            return RESPONSE::create(toNativeAttributes(env.get(), responseAttrsObj), errorCode);
         }
 
-        return RESPONSE::create(OC_EH_OK, errorCode);
+        return RESPONSE::create(errorCode);
     }
 
     RCSGetResponse onGetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
             const JavaGlobalRef& listener)
     {
         ScopedEnvWrapper env;
-        EXPECT_RET(env, "env is null!", RCSGetResponse::create(OC_EH_ERROR, -1));
+        EXPECT_RET(env, "env is null!", RCSGetResponse::create(-1));
 
         try
         {
@@ -227,14 +226,14 @@ namespace
             env->ExceptionDescribe();
             env->ExceptionClear();
         }
-        return RCSGetResponse::create(OC_EH_ERROR, -1);
+        return RCSGetResponse::create({ }, -1);
     }
 
     RCSSetResponse onSetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
              const JavaGlobalRef& listener)
     {
         ScopedEnvWrapper env;
-        EXPECT_RET(env, "env is null!", RCSSetResponse::create(OC_EH_ERROR, -1));
+        EXPECT_RET(env, "env is null!", RCSSetResponse::create(-1));
 
         try
         {
@@ -251,7 +250,7 @@ namespace
             env->ExceptionDescribe();
             env->ExceptionClear();
         }
-        return RCSSetResponse::create(OC_EH_ERROR, -1);
+        return RCSSetResponse::create(-1);
     }
 
 
index 43a8e40..cf607d5 100644 (file)
@@ -29,8 +29,6 @@
 #include <cstdint>
 #include <memory>
 
-#include <octypes.h>
-
 namespace OIC
 {
     namespace Service
@@ -61,11 +59,10 @@ namespace OIC
              * Creates a RCSGetResponse with a result and error code passed.
              * The attributes of the RCSResourceObject will be set as the result attributes.
              *
-             * @param result The response result.
              * @param errorCode The error code to set in response.
              *
              */
-            static RCSGetResponse create(const OCEntityHandlerResult& result, int errorCode);
+            static RCSGetResponse create(int errorCode);
 
             /**
              * Creates a RCSGetResponse with custom attributes.
@@ -90,20 +87,17 @@ namespace OIC
              * instead of the one the RCSResourceObject holds.
              *
              * @param attrs The attributes to set.
-             * @param result The response result.
              * @param errorCode The error code for response.
              *
              * @see RCSResourceAttributes
              *
              */
-            static RCSGetResponse create(const RCSResourceAttributes& attrs,
-                    const OCEntityHandlerResult& result, int errorCode);
+            static RCSGetResponse create(const RCSResourceAttributes& attrs, int errorCode);
 
             /**
              * @override
              */
-            static RCSGetResponse create(RCSResourceAttributes&& attrs,
-                    const OCEntityHandlerResult& result, int errorCode);
+            static RCSGetResponse create(RCSResourceAttributes&& attrs, int errorCode);
 
             //! @cond
             RequestHandler* getHandler() const;
@@ -174,11 +168,10 @@ namespace OIC
              * with a result and error code passed.
              * The attributes of the RCSResourceObject will be set as the result attributes.
              *
-             * @param result The response result.
              * @param errorCode The error code to set in response.
              *
              */
-            static RCSSetResponse accept(const OCEntityHandlerResult& result, int errorCode);
+            static RCSSetResponse accept(int errorCode);
 
             /**
              * Creates a default RCSSetResponse that has AcceptanceMethod::IGNORE.
@@ -193,22 +186,20 @@ namespace OIC
              * with a result and error code passed.
              * The attributes of the RCSResourceObject will be set as the result attributes.
              *
-             * @param result The response result.
              * @param errorCode The error code to set in response.
              *
              */
-            static RCSSetResponse ignore(const OCEntityHandlerResult& result, int errorCode);
+            static RCSSetResponse ignore(int errorCode);
 
             /**
              * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT
              * with a result and error code passed.
              * The attributes of the RCSResourceObject will be set as the result attributes.
              *
-             * @param result The response result.
              * @param errorCode The error code to set in response.
              *
              */
-            static RCSSetResponse create(const OCEntityHandlerResult& result, int errorCode);
+            static RCSSetResponse create(int errorCode);
 
             /**
              * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT with custom attributes.
@@ -225,7 +216,7 @@ namespace OIC
             /**
              * @override
              */
-            static RCSSetResponse create(RCSResourceAttributes &&attrs);
+            static RCSSetResponse create(RCSResourceAttributes&& attrs);
 
             /**
              * Creates a RCSSetResponse with a result and error code passed.
@@ -239,15 +230,12 @@ namespace OIC
              * @see RCSResourceAttributes
              *
              */
-            static RCSSetResponse create(const RCSResourceAttributes& attrs,
-                    const OCEntityHandlerResult& result, int errorCode);
-
+            static RCSSetResponse create(const RCSResourceAttributes& attrs, int errorCode);
 
             /**
              * @override
              */
-            static RCSSetResponse create(RCSResourceAttributes &&attrs,
-                    const OCEntityHandlerResult &result, int errorCode);
+            static RCSSetResponse create(RCSResourceAttributes&& attrs, int errorCode);
 
 
             //! @cond/
index c696fbd..d0321be 100644 (file)
@@ -350,8 +350,6 @@ namespace OIC
         RCSGetResponse ResourceContainerImpl::getRequestHandler(const RCSRequest &request,
                 const RCSResourceAttributes &)
         {
-            OCEntityHandlerResult result = OC_EH_ERROR;
-
             RCSResourceAttributes attr;
             std::string strResourceUri = request.getResourceUri();
 
@@ -367,18 +365,15 @@ namespace OIC
                     boost::thread getThread(getFunction);
                     getThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
 
-                    result = OC_EH_OK;
                 }
             }
 
-            return RCSGetResponse::create(attr, result, 200);
+            return RCSGetResponse::create(std::move(attr), 200);
         }
 
         RCSSetResponse ResourceContainerImpl::setRequestHandler(const RCSRequest &request,
                 const RCSResourceAttributes &attributes)
         {
-            OCEntityHandlerResult result = OC_EH_ERROR;
-
             RCSResourceAttributes attr;
             std::list<std::string> lstAttributes;
             std::string strResourceUri = request.getResourceUri();
@@ -406,12 +401,10 @@ namespace OIC
                     };
                     boost::thread setThread(setFunction);
                     setThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
-
-                    result = OC_EH_OK;
                 }
             }
 
-            return RCSSetResponse::create(attr, result, 200);
+            return RCSSetResponse::create(std::move(attr), 200);
         }
 
         void ResourceContainerImpl::onNotificationReceived(const std::string &strResourceUri)
index 7ee45b6..8c6f345 100644 (file)
@@ -47,23 +47,17 @@ namespace OIC
             typedef std::shared_ptr< RequestHandler > Pre;
 
             static constexpr int DEFAULT_ERROR_CODE = 200;
-            static constexpr OCEntityHandlerResult DEFAULT_RESULT = OC_EH_OK;
 
             RequestHandler();
 
             RequestHandler(const RequestHandler&) = delete;
             RequestHandler(RequestHandler&&) = default;
 
-            RequestHandler(const OCEntityHandlerResult& result, int errorCode);
+            RequestHandler(int errorCode);
 
-            RequestHandler(const RCSResourceAttributes&,
-                    const OCEntityHandlerResult& result = DEFAULT_RESULT,
-                    int errorCode = DEFAULT_ERROR_CODE);
-
-            RequestHandler(RCSResourceAttributes&&,
-                    const OCEntityHandlerResult& result = DEFAULT_RESULT,
-                    int errorCode = DEFAULT_ERROR_CODE);
+            RequestHandler(const RCSResourceAttributes&, int errorCode = DEFAULT_ERROR_CODE);
 
+            RequestHandler(RCSResourceAttributes&&, int errorCode = DEFAULT_ERROR_CODE);
 
             virtual ~RequestHandler() { };
 
@@ -87,15 +81,11 @@ namespace OIC
 
             SetRequestHandler();
 
-            SetRequestHandler(const OCEntityHandlerResult& result, int errorCode);
+            SetRequestHandler(int errorCode);
 
-            SetRequestHandler(const RCSResourceAttributes&,
-                    const OCEntityHandlerResult& result = DEFAULT_RESULT,
-                    int errorCode = DEFAULT_ERROR_CODE);
+            SetRequestHandler(const RCSResourceAttributes&, int errorCode = DEFAULT_ERROR_CODE);
 
-            SetRequestHandler(RCSResourceAttributes&&,
-                    const OCEntityHandlerResult& result = DEFAULT_RESULT,
-                    int errorCode = DEFAULT_ERROR_CODE);
+            SetRequestHandler(RCSResourceAttributes&&, int errorCode = DEFAULT_ERROR_CODE);
 
             AttrKeyValuePairs applyAcceptanceMethod(RCSSetResponse::AcceptanceMethod,
                     RCSResourceObject&, const RCSResourceAttributes&) const;
index 4151338..9a91c61 100644 (file)
@@ -30,16 +30,13 @@ namespace OIC
     {
         RCSGetResponse RCSGetResponse::defaultAction()
         {
-            static RCSGetResponse defaultRes { std::make_shared< RequestHandler >() };
-
-            return defaultRes;
+            return std::make_shared< RequestHandler >();
         }
 
-        RCSGetResponse RCSGetResponse::create(const OCEntityHandlerResult& result,
-                int errorCode)
+        RCSGetResponse RCSGetResponse::create(int errorCode)
         {
             return RCSGetResponse {
-                std::make_shared< RequestHandler >( result, errorCode) };
+                std::make_shared< RequestHandler >( errorCode) };
         }
 
         RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs)
@@ -47,11 +44,9 @@ namespace OIC
             return RCSGetResponse { std::make_shared< RequestHandler >(attrs) };
         }
 
-        RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs,
-                const OCEntityHandlerResult& result, int errorCode)
+        RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs, int errorCode)
         {
-            return RCSGetResponse {
-                std::make_shared< RequestHandler >(attrs, result, errorCode) };
+            return RCSGetResponse { std::make_shared< RequestHandler >(attrs, errorCode) };
         }
 
         RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& result)
@@ -60,11 +55,10 @@ namespace OIC
                 std::make_shared< RequestHandler >(std::move(result)) };
         }
 
-        RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& attrs,
-                const OCEntityHandlerResult& result, int errorCode)
+        RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& attrs, int errorCode)
         {
             return RCSGetResponse { std::make_shared< RequestHandler >(
-                std::move(attrs), result, errorCode) };
+                std::move(attrs), errorCode) };
         }
 
         RCSGetResponse::RCSGetResponse(std::shared_ptr< RequestHandler >&& handler) :
@@ -89,10 +83,9 @@ namespace OIC
             return defaultAction().setAcceptanceMethod(AcceptanceMethod::ACCEPT);
         }
 
-        RCSSetResponse RCSSetResponse::accept(const OCEntityHandlerResult& result,
-                int errorCode)
+        RCSSetResponse RCSSetResponse::accept(int errorCode)
         {
-            return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
+            return create(errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
         }
 
         RCSSetResponse RCSSetResponse::ignore()
@@ -100,16 +93,14 @@ namespace OIC
             return defaultAction().setAcceptanceMethod(AcceptanceMethod::IGNORE);
         }
 
-        RCSSetResponse RCSSetResponse::ignore(const OCEntityHandlerResult& result,
-                int errorCode)
+        RCSSetResponse RCSSetResponse::ignore(int errorCode)
         {
-            return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
+            return create(errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
         }
 
-        RCSSetResponse RCSSetResponse::create(const OCEntityHandlerResult& result,
-                int errorCode)
+        RCSSetResponse RCSSetResponse::create(int errorCode)
         {
-            return std::make_shared< SetRequestHandler >(result, errorCode);
+            return std::make_shared< SetRequestHandler >(errorCode);
         }
 
         RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs)
@@ -117,10 +108,9 @@ namespace OIC
             return std::make_shared< SetRequestHandler >(attrs);
         }
 
-        RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs,
-                const OCEntityHandlerResult& result, int errorCode)
+        RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs, int errorCode)
         {
-            return std::make_shared< SetRequestHandler >(attrs, result, errorCode);
+            return std::make_shared< SetRequestHandler >(attrs, errorCode);
         }
 
         RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& result)
@@ -128,10 +118,9 @@ namespace OIC
             return std::make_shared< SetRequestHandler >(std::move(result));
         }
 
-        RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& attrs,
-                const OCEntityHandlerResult& result, int errorCode)
+        RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& attrs, int errorCode)
         {
-            return std::make_shared< SetRequestHandler >(std::move(attrs), result, errorCode);
+            return std::make_shared< SetRequestHandler >(std::move(attrs), errorCode);
         }
 
         RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
index 58e8594..f1facbc 100644 (file)
@@ -25,6 +25,8 @@
 #include <RCSResourceObject.h>
 #include <ResourceAttributesUtils.h>
 
+#include <octypes.h>
+
 namespace
 {
     using namespace OIC::Service;
@@ -49,11 +51,11 @@ namespace
     }
 
     std::shared_ptr< OC::OCResourceResponse > doBuildResponse(RCSResourceObject& resource,
-            const OCEntityHandlerResult result, int errorCode, OCRepresentationGetter ocRepGetter)
+             int errorCode, OCRepresentationGetter ocRepGetter)
     {
         auto response = std::make_shared< OC::OCResourceResponse >();
 
-        response->setResponseResult(result);
+        response->setResponseResult(OC_EH_OK);
         response->setErrorCode(errorCode);
         response->setResourceRepresentation(ocRepGetter(resource));
 
@@ -113,30 +115,27 @@ namespace OIC
     namespace Service
     {
         constexpr int RequestHandler::DEFAULT_ERROR_CODE;
-        constexpr OCEntityHandlerResult RequestHandler::DEFAULT_RESULT;
 
         RequestHandler::RequestHandler() :
-                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, DEFAULT_RESULT,
-                        DEFAULT_ERROR_CODE, getOCRepresentationFromResource) }
+                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, DEFAULT_ERROR_CODE,
+                        getOCRepresentationFromResource) }
         {
         }
 
-        RequestHandler::RequestHandler(const OCEntityHandlerResult& result, int errorCode) :
-                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, result, errorCode,
+        RequestHandler::RequestHandler(int errorCode) :
+                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, errorCode,
                         getOCRepresentationFromResource) }
         {
         }
 
-        RequestHandler::RequestHandler(const RCSResourceAttributes& attrs,
-                const OCEntityHandlerResult& result, int errorCode) :
-                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, result, errorCode,
+        RequestHandler::RequestHandler(const RCSResourceAttributes& attrs, int errorCode) :
+                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, errorCode,
                         wrapGetOCRepresentation(attrs)) }
         {
         }
 
-        RequestHandler::RequestHandler(RCSResourceAttributes&& attrs,
-                const OCEntityHandlerResult& result, int errorCode) :
-                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, result, errorCode,
+        RequestHandler::RequestHandler(RCSResourceAttributes&& attrs, int errorCode) :
+                m_holder{ std::bind(doBuildResponse, std::placeholders::_1, errorCode,
                         wrapGetOCRepresentation(std::move(attrs))) }
         {
         }
@@ -153,21 +152,19 @@ namespace OIC
         {
         }
 
-        SetRequestHandler::SetRequestHandler(const OCEntityHandlerResult& result, int errorCode) :
-                RequestHandler{ result, errorCode }
+        SetRequestHandler::SetRequestHandler(int errorCode) :
+                RequestHandler{ errorCode }
         {
         }
 
 
-        SetRequestHandler::SetRequestHandler(const RCSResourceAttributes& attrs,
-                const OCEntityHandlerResult& result, int errorCode) :
-                RequestHandler{ attrs, result, errorCode }
+        SetRequestHandler::SetRequestHandler(const RCSResourceAttributes& attrs, int errorCode) :
+                RequestHandler{ attrs, errorCode }
         {
         }
 
-        SetRequestHandler::SetRequestHandler(RCSResourceAttributes&& attrs,
-                const OCEntityHandlerResult& result, int errorCode) :
-                RequestHandler{ std::move(attrs), result, errorCode }
+        SetRequestHandler::SetRequestHandler(RCSResourceAttributes&& attrs,  int errorCode) :
+                RequestHandler{ std::move(attrs), errorCode }
         {
         }
 
index f00d33a..3e15bbc 100644 (file)
@@ -167,6 +167,7 @@ TEST_F(ResourceObjectTest, SettingNestedVectorAttributesIsSameToGettingNestedVec
     ASSERT_EQ(arr31, server->getAttribute<vector<vector<vector<int>>>>(KEY));
 }
 
+
 class AutoNotifyTest: public ResourceObjectTest
 {
 protected:
@@ -374,30 +375,27 @@ TEST_F(ResourceObjectHandlingRequestTest, SendResponseWithSameHandlesPassedByReq
 TEST_F(ResourceObjectHandlingRequestTest, SendResponseWithRCSResponseResults)
 {
     constexpr int errorCode{ 1999 };
-    constexpr OCEntityHandlerResult result{ OC_EH_SLOW };
 
     server->setGetRequestHandler(
             [](const RCSRequest&, RCSResourceAttributes&) -> RCSGetResponse
             {
-                return RCSGetResponse::create(result, errorCode);
+                return RCSGetResponse::create(errorCode);
             }
     );
 
     mocks.ExpectCallFunc(OCPlatform::sendResponse).Match(
             [](const shared_ptr<OCResourceResponse> response)
             {
-                return response->getErrorCode() == errorCode &&
-                        response->getResponseResult() == result;
+                return response->getErrorCode() == errorCode;
             }
     ).Return(OC_STACK_OK);
 
     ASSERT_EQ(OC_EH_OK, handler(createRequest()));
 }
 
-TEST_F(ResourceObjectHandlingRequestTest, SendSetResponseWithCustomAttrsAndResults)
+TEST_F(ResourceObjectHandlingRequestTest, SendSetResponseWithCustomAttrs)
 {
     constexpr int errorCode{ 1999 };
-    constexpr OCEntityHandlerResult result{ OC_EH_SLOW };
     constexpr char value[]{ "value" };
 
     server->setSetRequestHandler(
@@ -405,7 +403,7 @@ TEST_F(ResourceObjectHandlingRequestTest, SendSetResponseWithCustomAttrsAndResul
             {
                 RCSResourceAttributes attrs;
                 attrs[KEY] = value;
-                return RCSSetResponse::create(attrs, result, errorCode);
+                return RCSSetResponse::create(attrs, errorCode);
             }
     );
 
@@ -413,8 +411,7 @@ TEST_F(ResourceObjectHandlingRequestTest, SendSetResponseWithCustomAttrsAndResul
             [](const shared_ptr<OCResourceResponse> response)
             {
                 return value == response->getResourceRepresentation()[KEY].getValue<std::string>()
-                        && response->getErrorCode() == errorCode
-                        && response->getResponseResult() == result;
+                        && response->getErrorCode() == errorCode;
             }
     ).Return(OC_STACK_OK);
 
index 16c7bb5..2ba3817 100644 (file)
@@ -43,10 +43,9 @@ typedef OCStackResult (*registerResourceSig)(OCResourceHandle&,
 static constexpr char KEY[] = "key";
 
 
-void EXPECT_RESPONSE(shared_ptr< OCResourceResponse > ocResponse,
-        const OCEntityHandlerResult& result, int errorCode, const RCSResourceAttributes& attrs)
+void EXPECT_RESPONSE(shared_ptr< OCResourceResponse > ocResponse, int errorCode,
+        const RCSResourceAttributes& attrs)
 {
-    EXPECT_EQ(ocResponse->getResponseResult(), result);
     EXPECT_EQ(ocResponse->getErrorCode(), errorCode);
     EXPECT_EQ(ResourceAttributesConverter::fromOCRepresentation(
                     ocResponse->getResourceRepresentation()), attrs);
@@ -80,34 +79,29 @@ protected:
 TEST_F(RCSResponseTest, GetDefaultActionHasEmptyAttrs)
 {
     EXPECT_RESPONSE(buildResponse(RCSGetResponse::defaultAction()),
-            RequestHandler::DEFAULT_RESULT, RequestHandler::DEFAULT_ERROR_CODE,
-            RCSResourceAttributes());
+            RequestHandler::DEFAULT_ERROR_CODE, RCSResourceAttributes());
 }
 
 TEST_F(RCSResponseTest, GetResponseHasResultsPassedCodes)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
-    EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(result, errorCode)),
-            result, errorCode, RCSResourceAttributes());
+    EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(errorCode)),
+            errorCode, RCSResourceAttributes());
 }
 
 TEST_F(RCSResponseTest, GetResponseHasAttrsAndResultsPassedCodes)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
     RCSResourceAttributes attrs;
     attrs[KEY] = 100;
 
-    EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(attrs, result, errorCode)),
-            result, errorCode, attrs);
+    EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(attrs, errorCode)), errorCode, attrs);
 }
 
 TEST_F(RCSResponseTest, GetResponseCanMoveAttrs)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
     RCSResourceAttributes attrs;
@@ -117,8 +111,8 @@ TEST_F(RCSResponseTest, GetResponseCanMoveAttrs)
     attrsClone[KEY] = 100;
 
     EXPECT_RESPONSE(
-            buildResponse(RCSGetResponse::create(std::move(attrs), result, errorCode)),
-            result, errorCode, attrsClone);
+            buildResponse(RCSGetResponse::create(std::move(attrs), errorCode)),
+            errorCode, attrsClone);
 
     EXPECT_TRUE(attrs.empty());
 }
@@ -126,34 +120,30 @@ TEST_F(RCSResponseTest, GetResponseCanMoveAttrs)
 TEST_F(RCSResponseTest, SetDefaultActionHasEmptyAttrs)
 {
     EXPECT_RESPONSE(buildResponse(RCSSetResponse::defaultAction()),
-            RequestHandler::DEFAULT_RESULT, RequestHandler::DEFAULT_ERROR_CODE,
-            RCSResourceAttributes());
+            RequestHandler::DEFAULT_ERROR_CODE, RCSResourceAttributes());
 }
 
 TEST_F(RCSResponseTest, SetResponseHasResultsPassedCodes)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
-    EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(result, errorCode)),
-            result, errorCode, RCSResourceAttributes());
+    EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(errorCode)),
+            errorCode, RCSResourceAttributes());
 }
 
 TEST_F(RCSResponseTest, SetResponseHasAttrsAndResultsPassedCodes)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
     RCSResourceAttributes attrs;
     attrs[KEY] = 100;
 
-    EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(attrs, result, errorCode)),
-            result, errorCode, attrs);
+    EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(attrs, errorCode)),
+            errorCode, attrs);
 }
 
 TEST_F(RCSResponseTest, SetResponseCanMoveAttrs)
 {
-    constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
     constexpr int errorCode{ -10 };
 
     RCSResourceAttributes attrs;
@@ -162,9 +152,8 @@ TEST_F(RCSResponseTest, SetResponseCanMoveAttrs)
     RCSResourceAttributes attrsClone;
     attrsClone[KEY] = 100;
 
-    EXPECT_RESPONSE(
-            buildResponse(RCSSetResponse::create(std::move(attrs), result, errorCode)),
-            result, errorCode, attrsClone);
+    EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(std::move(attrs), errorCode)),
+            errorCode, attrsClone);
 
     EXPECT_TRUE(attrs.empty());
 }
index 9761f3d..88d2757 100644 (file)
@@ -61,11 +61,10 @@ protected:
 
 TEST_F(RequestHandlerTest, ResponseHasSameValuesPassedToHandlerConstructor)
 {
-    RequestHandler handler{ OC_EH_ERROR, -1000 };
+    RequestHandler handler{ -1000 };
 
     auto response = handler.buildResponse(*server);
 
-    ASSERT_EQ(OC_EH_ERROR, response->getResponseResult());
     ASSERT_EQ(-1000, response->getErrorCode());
 }
 
index 732e0fe..64edc87 100644 (file)
@@ -73,6 +73,8 @@ protected:
         CreateResource();
 
         WaitUntilDiscovered();
+
+        ASSERT_NE(object, nullptr);
     }
 
     void TearDown()
@@ -100,7 +102,7 @@ private:
 
     void WaitUntilDiscovered()
     {
-        while (checkObject())
+        for (int i=0; i<10 && checkObject(); ++i)
         {
             const std::string uri  = "/oic/res";
             const std::string type = "Resource.Hosting";