@@ -207,37 +207,60 @@ TEST_CASE( "Reservation" ) {
207207
208208 // if connector 0 is reserved, accept at most one further reservation
209209 REQUIRE ( rService->updateReservation (1000 , 0 , expiryDate, idTag, parentIdTag) );
210- REQUIRE ( rService->updateReservation (1001 , 1 , expiryDate, idTag, parentIdTag) );
211- REQUIRE ( !rService->updateReservation (1002 , 2 , expiryDate, idTag, parentIdTag) );
212- REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Available );
210+ // first available connector reserved by connector 0 reservation
211+ REQUIRE ( !rService->updateReservation (1001 , 1 , expiryDate, idTag, parentIdTag) );
212+ REQUIRE ( rService->updateReservation (1002 , 2 , expiryDate, idTag, parentIdTag) );
213+
214+ loop ();
215+ REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Reserved );
216+ REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Reserved );
213217
214218 // reset reservations
215219 rService->getReservationById (1000 )->clear ();
216- rService->getReservationById (1001 )->clear ();
220+ rService->getReservationById (1002 )->clear ();
217221 REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Available );
222+ REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Available );
218223
219224 // if connector 0 is reserved, ensure that at least one physical connector remains available for the idTag of the reservation
220225 REQUIRE ( rService->updateReservation (1000 , 0 , expiryDate, idTag, parentIdTag) );
221226
222- beginTransaction (" other idTag" , 1 );
227+ beginTransaction (" other idTag" , 2 );
228+ loop ();
229+ REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Charging );
230+
231+ endTransaction (nullptr , nullptr , 2 );
223232 loop ();
224- REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Charging );
233+
234+ REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Available );
225235
226236 bool checkTxRejected = false ;
227237 setTxNotificationOutput ([&checkTxRejected] (Transaction*, TxNotification txNotification) {
228238 if (txNotification == TxNotification_ReservationConflict) {
229239 checkTxRejected = true ;
230240 }
231- }, 2 );
241+ }, 1 );
232242
233- beginTransaction (" other idTag 2" , 2 );
243+ beginTransaction (" other idTag 2" , 1 );
234244 loop ();
235245 REQUIRE ( checkTxRejected );
236- REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Available );
246+ REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Reserved );
247+
248+ beginTransaction (" mIdTag" , 1 );
249+ loop ();
237250
251+ REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Charging );
238252
239253 endTransaction (nullptr , nullptr , 1 );
240254 loop ();
255+
256+ // check if we skip connector 1 when unavailable
257+ model.getConnector (1 )->setAvailabilityVolatile (false );
258+ REQUIRE ( rService->updateReservation (1003 , 0 , expiryDate, idTag, parentIdTag) );
259+ loop ();
260+ REQUIRE ( model.getConnector (1 )->getStatus () == ChargePointStatus_Unavailable );
261+ REQUIRE ( model.getConnector (2 )->getStatus () == ChargePointStatus_Reserved );
262+ // @TODO: can we reserve Unavailable connectors?
263+ // REQUIRE( !rService->updateReservation(1004, 1, expiryDate, "other idTag 3", nullptr) );
241264 }
242265
243266 SECTION (" Expiry date" ) {
0 commit comments