From 1111a1f9032cd70770bb76bc33abd5471e5a82a0 Mon Sep 17 00:00:00 2001 From: kpetridis <petridkon@gmail.com> Date: Sun, 3 Apr 2022 21:21:08 +0300 Subject: [PATCH] Added Unit test for the valid addition of all report types of a service type --- .../x86/Parameters/PlatformParameters.hpp | 2 +- .../RealTimeForwardingControlService.cpp | 10 ++-- test/Services/RealTimeForwardingControl.cpp | 53 ++++++++++++++----- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/inc/Platform/x86/Parameters/PlatformParameters.hpp b/inc/Platform/x86/Parameters/PlatformParameters.hpp index a1332949..3977b370 100644 --- a/inc/Platform/x86/Parameters/PlatformParameters.hpp +++ b/inc/Platform/x86/Parameters/PlatformParameters.hpp @@ -21,4 +21,4 @@ namespace PlatformParameters { inline Parameter<uint32_t> parameter3(10); } -#endif \ No newline at end of file +#endif diff --git a/src/Services/RealTimeForwardingControlService.cpp b/src/Services/RealTimeForwardingControlService.cpp index 38f528ac..56b47946 100644 --- a/src/Services/RealTimeForwardingControlService.cpp +++ b/src/Services/RealTimeForwardingControlService.cpp @@ -111,10 +111,12 @@ void RealTimeForwardingControlService::addReportTypesToAppProcessConfiguration(M if (not checkService1(request, applicationID, serviceType, numOfMessages)) { continue; } - // if (numOfMessages == 0) { - // // todo: add all report types of the service type to the configuration. - // continue; - // } + + if (numOfMessages == 0) { + // todo: add all report types of the service type to the configuration. + applicationProcessConfiguration.definitions[applicationID][serviceType].clear(); + continue; + } for (uint8_t k = 0; k < numOfMessages; k++) { uint8_t messageType = request.readUint8(); diff --git a/test/Services/RealTimeForwardingControl.cpp b/test/Services/RealTimeForwardingControl.cpp index 39a4dfa4..ee3aa446 100644 --- a/test/Services/RealTimeForwardingControl.cpp +++ b/test/Services/RealTimeForwardingControl.cpp @@ -78,19 +78,25 @@ void initializeCombined(Message& request) { } } } +} - // REQUIRE(request.readUint8() == 3); - // REQUIRE(request.readUint8() == 1); - // REQUIRE(request.readUint8() == 17); - // REQUIRE(request.readUint8() == 1); - // REQUIRE(request.readUint8() == 2); - // REQUIRE(request.readUint8() == HousekeepingService::MessageType::HousekeepingPeriodicPropertiesReport); - // REQUIRE(request.readUint8() == HousekeepingService::MessageType::DisablePeriodicHousekeepingParametersReport); - // REQUIRE(request.readUint8() == 5); - // REQUIRE(request.readUint8() == 2); - // REQUIRE(request.readUint8() == EventReportService::MessageType::InformativeEventReport); - // REQUIRE(request.readUint8() == EventReportService::MessageType::DisabledListEventReport); - // request.resetRead(); +void allReportsOfService(Message& request) { + uint8_t numOfApplications = 1; + uint8_t numOfServicesPerApp = 2; + uint8_t numOfMessagesPerService = 0; + + request.appendUint8(numOfApplications); + + for (auto appID : applications) { + request.appendUint8(appID); + request.appendUint8(numOfServicesPerApp); + + for (uint8_t j = 0; j < numOfServicesPerApp; j++) { + uint8_t serviceType = services[j]; + request.appendUint8(serviceType); + request.appendUint8(numOfMessagesPerService); + } + } } void resetAppProcessConfiguration() { @@ -337,4 +343,27 @@ TEST_CASE("Add report types to the Application Process Configuration") { ServiceTests::reset(); Services.reset(); } + + SECTION("Valid addition of all report types of a specified service type") { + Message request(RealTimeForwardingControlService::ServiceType, + RealTimeForwardingControlService::MessageType::AddReportTypesToAppProcessConfiguration, + Message::TC, 1); + uint8_t applicationID1 = 1; + realTimeForwarding.controlledApplications.push_back(applicationID1); + allReportsOfService(request); + + MessageParser::execute(request); + + CHECK(ServiceTests::count() == 0); + auto& applicationProcesses = realTimeForwarding.applicationProcessConfiguration.definitions; + REQUIRE(applicationProcesses[applicationID1].size() == 2); + for (auto serviceType: services) { + REQUIRE(applicationProcesses[applicationID1].find(serviceType) != applicationProcesses[applicationID1].end()); + REQUIRE(applicationProcesses[applicationID1][serviceType].empty()); + } + + resetAppProcessConfiguration(); + ServiceTests::reset(); + Services.reset(); + } } -- GitLab