11 #include <gtest/gtest.h>
12 #include <log4cplus/loggingmacros.h>
22 s.rr_uri =
"zpb.rr://127.0.0.1/daq";
31 log4cplus::Logger
logger = log4cplus::Logger::getInstance(
"test");
45 spec.file_prefix =
"prefix";
55 ds.rr_uri =
"zpb.rr://127.0.0.1/daq";
56 spec.sources.emplace_back(ds);
57 m_ctx.
results.emplace_back(ds.source_name,
"host:/path.fits");
62 ds.rr_uri =
"zpb.rr://127.0.0.1/daq";
64 auto& rule = ds.keyword_rules.emplace_back(std::in_place_type<json::KeywordFilter>);
65 std::get<json::KeywordFilter>(rule).selection_patterns.push_back(
"+e *");
67 spec.sources.emplace_back(ds);
74 ds.rr_uri =
"zpb.rr://127.0.0.1/daq";
75 spec.sources.emplace_back(ds);
82 ds.rr_uri =
"zpb.rr://127.0.0.1/daq";
84 auto& rule = ds.keyword_rules.emplace_back(std::in_place_type<json::KeywordFilter>);
85 std::get<json::KeywordFilter>(rule).selection_patterns.push_back(
"+e FOO BAR");
87 spec.sources.emplace_back(ds);
90 v.emplace_back(std::in_place_type<fits::EsoKeyword>,
"FOO BAR",
true);
94 spec.merge_target.emplace().source_name =
"primary";
122 ASSERT_EQ(m_ctx.dp_name_prefix,
"prefix");
128 LOG4CPLUS_DEBUG(
"test",
"Serialized DpSpec: " << j.dump(2));
131 EXPECT_EQ(j[
"target"][
"fileId"],
"file_id");
132 EXPECT_EQ(j[
"target"][
"filePrefix"],
"prefix");
133 EXPECT_EQ(j[
"target"][
"source"][
"sourceName"],
"primary") <<
"Merge target not as expected: ";
138 EXPECT_EQ(j[
"sources"][0][
"sourceName"],
"meta1");
139 EXPECT_EQ(j[
"sources"][0][
"type"],
"fitsFile");
141 EXPECT_TRUE(j[
"sources"][0].contains(
"keywordRules"));
142 EXPECT_EQ(j[
"sources"][0][
"keywordRules"].size(), 1u);
143 EXPECT_EQ(j[
"sources"][0][
"keywordRules"][0][
"selectionPatterns"][0],
"+e *");
147 EXPECT_EQ(j[
"sources"][1][
"sourceName"],
"meta2");
148 EXPECT_EQ(j[
"sources"][1][
"type"],
"fitsFile");
149 EXPECT_FALSE(j[
"sources"][1].contains(
"keywordRules"));
153 EXPECT_EQ(j[
"sources"][2][
"sourceName"],
"meta3");
154 EXPECT_EQ(j[
"sources"][2][
"type"],
"fitsKeywords");
155 EXPECT_EQ(j[
"sources"][2][
"keywords"].size(), 1u);
156 EXPECT_EQ(j[
"sources"][2][
"keywords"][0][
"name"],
"FOO BAR");
158 EXPECT_TRUE(j[
"sources"][2].contains(
"keywordRules"));
159 EXPECT_EQ(j[
"sources"][2][
"keywordRules"].size(), 1u);
160 EXPECT_EQ(j[
"sources"][2][
"keywordRules"][0][
"selectionPatterns"][0],
"+e FOO BAR");
170 m_ctx.specification->merge_target = std::nullopt;
176 LOG4CPLUS_DEBUG(
"test",
"Serialized DpSpec: " << j.dump(2));
179 EXPECT_EQ(j[
"target"][
"fileId"],
"file_id");
180 EXPECT_EQ(j[
"target"][
"filePrefix"],
"prefix");
181 EXPECT_FALSE(j[
"target"].contains(
"source"));
186 EXPECT_EQ(j[
"sources"][0][
"sourceName"],
"primary");
187 EXPECT_EQ(j[
"sources"][0][
"type"],
"fitsFile");
188 EXPECT_FALSE(j[
"sources"][0].contains(
"keywordRules"));
191 EXPECT_EQ(j[
"sources"][1][
"sourceName"],
"meta1");
192 EXPECT_EQ(j[
"sources"][1][
"type"],
"fitsFile");
194 EXPECT_TRUE(j[
"sources"][1].contains(
"keywordRules"));
195 EXPECT_EQ(j[
"sources"][1][
"keywordRules"].size(), 1u);
196 EXPECT_EQ(j[
"sources"][1][
"keywordRules"][0][
"selectionPatterns"][0],
"+e *");
200 EXPECT_EQ(j[
"sources"][2][
"sourceName"],
"meta2");
201 EXPECT_EQ(j[
"sources"][2][
"type"],
"fitsFile");
202 EXPECT_FALSE(j[
"sources"][2].contains(
"keywordRules"));
206 EXPECT_EQ(j[
"sources"][3][
"sourceName"],
"meta3");
207 EXPECT_EQ(j[
"sources"][3][
"type"],
"fitsKeywords");
208 EXPECT_EQ(j[
"sources"][3][
"keywords"].size(), 1u);
209 EXPECT_EQ(j[
"sources"][3][
"keywords"][0][
"name"],
"FOO BAR");
211 EXPECT_TRUE(j[
"sources"][3].contains(
"keywordRules"));
212 EXPECT_EQ(j[
"sources"][3][
"keywordRules"].size(), 1u);
213 EXPECT_EQ(j[
"sources"][3][
"keywordRules"][0][
"selectionPatterns"][0],
"+e FOO BAR");
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
DpSpec ParseDpSpec(Json const &json)
Parse JSON to construct the DpSpec structure.
Close representation of the JSON structure but with stronger types.
TEST_F(TestDpmDaqController, StatusUpdateInNotScheduledSucceeds)
NLOHMANN_JSON_SERIALIZE_ENUM(State, { {State::NotStarted, "NotStarted"}, {State::Starting, "Starting"}, {State::Acquiring, "Acquiring"}, {State::Stopping, "Stopping"}, {State::Stopped, "Stopped"}, {State::NotScheduled, "NotScheduled"}, {State::Scheduled, "Scheduled"}, {State::Transferring, "Transferring"}, {State::Merging, "Merging"}, {State::Releasing, "Releasing"}, {State::AbortingAcquiring, "AbortingAcquiring"}, {State::AbortingMerging, "AbortingMerging"}, {State::Aborted, "Aborted"}, {State::Completed, "Completed"}, }) void to_json(nlohmann void to_json(nlohmann::json &j, Alert const &p)
json::DpSpec MakeDataProductSpecification(DaqContext const &ctx, log4cplus::Logger &logger)
Creates a Data Product Specification as serialized JSON from the provided DaqContext.
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
std::vector< Source > meta_sources
DpParts results
Results from Data Acquisition (FITS files and keywords).
std::optional< json::StartDaqV2Spec > specification
Optional specification, if DAQ was started using StartDaqV2.
std::string file_id
Data Product FileId as specified by OLAS ICD.
std::string dp_name_prefix
Data product file name prefix.
std::string id
DAQ identfier, possibly provided by user.
A type safe version of LiteralKeyword that consist of the three basic components of a FITS keyword ke...
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_EQ(meta.keyword_rules.size(), 1u)