Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:33

0001 #pragma once
0002 
0003 #include <string>
0004 #include <vector>
0005 #include <sstream>
0006 #include <nlohmann/json.hpp>
0007 
0008 #include <nopayloadclient/exception.hpp>
0009 #include <nopayloadclient/curlwrapper.hpp>
0010 #include <nopayloadclient/iov.hpp>
0011 
0012 
0013 namespace nopayloadclient {
0014 
0015 using nlohmann::json;
0016 using std::string;
0017 
0018 class FakeWrapper : public CurlWrapper {
0019 
0020 public:
0021     FakeWrapper() : CurlWrapper() {};
0022     FakeWrapper(const json& config) : CurlWrapper(config) {};
0023 
0024     json get(const string& url);
0025 
0026     json del(const string& /* url */) {
0027         throw BaseException("no writing implemented in fake backend");
0028     };
0029     json put(const string& /* url */) {
0030         throw BaseException("no writing implemented in fake backend");
0031     };
0032     json put(const string& /* url */, const json& /* data */) {
0033         throw BaseException("no writing implemented in fake backend");
0034     };
0035     json post(const string& /* url */, const json& /* data */) {
0036         throw BaseException("no writing implemented in fake backend");
0037     };
0038 
0039 
0040 private:
0041     std::vector<string> splitString(const string& input, const char splitter);
0042     IOV FAKE_IOV {42, 42};
0043     json FAKE_GLOBAL_TAGS = json{{
0044                    {"id", 162},
0045                    {"name", "ExampleGT"},
0046                    {"status", "unlocked"},
0047                    {"payload_lists_count", 2},
0048                    {"payload_iov_count", 3}
0049                   }};
0050 
0051     json FAKE_PAYLOAD_IOVS = json {
0052     {
0053         {"id", 154},
0054         {"name", "ExamplePT1_154"},
0055         {"global_tag", "ExampleGT"},
0056         {"payload_type", "ExamplePT1"},
0057         {"payload_iov", {{{"id", 589},
0058                          {"payload_url", "ExamplePT1/8d/77/8d777f385d3dfec8815d20f7496026dc_example_file.dat"},
0059                          {"checksum", "8d777f385d3dfec8815d20f7496026dc"},
0060                          {"major_iov", FAKE_IOV.start_.major_},
0061                          {"minor_iov", FAKE_IOV.start_.minor_},
0062                          {"major_iov_end", 9223372036854775807},
0063                          {"minor_iov_end", 9223372036854775807},
0064                          {"payload_list", "ExamplePT1_154"}
0065                         }}
0066          }
0067     },
0068     {
0069         {"id", 157},
0070         {"name", "ExamplePT2_157"},
0071         {"global_tag", "ExampleGT"},
0072         {"payload_type", "ExamplePT2"},
0073         {"payload_iov", {{{"id", 611},
0074                          {"payload_url", "ExamplePT2/8d/77/8d777f385d3dfec8815d20f7496026dc_example_file.dat"},
0075                          {"checksum", "8d777f385d3dfec8815d20f7496026dc"},
0076                          {"major_iov", FAKE_IOV.start_.major_},
0077                          {"minor_iov", FAKE_IOV.start_.minor_},
0078                          {"major_iov_end", 9223372036854775807},
0079                          {"minor_iov_end", 9223372036854775807},
0080                          {"payload_list", "ExamplePT2_157"}
0081                         }}
0082         }
0083     }
0084     };
0085 
0086     json FAKE_DATABASE = json {{"globalTags", FAKE_GLOBAL_TAGS},
0087                                {"payloadiovs", FAKE_PAYLOAD_IOVS}};
0088 };
0089 
0090 }