Skip to content

Commit

Permalink
database_handler: Rename function to get all profiles grouped by evse id
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Davis <[email protected]>
  • Loading branch information
christopher-davis-afs committed Aug 6, 2024
1 parent ac7cdf5 commit c10087f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/ocpp/v201/database_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DatabaseHandler : public common::DatabaseHandlerCommon {
void clear_charging_profiles();

/// \brief Retrieves all ChargingProfiles
virtual std::map<int32_t, std::vector<v201::ChargingProfile>> get_all_charging_profiles_by_evse();
virtual std::map<int32_t, std::vector<v201::ChargingProfile>> get_all_charging_profiles_group_by_evse();
};

} // namespace v201
Expand Down
2 changes: 1 addition & 1 deletion lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3862,7 +3862,7 @@ void ChargePoint::execute_change_availability_request(ChangeAvailabilityRequest
// K01.27 - load profiles from database
void ChargePoint::load_charging_profiles() {
try {
auto evses = this->database_handler->get_all_charging_profiles_by_evse();
auto evses = this->database_handler->get_all_charging_profiles_group_by_evse();
EVLOG_info << "Found " << evses.size() << " evse in the database";
for (const auto& [evse_id, profiles] : evses) {
for (auto profile : profiles) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ocpp/v201/database_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ void DatabaseHandler::clear_charging_profiles() {
this->database->clear_table("CHARGING_PROFILES");
}

std::map<int32_t, std::vector<v201::ChargingProfile>> DatabaseHandler::get_all_charging_profiles_by_evse() {
std::map<int32_t, std::vector<v201::ChargingProfile>> DatabaseHandler::get_all_charging_profiles_group_by_evse() {
std::map<int32_t, std::vector<v201::ChargingProfile>> map;

std::string sql = "SELECT EVSE_ID, PROFILE FROM CHARGING_PROFILES";
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/ocpp/v201/test_database_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TEST_F(DatabaseHandlerTest, KO1_FR27_DatabaseWithNoData_InsertProfile) {
1, ChargingProfile{
.id = 1, .stackLevel = 1, .chargingProfilePurpose = ChargingProfilePurposeEnum::TxDefaultProfile});

auto sut = this->database_handler.get_all_charging_profiles_by_evse();
auto sut = this->database_handler.get_all_charging_profiles_group_by_evse();

EXPECT_EQ(sut.size(), 1);
EXPECT_EQ(sut[1].size(), 1); // Access the profiles at EVSE_ID 1
Expand Down Expand Up @@ -274,7 +274,7 @@ TEST_F(DatabaseHandlerTest, KO1_FR27_DatabaseWithSingleProfileData_LoadsCharging
.id = 1, .stackLevel = 1, .chargingProfilePurpose = ChargingProfilePurposeEnum::TxDefaultProfile};
this->database_handler.insert_or_update_charging_profile(1, profile);

auto sut = this->database_handler.get_all_charging_profiles_by_evse();
auto sut = this->database_handler.get_all_charging_profiles_group_by_evse();

EXPECT_EQ(sut.size(), 1);

Expand All @@ -301,7 +301,7 @@ TEST_F(DatabaseHandlerTest, KO1_FR27_DatabaseWithMultipleProfileSameEvse_LoadsCh
.id = 3, .stackLevel = 3, .chargingProfilePurpose = ChargingProfilePurposeEnum::TxDefaultProfile};
this->database_handler.insert_or_update_charging_profile(1, p3);

auto sut = this->database_handler.get_all_charging_profiles_by_evse();
auto sut = this->database_handler.get_all_charging_profiles_group_by_evse();

EXPECT_EQ(sut.size(), 1);

Expand Down Expand Up @@ -340,7 +340,7 @@ TEST_F(DatabaseHandlerTest, KO1_FR27_DatabaseWithMultipleProfileDiffEvse_LoadsCh
ChargingProfile{.id = 6, .stackLevel = 6, .chargingProfilePurpose = ChargingProfilePurposeEnum::TxProfile};
this->database_handler.insert_or_update_charging_profile(3, p6);

auto sut = this->database_handler.get_all_charging_profiles_by_evse();
auto sut = this->database_handler.get_all_charging_profiles_group_by_evse();

EXPECT_EQ(sut.size(), 3);

Expand Down

0 comments on commit c10087f

Please sign in to comment.