The headers to be exposed as a part of API are moved to include folder of root of resource-manipulation
Change-Id: I40ee68e9aefcacdaef2272338674b66d5dbbf47c
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1703
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef RES_MANIPULATION_PRIMITIVEEXCEPTION_H
-#define RES_MANIPULATION_PRIMITIVEEXCEPTION_H
+#ifndef RES_MANIPULATION_RCSEXCEPTION_H
+#define RES_MANIPULATION_RCSEXCEPTION_H
#include <string>
namespace Service
{
- class PrimitiveException: public std::exception
+ class RCSException: public std::exception
{
public:
- PrimitiveException() {}
- explicit PrimitiveException(const std::string& what) : m_what{ what } {}
- explicit PrimitiveException(std::string&& what) : m_what{ std::move(what) } {}
+ RCSException();
+ explicit RCSException(const std::string&);
+ explicit RCSException(std::string&&);
- virtual ~PrimitiveException() noexcept {}
+ virtual ~RCSException() noexcept {}
- virtual const char* what() const noexcept
- {
- return m_what.c_str();
- }
+ virtual const char* what() const noexcept;
private:
std::string m_what;
};
- class PlatformException: public PrimitiveException
+ class PlatformException: public RCSException
{
public:
explicit PlatformException(OCStackResult reason);
}
}
-#endif // RES_MANIPULATION_PRIMITIVEEXCEPTION_H
+#endif // RES_MANIPULATION_RCSEXCEPTION_H
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef __PRIMITIVEREQUEST_H
-#define __PRIMITIVEREQUEST_H
+#ifndef SERVERBUILDER_PRIMITIVEREQUEST_H
+#define SERVERBUILDER_PRIMITIVEREQUEST_H
#include <string>
namespace Service
{
- class PrimitiveRequest
+ class RCSRequest
{
public:
- explicit PrimitiveRequest(const std::string& resourceUri);
+ explicit RCSRequest(const std::string& resourceUri);
- PrimitiveRequest& operator=(PrimitiveRequest&) = delete;
+ RCSRequest& operator=(RCSRequest&) = delete;
std::string getResourceUri() const;
}
}
-#endif // __PRIMITIVEREQUEST_H
+#endif // SERVERBUILDER_PRIMITIVEREQUEST_H
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef __PRIMITIVERESPONSE_H
-#define __PRIMITIVERESPONSE_H
+#ifndef SERVERBUILDER_RCSRESPONSE_H
+#define SERVERBUILDER_RCSRESPONSE_H
#include <cstdint>
#include <memory>
class RequestHandler;
class SetRequestHandler;
- class PrimitiveGetResponse
+ class RCSGetResponse
{
public:
- static PrimitiveGetResponse defaultAction();
+ static RCSGetResponse defaultAction();
- static PrimitiveGetResponse create(const OCEntityHandlerResult&, int errorCode);
+ static RCSGetResponse create(const OCEntityHandlerResult&, int errorCode);
- static PrimitiveGetResponse create(const ResourceAttributes&);
- static PrimitiveGetResponse create(const ResourceAttributes&,
+ static RCSGetResponse create(const ResourceAttributes&);
+ static RCSGetResponse create(const ResourceAttributes&,
const OCEntityHandlerResult&, int errorCode);
- static PrimitiveGetResponse create(ResourceAttributes&&);
- static PrimitiveGetResponse create(ResourceAttributes&&, const OCEntityHandlerResult&,
+ static RCSGetResponse create(ResourceAttributes&&);
+ static RCSGetResponse create(ResourceAttributes&&, const OCEntityHandlerResult&,
int errorCode);
RequestHandler* getHandler() const;
private:
- PrimitiveGetResponse(std::shared_ptr< RequestHandler >&&);
+ RCSGetResponse(std::shared_ptr< RequestHandler >&&);
private:
std::shared_ptr< RequestHandler > m_handler;
};
- class PrimitiveSetResponse
+ class RCSSetResponse
{
public:
enum class AcceptanceMethod
IGNORE
};
- static PrimitiveSetResponse defaultAction();
+ static RCSSetResponse defaultAction();
- static PrimitiveSetResponse accept();
- static PrimitiveSetResponse accept(const OCEntityHandlerResult&, int errorCode);
+ static RCSSetResponse accept();
+ static RCSSetResponse accept(const OCEntityHandlerResult&, int errorCode);
- static PrimitiveSetResponse ignore();
- static PrimitiveSetResponse ignore(const OCEntityHandlerResult&, int errorCode);
+ static RCSSetResponse ignore();
+ static RCSSetResponse ignore(const OCEntityHandlerResult&, int errorCode);
- static PrimitiveSetResponse create(const OCEntityHandlerResult&, int errorCode);
+ static RCSSetResponse create(const OCEntityHandlerResult&, int errorCode);
- static PrimitiveSetResponse create(const ResourceAttributes&);
- static PrimitiveSetResponse create(const ResourceAttributes&,
+ static RCSSetResponse create(const ResourceAttributes&);
+ static RCSSetResponse create(const ResourceAttributes&,
const OCEntityHandlerResult&, int errorCode);
- static PrimitiveSetResponse create(ResourceAttributes&&);
- static PrimitiveSetResponse create(ResourceAttributes&&, const OCEntityHandlerResult&,
+ static RCSSetResponse create(ResourceAttributes&&);
+ static RCSSetResponse create(ResourceAttributes&&, const OCEntityHandlerResult&,
int errorCode);
SetRequestHandler* getHandler() const;
AcceptanceMethod getAcceptanceMethod() const;
- PrimitiveSetResponse& setAcceptanceMethod(AcceptanceMethod);
+ RCSSetResponse& setAcceptanceMethod(AcceptanceMethod);
private:
- PrimitiveSetResponse(std::shared_ptr< SetRequestHandler >&&);
- PrimitiveSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
+ RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
+ RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
private:
AcceptanceMethod m_acceptanceMethod;
}
}
-#endif
+#endif // SERVERBUILDER_RCSRESPONSE_H
#include <boost/mpl/begin_end.hpp>
#include <boost/scoped_ptr.hpp>
-#include <PrimitiveException.h>
+#include <RCSException.h>
namespace OIC
{
namespace Service
{
- class BadGetException: public PrimitiveException
+ class BadGetException: public RCSException
{
public:
- BadGetException(const std::string& what) : PrimitiveException{ what } {}
- BadGetException(std::string&& what) : PrimitiveException{ std::move(what) } {}
+ BadGetException(const std::string& what) : RCSException{ what } {}
+ BadGetException(std::string&& what) : RCSException{ std::move(what) } {}
};
- class InvalidKeyException: public PrimitiveException
+ class InvalidKeyException: public RCSException
{
public:
- InvalidKeyException(const std::string& what) : PrimitiveException{ what } {}
- InvalidKeyException(std::string&& what) : PrimitiveException{ std::move(what) } {}
+ InvalidKeyException(const std::string& what) : RCSException{ what } {}
+ InvalidKeyException(std::string&& what) : RCSException{ std::move(what) } {}
};
class ResourceAttributes
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef __OIC_RESOURCEOBJECT_H
-#define __OIC_RESOURCEOBJECT_H
+#ifndef SERVERBUILDER_RESOURCEOBJECT_H
+#define SERVERBUILDER_RESOURCEOBJECT_H
#include <string>
#include <mutex>
#include <boost/atomic.hpp>
#include <ResourceAttributes.h>
-#include <PrimitiveResponse.h>
-#include <PrimitiveRequest.h>
+#include <RCSResponse.h>
+#include <RCSRequest.h>
namespace OC
{
namespace Service
{
- class NoLockException: public PrimitiveException
+ class NoLockException: public RCSException
{
public:
- NoLockException(std::string&& what) : PrimitiveException{ std::move(what) } {}
+ NoLockException(std::string&& what) : RCSException{ std::move(what) } {}
};
class ResourceObject
class LockGuard;
- typedef std::function< PrimitiveGetResponse(const PrimitiveRequest&,
+ typedef std::function< RCSGetResponse(const RCSRequest&,
ResourceAttributes&) > GetRequestHandler;
- typedef std::function< PrimitiveSetResponse(const PrimitiveRequest&,
+ typedef std::function< RCSSetResponse(const RCSRequest&,
ResourceAttributes&) > SetRequestHandler;
typedef std::function< void(const ResourceAttributes::Value&,
const ResourceAttributes::Value&) > AttributeUpdatedHandler;
}
}
-#endif // __OIC_RESOURCEOBJECT_H
+#endif // SERVERBUILDER_RESOURCEOBJECT_H
######################################################################
# Build flags
######################################################################
-service_common_env.AppendUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs', 'include', 'src'])
+service_common_env.AppendUnique(CPPPATH = [
+ env.get('SRC_DIR')+'/extlibs',
+ '../../../include',
+ 'include'])
if target_os not in ['windows', 'winrt']:
service_common_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
#include <octypes.h>
#include <OCException.h>
-#include <PrimitiveException.h>
+#include <RCSException.h>
namespace OIC
{
typedef A type;
};
-
template< typename T, typename = typename std::enable_if<
std::is_class<T>::value && std::is_pointer<T>::value>::type >
struct EnableIfClassPointer
#include <PrimitiveResource.h>
#include <ResponseStatement.h>
-#include <internal/AssertUtils.h>
+#include <AssertUtils.h>
-#include <internal/ResourceAttributesConverter.h>
+#include <ResourceAttributesConverter.h>
namespace OIC
{
#include <PresenceSubscriber.h>
-#include <internal/AssertUtils.h>
+#include <AssertUtils.h>
#include <OCPlatform.h>
#include <PrimitiveResource.h>
-#include <internal/PrimitiveResourceImpl.h>
-#include <internal/AssertUtils.h>
+#include <PrimitiveResourceImpl.h>
+#include <AssertUtils.h>
#include <OCPlatform.h>
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <PrimitiveException.h>
+#include <RCSException.h>
#include <OCException.h>
namespace Service
{
+ RCSException::RCSException()
+ {
+ }
+
+ RCSException::RCSException(const std::string& what) :
+ m_what{ what }
+ {
+ }
+
+ RCSException::RCSException(std::string&& what) :
+ m_what{ std::move(what) }
+ {
+ }
+
+ const char* RCSException::what() const noexcept
+ {
+ return m_what.c_str();
+ }
+
+
PlatformException::PlatformException(OCStackResult reason) :
- PrimitiveException{ "Failed : " + OC::OCException::reason(reason) },
- m_reason { reason }
+ RCSException{ "Failed : " + OC::OCException::reason(reason) },
+ m_reason { reason }
{
}
#include <ResourceAttributes.h>
-#include <internal/ResourceAttributesUtils.h>
-#include <internal/ResourceAttributesConverter.h>
+#include <ResourceAttributesUtils.h>
+#include <ResourceAttributesConverter.h>
#include <boost/lexical_cast.hpp>
#include <boost/mpl/advance.hpp>
#include <ResponseStatement.h>
-#include <internal/ResourceAttributesConverter.h>
+#include <ResourceAttributesConverter.h>
namespace OIC
{
#include <HippoMocks/hippomocks.h>
#include <PresenceSubscriber.h>
-#include <PrimitiveException.h>
+#include <RCSException.h>
#include <OCPlatform.h>
#include <gtest/gtest.h>
#include <HippoMocks/hippomocks.h>
-#include <internal/PrimitiveResourceImpl.h>
-#include <internal/AssertUtils.h>
+#include <PrimitiveResourceImpl.h>
+#include <AssertUtils.h>
#include <OCResource.h>
#include <OCPlatform.h>
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <ResourceAttributes.h>
-#include <internal/ResourceAttributesConverter.h>
-#include <internal/ResourceAttributesUtils.h>
+#include <ResourceAttributesConverter.h>
+#include <ResourceAttributesUtils.h>
#include <gtest/gtest.h>
# Build flags
######################################################################
server_builder_env.AppendUnique(CPPPATH = [
- '../common/primitiveResource/include/',
+ '../common/primitiveResource/include',
+ '../../include',
])
server_builder_env.AppendUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs', 'include'])
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef __REQUESTHANDLER_H
-#define __REQUESTHANDLER_H
+#ifndef SERVERBUILDER_REQUESTHANDLER_H
+#define SERVERBUILDER_REQUESTHANDLER_H
#include <ResourceObject.h>
-#include <PrimitiveResponse.h>
-
-#include <internal/ResourceAttributesUtils.h>
+#include <RCSResponse.h>
+#include <ResourceAttributesUtils.h>
namespace OC
{
{
namespace Service
{
+
class RequestHandler
{
private:
const OCEntityHandlerResult& result = DEFAULT_RESULT,
int errorCode = DEFAULT_ERROR_CODE);
- AttrKeyValuePairs applyAcceptanceMethod(PrimitiveSetResponse::AcceptanceMethod,
+ AttrKeyValuePairs applyAcceptanceMethod(RCSSetResponse::AcceptanceMethod,
ResourceObject&, const ResourceAttributes&) const;
};
}
}
-#endif // __REQUESTHANDLER_H
+#endif // SERVERBUILDER_REQUESTHANDLER_H
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <PrimitiveRequest.h>
+#include <RCSRequest.h>
namespace OIC
{
namespace Service
{
- PrimitiveRequest::PrimitiveRequest(const std::string& resourceUri) :
+ RCSRequest::RCSRequest(const std::string& resourceUri) :
m_resourceUri{ resourceUri }
{
}
- std::string PrimitiveRequest::getResourceUri() const
+ std::string RCSRequest::getResourceUri() const
{
return m_resourceUri;
}
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <PrimitiveResponse.h>
+#include <RCSResponse.h>
-#include <internal/RequestHandler.h>
+#include <RequestHandler.h>
namespace OIC
{
namespace Service
{
- PrimitiveGetResponse PrimitiveGetResponse::defaultAction()
+ RCSGetResponse RCSGetResponse::defaultAction()
{
- static PrimitiveGetResponse defaultRes { std::make_shared< RequestHandler >() };
+ static RCSGetResponse defaultRes { std::make_shared< RequestHandler >() };
return defaultRes;
}
- PrimitiveGetResponse PrimitiveGetResponse::create(const OCEntityHandlerResult& result,
+ RCSGetResponse RCSGetResponse::create(const OCEntityHandlerResult& result,
int errorCode)
{
- return PrimitiveGetResponse {
+ return RCSGetResponse {
std::make_shared< RequestHandler >( result, errorCode) };
}
- PrimitiveGetResponse PrimitiveGetResponse::create(const ResourceAttributes& attrs)
+ RCSGetResponse RCSGetResponse::create(const ResourceAttributes& attrs)
{
- return PrimitiveGetResponse { std::make_shared< RequestHandler >(attrs) };
+ return RCSGetResponse { std::make_shared< RequestHandler >(attrs) };
}
- PrimitiveGetResponse PrimitiveGetResponse::create(const ResourceAttributes& attrs,
+ RCSGetResponse RCSGetResponse::create(const ResourceAttributes& attrs,
const OCEntityHandlerResult& result, int errorCode)
{
- return PrimitiveGetResponse {
+ return RCSGetResponse {
std::make_shared< RequestHandler >(attrs, result, errorCode) };
}
- PrimitiveGetResponse PrimitiveGetResponse::create(ResourceAttributes&& result)
+ RCSGetResponse RCSGetResponse::create(ResourceAttributes&& result)
{
- return PrimitiveGetResponse {
+ return RCSGetResponse {
std::make_shared< RequestHandler >(std::move(result)) };
}
- PrimitiveGetResponse PrimitiveGetResponse::create(ResourceAttributes&& attrs,
+ RCSGetResponse RCSGetResponse::create(ResourceAttributes&& attrs,
const OCEntityHandlerResult& result, int errorCode)
{
- return PrimitiveGetResponse { std::make_shared< RequestHandler >(
+ return RCSGetResponse { std::make_shared< RequestHandler >(
std::move(attrs), result, errorCode) };
}
- PrimitiveGetResponse::PrimitiveGetResponse(std::shared_ptr< RequestHandler >&& handler) :
+ RCSGetResponse::RCSGetResponse(std::shared_ptr< RequestHandler >&& handler) :
m_handler{ std::move(handler) }
{
assert(m_handler);
}
- RequestHandler* PrimitiveGetResponse::getHandler() const
+ RequestHandler* RCSGetResponse::getHandler() const
{
return m_handler.get();
}
- PrimitiveSetResponse PrimitiveSetResponse::defaultAction()
+ RCSSetResponse RCSSetResponse::defaultAction()
{
return std::make_shared< SetRequestHandler >();
}
- PrimitiveSetResponse PrimitiveSetResponse::accept()
+ RCSSetResponse RCSSetResponse::accept()
{
return defaultAction().setAcceptanceMethod(AcceptanceMethod::ACCEPT);
}
- PrimitiveSetResponse PrimitiveSetResponse::accept(const OCEntityHandlerResult& result,
+ RCSSetResponse RCSSetResponse::accept(const OCEntityHandlerResult& result,
int errorCode)
{
return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
}
- PrimitiveSetResponse PrimitiveSetResponse::ignore()
+ RCSSetResponse RCSSetResponse::ignore()
{
return defaultAction().setAcceptanceMethod(AcceptanceMethod::IGNORE);
}
- PrimitiveSetResponse PrimitiveSetResponse::ignore(const OCEntityHandlerResult& result,
+ RCSSetResponse RCSSetResponse::ignore(const OCEntityHandlerResult& result,
int errorCode)
{
return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
}
- PrimitiveSetResponse PrimitiveSetResponse::create(const OCEntityHandlerResult& result,
+ RCSSetResponse RCSSetResponse::create(const OCEntityHandlerResult& result,
int errorCode)
{
return std::make_shared< SetRequestHandler >(result, errorCode);
}
- PrimitiveSetResponse PrimitiveSetResponse::create(const ResourceAttributes& attrs)
+ RCSSetResponse RCSSetResponse::create(const ResourceAttributes& attrs)
{
return std::make_shared< SetRequestHandler >(attrs);
}
- PrimitiveSetResponse PrimitiveSetResponse::create(const ResourceAttributes& attrs,
+ RCSSetResponse RCSSetResponse::create(const ResourceAttributes& attrs,
const OCEntityHandlerResult& result, int errorCode)
{
return std::make_shared< SetRequestHandler >(attrs, result, errorCode);
}
- PrimitiveSetResponse PrimitiveSetResponse::create(ResourceAttributes&& result)
+ RCSSetResponse RCSSetResponse::create(ResourceAttributes&& result)
{
return std::make_shared< SetRequestHandler >(std::move(result));
}
- PrimitiveSetResponse PrimitiveSetResponse::create(ResourceAttributes&& attrs,
+ RCSSetResponse RCSSetResponse::create(ResourceAttributes&& attrs,
const OCEntityHandlerResult& result, int errorCode)
{
return std::make_shared< SetRequestHandler >(std::move(attrs), result, errorCode);
}
- PrimitiveSetResponse::PrimitiveSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
+ RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
m_acceptanceMethod { AcceptanceMethod::DEFAULT },
m_handler{ std::move(handler) }
{
}
- PrimitiveSetResponse::PrimitiveSetResponse(std::shared_ptr< SetRequestHandler >&& handler,
+ RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler,
AcceptanceMethod method) :
m_acceptanceMethod{ method },
m_handler{ std::move(handler) }
assert(m_handler);
}
- SetRequestHandler* PrimitiveSetResponse::getHandler() const
+ SetRequestHandler* RCSSetResponse::getHandler() const
{
return m_handler.get();
}
- auto PrimitiveSetResponse::getAcceptanceMethod() const -> AcceptanceMethod
+ auto RCSSetResponse::getAcceptanceMethod() const -> AcceptanceMethod
{
return m_acceptanceMethod;
}
- PrimitiveSetResponse& PrimitiveSetResponse::setAcceptanceMethod(AcceptanceMethod method)
+ RCSSetResponse& RCSSetResponse::setAcceptanceMethod(AcceptanceMethod method)
{
m_acceptanceMethod = method;
return *this;
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include <internal/RequestHandler.h>
-
-#include <internal/ResourceAttributesConverter.h>
+#include <RequestHandler.h>
#include <OCResourceResponse.h>
+#include <ResourceAttributesConverter.h>
namespace
{
return AttrKeyValuePairs();
}
- auto getApplyAcceptanceFunc(PrimitiveSetResponse::AcceptanceMethod method) ->
+ auto getApplyAcceptanceFunc(RCSSetResponse::AcceptanceMethod method) ->
std::function<AttrKeyValuePairs(ResourceObject&, const ResourceAttributes&)>
{
switch (method)
{
- case PrimitiveSetResponse::AcceptanceMethod::DEFAULT:
+ case RCSSetResponse::AcceptanceMethod::DEFAULT:
return applyDefaultMethod;
- case PrimitiveSetResponse::AcceptanceMethod::ACCEPT:
+ case RCSSetResponse::AcceptanceMethod::ACCEPT:
return applyAcceptMethod;
- case PrimitiveSetResponse::AcceptanceMethod::IGNORE:
+ case RCSSetResponse::AcceptanceMethod::IGNORE:
return applyIgnoreMethod;
}
}
AttrKeyValuePairs SetRequestHandler::applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod method, ResourceObject& resource,
+ RCSSetResponse::AcceptanceMethod method, ResourceObject& resource,
const ResourceAttributes& requestAttrs) const
{
return getApplyAcceptanceFunc(method)(resource, requestAttrs);
#include <functional>
#include <vector>
-#include <internal/RequestHandler.h>
-#include <internal/AssertUtils.h>
-#include <internal/ResourceAttributesConverter.h>
+#include <RequestHandler.h>
+#include <AssertUtils.h>
+#include <ResourceAttributesConverter.h>
#include <logger.h>
#include <OCPlatform.h>
{
using namespace OIC::Service;
- constexpr char LOG_TAG[]{ "PrimitiveServerResource" };
+ constexpr char LOG_TAG[]{ "ResourceObject" };
inline bool hasProperty(uint8_t base, uint8_t target)
{
{
if (handler)
{
- return handler(PrimitiveRequest{ ocRequest->getResourceUri() }, attrs);
+ return handler(RCSRequest{ ocRequest->getResourceUri() }, attrs);
}
return RESPONSE::defaultAction();
#include <gtest/gtest.h>
#include <HippoMocks/hippomocks.h>
-#include <PrimitiveResponse.h>
+#include <RCSResponse.h>
#include <ResourceObject.h>
-#include <internal/RequestHandler.h>
-#include <internal/ResourceAttributesConverter.h>
+#include <RequestHandler.h>
+#include <ResourceAttributesConverter.h>
#include <OCPlatform.h>
}
-class PrimitiveResponseTest: public Test
+class RCSResponseTest: public Test
{
public:
MockRepository mocks;
}
};
-TEST_F(PrimitiveResponseTest, GetDefaultActionHasEmptyAttrs)
+TEST_F(RCSResponseTest, GetDefaultActionHasEmptyAttrs)
{
- EXPECT_RESPONSE(buildResponse(PrimitiveGetResponse::defaultAction()),
+ EXPECT_RESPONSE(buildResponse(RCSGetResponse::defaultAction()),
RequestHandler::DEFAULT_RESULT, RequestHandler::DEFAULT_ERROR_CODE,
ResourceAttributes());
}
-TEST_F(PrimitiveResponseTest, GetResponseHasResultsPassedCodes)
+TEST_F(RCSResponseTest, GetResponseHasResultsPassedCodes)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
- EXPECT_RESPONSE(buildResponse(PrimitiveGetResponse::create(result, errorCode)),
+ EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(result, errorCode)),
result, errorCode, ResourceAttributes());
}
-TEST_F(PrimitiveResponseTest, GetResponseHasAttrsAndResultsPassedCodes)
+TEST_F(RCSResponseTest, GetResponseHasAttrsAndResultsPassedCodes)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
ResourceAttributes attrs;
attrs[KEY] = 100;
- EXPECT_RESPONSE(buildResponse(PrimitiveGetResponse::create(attrs, result, errorCode)),
+ EXPECT_RESPONSE(buildResponse(RCSGetResponse::create(attrs, result, errorCode)),
result, errorCode, attrs);
}
-TEST_F(PrimitiveResponseTest, GetResponseCanMoveAttrs)
+TEST_F(RCSResponseTest, GetResponseCanMoveAttrs)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
attrsClone[KEY] = 100;
EXPECT_RESPONSE(
- buildResponse(PrimitiveGetResponse::create(std::move(attrs), result, errorCode)),
+ buildResponse(RCSGetResponse::create(std::move(attrs), result, errorCode)),
result, errorCode, attrsClone);
EXPECT_TRUE(attrs.empty());
}
-TEST_F(PrimitiveResponseTest, SetDefaultActionHasEmptyAttrs)
+TEST_F(RCSResponseTest, SetDefaultActionHasEmptyAttrs)
{
- EXPECT_RESPONSE(buildResponse(PrimitiveSetResponse::defaultAction()),
+ EXPECT_RESPONSE(buildResponse(RCSSetResponse::defaultAction()),
RequestHandler::DEFAULT_RESULT, RequestHandler::DEFAULT_ERROR_CODE,
ResourceAttributes());
}
-TEST_F(PrimitiveResponseTest, SetResponseHasResultsPassedCodes)
+TEST_F(RCSResponseTest, SetResponseHasResultsPassedCodes)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
- EXPECT_RESPONSE(buildResponse(PrimitiveSetResponse::create(result, errorCode)),
+ EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(result, errorCode)),
result, errorCode, ResourceAttributes());
}
-TEST_F(PrimitiveResponseTest, SetResponseHasAttrsAndResultsPassedCodes)
+TEST_F(RCSResponseTest, SetResponseHasAttrsAndResultsPassedCodes)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
ResourceAttributes attrs;
attrs[KEY] = 100;
- EXPECT_RESPONSE(buildResponse(PrimitiveSetResponse::create(attrs, result, errorCode)),
+ EXPECT_RESPONSE(buildResponse(RCSSetResponse::create(attrs, result, errorCode)),
result, errorCode, attrs);
}
-TEST_F(PrimitiveResponseTest, SetResponseCanMoveAttrs)
+TEST_F(RCSResponseTest, SetResponseCanMoveAttrs)
{
constexpr OCEntityHandlerResult result{ OC_EH_ERROR };
constexpr int errorCode{ -10 };
attrsClone[KEY] = 100;
EXPECT_RESPONSE(
- buildResponse(PrimitiveSetResponse::create(std::move(attrs), result, errorCode)),
+ buildResponse(RCSSetResponse::create(std::move(attrs), result, errorCode)),
result, errorCode, attrsClone);
EXPECT_TRUE(attrs.empty());
}
-TEST_F(PrimitiveResponseTest, DefaultSetResponseHasDefaultMethod)
+TEST_F(RCSResponseTest, DefaultSetResponseHasDefaultMethod)
{
- EXPECT_EQ(PrimitiveSetResponse::AcceptanceMethod::DEFAULT,
- PrimitiveSetResponse::defaultAction().getAcceptanceMethod());
+ EXPECT_EQ(RCSSetResponse::AcceptanceMethod::DEFAULT,
+ RCSSetResponse::defaultAction().getAcceptanceMethod());
}
-TEST_F(PrimitiveResponseTest, AcceptSetResponseHasAcceptMethod)
+TEST_F(RCSResponseTest, AcceptSetResponseHasAcceptMethod)
{
- EXPECT_EQ(PrimitiveSetResponse::AcceptanceMethod::ACCEPT,
- PrimitiveSetResponse::accept().getAcceptanceMethod());
+ EXPECT_EQ(RCSSetResponse::AcceptanceMethod::ACCEPT,
+ RCSSetResponse::accept().getAcceptanceMethod());
}
-TEST_F(PrimitiveResponseTest, IgnoreSetResponseHasIgnoreMethod)
+TEST_F(RCSResponseTest, IgnoreSetResponseHasIgnoreMethod)
{
- EXPECT_EQ(PrimitiveSetResponse::AcceptanceMethod::IGNORE,
- PrimitiveSetResponse::ignore().getAcceptanceMethod());
+ EXPECT_EQ(RCSSetResponse::AcceptanceMethod::IGNORE,
+ RCSSetResponse::ignore().getAcceptanceMethod());
}
-TEST_F(PrimitiveResponseTest, SetResponseHasMethodSetBySetter)
+TEST_F(RCSResponseTest, SetResponseHasMethodSetBySetter)
{
- PrimitiveSetResponse::AcceptanceMethod method = PrimitiveSetResponse::AcceptanceMethod::ACCEPT;
- PrimitiveSetResponse response =
- PrimitiveSetResponse::defaultAction().setAcceptanceMethod(method);
+ RCSSetResponse::AcceptanceMethod method = RCSSetResponse::AcceptanceMethod::ACCEPT;
+ RCSSetResponse response =
+ RCSSetResponse::defaultAction().setAcceptanceMethod(method);
EXPECT_EQ(method, response.getAcceptanceMethod());
}
#include <gtest/gtest.h>
#include <HippoMocks/hippomocks.h>
-#include <internal/RequestHandler.h>
+#include <RequestHandler.h>
#include <OCPlatform.h>
TEST_F(SetRequestHandlerAcceptanceTest, NothingReplacedWithIgnoreMethod)
{
auto replaced = setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::IGNORE, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::IGNORE, *server, requestAttrs);
ASSERT_TRUE(replaced.empty());
}
TEST_F(SetRequestHandlerAcceptanceTest, NewValueApplyedWithAcceptMethod)
{
setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
ASSERT_EQ(NEW_VALUE, server->getAttribute<int>(EXISTING));
}
TEST_F(SetRequestHandlerAcceptanceTest, ReturnedAttrPairsHaveOldValue)
{
auto replaced = setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
ASSERT_EQ(ORIGIN_VALUE, replaced[0].second);
}
TEST_F(SetRequestHandlerAcceptanceTest, NothingHappenedWithEmptyAttrs)
{
setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::ACCEPT, *server, ResourceAttributes{ });
+ RCSSetResponse::AcceptanceMethod::ACCEPT, *server, ResourceAttributes{ });
ASSERT_EQ(ORIGIN_VALUE, server->getAttribute<int>(EXISTING));
}
requestAttrs[EXISTING] = "";
auto replaced = setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::ACCEPT, *server, requestAttrs);
ASSERT_EQ(ORIGIN_VALUE, replaced[0].second);
}
requestAttrs[EXISTING] = "";
auto replaced = setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::DEFAULT, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::DEFAULT, *server, requestAttrs);
ASSERT_TRUE(replaced.empty());
}
auto replaced = setRequestHandler->applyAcceptanceMethod(
- PrimitiveSetResponse::AcceptanceMethod::DEFAULT, *server, requestAttrs);
+ RCSSetResponse::AcceptanceMethod::DEFAULT, *server, requestAttrs);
ASSERT_TRUE(replaced.empty());
}
mc.addRepresentation(ocRep);
- string json = mc.getJSONRepresentation(OCInfoFormat::IncludeOC);
ocEntityHandlerRequest.requestHandle = fakeRequestHandle;
ocEntityHandlerRequest.resource = fakeResourceHandle;
ocEntityHandlerRequest.method = method;
- ocEntityHandlerRequest.reqJSONPayload = &json[0];
+ ocEntityHandlerRequest.payload = reinterpret_cast<OCPayload*>(mc.getPayload());
formResourceRequest(OC_REQUEST_FLAG, &ocEntityHandlerRequest, request);
ASSERT_EQ(OC_EH_OK, handler(createRequest()));
}
-TEST_F(ResourceObjectHandlingRequestTest, SendResponseWithPrimitiveResponseResults)
+TEST_F(ResourceObjectHandlingRequestTest, SendResponseWithRCSResponseResults)
{
constexpr int errorCode{ 1999 };
constexpr OCEntityHandlerResult result{ OC_EH_SLOW };
server->setGetRequestHandler(
- [](const PrimitiveRequest&, ResourceAttributes&) -> PrimitiveGetResponse
+ [](const RCSRequest&, ResourceAttributes&) -> RCSGetResponse
{
- return PrimitiveGetResponse::create(result, errorCode);
+ return RCSGetResponse::create(result, errorCode);
}
);
constexpr char value[]{ "value" };
server->setSetRequestHandler(
- [](const PrimitiveRequest&, ResourceAttributes&) -> PrimitiveSetResponse
+ [](const RCSRequest&, ResourceAttributes&) -> RCSSetResponse
{
ResourceAttributes attrs;
attrs[KEY] = value;
- return PrimitiveSetResponse::create(attrs, result, errorCode);
+ return RCSSetResponse::create(attrs, result, errorCode);
}
);