From d5889261cbb12d7f06553ad9d03c7ef11751b1c2 Mon Sep 17 00:00:00 2001 From: "Maaike Zijderveld, iolar" Date: Tue, 3 Sep 2024 16:01:43 +0200 Subject: [PATCH] Rename `DeviceModelStorage` to `DeviceModelInterface` Signed-off-by: Maaike Zijderveld, iolar --- include/ocpp/v201/charge_point.hpp | 8 +-- include/ocpp/v201/device_model.hpp | 20 +++---- ...storage.hpp => device_model_interface.hpp} | 18 +++--- .../ocpp/v201/device_model_storage_sqlite.hpp | 4 +- include/ocpp/v201/init_device_model_db.hpp | 4 +- include/ocpp/v201/monitoring_updater.hpp | 4 +- lib/ocpp/v201/charge_point.cpp | 23 ++++---- lib/ocpp/v201/device_model.cpp | 59 +++++++++---------- lib/ocpp/v201/device_model_storage_sqlite.cpp | 4 +- lib/ocpp/v201/monitoring_updater.cpp | 2 +- ...ck.hpp => device_model_interface_mock.hpp} | 4 +- tests/lib/ocpp/v201/test_charge_point.cpp | 10 ++-- .../v201/test_device_model_storage_sqlite.cpp | 2 +- .../ocpp/v201/test_smart_charging_handler.cpp | 2 +- 14 files changed, 80 insertions(+), 84 deletions(-) rename include/ocpp/v201/{device_model_storage.hpp => device_model_interface.hpp} (91%) rename tests/lib/ocpp/v201/mocks/{device_model_storage_mock.hpp => device_model_interface_mock.hpp} (91%) diff --git a/include/ocpp/v201/charge_point.hpp b/include/ocpp/v201/charge_point.hpp index 09b758973..25b7c1d95 100644 --- a/include/ocpp/v201/charge_point.hpp +++ b/include/ocpp/v201/charge_point.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -838,14 +838,14 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa /// \param evse_connector_structure Map that defines the structure of EVSE and connectors of the chargepoint. The /// key represents the id of the EVSE and the value represents the number of connectors for this EVSE. The ids of /// the EVSEs have to increment starting with 1. - /// \param device_model_storage device model storage instance + /// \param device_model_interface device model interface instance /// \param ocpp_main_path Path where utility files for OCPP are read and written to /// \param core_database_path Path to directory where core database is located /// \param message_log_path Path to where logfiles are written to /// \param evse_security Pointer to evse_security that manages security related operations /// \param callbacks Callbacks that will be registered for ChargePoint ChargePoint(const std::map& evse_connector_structure, - std::unique_ptr device_model_storage, const std::string& ocpp_main_path, + std::unique_ptr device_model_interface, const std::string& ocpp_main_path, const std::string& core_database_path, const std::string& sql_init_path, const std::string& message_log_path, const std::shared_ptr evse_security, const Callbacks& callbacks); @@ -854,7 +854,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa /// \param evse_connector_structure Map that defines the structure of EVSE and connectors of the chargepoint. The /// key represents the id of the EVSE and the value represents the number of connectors for this EVSE. The ids of /// the EVSEs have to increment starting with 1. - /// \param device_model_storage device model storage instance + /// \param device_model device model instance /// \param database_handler database handler instance /// \param message_queue message queue instance /// \param message_log_path Path to where logfiles are written to diff --git a/include/ocpp/v201/device_model.hpp b/include/ocpp/v201/device_model.hpp index f74eac9f7..031c1de78 100644 --- a/include/ocpp/v201/device_model.hpp +++ b/include/ocpp/v201/device_model.hpp @@ -8,7 +8,7 @@ #include -#include +#include namespace ocpp { namespace v201 { @@ -91,13 +91,13 @@ typedef std::function on_monitor_updated; -/// \brief This class manages access to the device model representation and to the device model storage and provides +/// \brief This class manages access to the device model representation and to the device model interface and provides /// functionality to support the use cases defined in the functional block Provisioning class DeviceModel { private: DeviceModelMap device_model; - std::unique_ptr storage; + std::unique_ptr interface; /// \brief Listener for the internal change of a variable on_variable_changed variable_listener; @@ -106,7 +106,7 @@ class DeviceModel { /// \brief Private helper method that does some checks with the device model representation in memory to evaluate if /// a value for the given parameters can be requested. If it can be requested it will be retrieved from the device - /// model storage and the given \p value will be set to the value that was retrieved + /// model interface and the given \p value will be set to the value that was retrieved /// \param component_id /// \param variable_id /// \param attribute_enum @@ -138,15 +138,15 @@ class DeviceModel { public: /// \brief Constructor for the device model - /// \param device_model_storage pointer to a device model storage class - explicit DeviceModel(std::unique_ptr device_model_storage); + /// \param device_model_interface pointer to a device model interface class + explicit DeviceModel(std::unique_ptr device_model_interface); /// \brief Direct access to value of a VariableAttribute for the given component, variable and attribute_enum. This /// should only be called for variables that have a role standardized in the OCPP2.0.1 specification. /// \tparam T datatype of the value that is requested /// \param component_variable Combination of Component and Variable that identifies the Variable /// \param attribute_enum defaults to AttributeEnum::Actual - /// \return the requested value from the device model storage + /// \return the requested value from the device model interface template T get_value(const RequiredComponentVariable& component_variable, const AttributeEnum& attribute_enum = AttributeEnum::Actual) { @@ -160,10 +160,10 @@ class DeviceModel { return to_specific_type(value); } else { EVLOG_critical - << "Directly requested value for ComponentVariable that doesn't exist in the device model storage: " + << "Directly requested value for ComponentVariable that doesn't exist in the device model: " << component_variable; EVLOG_AND_THROW(std::runtime_error( - "Directly requested value for ComponentVariable that doesn't exist in the device model storage.")); + "Directly requested value for ComponentVariable that doesn't exist in the device model.")); } } @@ -190,7 +190,7 @@ class DeviceModel { } /// \brief Requests a value of a VariableAttribute specified by combination of \p component_id and \p variable_id - /// from the device model storage + /// from the device model /// \tparam T datatype of the value that is requested /// \param component_id /// \param variable_id diff --git a/include/ocpp/v201/device_model_storage.hpp b/include/ocpp/v201/device_model_interface.hpp similarity index 91% rename from include/ocpp/v201/device_model_storage.hpp rename to include/ocpp/v201/device_model_interface.hpp index 2892a781e..3e590a594 100644 --- a/include/ocpp/v201/device_model_storage.hpp +++ b/include/ocpp/v201/device_model_interface.hpp @@ -1,8 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest -#ifndef OCPP_V201_DEVICE_MODEL_STORAGE_HPP -#define OCPP_V201_DEVICE_MODEL_STORAGE_HPP +#pragma once #include #include @@ -39,15 +38,15 @@ struct VariableMetaData { using VariableMap = std::map; using DeviceModelMap = std::map; -class DeviceModelStorageError : public std::exception { +class DeviceModelError : public std::exception { public: [[nodiscard]] const char* what() const noexcept override { return this->reason.c_str(); } - explicit DeviceModelStorageError(std::string msg) { + explicit DeviceModelError(std::string msg) { this->reason = std::move(msg); } - explicit DeviceModelStorageError(const char* msg) { + explicit DeviceModelError(const char* msg) { this->reason = std::string(msg); } @@ -55,15 +54,15 @@ class DeviceModelStorageError : public std::exception { std::string reason; }; -/// \brief Abstract base class for device model storage. This class provides an interface for accessing and modifying +/// \brief Abstract base class for device model interface. This class provides an interface for accessing and modifying /// device model data. Implementations of this class should provide concrete implementations for the virtual methods /// declared here. -class DeviceModelStorage { +class DeviceModelInterface { public: - virtual ~DeviceModelStorage() = default; + virtual ~DeviceModelInterface() = default; - /// \brief Gets the device model from the device model storage + /// \brief Gets the device model from the device model interface /// \return std::map> that will contain a full representation of the /// device model except for the VariableAttribute(s) of each Variable. virtual DeviceModelMap get_device_model() = 0; @@ -141,4 +140,3 @@ class DeviceModelStorage { } // namespace v201 } // namespace ocpp -#endif // OCPP_V201_DEVICE_MODEL_STORAGE_HPP diff --git a/include/ocpp/v201/device_model_storage_sqlite.hpp b/include/ocpp/v201/device_model_storage_sqlite.hpp index dd52d7e46..381fad322 100644 --- a/include/ocpp/v201/device_model_storage_sqlite.hpp +++ b/include/ocpp/v201/device_model_storage_sqlite.hpp @@ -9,12 +9,12 @@ #include #include -#include +#include namespace ocpp { namespace v201 { -class DeviceModelStorageSqlite : public DeviceModelStorage { +class DeviceModelStorageSqlite : public DeviceModelInterface { private: std::unique_ptr db; diff --git a/include/ocpp/v201/init_device_model_db.hpp b/include/ocpp/v201/init_device_model_db.hpp index dcb35a2f6..05c02e0f9 100644 --- a/include/ocpp/v201/init_device_model_db.hpp +++ b/include/ocpp/v201/init_device_model_db.hpp @@ -18,7 +18,7 @@ /// database is not set by an external source, like the CSMS. /// /// The data from the schema json files or database are read into some structs. Some structs could be reused from -/// the DeviceModelStorage class, but some members are missing there and and to prevent too many database reads, some +/// the DeviceModelInterface class, but some members are missing there and and to prevent too many database reads, some /// structs are 'redefined' in this class with the proper members. /// /// Since the DeviceModel class creates a map based on the device model database in the constructor, this class should @@ -36,7 +36,7 @@ #include #include -#include +#include namespace ocpp::v201 { /// diff --git a/include/ocpp/v201/monitoring_updater.hpp b/include/ocpp/v201/monitoring_updater.hpp index 6337ea939..5e73c56b0 100644 --- a/include/ocpp/v201/monitoring_updater.hpp +++ b/include/ocpp/v201/monitoring_updater.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include namespace ocpp::v201 { @@ -187,4 +187,4 @@ class MonitoringUpdater { std::unordered_map updater_monitors_meta; }; -} // namespace ocpp::v201 \ No newline at end of file +} // namespace ocpp::v201 diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 45c465879..9c969c680 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -125,10 +125,10 @@ ChargePoint::ChargePoint(const std::map& evse_connector_struct } ChargePoint::ChargePoint(const std::map& evse_connector_structure, - std::unique_ptr device_model_storage, const std::string& ocpp_main_path, - const std::string& core_database_path, const std::string& sql_init_path, - const std::string& message_log_path, const std::shared_ptr evse_security, - const Callbacks& callbacks) : + std::unique_ptr device_model_interface, + const std::string& ocpp_main_path, const std::string& core_database_path, + const std::string& sql_init_path, const std::string& message_log_path, + const std::shared_ptr evse_security, const Callbacks& callbacks) : ocpp::ChargingStationBase(evse_security), registration_status(RegistrationStatusEnum::Rejected), skip_invalid_csms_certificate_notifications(false), @@ -139,7 +139,7 @@ ChargePoint::ChargePoint(const std::map& evse_connector_struct bootreason(BootReasonEnum::PowerUp), ocsp_updater(this->evse_security, this->send_callback( MessageType::GetCertificateStatusResponse)), - device_model(std::make_shared(std::move(device_model_storage))), + device_model(std::make_shared(std::move(device_model_interface))), monitoring_updater( device_model, [this](const std::vector& events) { this->notify_event_req(events); }, [this]() { return this->is_offline(); }), @@ -2434,8 +2434,7 @@ void ChargePoint::handle_set_network_profile_req(Call ControllerComponentVariables::NetworkConnectionProfiles.variable.value(), AttributeEnum::Actual, network_connection_profiles.dump(), VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL) != SetVariableStatusEnum::Accepted) { - EVLOG_warning - << "CSMS attempted to set a network profile that could not be written to the device model storage"; + EVLOG_warning << "CSMS attempted to set a network profile that could not be written to the device model"; response.status = SetNetworkProfileStatusEnum::Rejected; ocpp::CallResult call_result(response, call.uniqueId); this->send(call_result); @@ -3339,7 +3338,7 @@ void ChargePoint::handle_set_monitoring_base_req(Call msg.monitoringBase == MonitoringBaseEnum::FactoryDefault) { try { this->device_model->clear_custom_monitors(); - } catch (const DeviceModelStorageError& e) { + } catch (const DeviceModelError& e) { EVLOG_warning << "Could not clear custom monitors from DB: " << e.what(); response.status = GenericDeviceModelStatusEnum::Rejected; } @@ -3399,7 +3398,7 @@ void ChargePoint::handle_set_variable_monitoring_req(const EnhancedMessagedevice_model->set_monitors(msg.setMonitoringData); - } catch (const DeviceModelStorageError& e) { + } catch (const DeviceModelError& e) { EVLOG_error << "Set monitors failed:" << e.what(); } @@ -3479,7 +3478,7 @@ void ChargePoint::handle_get_monitoring_report_req(Calldevice_model->clear_monitors(msg.id); - } catch (const DeviceModelStorageError& e) { + } catch (const DeviceModelError& e) { EVLOG_error << "Clear variable monitoring failed:" << e.what(); } @@ -3633,7 +3632,7 @@ void ChargePoint::handle_send_local_authorization_list_req(Calldevice_model->set_read_only_value(local_entries.component, local_entries.variable.value(), AttributeEnum::Actual, std::to_string(entries), VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL); - } catch (const DeviceModelStorageError& e) { + } catch (const DeviceModelError& e) { EVLOG_warning << "Could not get local list count from database:" << e.what(); } catch (const DatabaseException& e) { EVLOG_warning << "Could not get local list count from database: " << e.what(); diff --git a/lib/ocpp/v201/device_model.cpp b/lib/ocpp/v201/device_model.cpp index fe56abac2..836486c8c 100644 --- a/lib/ocpp/v201/device_model.cpp +++ b/lib/ocpp/v201/device_model.cpp @@ -233,7 +233,7 @@ GetVariableStatusEnum DeviceModel::request_value_internal(const Component& compo return GetVariableStatusEnum::UnknownVariable; } - const auto attribute_opt = this->storage->get_variable_attribute(component_id, variable_id, attribute_enum); + const auto attribute_opt = this->interface->get_variable_attribute(component_id, variable_id, attribute_enum); if ((not attribute_opt) or (not attribute_opt->value)) { return GetVariableStatusEnum::NotSupportedAttributeType; @@ -274,7 +274,7 @@ SetVariableStatusEnum DeviceModel::set_value(const Component& component, const V return SetVariableStatusEnum::Rejected; } - const auto attribute = this->storage->get_variable_attribute(component, variable, attribute_enum); + const auto attribute = this->interface->get_variable_attribute(component, variable, attribute_enum); if (!attribute.has_value()) { return SetVariableStatusEnum::NotSupportedAttributeType; @@ -287,7 +287,7 @@ SetVariableStatusEnum DeviceModel::set_value(const Component& component, const V } const auto success = - this->storage->set_variable_attribute_value(component, variable, attribute_enum, value, source); + this->interface->set_variable_attribute_value(component, variable, attribute_enum, value, source); // Only trigger for actual values if ((attribute_enum == AttributeEnum::Actual) && success && variable_listener) { @@ -310,9 +310,9 @@ SetVariableStatusEnum DeviceModel::set_value(const Component& component, const V return success ? SetVariableStatusEnum::Accepted : SetVariableStatusEnum::Rejected; }; -DeviceModel::DeviceModel(std::unique_ptr device_model_storage) : - storage{std::move(device_model_storage)} { - this->device_model = this->storage->get_device_model(); +DeviceModel::DeviceModel(std::unique_ptr device_model_interface) : + interface{std::move(device_model_interface)} { + this->device_model = this->interface->get_device_model(); } SetVariableStatusEnum DeviceModel::set_read_only_value(const Component& component, const Variable& variable, @@ -347,8 +347,8 @@ std::vector DeviceModel::get_base_report_data(const ReportBaseEnum& ComponentVariable cv = {component, std::nullopt, variable}; - // request the variable attribute from the device model storage - const auto variable_attributes = this->storage->get_variable_attributes(component, variable); + // request the variable attribute from the device model + const auto variable_attributes = this->interface->get_variable_attributes(component, variable); // iterate over possibly (Actual, Target, MinSet, MaxSet) for (const auto& variable_attribute : variable_attributes) { @@ -391,8 +391,8 @@ DeviceModel::get_custom_report_data(const std::optionalstorage->get_variable_attributes(component, variable); + // request the variable attribute from the device model + const auto variable_attributes = this->interface->get_variable_attributes(component, variable); for (const auto& variable_attribute : variable_attributes) { report_data.variableAttribute.push_back(variable_attribute); @@ -412,7 +412,7 @@ DeviceModel::get_custom_report_data(const std::optional& evse_connector_structure) { EVLOG_debug << "Checking integrity of device model in storage"; try { - this->storage->check_integrity(); + this->interface->check_integrity(); int32_t nr_evse_components = 0; std::map evse_id_nr_connector_components; @@ -431,34 +431,33 @@ void DeviceModel::check_integrity(const std::map& evse_connect // check if number of EVSE in the device model matches the configured number if (nr_evse_components != evse_connector_structure.size()) { - throw DeviceModelStorageError("Number of EVSE configured in device model is incompatible with number of " - "configured EVSEs of the ChargePoint"); + throw DeviceModelError("Number of EVSE configured in device model is incompatible with number of " + "configured EVSEs of the ChargePoint"); } for (const auto [evse_id, nr_of_connectors] : evse_connector_structure) { // check if number of Cpnnectors for this EVSE in the device model matches the configured number if (evse_id_nr_connector_components[evse_id] != nr_of_connectors) { - throw DeviceModelStorageError( - "Number of Connectors configured in device model is incompatible with number " - "of configured Connectors of the ChargePoint"); + throw DeviceModelError("Number of Connectors configured in device model is incompatible with number " + "of configured Connectors of the ChargePoint"); } // check if all relevant EVSE and Connector components can be found EVSE evse = {evse_id}; Component evse_component = {"EVSE", std::nullopt, evse}; if (!this->device_model.count(evse_component)) { - throw DeviceModelStorageError("Could not find required EVSE component in device model"); + throw DeviceModelError("Could not find required EVSE component in device model"); } for (size_t connector_id = 1; connector_id <= nr_of_connectors; connector_id++) { evse_component.name = "Connector"; evse_component.evse.value().connectorId = connector_id; if (!this->device_model.count(evse_component)) { - throw DeviceModelStorageError("Could not find required Connector component in device model"); + throw DeviceModelError("Could not find required Connector component in device model"); } } } - } catch (const DeviceModelStorageError& e) { - EVLOG_error << "Integrity check in Device Model storage failed:" << e.what(); + } catch (const DeviceModelError& e) { + EVLOG_error << "Integrity check in Device Model failed:" << e.what(); throw e; } } @@ -500,7 +499,7 @@ bool DeviceModel::update_monitor_reference(int32_t monitor_id, const std::string if (found_monitor) { try { - if (this->storage->update_monitoring_reference(monitor_id, reference_value)) { + if (this->interface->update_monitoring_reference(monitor_id, reference_value)) { // Update value in-memory too monitor_meta->reference_value = reference_value; return true; @@ -510,7 +509,7 @@ bool DeviceModel::update_monitor_reference(int32_t monitor_id, const std::string } } catch (const DatabaseException& e) { EVLOG_error << "Exception while updating trivial delta monitor reference with ID: " << monitor_id; - throw DeviceModelStorageError(e.what()); + throw DeviceModelError(e.what()); } } else { EVLOG_warning << "Could not find trivial delta monitor with ID: " << monitor_id @@ -655,14 +654,14 @@ std::vector DeviceModel::set_monitors(const std::vectorstorage->set_monitoring_data(request, type); + auto monitor_meta = this->interface->set_monitoring_data(request, type); if (monitor_meta.has_value()) { // N07.FR.11 // In case of an existing monitor update if (request_has_id && monitor_update_listener) { - auto attribute = this->storage->get_variable_attribute(component_it->first, variable_it->first, - AttributeEnum::Actual); + auto attribute = this->interface->get_variable_attribute(component_it->first, variable_it->first, + AttributeEnum::Actual); if (attribute.has_value()) { static std::string empty_value{}; @@ -686,7 +685,7 @@ std::vector DeviceModel::set_monitors(const std::vector DeviceModel::clear_monitors(const std::vector clear_monitor_res.id = id; try { - auto clear_result = this->storage->clear_variable_monitor(id, allow_protected); + auto clear_result = this->interface->clear_variable_monitor(id, allow_protected); if (clear_result == ClearMonitoringStatusEnum::Accepted) { // Clear from memory too for (auto& [component, variable_map] : this->device_model) { @@ -824,7 +823,7 @@ std::vector DeviceModel::clear_monitors(const std::vector clear_monitor_res.status = clear_result; } catch (const DatabaseException& e) { EVLOG_error << "Clear monitors failed:" << e.what(); - throw DeviceModelStorageError(e.what()); + throw DeviceModelError(e.what()); } clear_monitors_vec.push_back(clear_monitor_res); @@ -835,7 +834,7 @@ std::vector DeviceModel::clear_monitors(const std::vector int32_t DeviceModel::clear_custom_monitors() { try { - int32_t deleted = this->storage->clear_custom_variable_monitors(); + int32_t deleted = this->interface->clear_custom_variable_monitors(); // Clear from memory too for (auto& [component, variable_map] : this->device_model) { @@ -854,7 +853,7 @@ int32_t DeviceModel::clear_custom_monitors() { return deleted; } catch (const DatabaseException& e) { EVLOG_error << "Clear custom monitors failed:" << e.what(); - throw DeviceModelStorageError(e.what()); + throw DeviceModelError(e.what()); } return 0; diff --git a/lib/ocpp/v201/device_model_storage_sqlite.cpp b/lib/ocpp/v201/device_model_storage_sqlite.cpp index 90aff34e9..636b846ec 100644 --- a/lib/ocpp/v201/device_model_storage_sqlite.cpp +++ b/lib/ocpp/v201/device_model_storage_sqlite.cpp @@ -23,7 +23,7 @@ DeviceModelStorageSqlite::DeviceModelStorageSqlite(const fs::path& db_path, cons if (init_db) { if (db_path.empty() || migration_files_path.empty() || config_path.empty()) { EVLOG_AND_THROW( - DeviceModelStorageError("Can not initialize device model storage: one of the paths is empty.")); + DeviceModelError("Can not initialize device model storage: one of the paths is empty.")); } InitDeviceModelDb init_device_model_db(db_path, migration_files_path); init_device_model_db.initialize_database(config_path, false); @@ -481,7 +481,7 @@ void DeviceModelStorageSqlite::check_integrity() { << "/" << select_stmt->column_text_nullable(4).value_or("") << ")" << std::endl; } while (select_stmt->step() == SQLITE_ROW); - throw DeviceModelStorageError(error.str()); + throw DeviceModelError(error.str()); } } diff --git a/lib/ocpp/v201/monitoring_updater.cpp b/lib/ocpp/v201/monitoring_updater.cpp index d1e7594f9..f7ff5c8e2 100644 --- a/lib/ocpp/v201/monitoring_updater.cpp +++ b/lib/ocpp/v201/monitoring_updater.cpp @@ -265,7 +265,7 @@ void MonitoringUpdater::evaluate_monitor(const VariableMonitoringMeta& monitor_m if (!this->device_model->update_monitor_reference(monitor_id, value_current)) { EVLOG_warning << "Could not update delta monitor: " << monitor_id << " reference!"; } - } catch (const DeviceModelStorageError& e) { + } catch (const DeviceModelError& e) { EVLOG_error << "Could not update delta monitor reference with exception: " << e.what(); } } diff --git a/tests/lib/ocpp/v201/mocks/device_model_storage_mock.hpp b/tests/lib/ocpp/v201/mocks/device_model_interface_mock.hpp similarity index 91% rename from tests/lib/ocpp/v201/mocks/device_model_storage_mock.hpp rename to tests/lib/ocpp/v201/mocks/device_model_interface_mock.hpp index e882a66ad..db5989795 100644 --- a/tests/lib/ocpp/v201/mocks/device_model_storage_mock.hpp +++ b/tests/lib/ocpp/v201/mocks/device_model_interface_mock.hpp @@ -5,10 +5,10 @@ #include -#include "ocpp/v201/device_model_storage.hpp" +#include "ocpp/v201/device_model_interface.hpp" namespace ocpp::v201 { -class DeviceModelStorageMock : public DeviceModelStorage { +class DeviceModelStorageMock : public DeviceModelInterface { public: MOCK_METHOD(DeviceModelMap, get_device_model, ()); MOCK_METHOD(std::optional, get_variable_attribute, diff --git a/tests/lib/ocpp/v201/test_charge_point.cpp b/tests/lib/ocpp/v201/test_charge_point.cpp index ebc2775e9..0b61b929f 100644 --- a/tests/lib/ocpp/v201/test_charge_point.cpp +++ b/tests/lib/ocpp/v201/test_charge_point.cpp @@ -35,11 +35,11 @@ class TestChargePoint : public ChargePoint { using ChargePoint::smart_charging_handler; TestChargePoint(std::map& evse_connector_structure, - std::unique_ptr device_model_storage, const std::string& ocpp_main_path, + std::unique_ptr device_model_interface, const std::string& ocpp_main_path, const std::string& core_database_path, const std::string& sql_init_path, const std::string& message_log_path, const std::shared_ptr evse_security, const Callbacks& callbacks, std::shared_ptr smart_charging_handler) : - ChargePoint(evse_connector_structure, std::move(device_model_storage), ocpp_main_path, core_database_path, + ChargePoint(evse_connector_structure, std::move(device_model_interface), ocpp_main_path, core_database_path, sql_init_path, message_log_path, evse_security, callbacks) { this->smart_charging_handler = smart_charging_handler; } @@ -91,7 +91,7 @@ class ChargePointFixture : public DatabaseTestingUtils { std::unique_ptr create_charge_point() { std::map evse_connector_structure = {{1, 1}, {2, 1}}; - std::unique_ptr device_model_storage = + std::unique_ptr device_model_storage = std::make_unique(DEVICE_MODEL_DB_IN_MEMORY_PATH); auto charge_point = std::make_unique(evse_connector_structure, std::move(device_model_storage), "", TEMP_OUTPUT_PATH, MIGRATION_FILES_LOCATION_V201, @@ -280,7 +280,7 @@ TEST_F(ChargePointFixture, CreateChargePoint) { "/tmp", evse_security, callbacks)); } -TEST_F(ChargePointFixture, CreateChargePoint_EVSEConnectorStructureDefinedBadly_ThrowsDeviceModelStorageError) { +TEST_F(ChargePointFixture, CreateChargePoint_EVSEConnectorStructureDefinedBadly_ThrowsDeviceModelError) { auto database_handler = create_database_handler(); auto evse_security = std::make_shared(); configure_callbacks_with_mocks(); @@ -290,7 +290,7 @@ TEST_F(ChargePointFixture, CreateChargePoint_EVSEConnectorStructureDefinedBadly_ EXPECT_THROW(ocpp::v201::ChargePoint(evse_connector_structure, device_model, database_handler, message_queue, "/tmp", evse_security, callbacks), - DeviceModelStorageError); + DeviceModelError); } TEST_F(ChargePointFixture, CreateChargePoint_MissingDeviceModel_ThrowsInvalidArgument) { diff --git a/tests/lib/ocpp/v201/test_device_model_storage_sqlite.cpp b/tests/lib/ocpp/v201/test_device_model_storage_sqlite.cpp index 2197fc600..28a0da2ba 100644 --- a/tests/lib/ocpp/v201/test_device_model_storage_sqlite.cpp +++ b/tests/lib/ocpp/v201/test_device_model_storage_sqlite.cpp @@ -25,7 +25,7 @@ TEST_F(DeviceModelStorageSQLiteTest, test_check_integrity_valid) { TEST_F(DeviceModelStorageSQLiteTest, test_check_integrity_invalid) { auto dm_storage = DeviceModelStorageSqlite(INVALID_DEVICE_MODEL_DATABASE); - EXPECT_THROW(dm_storage.check_integrity(), DeviceModelStorageError); + EXPECT_THROW(dm_storage.check_integrity(), DeviceModelError); } } // namespace v201 diff --git a/tests/lib/ocpp/v201/test_smart_charging_handler.cpp b/tests/lib/ocpp/v201/test_smart_charging_handler.cpp index 5bc280b9a..01158cc5f 100644 --- a/tests/lib/ocpp/v201/test_smart_charging_handler.cpp +++ b/tests/lib/ocpp/v201/test_smart_charging_handler.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include