--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is licensed under the terms of MIT License or the Apache License
+ * Version 2.0 of your choice. See the LICENSE.MIT file for MIT license details.
+ * See the LICENSE file or the notice below for Apache License Version 2.0
+ * details.
+ *
+ * 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
+ */
+/**
+ * @file test/common/protocols/client/protocolclient.cpp
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @version 1.0
+ * @brief Negative tests for Cynara::ProtocolClient
+ */
+
+#include <gtest/gtest.h>
+
+#include <exceptions/NotImplementedException.h>
+
+#include <protocol/ProtocolClient.h>
+
+#include <request/AdminCheckRequest.h>
+#include <request/AgentActionRequest.h>
+#include <request/AgentRegisterRequest.h>
+#include <request/DescriptionListRequest.h>
+#include <request/EraseRequest.h>
+#include <request/InsertOrUpdateBucketRequest.h>
+#include <request/ListRequest.h>
+#include <request/MonitorGetEntriesRequest.h>
+#include <request/MonitorGetFlushRequest.h>
+#include <request/RemoveBucketRequest.h>
+#include <request/SetPoliciesRequest.h>
+#include <request/SignalRequest.h>
+
+#include <response/AdminCheckResponse.h>
+#include <response/AgentActionResponse.h>
+#include <response/AgentRegisterResponse.h>
+#include <response/CodeResponse.h>
+#include <response/DescriptionListResponse.h>
+#include <response/ListResponse.h>
+#include <response/MonitorGetEntriesResponse.h>
+
+#include <NegativeTestHelper.h>
+#include <TestDataCollection.h>
+
+using namespace Cynara;
+using namespace NegativeTestHelper;
+using namespace TestDataCollection;
+
+namespace {
+
+const RawBuffer SOME_DATA = {'d'};
+const struct timespec SOME_TIMESPEC = {Times::Sec::mid, Times::NSec::max};
+const MonitorEntry SOME_ENTRY(Keys::k_nun, 42, SOME_TIMESPEC);
+const std::vector<MonitorEntry> SOME_ENTRIES = {{SOME_ENTRY}};
+
+} /* namespace anonymous */
+
+/* *** compare by objects test cases *** */
+
+TEST(ProtocolClient, AdminCheckRequestNegative) {
+ testNotImplemented<ProtocolClient, AdminCheckRequest>
+ (Keys::k_cup, Buckets::empty, false, SN::mid);
+}
+
+TEST(ProtocolClient, AgentActionRequestNegative) {
+ testNotImplemented<ProtocolClient, AgentActionRequest>
+ (Agent::RequestType::mid, SOME_DATA, SN::min_2);
+}
+
+TEST(ProtocolClient, AgentRegisterRequestNegative) {
+ testNotImplemented<ProtocolClient, AgentRegisterRequest>(Agent::Type::not_empty, SN::mid);
+}
+
+TEST(ProtocolClient, DescriptionListRequestNegative) {
+ testNotImplemented<ProtocolClient, DescriptionListRequest>(SN::max_1);
+}
+
+TEST(ProtocolClient, EraseRequestNegative) {
+ testNotImplemented<ProtocolClient, EraseRequest>
+ (Buckets::not_empty, false, Keys::k_wwp, SN::min_2);
+}
+
+TEST(ProtocolClient, InsertOrUpdateBucketRequestNegative) {
+ testNotImplemented<ProtocolClient, InsertOrUpdateBucketRequest>
+ (Buckets::not_empty, Results::plugin_1, SN::min_1);
+}
+
+TEST(ProtocolClient, ListRequestNegative) {
+ testNotImplemented<ProtocolClient, ListRequest>(Buckets::empty, Keys::k_cww, SN::max_2);
+}
+
+TEST(ProtocolClient, MonitorGetEntriesRequestNegative) {
+ testNotImplemented<ProtocolClient, MonitorGetEntriesRequest>(Buffer::Size::min_2, SN::min_1);
+}
+
+TEST(ProtocolClient, MonitorGetFlushRequestNegative) {
+ testNotImplemented<ProtocolClient, MonitorGetFlushRequest>(SN::mid);
+}
+
+TEST(ProtocolClient, RemoveBucketRequestNegative) {
+ testNotImplemented<ProtocolClient, RemoveBucketRequest>(Buckets::not_empty, SN::max);
+}
+
+TEST(ProtocolClient, SetPoliciesRequestNegative) {
+ const std::map<PolicyBucketId, std::vector<Policy>> SOME_INSERT_POLICY =
+ {{Buckets::not_empty, {{Keys::k_nua, Results::deny}}}};
+ const std::map<PolicyBucketId, std::vector<PolicyKey>> SOME_REMOVE_POLICY =
+ {{Buckets::empty, {Keys::k_nun}}};
+ testNotImplemented<ProtocolClient, SetPoliciesRequest>
+ (SOME_INSERT_POLICY, SOME_REMOVE_POLICY, SN::min);
+}
+
+TEST(ProtocolClient, SignalRequestNegative) {
+ const struct signalfd_siginfo SOME_SIGINFO = {};
+ testNotImplemented<ProtocolClient, SignalRequest>(SOME_SIGINFO);
+}
+
+TEST(ProtocolClient, AdminCheckResponseNegative) {
+ testNotImplemented<ProtocolClient, AdminCheckResponse>
+ (Results::plugin_2, false, false, SN::min);
+}
+
+TEST(ProtocolClient, AgentActionResponseNegative) {
+ testNotImplemented<ProtocolClient, AgentActionResponse>
+ (Agent::ResponseType::max_2, SOME_DATA, SN::min);
+}
+
+TEST(ProtocolClient, AgentRegisterResponseNegative) {
+ const AgentRegisterResponse::Code SOME_CODE = AgentRegisterResponse::DONE;
+ testNotImplemented<ProtocolClient, AgentRegisterResponse>(SOME_CODE, SN::max_2);
+}
+
+TEST(ProtocolClient, CodeResponseNegative) {
+ testNotImplemented<ProtocolClient, CodeResponse>(CodeResponse::NOT_ALLOWED, SN::max_1);
+}
+
+TEST(ProtocolClient, DescriptionListResponseNegative) {
+ std::vector<PolicyDescription> SOME_DESCRIPTIONS = {{Types::plugin_type, "plugin_type"}};
+ testNotImplemented<ProtocolClient, DescriptionListResponse>(SOME_DESCRIPTIONS, true, SN::mid);
+}
+
+TEST(ProtocolClient, ListResponseNegative) {
+ const std::vector<Policy> SOME_POLICIES = {{Keys::k_wwa, Results::none}};
+ testNotImplemented<ProtocolClient, ListResponse>(SOME_POLICIES, true, false, SN::max_2);
+}
+
+TEST(ProtocolClient, MonitorGetEntriesResponseNegative) {
+ testNotImplemented<ProtocolClient, MonitorGetEntriesResponse>(SOME_ENTRIES, SN::max);
+}
+
+TEST(ProtocolClient, WrongOpCodeRequestNegative) {
+ auto queue = prepareWrongOpCode();
+ auto protocol = std::make_shared<ProtocolClient>();
+ ASSERT_THROW(protocol->extractRequestFromBuffer(queue), InvalidProtocolException);
+}
+
+TEST(ProtocolClient, WrongOpCodeResponseNegative) {
+ auto queue = prepareWrongOpCode();
+ auto protocol = std::make_shared<ProtocolClient>();
+ ASSERT_THROW(protocol->extractResponseFromBuffer(queue), InvalidProtocolException);
+}
+
+TEST(ProtocolClient, UnfinishedFrameRequestNegative) {
+ auto queue = prepareUnfinishedFrame();
+ auto protocol = std::make_shared<ProtocolClient>();
+ ASSERT_EQ(protocol->extractRequestFromBuffer(queue), nullptr);
+}
+
+TEST(ProtocolClient, UnfinishedFrameResponseNegative) {
+ auto queue = prepareUnfinishedFrame();
+ auto protocol = std::make_shared<ProtocolClient>();
+ ASSERT_EQ(protocol->extractResponseFromBuffer(queue), nullptr);
+}
+