9 #include <gmock/gmock.h>
10 #include <gtest/gtest.h>
14 using namespace testing;
58 using namespace nlohmann;
63 "fileId": "TEST.FILEID",
66 "location": "dcs-host:/path/to/somefile.fits",
70 "selectionPatterns": [
78 "selectionPatterns": [
88 "type": "fitsKeywords",
93 "selectionPatterns": [
101 "type": "valueKeyword",
103 "value": "ESO-PARANAL"
106 "type": "valueKeyword",
111 "type": "valueKeyword",
113 "value": "OBJECT,SKY"
116 "type": "esoKeyword",
117 "name": "OCS TEMPL ID",
118 "value": "template-id"
121 "type": "literalKeyword",
122 "value": "COMMENT Example of a commentary keyword."
127 "type": "fitsKeywords",
133 "type": "esoKeyword",
134 "name": "TEL AIRM START",
138 "type": "esoKeyword",
139 "name": "TEL AIRM END",
147 "location": "fcs-host:/path/to/somefile.fits",
151 "selectionPatterns": [
159 "selectionPatterns": [
188 auto const& filter = std::get<KeywordFilter>(spec.
target.
source->keyword_rules.at(1));
189 EXPECT_THAT(filter.selection_patterns, ElementsAre(
"+e INS2 *",
"+v VALUEKW"));
192 auto const& ocm_kws_var = spec.
sources[0];
193 ASSERT_TRUE(std::holds_alternative<FitsKeywordsSource>(ocm_kws_var));
194 auto const& tcs_kws_var = spec.
sources[1];
195 ASSERT_TRUE(std::holds_alternative<FitsKeywordsSource>(tcs_kws_var));
196 auto const& fcs_fits_var = spec.
sources[2];
197 ASSERT_TRUE(std::holds_alternative<FitsFileSource>(fcs_fits_var));
198 auto const& ocm_kws = std::get<FitsKeywordsSource>(spec.
sources[0]);
199 auto const& tcs_kws = std::get<FitsKeywordsSource>(spec.
sources[1]);
200 auto const& fcs_fits = std::get<FitsFileSource>(spec.
sources[2]);
204 ASSERT_EQ(ocm_kws.keyword_rules.size(), 1);
205 auto const& filter = std::get<KeywordFilter>(ocm_kws.keyword_rules.at(0));
206 ASSERT_EQ(filter.selection_patterns.size(), 2);
207 EXPECT_THAT(filter.selection_patterns, ElementsAre(
"+e *",
"+v *"));
215 m_spec[
"target"].erase(
"targetSource");
225 m_spec[
"sources"] = nlohmann::json::array();
236 m_spec["target"].erase(
"fileId");
242 m_spec["target"][
"fileId"] = 0u;
245 MatchesRegex(R
"(.*\(/target/fileId\).*must be a string.*)"));
249 m_spec["sources"][0][
"keywords"][0][
"type"] =
"";
252 MatchesRegex(R
"(.*\(/sources/0/keywords/0/type\).*empty.*)"));
256 m_spec["sources"][0].erase(
"keywords");
261 m_spec["sources"][2].erase(
"keywordRules");
266 m_spec[
"target"].erase(
"source");
267 m_spec[
"sources"] = nlohmann::json::array();
274 m_spec["sources"][0][
"type"] =
"unknown";
#define EXPECT_THROW_WITH_MESSAGE(stmt, etype, matcher)
Expect that stmt throws exception of type etype and that the exception message matches matcher.
Location ParseSourceLocation(std::string const &location_str)
Parse location string from DpSpec into component parts.
DpSpec ParseDpSpec(Json const &json)
Parse JSON to construct the DpSpec structure.
std::optional< FitsFileSource > source
std::vector< SourceTypes > sources
daq::json::TestParseStartDaqV2Spec _json
TEST_F(TestParseDpSpec, ParseFailsWithUnknownSourcesWrongType)
Close representation of the JSON structure but with stronger types.
Describes parsed location string into its components "host" and "path".
std::filesystem::path path
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_EQ(meta.keyword_rules.size(), 1u)