diff --git a/tests/lib/ocpp/v201/test_charge_point.cpp b/tests/lib/ocpp/v201/test_charge_point.cpp index bd4428b30..44c043993 100644 --- a/tests/lib/ocpp/v201/test_charge_point.cpp +++ b/tests/lib/ocpp/v201/test_charge_point.cpp @@ -163,6 +163,8 @@ class ChargePointCommonTestFixtureV201 : public DatabaseTestingUtils { callbacks.update_firmware_request_callback = update_firmware_request_callback_mock.AsStdFunction(); callbacks.security_event_callback = security_event_callback_mock.AsStdFunction(); callbacks.set_charging_profiles_callback = set_charging_profiles_callback_mock.AsStdFunction(); + callbacks.reserve_now_callback = reserve_now_callback_mock.AsStdFunction(); + callbacks.cancel_reservation_callback = cancel_reservation_callback_mock.AsStdFunction(); } std::shared_ptr device_model; @@ -191,6 +193,8 @@ class ChargePointCommonTestFixtureV201 : public DatabaseTestingUtils { testing::MockFunction& event_type, const std::optional>& tech_info)> security_event_callback_mock; testing::MockFunction set_charging_profiles_callback_mock; + testing::MockFunction reserve_now_callback_mock; + testing::MockFunction cancel_reservation_callback_mock; ocpp::v201::Callbacks callbacks; }; @@ -492,6 +496,42 @@ TEST_F(ChargePointCommonTestFixtureV201, EXPECT_TRUE(callbacks.all_callbacks_valid(device_model)); } +TEST_F(ChargePointCommonTestFixtureV201, ReservationAvailableReserveNowCallbackNotSet) { + configure_callbacks_with_mocks(); + device_model->set_value(ControllerComponentVariables::ReservationCtrlrAvailable.component, + ControllerComponentVariables::ReservationCtrlrAvailable.variable.value(), + AttributeEnum::Actual, "true", "test", true); + callbacks.reserve_now_callback = nullptr; + EXPECT_FALSE(callbacks.all_callbacks_valid(device_model)); +} + +TEST_F(ChargePointCommonTestFixtureV201, ReservationAvailableCancelReservationCallbackNotSet) { + configure_callbacks_with_mocks(); + device_model->set_value(ControllerComponentVariables::ReservationCtrlrAvailable.component, + ControllerComponentVariables::ReservationCtrlrAvailable.variable.value(), + AttributeEnum::Actual, "true", "test", true); + callbacks.cancel_reservation_callback = nullptr; + EXPECT_FALSE(callbacks.all_callbacks_valid(device_model)); +} + +TEST_F(ChargePointCommonTestFixtureV201, ReservationNotAvailableReserveNowCallbackNotSet) { + configure_callbacks_with_mocks(); + device_model->set_value(ControllerComponentVariables::ReservationCtrlrAvailable.component, + ControllerComponentVariables::ReservationCtrlrAvailable.variable.value(), + AttributeEnum::Actual, "false", "test", true); + callbacks.reserve_now_callback = nullptr; + EXPECT_TRUE(callbacks.all_callbacks_valid(device_model)); +} + +TEST_F(ChargePointCommonTestFixtureV201, ReservationNotAvailableCancelReservationCallbackNotSet) { + configure_callbacks_with_mocks(); + device_model->set_value(ControllerComponentVariables::ReservationCtrlrAvailable.component, + ControllerComponentVariables::ReservationCtrlrAvailable.variable.value(), + AttributeEnum::Actual, "false", "test", true); + callbacks.cancel_reservation_callback = nullptr; + EXPECT_TRUE(callbacks.all_callbacks_valid(device_model)); +} + class ChargePointConstructorTestFixtureV201 : public ChargePointCommonTestFixtureV201 { public: ChargePointConstructorTestFixtureV201() :