diff --git a/README.md b/README.md index fb21869b5..c176b3fc0 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ All documentation and the issue tracking can be found in our main repository her | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | | [OCPP 1.6 Security Whitepaper (3rd edition)](https://www.openchargealliance.org/uploads/files/OCPP-1.6-security-whitepaper-edition-3.zip) | :heavy_check_mark: yes | | [Using ISO 15118 Plug & Charge with OCPP 1.6](https://www.openchargealliance.org/uploads/files/ocpp_1_6_ISO_15118_v10.pdf) | :heavy_check_mark: yes | -| [OCPP & California Pricing Requirements](https://www.openchargealliance.org/uploads/files/ocpp_and_dms_evse_regulation-v2.0.pdf) | | +| [OCPP & California Pricing Requirements](https://www.openchargealliance.org/uploads/files/ocpp_and_dms_evse_regulation-v2.0.pdf) | :heavy_check_mark: yes | ## Support for OCPP 2.0.1 @@ -88,7 +88,7 @@ The development of OCPP2.0.1 is in progress. | Whitepapers & Application Notes | Supported | | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -| [OCPP & California Pricing Requirements](https://www.openchargealliance.org/uploads/files/ocpp_and_dms_evse_regulation-v2.0.pdf) | | +| [OCPP & California Pricing Requirements](https://www.openchargealliance.org/uploads/files/ocpp_and_dms_evse_regulation-v2.0.pdf) | WIP | @@ -158,7 +158,7 @@ This library is automatically integrated as the OCPP and OCPP201 module within [ If you run libocpp with OCPP1.6 with EVerest, the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you. ### Run OCPP2.0.1 with EVerest -If you run libocpp with OCPP1.6 with EVerest, the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you. This includes the initialization of the device model database using the [config.json](config/v201/config.json) file. +If you run libocpp with OCPP1.6 with EVerest, the build process of [everest-core](https://github.com/EVerest/everest-core) will take care of installing all necessary dependencies for you. This includes the initialization of the device model database using the [component config](config/v201/component_config) files. ## Integrate this library with your Charging Station Implementation for OCPP1.6 diff --git a/doc/ocpp_201_device_model_initialization.md b/doc/ocpp_201_device_model_initialization.md index 61a52a1f4..b28c34b50 100644 --- a/doc/ocpp_201_device_model_initialization.md +++ b/doc/ocpp_201_device_model_initialization.md @@ -6,39 +6,32 @@ give more information about the files you need and what will be updated when the to true. -## Database, component schemas and config file paths +## Database, component config and config file paths Along with the 'initialize_device_model' flag, a few paths must be given to the constructor: - The path of the device model migration files (normally `resources/v201/device_model_migration_files`). - The path of the device model database. -- The path of the directory with the device model schemas. There should be two directories in it: 'standardized' and - 'custom', both containing device model schemas. -- The path of the config file. +- The path of the directory with the device model config. There should be two directories in it: 'standardized' and + 'custom', both containing device model config. -## Component schemas and config file +## Component config When the database is created for the first time, it will insert all components, variables, characteristics and -attributes from the component schemas. - -It will then set all the values read from the config file. - -The config and the component schemas depend on each other. If the definition in the component schema does not match the -definition in the config, no values will be set in the device model database. So if for example there is a variable set -in the config that is not in the component schema, the config values will not be set. +attributes from the component config. ## Update config values -Each time the ChargePoint class is instantiated, the config file is read and the values will be set to the database -accordingly. Only the initial values will be set to the values in the config file. So if for example the CSMS changed a -value, it will not be updated to the value from the config file. +Each time the ChargePoint class is instantiated, the component config is read and the values will be set to the database +accordingly. Only the initial values will be set to the values in the component config. So if for example the CSMS +changed a value, it will not be updated to the value from the component config file. ## Update component config -To update a component, just place the correct json schema in the `component_config/custom` folder. When restarting the -software, it will: +To update a component, just place the correct json component config in the `component_config/custom` or +`component_config/standardized` folder. When restarting the software, it will: - Check if there are Components in the database that are not in the component config's. Those will be removed. - Check if there are Components in the component config's that are not in the database. Those will be added. - Check if anything has changed inside the Component (`Variable`, `Characteristics` or `Attributes`). @@ -48,3 +41,5 @@ Note: When the `evse_id` or `connector_id` of a component is changed, this is se addition of a new one. Note: OCPP requires EVSE and Connector numbering starting from 1 counting upwards. + +Note: There should be no duplicate components or variables in the component config files. diff --git a/include/ocpp/v201/device_model_storage_sqlite.hpp b/include/ocpp/v201/device_model_storage_sqlite.hpp index dd52d7e46..662e4ef01 100644 --- a/include/ocpp/v201/device_model_storage_sqlite.hpp +++ b/include/ocpp/v201/device_model_storage_sqlite.hpp @@ -31,7 +31,7 @@ class DeviceModelStorageSqlite : public DeviceModelStorage { /// \param db_path Path to database /// \param migration_files_path Path to the migration files to initialize the database (only needs to be set if /// `init_db` is true) - /// \param config_path Path to the device model schemas (only needs to be set if `init_db` is true) + /// \param config_path Path to the device model config (only needs to be set if `init_db` is true) /// \param init_db True to initialize the database /// explicit DeviceModelStorageSqlite(const fs::path& db_path, const std::filesystem::path& migration_files_path = "", diff --git a/include/ocpp/v201/init_device_model_db.hpp b/include/ocpp/v201/init_device_model_db.hpp index dcb35a2f6..709b29c9c 100644 --- a/include/ocpp/v201/init_device_model_db.hpp +++ b/include/ocpp/v201/init_device_model_db.hpp @@ -7,19 +7,19 @@ /// @details @copydetails ocpp::v201::InitDeviceModelDb /// /// @class ocpp::v201::InitDeviceModelDb -/// @brief Class to initialize the device model db using the schema's and config file +/// @brief Class to initialize the device model db using the component config files /// -/// This class will read the device model schemas and config file and put them in the device model database. +/// This class will read the device model config files and put them in the device model database. /// /// If the database already exists and there are some changes on components, this class will make the changes in the /// database accordingly. /// -/// It will also re-apply the config file. Config items will only be replaced if they are changed and the value in the -/// database is not set by an external source, like the CSMS. +/// It will also re-apply the component config. Config items will only be replaced if they are changed and the value in +/// the 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 -/// structs are 'redefined' in this class with the proper members. +/// The data from the component config 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 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 /// first be finished with the initialization before creating the DeviceModel class. @@ -43,7 +43,7 @@ namespace ocpp::v201 { /// \brief Class that holds a component. /// /// When the component is read from the database, the component id will be set. -/// When the component is read from the schema file, the 'required' vector will be filled. +/// When the component is read from the component config file, the 'required' vector will be filled. /// struct ComponentKey { std::optional db_id; ///< \brief Component id in the database. @@ -89,22 +89,22 @@ struct DeviceModelVariable { bool required; /// \brief Variable instance std::optional instance; - /// \brief Default value, if this is set in the schemas json + /// \brief Default value, if this is set in the component config json std::optional default_actual_value; /// \brief Config monitors, if any std::vector monitors; }; /// \brief Convert from json to a ComponentKey struct. -/// The to_json is not implemented as we don't need to write the schema to a json file. +/// The to_json is not implemented as we don't need to write the component config to a json file. void from_json(const json& j, ComponentKey& c); /// \brief Convert from json to a DeviceModelVariable struct. -/// The to_json is not implemented for this struct as we don't need to write the schema to a json file. +/// The to_json is not implemented for this struct as we don't need to write the component config to a json file. void from_json(const json& j, DeviceModelVariable& c); /// \brief Convert from json to a VariableMonitoringMeta struct. -/// The to_json is not implemented for this struct as we don't need to write the schema to a json file. +/// The to_json is not implemented for this struct as we don't need to write the component config to a json file. void from_json(const json& j, VariableMonitoringMeta& c); /// @@ -147,8 +147,8 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon { virtual ~InitDeviceModelDb(); /// - /// \brief Initialize the database schema. - /// \param config_path Path to the database schemas. + /// \brief Initialize the database schema and component config. + /// \param config_path Path to the component config. /// \param delete_db_if_exists Set to true to delete the database if it already exists. /// /// \throws InitDeviceModelDbError - When database could not be initialized or @@ -157,7 +157,7 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon { /// \throws std::runtime_error If something went wrong during migration /// \throws DatabaseMigrationException If something went wrong during migration /// \throws DatabaseConnectionException If the database could not be opened - /// \throws std::filesystem::filesystem_error If the schemas path does not exist + /// \throws std::filesystem::filesystem_error If the component config path does not exist /// /// void initialize_database(const std::filesystem::path& config_path, const bool delete_db_if_exists); @@ -183,8 +183,8 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon { std::vector get_component_config_from_directory(const std::filesystem::path& directory); /// - /// \brief Read all component schema's from the given directory and create a map holding the structure. - /// \param directory The parent directory containing the standardized and custom schema's. + /// \brief Read all component config files from the given directory and create a map holding the structure. + /// \param directory The parent directory containing the standardized and custom component config files. /// \return A map with the device model components, variables, characteristics and attributes. /// std::map> @@ -209,12 +209,12 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon { const std::vector& component_variables); /// - /// \brief Read component schemas from given files. - /// \param components_schema_path The paths to the component schema files. + /// \brief Read component config from given files. + /// \param components_config_path The paths to the component config files. /// \return A map holding the components with its variables, characteristics and attributes. /// std::map> - read_component_config(const std::vector& components_schema_path); + read_component_config(const std::vector& components_config_path); /// /// \brief Get all component properties (variables) from the given (component) json. @@ -388,13 +388,13 @@ class InitDeviceModelDb : public common::DatabaseHandlerCommon { const ComponentKey& component); /// - /// \brief Check if a component exist in the component schema. - /// \param component_schema The map of component / variables read from the json component schema. + /// \brief Check if a component exist in the component config. + /// \param component_config The map of component / variables read from the json component config. /// \param component The component to check. - /// \return True when the component exists in the schema. + /// \return True when the component exists in the config. /// - bool component_exists_in_schemas(const std::map>& component_schema, - const ComponentKey& component); + bool component_exists_in_config(const std::map>& component_config, + const ComponentKey& component); /// /// \brief Remove components from db that do not exist in the component config. diff --git a/lib/ocpp/v201/init_device_model_db.cpp b/lib/ocpp/v201/init_device_model_db.cpp index 74fe11bc8..d236eed65 100644 --- a/lib/ocpp/v201/init_device_model_db.cpp +++ b/lib/ocpp/v201/init_device_model_db.cpp @@ -62,13 +62,13 @@ void InitDeviceModelDb::initialize_database(const std::filesystem::path& config_ existing_components = get_all_components_from_db(); } - // Get component schemas from the filesystem. + // Get component config files from the filesystem. std::map> component_configs = get_all_component_configs(config_path); // Check if the config is consistent (fe has a value when required). check_integrity(component_configs); - // Remove components from db if they do not exist in the component schemas + // Remove components from db if they do not exist in the component config if (this->database_exists) { remove_not_existing_components_from_db(component_configs, existing_components); } @@ -111,27 +111,27 @@ void InitDeviceModelDb::execute_init_sql(const bool delete_db_if_exists) { std::vector InitDeviceModelDb::get_component_config_from_directory(const std::filesystem::path& directory) { - std::vector component_schema_files; + std::vector component_config_files; for (const auto& p : std::filesystem::directory_iterator(directory)) { if (p.path().extension() == ".json") { - component_schema_files.push_back(p.path()); + component_config_files.push_back(p.path()); } } - return component_schema_files; + return component_config_files; } std::map> InitDeviceModelDb::get_all_component_configs(const std::filesystem::path& directory) { - const std::vector standardized_component_schema_files = + const std::vector standardized_component_config_files = get_component_config_from_directory(directory / STANDARDIZED_COMPONENT_CONFIG_DIR); - const std::vector custom_component_schema_files = + const std::vector custom_component_config_files = get_component_config_from_directory(directory / CUSTOM_COMPONENT_CONFIG_DIR); std::map> standardized_components_map = - read_component_config(standardized_component_schema_files); + read_component_config(standardized_component_config_files); std::map> components = - read_component_config(custom_component_schema_files); + read_component_config(custom_component_config_files); // Merge the two maps so they can be used for the insert_component function with a single iterator. This will use // the custom components map as base and add not existing standardized components to the components map. So if the @@ -209,12 +209,12 @@ void InitDeviceModelDb::insert_component(const ComponentKey& component_key, } std::map> -InitDeviceModelDb::read_component_config(const std::vector& components_schema_path) { +InitDeviceModelDb::read_component_config(const std::vector& components_config_path) { std::map> components; - for (const auto& path : components_schema_path) { - std::ifstream schema_file(path); + for (const auto& path : components_config_path) { + std::ifstream config_file(path); try { - json data = json::parse(schema_file); + json data = json::parse(config_file); ComponentKey p = data; if (data.contains("properties")) { std::vector variables = @@ -225,7 +225,7 @@ InitDeviceModelDb::read_component_config(const std::vector>& component_schema, const ComponentKey& component) { - for (const auto& component_in_schema : component_schema) { - if (is_same_component_key(component, component_in_schema.first)) { +bool InitDeviceModelDb::component_exists_in_config( + const std::map>& component_config, const ComponentKey& component) { + for (const auto& component_in_config : component_config) { + if (is_same_component_key(component, component_in_config.first)) { return true; } } @@ -954,7 +954,7 @@ void InitDeviceModelDb::remove_not_existing_components_from_db( const std::map>& component_config, const std::map>& db_components) { for (const auto& component : db_components) { - if (!component_exists_in_schemas(component_config, component.first)) { + if (!component_exists_in_config(component_config, component.first)) { remove_component_from_db(component.first); } } @@ -1197,8 +1197,8 @@ void from_json(const json& j, DeviceModelVariable& c) { c.instance = j.at("instance"); } - // Required is normally not in the schema here but somewhere else, but well, if it is occasionally or just later on, - // it will be added here as well. + // Required is normally not in the config here but somewhere else, but well, if it is occasionally or just later + // on, it will be added here as well. if (j.contains("required")) { c.required = j.at("required"); } @@ -1376,7 +1376,7 @@ static bool value_is_of_type(const std::string& value, const DataEnum& type) { return false; } -/* Below functions check if components, attributes, variables, characteristics are the same / equal in the schema +/* Below functions check if components, attributes, variables, characteristics are the same / equal in the config * and database. The 'is_same' functions check if two objects are the same, comparing their unique properties. The * is_..._different functions check if the objects properties are different (and as a result should be changed in * the database). diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3af471e5a..893fc1e96 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,8 +8,8 @@ set(DEVICE_MODEL_RESOURCES_WRONG_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/reso set(DEVICE_MODEL_CURRENT_RESOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config/v201/resources) set(DEVICE_MODEL_CURRENT_CHANGED_RESOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config/v201/resources_changed) set(DEVICE_MODEL_CURRENT_WRONG_RESOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config/v201/resources_wrong) -set(DEVICE_MODEL_EXAMPLE_SCHEMAS_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/example_config/v201/component_config") -set(DEVICE_MODEL_CURRENT_EXAMPLE_SCHEMAS_LOCATION_V201 "${PROJECT_SOURCE_DIR}/config/v201/component_config") +set(DEVICE_MODEL_EXAMPLE_CONFIG_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/example_config/v201/component_config") +set(DEVICE_MODEL_CURRENT_EXAMPLE_CONFIG_LOCATION_V201 "${PROJECT_SOURCE_DIR}/config/v201/component_config") set(TEST_PROFILES_LOCATION_V16 "${CMAKE_CURRENT_BINARY_DIR}/resources/profiles/v16") set(TEST_PROFILES_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/profiles/v201") @@ -43,8 +43,8 @@ add_custom_command(TARGET libocpp_unit_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEVICE_MODEL_CURRENT_CHANGED_RESOURCES_DIR} ${DEVICE_MODEL_RESOURCES_CHANGED_LOCATION_V201} COMMAND ${CMAKE_COMMAND} -E remove_directory ${DEVICE_MODEL_RESOURCES_WRONG_LOCATION_V201} COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEVICE_MODEL_CURRENT_WRONG_RESOURCES_DIR} ${DEVICE_MODEL_RESOURCES_WRONG_LOCATION_V201} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${DEVICE_MODEL_EXAMPLE_SCHEMAS_LOCATION_V201} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEVICE_MODEL_CURRENT_EXAMPLE_SCHEMAS_LOCATION_V201} ${DEVICE_MODEL_EXAMPLE_SCHEMAS_LOCATION_V201} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${DEVICE_MODEL_EXAMPLE_CONFIG_LOCATION_V201} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEVICE_MODEL_CURRENT_EXAMPLE_CONFIG_LOCATION_V201} ${DEVICE_MODEL_EXAMPLE_CONFIG_LOCATION_V201} ) add_test(libocpp_unit_tests libocpp_unit_tests) diff --git a/tests/lib/ocpp/v201/test_charge_point.cpp b/tests/lib/ocpp/v201/test_charge_point.cpp index 598d935e4..f1b72ad6e 100644 --- a/tests/lib/ocpp/v201/test_charge_point.cpp +++ b/tests/lib/ocpp/v201/test_charge_point.cpp @@ -31,7 +31,7 @@ static const ocpp::v201::AddChargingProfileSource DEFAULT_REQUEST_TO_ADD_PROFILE ocpp::v201::AddChargingProfileSource::SetChargingProfile; static const std::string TEMP_OUTPUT_PATH = "/tmp/ocpp201"; const static std::string MIGRATION_FILES_PATH = "./resources/v201/device_model_migration_files"; -const static std::string SCHEMAS_PATH = "./resources/example_config/v201/component_config"; +const static std::string CONFIG_PATH = "./resources/example_config/v201/component_config"; const static std::string DEVICE_MODEL_DB_IN_MEMORY_PATH = "file::memory:?cache=shared"; static const std::string DEFAULT_TX_ID = "10c75ff7-74f5-44f5-9d01-f649f3ac7b78"; @@ -77,7 +77,7 @@ class ChargepointTestFixtureV201 : public DatabaseTestingUtils { void create_device_model_db(const std::string& path) { InitDeviceModelDb db(path, MIGRATION_FILES_PATH); - db.initialize_database(SCHEMAS_PATH, true); + db.initialize_database(CONFIG_PATH, true); } std::shared_ptr diff --git a/tests/lib/ocpp/v201/test_composite_schedule.cpp b/tests/lib/ocpp/v201/test_composite_schedule.cpp index b23a8beed..78a57d255 100644 --- a/tests/lib/ocpp/v201/test_composite_schedule.cpp +++ b/tests/lib/ocpp/v201/test_composite_schedule.cpp @@ -47,8 +47,7 @@ static const int DEFAULT_PROFILE_ID = 1; static const int DEFAULT_STACK_LEVEL = 1; static const std::string DEFAULT_TX_ID = "10c75ff7-74f5-44f5-9d01-f649f3ac7b78"; const static std::string MIGRATION_FILES_PATH = "./resources/v201/device_model_migration_files"; -const static std::string SCHEMAS_PATH = "./resources/example_config/v201/component_config"; -const static std::string CONFIG_PATH = "./resources/example_config/v201/config.json"; +const static std::string CONFIG_PATH = "./resources/example_config/v201/component_config"; const static std::string DEVICE_MODEL_DB_IN_MEMORY_PATH = "file::memory:?cache=shared"; class TestSmartChargingHandler : public SmartChargingHandler { @@ -166,8 +165,7 @@ class CompositeScheduleTestFixtureV201 : public DatabaseTestingUtils { void create_device_model_db(const std::string& path) { InitDeviceModelDb db(path, MIGRATION_FILES_PATH); - db.initialize_database(SCHEMAS_PATH, true); - // db.initialize_database(CONFIG_PATH, false); + db.initialize_database(CONFIG_PATH, true); } std::shared_ptr @@ -813,4 +811,4 @@ TEST_F(CompositeScheduleTestFixtureV201, K08_CalculateCompositeSchedule_External ASSERT_EQ(actual, expected); } -} // namespace ocpp::v201 \ No newline at end of file +} // namespace ocpp::v201 diff --git a/tests/lib/ocpp/v201/test_init_device_model_db.cpp b/tests/lib/ocpp/v201/test_init_device_model_db.cpp index 110fca4bd..cd41175ec 100644 --- a/tests/lib/ocpp/v201/test_init_device_model_db.cpp +++ b/tests/lib/ocpp/v201/test_init_device_model_db.cpp @@ -19,11 +19,11 @@ class InitDeviceModelDbTest : public DatabaseTestingUtils { protected: const std::string DATABASE_PATH = "file::memory:?cache=shared"; const std::string MIGRATION_FILES_PATH = "./resources/v201/device_model_migration_files"; - const std::string SCHEMAS_PATH = "./resources/config/v201/component_config"; - const std::string SCHEMAS_PATH_CHANGED = "./resources/config/v201/changed/component_config"; - const std::string SCHEMAS_PATH_REQUIRED_NO_VALUE = + const std::string CONFIGS_PATH = "./resources/config/v201/component_config"; + const std::string CONFIGS_PATH_CHANGED = "./resources/config/v201/changed/component_config"; + const std::string CONFIGS_PATH_REQUIRED_NO_VALUE = "./resources/config/v201/wrong/component_config_required_no_value"; - const std::string SCHEMAS_PATH_WRONG_VALUE_TYPE = "./resources/config/v201/wrong/component_config_wrong_value_type"; + const std::string CONFIGS_PATH_WRONG_VALUE_TYPE = "./resources/config/v201/wrong/component_config_wrong_value_type"; public: InitDeviceModelDbTest() { @@ -154,8 +154,8 @@ class InitDeviceModelDbTest : public DatabaseTestingUtils { TEST_F(InitDeviceModelDbTest, init_db) { /* This test tests if the initialization of the database is running successfully. It will first initialize with - * a given schema and check some variables and attributes to see if they exist. It will then initialize again, but - * with a changed schema, which should update the database (in some cases). + * a given component config and check some variables and attributes to see if they exist. It will then initialize + * again, but with a changed component config, which should update the database (in some cases). * Because we test with an in memory database, and we never know what the order is of the tests, we test both cases * in one test. * @@ -188,7 +188,7 @@ TEST_F(InitDeviceModelDbTest, init_db) { // Database should not exist yet. But since it does a filesystem check and we have an in memory database, we // explicitly set the variable here. db.database_exists = false; - ASSERT_NO_THROW(db.initialize_database(std::filesystem::path(SCHEMAS_PATH), true)); + ASSERT_NO_THROW(db.initialize_database(std::filesystem::path(CONFIGS_PATH), true)); // Tables should have been created now. EXPECT_TRUE(check_all_tables_exist({"COMPONENT", "VARIABLE", "DATATYPE", "MONITOR", "MUTABILITY", "SEVERITY", @@ -292,7 +292,7 @@ TEST_F(InitDeviceModelDbTest, init_db) { // This time, the database does exist (again: std::filesystem::exists, which is automatically used, will not work // here because we use an in memory database, so we set the member ourselves). db2.database_exists = true; - ASSERT_NO_THROW(db2.initialize_database(SCHEMAS_PATH_CHANGED, false)); + ASSERT_NO_THROW(db2.initialize_database(CONFIGS_PATH_CHANGED, false)); // So now some records should have been changed ! EXPECT_TRUE(attribute_exists("EVSE", std::nullopt, 1, std::nullopt, "AllowReset", std::nullopt, @@ -409,11 +409,11 @@ TEST_F(InitDeviceModelDbTest, init_db) { TEST_F(InitDeviceModelDbTest, wrong_migration_file_path) { InitDeviceModelDb db(DATABASE_PATH, "/tmp/thisdoesnotexisthopefully"); // The migration script is not correct (there is none in the given folder), this should throw an exception. - EXPECT_THROW(db.initialize_database(SCHEMAS_PATH, true), DatabaseMigrationException); + EXPECT_THROW(db.initialize_database(CONFIGS_PATH, true), DatabaseMigrationException); } -TEST_F(InitDeviceModelDbTest, wrong_schemas_path) { - // Wrong schemas path while initializing database +TEST_F(InitDeviceModelDbTest, wrong_config_path) { + // Wrong component config path while initializing database InitDeviceModelDb db(DATABASE_PATH, MIGRATION_FILES_PATH); EXPECT_THROW(db.initialize_database("/tmp/thisdoesnotexisthopefully", true), std::filesystem::filesystem_error); } @@ -421,16 +421,16 @@ TEST_F(InitDeviceModelDbTest, wrong_schemas_path) { TEST_F(InitDeviceModelDbTest, default_device_model_config) { // Test if the default device model config is correct and will create a valid database with valid values. const static std::string MIGRATION_FILES_PATH_DEFAULT = "./resources/v201/device_model_migration_files"; - const static std::string SCHEMAS_PATH_DEFAULT = "./resources/example_config/v201/component_config"; + const static std::string CONFIG_PATH_DEFAULT = "./resources/example_config/v201/component_config"; InitDeviceModelDb db(DATABASE_PATH, MIGRATION_FILES_PATH_DEFAULT); - EXPECT_NO_THROW(db.initialize_database(SCHEMAS_PATH_DEFAULT, true)); + EXPECT_NO_THROW(db.initialize_database(CONFIG_PATH_DEFAULT, true)); } TEST_F(InitDeviceModelDbTest, missing_required_values) { // Test if initializing fails when there is a missing required value. InitDeviceModelDb db(DATABASE_PATH, MIGRATION_FILES_PATH); try { - db.initialize_database(SCHEMAS_PATH_REQUIRED_NO_VALUE, true); + db.initialize_database(CONFIGS_PATH_REQUIRED_NO_VALUE, true); FAIL() << "Expected InitDeviceModelDbError, but no exception was thrown"; } catch (const InitDeviceModelDbError& exception) { EXPECT_EQ(std::string(exception.what()), "Check integrity failed:\n" @@ -449,7 +449,7 @@ TEST_F(InitDeviceModelDbTest, wrong_type) { // Test if initializing fails when there is a missing required value. InitDeviceModelDb db(DATABASE_PATH, MIGRATION_FILES_PATH); try { - db.initialize_database(SCHEMAS_PATH_WRONG_VALUE_TYPE, true); + db.initialize_database(CONFIGS_PATH_WRONG_VALUE_TYPE, true); FAIL() << "Expected InitDeviceModelDbError, but no exception was thrown"; } catch (const InitDeviceModelDbError& exception) { EXPECT_EQ(std::string(exception.what()), diff --git a/tests/lib/ocpp/v201/test_smart_charging_handler.cpp b/tests/lib/ocpp/v201/test_smart_charging_handler.cpp index 453f838ee..0699b2daa 100644 --- a/tests/lib/ocpp/v201/test_smart_charging_handler.cpp +++ b/tests/lib/ocpp/v201/test_smart_charging_handler.cpp @@ -42,7 +42,7 @@ static const int DEFAULT_STACK_LEVEL = 1; static const int DEFAULT_REQUEST_ID = 1; static const std::string DEFAULT_TX_ID = "10c75ff7-74f5-44f5-9d01-f649f3ac7b78"; const static std::string MIGRATION_FILES_PATH = "./resources/v201/device_model_migration_files"; -const static std::string SCHEMAS_PATH = "./resources/example_config/v201/component_config"; +const static std::string CONFIG_PATH = "./resources/example_config/v201/component_config"; const static std::string DEVICE_MODEL_DB_IN_MEMORY_PATH = "file::memory:?cache=shared"; class TestSmartChargingHandler : public SmartChargingHandler { @@ -201,7 +201,7 @@ class SmartChargingHandlerTestFixtureV201 : public DatabaseTestingUtils { void create_device_model_db(const std::string& path) { InitDeviceModelDb db(path, MIGRATION_FILES_PATH); - db.initialize_database(SCHEMAS_PATH, true); + db.initialize_database(CONFIG_PATH, true); } std::shared_ptr