2 * Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
18 #include <gmock/gmock.h>
21 #include <jsoncpp/json/reader.h>
22 #include <jsoncpp/json/value.h>
24 #include "connection.h"
25 #include "restservicemock.h"
26 #include "reportadapter.h"
32 using ::testing::Return;
36 const std::chrono::milliseconds TEST_TIMEOUT_INTERVAL{1};
37 const std::string TEST_REPORT_DATA{"{\"value\": 1}"};
40 TEST(TestReportAdapter, test_sendReport)
43 auto& settings = agent::Settings::instance();
46 communication::Connection conn("", TEST_TIMEOUT_INTERVAL, &rest, [](){return true;});
47 agent::ReportAdapter adapter(conn);
51 ASSERT_TRUE(reader.parse(TEST_REPORT_DATA, value));
53 EXPECT_CALL(rest, sendData(_, A<const Json::Value&>())).Times(1);
54 EXPECT_CALL(rest, getUpdates(_)).WillRepeatedly(Return(""));
56 std::thread t(&communication::Connection::loop, &conn);
58 settings.setLock(false);
59 adapter.sendReport(std::string{"syscall"}, value);
60 settings.setLock(true);
61 adapter.sendReport(std::string{"syscall"}, value);
63 std::this_thread::sleep_for(std::chrono::milliseconds(50));
68 } catch (std::exception& e) {