Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Adapt unittests to internal API changes string->json
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schildt <[email protected]>
  • Loading branch information
SebastianSchildt committed Jul 15, 2022
1 parent 76a9079 commit 3fc26d6
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 314 deletions.
30 changes: 10 additions & 20 deletions kuksa-val-server/test/unit-test/Gen2GetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Sensor) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

// Does result have a timestamp?
verify_and_erase_timestamp(res);
Expand Down Expand Up @@ -172,9 +171,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON) {
jsoncons::json expectedJson = jsoncons::json::parse(expectedJsonString);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

// Does result have a timestamp?
verify_and_erase_timestamp(res);
Expand Down Expand Up @@ -207,9 +205,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Invalid_JSON_NoRequestID) {
jsoncons::json expectedJson = jsoncons::json::parse(expectedJsonString);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);
// Does result have a timestamp?
verify_and_erase_timestamp(res);

Expand Down Expand Up @@ -237,9 +234,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_NonExistingPath) {
JsonResponses::pathNotFound(requestId, "get", path, jsonPathNotFound);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

BOOST_TEST(res == jsonPathNotFound);
}
Expand Down Expand Up @@ -298,9 +294,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Branch) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

// Does result have a timestamp?
verify_and_erase_timestamp(res);
Expand Down Expand Up @@ -366,9 +361,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_End) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

// Does result have a timestamp?
verify_and_erase_timestamp(res);
Expand Down Expand Up @@ -400,9 +394,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_Wildcard_NonExisting) {
JsonResponses::pathNotFound(requestId, "get", path, jsonPathNotFound);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

BOOST_TEST(res == jsonPathNotFound);
}
Expand Down Expand Up @@ -432,8 +425,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_noPermissionException) {
.returns(false);

// run UUT
auto resStr = processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);
auto res = processor->processQuery(jsonGetRequestForSignal.as_string(), channel);

// verify

Expand Down Expand Up @@ -493,9 +485,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_StableTimestamp) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

verify_and_erase_timestamp(res);
verify_and_erase_timestamp(res["data"]["dp"]);
Expand All @@ -510,8 +501,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Get_StableTimestamp) {
.once()
.with(mock::any, vss_path)
.returns(true);
resStr = processor->processQuery(jsonGetRequestForSignal.as_string(), channel);
res = json::parse(resStr);
res = processor->processQuery(jsonGetRequestForSignal.as_string(), channel);

verify_and_erase_timestamp(res);
verify_and_erase_timestamp(res["data"]["dp"]);
Expand Down
27 changes: 8 additions & 19 deletions kuksa-val-server/test/unit-test/Gen2SetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Sensor_Simple) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

Expand Down Expand Up @@ -172,9 +171,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Array) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

Expand Down Expand Up @@ -210,9 +208,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON) {
jsoncons::json expectedJson = jsoncons::json::parse(expectedJsonString);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

Expand Down Expand Up @@ -245,9 +242,8 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Invalid_JSON_NoRequestID) {
jsoncons::json expectedJson = jsoncons::json::parse(expectedJsonString);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

Expand Down Expand Up @@ -292,11 +288,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Non_Existing_Path) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);

auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

BOOST_TEST(res == expectedJson);
Expand Down Expand Up @@ -341,11 +335,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Branch) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);

auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

BOOST_TEST(res == expectedJson);
Expand Down Expand Up @@ -390,11 +382,9 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_Attribute) {
.returns(true);

// run UUT
auto resStr =
auto res =
processor->processQuery(jsonSetRequestForSignal.as_string(), channel);

auto res = json::parse(resStr);

verify_and_erase_timestamp(res);

BOOST_TEST(res == expectedJson);
Expand Down Expand Up @@ -426,8 +416,7 @@ BOOST_AUTO_TEST_CASE(Gen2_Set_noPermissionException) {
.returns(false);

// run UUT
auto resStr = processor->processQuery(jsonSetRequestForSignal.as_string(), channel);
auto res = json::parse(resStr);
auto res = processor->processQuery(jsonSetRequestForSignal.as_string(), channel);

// verify
verify_and_erase_timestamp(res);
Expand Down
Loading

0 comments on commit 3fc26d6

Please sign in to comment.