11 #include <gtest/gtest.h>
13 using namespace ::testing;
20 using namespace nlohmann;
24 "awaitCompletionInterval": 3.0,
26 "sourcename": "primary"
30 "type": "primaryDataSource",
31 "sourceName": "primary",
32 "rrUri": "zpb.rr://prim",
36 "selectionPatterns": [
44 "type": "metadataSource",
45 "sourceName": "metadata",
46 "rrUri": "zpb.rr://meta",
47 "initialKeywords": "user",
51 "selectionPatterns": [
60 "type": "fitsKeywords",
61 "sourceName": "keywords",
64 "type": "valueKeyword",
72 "selectionPatterns": [
83 "location": "host:/path/to.fits.",
87 "selectionPatterns": [
96 "filePrefix": "prefix"
105 auto spec_1_json = nlohmann::json();
117 EXPECT_EQ(spec.await_completion_interval, std::chrono::milliseconds(3000));
122 auto const& prim = std::get<StartDaqV2Spec::PrimaryDataSource>(spec.sources[0]);
126 ASSERT_EQ(prim.keyword_rules.size(), 1u);
127 auto const& filter = std::get<KeywordFilter>(prim.keyword_rules.at(0));
128 ASSERT_EQ(filter.selection_patterns.size(), 2u);
129 EXPECT_EQ(filter.selection_patterns[0],
"+e *");
130 EXPECT_EQ(filter.selection_patterns[1],
"+v *");
133 auto const& meta = std::get<StartDaqV2Spec::MetadataSource>(spec.sources[1]);
139 auto const&
transform = std::get<KeywordTransform>(meta.keyword_rules.at(0));
146 auto const& kws = std::get<FitsKeywordsSource>(spec.sources[2]);
150 auto const& file = std::get<FitsFileSource>(spec.sources[3]);
155 TEST_F(TestParseStartDaqV2Spec, EmptyKeywordRulesModelledAsEmptyOptional) {
156 m_spec[
"sources"][0].erase(
"keywordRules");
157 m_spec[
"sources"][1].erase(
"keywordRules");
166 auto const& prim = std::get<StartDaqV2Spec::PrimaryDataSource>(spec.sources[0]);
170 ASSERT_TRUE(prim.keyword_rules.empty());
173 auto const& meta = std::get<StartDaqV2Spec::MetadataSource>(spec.sources[1]);
177 ASSERT_TRUE(meta.keyword_rules.empty());
181 TEST_F(TestParseStartDaqV2Spec, NoIdIsModelledAsEmptyString) {
187 TEST_F(TestParseStartDaqV2Spec, EmptydIsAllowed) {
193 TEST_F(TestParseStartDaqV2Spec, AwaitCompletionIntervalIsOptional) {
194 m_spec.erase(
"awaitCompletionInterval");
197 EXPECT_EQ(spec.await_completion_interval, std::nullopt);
200 TEST_F(TestParseStartDaqV2Spec, AwaitCompletionIntervalAcceptsIntegers) {
201 m_spec[
"awaitCompletionInterval"] = 2;
204 EXPECT_EQ(spec.await_completion_interval, std::chrono::milliseconds(2000));
207 TEST_F(TestParseStartDaqV2Spec, AwaitCompletionIntervalMustBePositive) {
208 m_spec[
"awaitCompletionInterval"] = -1.0;
@ User
Keep only user-keywords.
TEST_F(TestParseLocation, ParseSucceeds)
StartDaqV2Spec ParseStartDaqV2Spec(nlohmann::json const &json)
Parse StartDaqSpec.
daq::json::TestParseStartDaqV2Spec _json
void to_json(nlohmann::json &out, KeywordFilter const &s)
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
ASSERT_EQ(meta.keyword_rules.size(), 1u)