2828#include " rapidjson/document.h"
2929#include " QualityControl/RepoPathUtils.h"
3030#include " QualityControl/testUtils.h"
31+ // #include "rapidjson/writer.h"
32+ // #include "rapidjson/stringbuffer.h"
3133
3234namespace utf = boost::unit_test;
3335
@@ -238,6 +240,24 @@ BOOST_AUTO_TEST_CASE(ccdb_retrieve_qo, *utf::depends_on("ccdb_store"))
238240 BOOST_CHECK_EQUAL (q.getLevel (), 3 );
239241}
240242
243+ /* *
244+ * Compares the two provided json string. They must be identical at the exception of
245+ * the metadata "Date" that can differ. This is due to the way CCDB sets this property.
246+ * @param ccdbObjectJson1
247+ * @param ccdbObjectJson2
248+ * @return
249+ */
250+ bool areIdentical (std::string ccdbObjectJson1, std::string ccdbObjectJson2)
251+ {
252+ Document jsonDocumentA;
253+ Document jsonDocumentB;
254+ jsonDocumentA.Parse (ccdbObjectJson1.c_str ());
255+ jsonDocumentB.Parse (ccdbObjectJson2.c_str ());
256+ jsonDocumentA[" metadata" ].RemoveMember (" Date" );
257+ jsonDocumentB[" metadata" ].RemoveMember (" Date" );
258+ return jsonDocumentA == jsonDocumentB;
259+ }
260+
241261BOOST_AUTO_TEST_CASE (ccdb_retrieve_json, *utf::depends_on (" ccdb_store" ))
242262{
243263 test_fixture f;
@@ -247,20 +267,17 @@ BOOST_AUTO_TEST_CASE(ccdb_retrieve_json, *utf::depends_on("ccdb_store"))
247267 std::cout << " [json retrieve]: " << path << std::endl;
248268 auto json = f.backend ->retrieveJson (path, -1 , f.metadata );
249269 auto json2 = f.backend ->retrieveMOJson (f.getMoFolder (object), object);
250- cout << " asdf" << endl;
251- cout << json << endl;
252- cout << json2 << endl;
253-
254270 BOOST_CHECK (!json.empty ());
255- BOOST_CHECK_EQUAL (json, json2);
271+ BOOST_CHECK (!json2.empty ());
272+ BOOST_CHECK (areIdentical (json, json2));
256273
257274 std::string checkName = " test-ccdb-check" ;
258275 string qualityPath = f.getQoPath (checkName);
259276 std::cout << " [json retrieve]: " << qualityPath << std::endl;
260277 auto json3 = f.backend ->retrieveJson (qualityPath, -1 , f.metadata );
261278 auto json4 = f.backend ->retrieveQOJson (qualityPath);
262279 BOOST_CHECK (!json3.empty ());
263- BOOST_CHECK_EQUAL ( json3, json4);
280+ BOOST_CHECK ( areIdentical ( json3, json4) );
264281
265282 Document jsonDocument;
266283 jsonDocument.Parse (json.c_str ());
0 commit comments