Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / serverBuilder / unittests / RCSResponseTest.cpp
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include "UnitTestHelper.h"
22
23 #include "RCSResponse.h"
24 #include "RCSSeparateResponse.h"
25 #include "RCSException.h"
26
27 using namespace OIC::Service;
28
29 TEST(RCSResponseTest, DefaultSetResponseHasDefaultMethod)
30 {
31     EXPECT_EQ(RCSSetResponse::AcceptanceMethod::DEFAULT,
32             RCSSetResponse::defaultAction().getAcceptanceMethod());
33 }
34
35 TEST(RCSResponseTest, AcceptSetResponseHasAcceptMethod)
36 {
37     EXPECT_EQ(RCSSetResponse::AcceptanceMethod::ACCEPT,
38             RCSSetResponse::accept().getAcceptanceMethod());
39 }
40
41 TEST(RCSResponseTest, IgnoreSetResponseHasIgnoreMethod)
42 {
43     EXPECT_EQ(RCSSetResponse::AcceptanceMethod::IGNORE,
44             RCSSetResponse::ignore().getAcceptanceMethod());
45 }
46
47 TEST(RCSResponseTest, SetResponseHasMethodSetBySetter)
48 {
49     RCSSetResponse::AcceptanceMethod method = RCSSetResponse::AcceptanceMethod::ACCEPT;
50     RCSSetResponse response =
51             RCSSetResponse::defaultAction().setAcceptanceMethod(method);
52
53     EXPECT_EQ(method, response.getAcceptanceMethod());
54 }
55
56 TEST(RCSResponseTest, SeparateResponseHasNoHandler)
57 {
58     RCSGetResponse response = RCSGetResponse::separate();
59     EXPECT_EQ(nullptr, response.getHandler());
60 }
61
62 TEST(RCSResponseTest, ThrowIfRequestIsInvalidWhenConstructingSeparateResponse)
63 {
64     RCSRequest aRequest;
65
66     EXPECT_THROW(RCSSeparateResponse resp(aRequest), RCSInvalidParameterException);
67 }