diff --git a/CMakeLists.txt.athena b/CMakeLists.txt.athena index 8822da8e1b4de87124c9ee8a4cb3b77b9bcd9b7e..489f43f4de48004890f28c9034403be863dfb25b 100644 --- a/CMakeLists.txt.athena +++ b/CMakeLists.txt.athena @@ -61,7 +61,7 @@ set(HEADERS ${header_path}/CrestApi.h ${header_path}/CrestApiExt.h ${header_path}/picosha2.h) -set(SOURCES src/CrestApi.cxx src/CrestRequest.cxx src/CrestApiFs.cxx) +set(SOURCES src/CrestApi.cxx src/CrestRequest.cxx src/CrestApiFs.cxx src/CrestModel.cxx) include_directories(CrestApi ./ nlohmann ${Boost_INCLUDE_DIRS}) diff --git a/src/CrestModel.cxx b/src/CrestModel.cxx index 6b8ed413d1777f124068a0295a88caa498984b5b..0217250c3302e3ed0c1c50071e55029b71c57d31 100644 --- a/src/CrestModel.cxx +++ b/src/CrestModel.cxx @@ -79,7 +79,15 @@ crestResponse.format = j.value("format", ""); // Check for the presence of "page" key and create an optional - crestResponse.page = j.contains("page") ? std::make_optional(RespPage::from_json(j["page"])) : std::nullopt; + if (j.contains("page")){ + if (!j["page"].is_null()){ + crestResponse.page = std::make_optional((RespPage::from_json(j["page"]))); + } + } + else { + crestResponse.page = std::nullopt; + } + // Check for the presence of "filter" key and create an optional crestResponse.filter = j.contains("filter") ? std::make_optional(GenericMap::from_json(j["filter"])) : std::nullopt; @@ -365,6 +373,7 @@ } return tagSet; } + json IovDto::to_json() const { return { @@ -373,13 +382,37 @@ {"insertionTime", insertionTime}, {"payloadHash", payloadHash}}; } + IovDto IovDto::from_json(const json &j) { IovDto iov; iov.tagName = j.value("tagName", ""); - iov.since = j.value<long_t>("since", 0); - iov.insertionTime = j.value("insertionTime", ""); - iov.payloadHash = j.value("payloadHash", ""); + iov.since = j.value<long_t>("since", 0); + + if (j.contains("insertionTime")){ + if (!j["insertionTime"].is_null()){ + iov.insertionTime = j["insertionTime"]; + } + else { + iov.insertionTime = ""; + } + } + else { + iov.insertionTime = ""; + } + + if (j.contains("payloadHash")){ + if (!j["payloadHash"].is_null()){ + iov.payloadHash = j["payloadHash"]; + } + else { + iov.payloadHash = ""; + } + } + else { + iov.payloadHash = ""; + } + return iov; } diff --git a/test/CrestApiFs_test.cxx b/test/CrestApiFs_test.cxx index 6c76c8b1f18c7acde8cf6c372b910522c03534a4..9ef76f758d14ebaf3d9ac4758c89547cf01b621f 100644 --- a/test/CrestApiFs_test.cxx +++ b/test/CrestApiFs_test.cxx @@ -22,7 +22,7 @@ BOOST_AUTO_TEST_SUITE(CrestApiFsTest) std::string workdir = "/tmp/crest"; CrestFsClient myCrestClient = CrestFsClient(true, workdir); - std::string tagname = "test_tag_01"; + std::string tagname = "test_ctest_tag_01"; std::string global_tag = "TEST_GLOBAL_TAG_01"; @@ -40,7 +40,8 @@ BOOST_AUTO_TEST_SUITE(CrestApiFsTest) {"lastValidatedTime", 0}, {"modificationTime", "2018-12-06T11:18:35.641+0000"}, {"name", tagname}, - {"payloadSpec", "Json2Cool"}, + //{"objectType", "Json2Cool"}, + {"payloadSpec", "Json2Cool"}, {"synchronization", "none"}, {"timeType", "time"} }; diff --git a/test/CrestApi_test.cxx b/test/CrestApi_test.cxx index dbbf5bcf994fc7db07f3906f6c1fa90d36b3eae8..8254124c643a57b29e6ab629be225d0af871400a 100644 --- a/test/CrestApi_test.cxx +++ b/test/CrestApi_test.cxx @@ -17,9 +17,10 @@ using namespace Crest; BOOST_AUTO_TEST_SUITE(CrestApiTest) - std::string crest_server = "http://crest-undertow-api.web.cern.ch:80/api-v4.0"; + // std::string crest_server = "http://crest-undertow-api.web.cern.ch:80/api-v4.0"; + std::string crest_server = "http://crest-03.cern.ch:8090"; CrestClient myCrestClient = CrestClient(crest_server,false); - std::string tagname = "test_tag_01"; + std::string tagname = "test_ctest_tag_01"; std::string global_tag = "TEST_GLOBAL_TAG_01";