From a43c98261d588ad325726199118c30665f573605 Mon Sep 17 00:00:00 2001 From: Vishakha Gupta-Cledat Date: Thu, 4 Apr 2019 23:41:41 -0700 Subject: [PATCH] Add test for lost sub-second when returning date. Needs updated PMGD. --- tests/cleandbs.sh | 2 +- tests/server/DataTypeChecks.json | 68 +++++++++++++++++++++++++ tests/server/config-datatype-tests.json | 10 ++++ tests/server/json_queries.cc | 43 ++++++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/server/DataTypeChecks.json create mode 100644 tests/server/config-datatype-tests.json diff --git a/tests/cleandbs.sh b/tests/cleandbs.sh index 3edc94bc..4fee0b54 100644 --- a/tests/cleandbs.sh +++ b/tests/cleandbs.sh @@ -1,4 +1,4 @@ -rm -r jsongraph qhgraph simpleAdd_db simpleAddx10_db simpleUpdate_db entitycheck_db +rm -r jsongraph qhgraph simpleAdd_db simpleAddx10_db simpleUpdate_db entitycheck_db datatypecheck_db rm -r tdb rm -r dbs diff --git a/tests/server/DataTypeChecks.json b/tests/server/DataTypeChecks.json new file mode 100644 index 00000000..28c3a9b9 --- /dev/null +++ b/tests/server/DataTypeChecks.json @@ -0,0 +1,68 @@ +[ + { + "AddEntity": + { + + "_ref": 1, + "class": "Patient", + + "properties": { + "Email":"rst@rashed.com", + "Age": 83, + "timestamp": 1544069566053, + "Birthday":{"_date":"1936-10-01T17:59:24.001-07:00"}, + "Name":"Mark", + "fv": {"_blob":"Raghed----ghjhsglfhwa"} + } + } + + }, + { + "AddEntity": + { + "_ref": 2, + "class": "Patient", + + "properties": { + "Email":"gst@raghehed.com1", + "Age": 73, + "timestamp": 2544069566053, + "Birthday":{"_date":"1946-10-01T17:49:24.009010-07:00"}, + "fv":{"_blob" :"Ahmad----ghjhsglfhwa"}, + "Name": "Kai" + + } + } + + }, + { + "AddConnection": + { + "ref1" : 1, + "ref2" : 2, + "class": "Married", + "properties":{ + "since" : {"_date":"Sat Sep 1 19:59:24 PDT 1956"}, + "fv": {"_blob":"----ghjhsglfhwa"}, + "city" : "Boston", + "location" : "residence" + } + } + + }, + { + "FindEntity" : { + "class" : "Patient", + "constraints": { + "Age": ["<", 100 ] + }, + "results": { + "list":["Name","Birthday"], + "sort" : { + "key" : "Age", + "order" : "descending" + } + } + } + } +] diff --git a/tests/server/config-datatype-tests.json b/tests/server/config-datatype-tests.json new file mode 100644 index 00000000..69f2762a --- /dev/null +++ b/tests/server/config-datatype-tests.json @@ -0,0 +1,10 @@ +// VDMS Config File +// This is the run-time config file +// Sets database paths and other parameters +{ + // Network + "port": 55555, + + // Database paths + "pmgd_path": "datatypecheck_db" +} diff --git a/tests/server/json_queries.cc b/tests/server/json_queries.cc index 032353f8..4e0e71c6 100644 --- a/tests/server/json_queries.cc +++ b/tests/server/json_queries.cc @@ -420,3 +420,46 @@ TEST(QueryHandler, EmptyResultCheck) VDMSConfig::destroy(); PMGDQueryHandler::destroy(); } + +TEST(QueryHandler, DataTypeChecks) +{ + Json::Reader reader; + Json::StyledWriter writer; + + std::ifstream ifile; + int fsize; + char * inBuf; + ifile.open("server/DataTypeChecks.json", std::ifstream::in); + ifile.seekg(0, std::ios::end); + fsize = (int)ifile.tellg(); + ifile.seekg(0, std::ios::beg); + inBuf = new char[fsize]; + ifile.read(inBuf, fsize); + std::string json_query = std::string(inBuf); + ifile.close(); + delete[] inBuf; + + VDMSConfig::init("server/config-datatype-tests.json"); + PMGDQueryHandler::init(); + QueryHandler::init(); + + QueryHandler qh_base; + QueryHandlerTester query_handler(qh_base); + + VDMS::protobufs::queryMessage proto_query; + proto_query.set_json(json_query); + VDMS::protobufs::queryMessage response; + + query_handler.pq(proto_query, response ); + + Json::Value parsed; + reader.parse(response.json().c_str(), parsed); + + // std::cout << writer.write(parsed) << std::endl; + const Json::Value& query = parsed[3]; + EXPECT_EQ(query["FindEntity"]["entities"][0]["Birthday"].asString(), "1936-10-01T17:59:24.001-07:00"); + EXPECT_EQ(query["FindEntity"]["entities"][1]["Birthday"].asString(), "1946-10-01T17:49:24.009010-07:00"); + + VDMSConfig::destroy(); + PMGDQueryHandler::destroy(); +}