From 6b5ce761f84a9635fa8fd2c1151a3a0d9fcd961d Mon Sep 17 00:00:00 2001 From: athatheocsd <athatheo@csd.auth.gr> Date: Wed, 26 Dec 2018 15:27:52 +0200 Subject: [PATCH] Updated MessageParser::execute function Added test basics --- CMakeLists.txt | 2 +- inc/Services/EventActionService.hpp | 7 ++++- src/MessageParser.cpp | 4 +++ src/Services/EventActionService.cpp | 2 +- test/Services/EventActionService.cpp | 41 ++++++++++++++++++++++++++++ test/Services/EventReportService.cpp | 2 +- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 test/Services/EventActionService.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d25e161a..c8b7254b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,6 @@ IF (EXISTS "${PROJECT_SOURCE_DIR}/lib/Catch2/CMakeLists.txt") add_executable(tests $<TARGET_OBJECTS:common> ${test_main_SRC} - ${test_SRC}) + ${test_SRC} test/Services/EventActionService.cpp) target_link_libraries(tests Catch2::Catch2) ENDIF () diff --git a/inc/Services/EventActionService.hpp b/inc/Services/EventActionService.hpp index 59cc8693..22f94e49 100644 --- a/inc/Services/EventActionService.hpp +++ b/inc/Services/EventActionService.hpp @@ -97,7 +97,7 @@ public: * Custom function that is called right after an event takes place, to initiate * the execution of the action */ - void executeAction(); + void execute(Message &message); /** * Setter for event-action function status @@ -105,6 +105,11 @@ public: void setEventActionFunctionStatus(EventActionFunctionStatus e) { eventActionFunctionStatus = e; } + + /** + * The purpose of this instance is to access the execute function + */ + static EventActionService instance; }; #endif //ECSS_SERVICES_EVENTACTIONSERVICE_HPP diff --git a/src/MessageParser.cpp b/src/MessageParser.cpp index fe2426e5..f9b0394c 100644 --- a/src/MessageParser.cpp +++ b/src/MessageParser.cpp @@ -1,4 +1,5 @@ #include <cstring> +#include <Services/EventActionService.hpp> #include "ErrorHandler.hpp" #include "MessageParser.hpp" #include "macros.hpp" @@ -7,6 +8,7 @@ TestService TestService::instance; RequestVerificationService RequestVerificationService::instance; +EventActionService EventActionService::instance; void MessageParser::execute(Message &message) { switch (message.serviceType) { @@ -16,6 +18,8 @@ void MessageParser::execute(Message &message) { case 17: TestService::instance.execute(message); break; + case 19: + EventActionService::instance.execute(message); default: // cout is very bad for embedded systems std::cout << "This service hasn't been implemented yet or it doesn't exist"; diff --git a/src/Services/EventActionService.cpp b/src/Services/EventActionService.cpp index c26e07c7..497d3aa8 100644 --- a/src/Services/EventActionService.cpp +++ b/src/Services/EventActionService.cpp @@ -171,7 +171,7 @@ void EventActionService::disableEventActionFunction(Message message) { } } -void EventActionService::executeAction() { +void EventActionService::execute(Message &message) { // Custom function if (eventActionFunctionStatus == enabledFunction) { diff --git a/test/Services/EventActionService.cpp b/test/Services/EventActionService.cpp new file mode 100644 index 00000000..e783b1a1 --- /dev/null +++ b/test/Services/EventActionService.cpp @@ -0,0 +1,41 @@ +#include <catch2/catch.hpp> +#include <Services/EventActionService.hpp> +#include <Message.hpp> +#include "ServiceTests.hpp" +#include <cstring> + +TEST_CASE("Add event-action definitions TC[19,1]", "[service][st09]") { + +} + +TEST_CASE("Delete event-action definitions TC[19,2]", "[service][st09]") { + +} + +TEST_CASE("Delete all event-action definitions TC[19,3]", "[service][st09]") { + +} + +TEST_CASE("Enable event-action definitions TC[19,4]", "[service][st09]") { + +} + +TEST_CASE("Disable event-action definitions TC[19,5]", "[service][st09]") { + +} + +TEST_CASE("Request event-action definition status TC[19,6]", "[service][st09]") { + +} + +TEST_CASE("Event-action status report TM[19,7]", "[service][st09]") { + +} + +TEST_CASE("Enable event-action function TC[19,8]", "[service][st09]") { + +} + +TEST_CASE("Disable event-action function TC[19,1]", "[service][st09]") { + +} diff --git a/test/Services/EventReportService.cpp b/test/Services/EventReportService.cpp index 0bf8133a..ca90bee5 100644 --- a/test/Services/EventReportService.cpp +++ b/test/Services/EventReportService.cpp @@ -5,7 +5,7 @@ #include <cstring> /* - * @todo Change the reinterpret_cast + * @todo: Change the reinterpret_cast */ TEST_CASE("Informative Event Report TM[5,1]", "[service][st05]") { EventReportService eventReportService; -- GitLab