@@ -74,6 +74,15 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
7474 connectors.initDatabaseTable ();
7575 }
7676
77+ void clearAllProfiles (SmartChargingManager & smartcharging_mgr)
78+ {
79+ ClearChargingProfileReq clearprofiles_req;
80+ ClearChargingProfileConf clearprofiles_conf;
81+ std::string error_code;
82+ std::string error_message;
83+ smartcharging_mgr.handleMessage (clearprofiles_req, clearprofiles_conf, error_code, error_message);
84+ }
85+
7786 bool installProfile (unsigned int connector_id, const ChargingProfile& profile, SmartChargingManager& smartcharging_mgr)
7887 {
7988 SetChargingProfileReq setprofile_req;
@@ -109,6 +118,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
109118 {
110119 SmartChargingManager smartcharging_mgr (
111120 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
121+ clearAllProfiles (smartcharging_mgr);
112122
113123 ChargingProfile profile1;
114124 profile1.chargingProfileId = 1 ;
@@ -154,6 +164,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
154164 {
155165 SmartChargingManager smartcharging_mgr (
156166 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
167+ clearAllProfiles (smartcharging_mgr);
157168
158169 ChargingProfile profile1;
159170 profile1.chargingProfileId = 1 ;
@@ -201,6 +212,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
201212 {
202213 SmartChargingManager smartcharging_mgr (
203214 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
215+ clearAllProfiles (smartcharging_mgr);
204216
205217 ChargingProfile profile1;
206218 profile1.chargingProfileId = 1 ;
@@ -247,6 +259,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
247259 {
248260 SmartChargingManager smartcharging_mgr (
249261 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
262+ clearAllProfiles (smartcharging_mgr);
250263
251264 ChargingProfile profile1;
252265 profile1.chargingProfileId = 1 ;
@@ -267,6 +280,10 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
267280 charging_period.startPeriod = 1700 ;
268281 charging_period.numberPhases = 3 ;
269282 profile1.chargingSchedule .chargingSchedulePeriod .push_back (charging_period);
283+ charging_period.limit = 24 .f ;
284+ charging_period.startPeriod = 3700 ;
285+ charging_period.numberPhases = 1 ;
286+ profile1.chargingSchedule .chargingSchedulePeriod .push_back (charging_period);
270287 profile1.chargingSchedule .duration = 5000 ;
271288 profile1.chargingSchedule .chargingRateUnit = ChargingRateUnitType::A;
272289 CHECK (installProfile (1 , profile1, smartcharging_mgr));
@@ -279,9 +296,9 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
279296 CHECK_EQ (schedule.chargingRateUnit , ChargingRateUnitType::A);
280297 CHECK_GE (schedule.startSchedule .value (), now);
281298 CHECK_LE (schedule.startSchedule .value (), DateTime (now.timestamp () + 1 ));
282- CHECK_EQ (schedule.chargingSchedulePeriod .size (), profile1.chargingSchedule .chargingSchedulePeriod .size ());
299+ CHECK_EQ (schedule.chargingSchedulePeriod .size (), profile1.chargingSchedule .chargingSchedulePeriod .size () - 1 );
283300
284- for (size_t i = 0 ; i < profile1.chargingSchedule .chargingSchedulePeriod .size (); i++)
301+ for (size_t i = 0 ; i < profile1.chargingSchedule .chargingSchedulePeriod .size () - 1 ; i++)
285302 {
286303 CHECK_EQ (schedule.chargingSchedulePeriod [i].startPeriod , profile1.chargingSchedule .chargingSchedulePeriod [i].startPeriod );
287304 CHECK_EQ (schedule.chargingSchedulePeriod [i].limit , profile1.chargingSchedule .chargingSchedulePeriod [i].limit );
@@ -293,6 +310,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
293310 {
294311 SmartChargingManager smartcharging_mgr (
295312 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
313+ clearAllProfiles (smartcharging_mgr);
296314
297315 DateTime now = DateTime::now ();
298316
@@ -340,6 +358,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
340358 {
341359 SmartChargingManager smartcharging_mgr (
342360 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
361+ clearAllProfiles (smartcharging_mgr);
343362
344363 DateTime now = DateTime::now ();
345364
@@ -390,6 +409,7 @@ TEST_SUITE("Get composite schedule - single OCPP profile")
390409 {
391410 SmartChargingManager smartcharging_mgr (
392411 stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
412+ clearAllProfiles (smartcharging_mgr);
393413
394414 DateTime now = DateTime::now ();
395415
0 commit comments