|
14 | 14 | /// \author Piotr Konopka |
15 | 15 | /// |
16 | 16 |
|
| 17 | +#include "Framework/include/QualityControl/Reductor.h" |
17 | 18 | #include "QualityControl/TrendingTask.h" |
18 | 19 | #include "QualityControl/DatabaseFactory.h" |
19 | 20 | #include "QualityControl/MonitorObject.h" |
@@ -51,6 +52,25 @@ struct CleanupAtDestruction { |
51 | 52 | std::function<void()> mCallback = nullptr; |
52 | 53 | }; |
53 | 54 |
|
| 55 | +// https://stackoverflow.com/questions/424104/can-i-access-private-members-from-outside-the-class-without-using-friends |
| 56 | +template <typename Accessor, typename Accessor::type Member> |
| 57 | +struct DeclareGlobalGet { |
| 58 | + friend typename Accessor::type get(Accessor) { return Member; } |
| 59 | +}; |
| 60 | + |
| 61 | +struct TrendingTaskReductorAccessor { |
| 62 | + using type = std::unordered_map<std::string, std::unique_ptr<Reductor>> TrendingTask::*; |
| 63 | + friend type get(TrendingTaskReductorAccessor); |
| 64 | +}; |
| 65 | + |
| 66 | +struct ReductorConfigAccessor { |
| 67 | + using type = CustomParameters Reductor::*; |
| 68 | + friend type get(ReductorConfigAccessor); |
| 69 | +}; |
| 70 | + |
| 71 | +template struct DeclareGlobalGet<TrendingTaskReductorAccessor, &TrendingTask::mReductors>; |
| 72 | +template struct DeclareGlobalGet<ReductorConfigAccessor, &Reductor::mCustomParameters>; |
| 73 | + |
54 | 74 | TEST_CASE("test_trending_task") |
55 | 75 | { |
56 | 76 | const std::string pid = std::to_string(getpid()); |
@@ -88,6 +108,13 @@ TEST_CASE("test_trending_task") |
88 | 108 | taskName + R"json(", |
89 | 109 | "name": "testHistoTrending", |
90 | 110 | "reductorName": "o2::quality_control_modules::common::TH1Reductor", |
| 111 | + "reductorParameters": { |
| 112 | + "default": { |
| 113 | + "default": { |
| 114 | + "key":"value" |
| 115 | + } |
| 116 | + } |
| 117 | + }, |
91 | 118 | "moduleName": "QcCommon" |
92 | 119 | }, |
93 | 120 | { |
@@ -146,6 +173,20 @@ TEST_CASE("test_trending_task") |
146 | 173 | task.setObjectsManager(objectManager); |
147 | 174 | REQUIRE_NOTHROW(task.configure(config)); |
148 | 175 |
|
| 176 | + { |
| 177 | + auto& reductors = task.*get(TrendingTaskReductorAccessor()); |
| 178 | + size_t foundCount{}; |
| 179 | + for (const auto& reductor : reductors) { |
| 180 | + auto& config = (*reductor.second.get()).*get(ReductorConfigAccessor()); |
| 181 | + if (auto found = config.find("key"); found != config.end()) { |
| 182 | + if (found->second == "value") { |
| 183 | + foundCount++; |
| 184 | + } |
| 185 | + } |
| 186 | + } |
| 187 | + REQUIRE(foundCount == 1); |
| 188 | + } |
| 189 | + |
149 | 190 | // test initialize() |
150 | 191 | REQUIRE_NOTHROW(task.initialize({ TriggerType::UserOrControl, true, { 0, "NONE", "", "", "qc" }, 1 }, services)); |
151 | 192 | REQUIRE(objectManager->getNumberPublishedObjects() == 1); |
|
0 commit comments