-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
692 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...src/test/groovy/eu/chargetime/ocpp/test/reservation/json/JSONCancelReservationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package eu.chargetime.ocpp.test.reservation.json | ||
|
||
import eu.chargetime.ocpp.test.FakeCentral | ||
import eu.chargetime.ocpp.test.FakeCentralSystem | ||
import eu.chargetime.ocpp.test.FakeChargePoint | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
import spock.util.concurrent.PollingConditions | ||
|
||
/* | ||
ChargeTime.eu - Java-OCA-OCPP | ||
MIT License | ||
Copyright (C) 2016-2018 Thomas Volden <tv@chargetime.eu> | ||
Copyright (C) 2018 Mikhail Kladkevich <kladmv@ecp-share.com> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
class JSONCancelReservationSpec extends Specification { | ||
@Shared | ||
FakeCentralSystem centralSystem = FakeCentral.getSystem(FakeCentral.serverType.JSON) | ||
@Shared | ||
FakeChargePoint chargePoint = new FakeChargePoint() | ||
|
||
def setupSpec() { | ||
// When a Central System is running | ||
centralSystem.started() | ||
} | ||
|
||
def setup() { | ||
chargePoint.connect() | ||
} | ||
|
||
def cleanup() { | ||
chargePoint.disconnect() | ||
} | ||
|
||
def "Central System sends a CancelReservation request and receives a response"() { | ||
def conditions = new PollingConditions(timeout: 1) | ||
given: | ||
conditions.eventually { | ||
assert centralSystem.connected() | ||
} | ||
|
||
when: | ||
centralSystem.sendCancelReservationRequest(1) | ||
|
||
then: | ||
conditions.eventually { | ||
assert chargePoint.hasHandledCancelReservationRequest() | ||
assert centralSystem.hasReceivedCancelReservationConfirmation() | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/CancelReservationFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package eu.chargetime.ocpp.feature; | ||
|
||
import eu.chargetime.ocpp.feature.profile.Profile; | ||
import eu.chargetime.ocpp.model.Confirmation; | ||
import eu.chargetime.ocpp.model.Request; | ||
import eu.chargetime.ocpp.model.reservation.CancelReservationConfirmation; | ||
import eu.chargetime.ocpp.model.reservation.CancelReservationRequest; | ||
|
||
/* | ||
ChargeTime.eu - Java-OCA-OCPP | ||
MIT License | ||
Copyright (C) 2016-2018 Thomas Volden | ||
Copyright (C) 2018 Mikhail Kladkevich <kladmv@ecp-share.com> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
public class CancelReservationFeature extends Feature { | ||
|
||
public CancelReservationFeature(Profile ownerProfile) { | ||
super(ownerProfile); | ||
} | ||
|
||
@Override | ||
public Class<? extends Request> getRequestType() { | ||
return CancelReservationRequest.class; | ||
} | ||
|
||
@Override | ||
public Class<? extends Confirmation> getConfirmationType() { | ||
return CancelReservationConfirmation.class; | ||
} | ||
|
||
@Override | ||
public String getAction() { | ||
return "CancelReservation"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...1_6/src/main/java/eu/chargetime/ocpp/model/reservation/CancelReservationConfirmation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package eu.chargetime.ocpp.model.reservation; | ||
|
||
/* | ||
* ChargeTime.eu - Java-OCA-OCPP | ||
* | ||
* MIT License | ||
* | ||
* Copyright (C) 2016 Thomas Volden <tv@chargetime.eu> | ||
* Copyright (C) 2018 Mikhail Kladkevich <kladmv@ecp-share.com> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import eu.chargetime.ocpp.model.Confirmation; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Sent by the Charge Point to the Central System in response to an {@link CancelReservationRequest}. | ||
*/ | ||
@XmlRootElement(name = "cancelReservationResponse") | ||
public class CancelReservationConfirmation implements Confirmation { | ||
private CancelReservationStatus status; | ||
|
||
public CancelReservationConfirmation() { } | ||
|
||
public CancelReservationConfirmation(CancelReservationStatus status) { | ||
setStatus(status); | ||
} | ||
|
||
@Override | ||
public boolean validate() { | ||
return status != null; | ||
} | ||
|
||
/** | ||
* This indicates the success or failure of the cancelling of a reservation by Central System. | ||
* | ||
* @return CancelReservationStatus, status of the request. | ||
*/ | ||
public CancelReservationStatus getStatus() { | ||
return status; | ||
} | ||
|
||
/** | ||
* Required. | ||
* This indicates the success or failure of the cancelling of a reservation by Central System. | ||
* | ||
* @param status CancelReservationStatus, status of the request. | ||
*/ | ||
@XmlElement | ||
public void setStatus(CancelReservationStatus status) { | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
CancelReservationConfirmation that = (CancelReservationConfirmation) o; | ||
return status == that.status; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(status); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CancelReservationConfirmation{" + | ||
"status=" + status + | ||
", isValid=" + String.valueOf(validate()) + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.