/test/common/protocols/monitor/flushrequest.cpp

https://gitlab.com/github-cloud-corporation/cynara · C++ · 216 lines · 87 code · 24 blank · 105 comment · 0 complexity · 1845774de0cd62dc5f1767df154d756e MD5 · raw file

  1. /*
  2. * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file test/common/protocols/monitor/flushrequest.cpp
  18. * @author Zofia Abramowska <z.abramowska@samsung.com>
  19. * @version 1.0
  20. * @brief Tests for Cynara::MonitorGetFlushRequest usage in
  21. * Cynara::ProtocolMonitorGet
  22. */
  23. #include <vector>
  24. #include <gtest/gtest.h>
  25. #include <protocol/ProtocolMonitorGet.h>
  26. #include <request/MonitorGetFlushRequest.h>
  27. #include <types/Policy.h>
  28. #include <RequestTestHelper.h>
  29. #include <TestDataCollection.h>
  30. namespace {
  31. template<>
  32. void compare(const Cynara::MonitorGetFlushRequest &req1,
  33. const Cynara::MonitorGetFlushRequest &req2) {
  34. EXPECT_EQ(req1.sequenceNumber(), req2.sequenceNumber());
  35. }
  36. } /* namespace anonymous */
  37. using namespace Cynara;
  38. using namespace RequestTestHelper;
  39. using namespace TestDataCollection;
  40. /* *** compare by objects test cases *** */
  41. /**
  42. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal sequence number
  43. * @test Expected result:
  44. * - sequence number is 0
  45. */
  46. TEST(ProtocolMonitorGet, MonitorGetFlushRequest01) {
  47. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min);
  48. auto protocol = std::make_shared<ProtocolMonitorGet>();
  49. testRequest(request, protocol);
  50. }
  51. /**
  52. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal + 1 sequence
  53. number
  54. * @test Expected result:
  55. * - sequence number is minimal + 1
  56. */
  57. TEST(ProtocolMonitorGet, MonitorGetFlushRequest02) {
  58. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min_1);
  59. auto protocol = std::make_shared<ProtocolMonitorGet>();
  60. testRequest(request, protocol);
  61. }
  62. /**
  63. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal + 2 sequence
  64. number
  65. * @test Expected result:
  66. * - sequence number is min + 2
  67. */
  68. TEST(ProtocolMonitorGet, MonitorGetFlushRequest03) {
  69. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min_2);
  70. auto protocol = std::make_shared<ProtocolMonitorGet>();
  71. testRequest(request, protocol);
  72. }
  73. /**
  74. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with medium sequence number
  75. * @test Expected result:
  76. * - sequence number is medium
  77. */
  78. TEST(ProtocolMonitorGet, MonitorGetFlushRequest04) {
  79. auto request = std::make_shared<MonitorGetFlushRequest>(SN::mid);
  80. auto protocol = std::make_shared<ProtocolMonitorGet>();
  81. testRequest(request, protocol);
  82. }
  83. /**
  84. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with max - 1 sequence
  85. number
  86. * @test Expected result:
  87. * - sequence number is max - 1
  88. */
  89. TEST(ProtocolMonitorGet, MonitorGetFlushRequest05) {
  90. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max_1);
  91. auto protocol = std::make_shared<ProtocolMonitorGet>();
  92. testRequest(request, protocol);
  93. }
  94. /**
  95. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with max - 2 sequence
  96. number
  97. * @test Expected result:
  98. * - sequence number is max - 2
  99. */
  100. TEST(ProtocolMonitorGet, MonitorGetFlushRequest06) {
  101. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max_2);
  102. auto protocol = std::make_shared<ProtocolMonitorGet>();
  103. testRequest(request, protocol);
  104. }
  105. /**
  106. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with maximum sequence
  107. number
  108. * @test Expected result:
  109. * - sequence number is maximum
  110. */
  111. TEST(ProtocolMonitorGet, MonitorGetFlushRequest07) {
  112. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max);
  113. auto protocol = std::make_shared<ProtocolMonitorGet>();
  114. testRequest(request, protocol);
  115. }
  116. /* *** compare by serialized data test cases *** */
  117. /**
  118. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal sequence
  119. number
  120. * @test Expected result:
  121. * - sequence number is minimal
  122. */
  123. TEST(ProtocolMonitorGet, MonitorGetFlushRequest08) {
  124. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min);
  125. auto protocol = std::make_shared<ProtocolMonitorGet>();
  126. binaryTestRequest(request, protocol);
  127. }
  128. /**
  129. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal + 1 sequence
  130. number
  131. * @test Expected result:
  132. * - sequence number is minimal + 1
  133. */
  134. TEST(ProtocolMonitorGet, MonitorGetFlushRequest09) {
  135. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min_1);
  136. auto protocol = std::make_shared<ProtocolMonitorGet>();
  137. binaryTestRequest(request, protocol);
  138. }
  139. /**
  140. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with minimal + 2 sequence
  141. number
  142. * @test Expected result:
  143. * - sequence number is minimal + 2
  144. */
  145. TEST(ProtocolMonitorGet, MonitorGetFlushRequest10) {
  146. auto request = std::make_shared<MonitorGetFlushRequest>(SN::min_2);
  147. auto protocol = std::make_shared<ProtocolMonitorGet>();
  148. binaryTestRequest(request, protocol);
  149. }
  150. /**
  151. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with medium sequence number
  152. * @test Expected result:
  153. * - sequence number is medium
  154. */
  155. TEST(ProtocolMonitorGet, MonitorGetFlushRequest11) {
  156. auto request = std::make_shared<MonitorGetFlushRequest>(SN::mid);
  157. auto protocol = std::make_shared<ProtocolMonitorGet>();
  158. binaryTestRequest(request, protocol);
  159. }
  160. /**
  161. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with maximum - 1 sequence
  162. number
  163. * @test Expected result:
  164. * - sequence number is maximum -1
  165. */
  166. TEST(ProtocolMonitorGet, MonitorGetFlushRequest12) {
  167. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max_1);
  168. auto protocol = std::make_shared<ProtocolMonitorGet>();
  169. binaryTestRequest(request, protocol);
  170. }
  171. /**
  172. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with maximum - 2 sequence
  173. number
  174. * @test Expected result:
  175. * - sequence number is maximum - 2
  176. */
  177. TEST(ProtocolMonitorGet, MonitorGetFlushRequest13) {
  178. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max_2);
  179. auto protocol = std::make_shared<ProtocolMonitorGet>();
  180. binaryTestRequest(request, protocol);
  181. }
  182. /**
  183. * @brief Verify if MonitorGetFlushRequest is properly (de)serialized with maximum sequence
  184. number
  185. * @test Expected result:
  186. * - sequence number is max
  187. */
  188. TEST(ProtocolMonitorGet, MonitorGetFlushRequest14) {
  189. auto request = std::make_shared<MonitorGetFlushRequest>(SN::max);
  190. auto protocol = std::make_shared<ProtocolMonitorGet>();
  191. binaryTestRequest(request, protocol);
  192. }