9#include <gmock/gmock.h>
10#include <gtest/gtest.h>
14using namespace ::testing;
42 EXPECT_EQ(State::NotStarted, s.
GetState()) <<
"Default state should be State::NotStarted";
43 EXPECT_FALSE(
HasError(s)) <<
"By default error flag should be false";
55 MatchesRegex(
"ObservableStatus\\(id='id', file_id='fileid', state=.*, error=false\\)"));
65 auto time = Status::Clock::now();
82TEST(TestStatus, OstreamOperator) {
85 s.
timestamp = std::chrono::time_point<std::chrono::system_clock>(
86 std::chrono::nanoseconds(1693899318896895717));
90 MatchesRegex(
"Status\\(id='id', file_id='fileid', state=.*, error=false, "
91 "result=''\\, timestamp=2023-09-05T07:35:18.896)"));
94TEST(TestStatus, Comparison) {
107 Status s1(
"id",
"fileid");
110 alert.
id.
key =
"key";
119 alert2.
id.
key =
"different key";
141 auto alert2 = alert1;
142 alert2.
key =
"different key";
143 EXPECT_NE(alert1, alert2);
145 auto alert3 = alert1;
146 alert3.
category =
"different category";
147 EXPECT_NE(alert1, alert3);
153 alert1.
id.
key =
"key";
157 auto alert2 = alert1;
158 alert2.
id.
key =
"different key";
159 EXPECT_NE(alert1, alert2);
161 auto alert3 = alert1;
163 EXPECT_NE(alert1, alert3);
Stores data acquisition status and allows subscription to status changes.
boost::signals2::connection ConnectObserver(Observer o)
Connect observer that is invoked when state is modified.
State GetState() const noexcept
Status const & GetStatus() const noexcept
Connect observer that is invoked when state is modified.
void SetState(State s) noexcept
Set state of data acquisition.
Status::Clock::time_point GetTimestamp() const noexcept
void SetAlert(Alert alert)
Set alert.
ObservableStatus test fixture.
Simple observer used for testing.
std::string key
Unique key for each alert.
bool HasError(Status const &status) noexcept
std::string category
Standardized category.
void SetAlert(std::vector< Alert > &alerts, Alert alert)
Set alert.
bool ClearAlert(std::vector< Alert > &alerts, AlertId const &alert)
Clear alert.
State
Observable states of the data acquisition process.
std::vector< Alert > Alerts
Alert MakeAlert(std::string_view category, std::string key, std::string description)
Construct alert.
Describes an active Data Acquisition alert.
Uniquely identfies an alert.
Contains declaration for Status and ObservableStatus.
Non observable status object that keeps stores status of data acquisition.
std::vector< Alert > alerts
Active alerts.
TimePoint timestamp
Timestamp of last update.
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_EQ(meta.keyword_rules.size(), 1u)
TEST_F(TestObservableStatus, Construct)
TEST(TestStatus, OstreamOperator)