-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DiagnosticsStatusNotification support.
- Loading branch information
Mikhail Kladkevich
committed
Apr 15, 2018
1 parent
72e5393
commit 985079f
Showing
6 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
ocpp-v1_6/src/main/java/eu/chargetime/ocpp/feature/DiagnosticsStatusNotificationFeature.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.firmware.DiagnosticsStatusNotificationConfirmation; | ||
import eu.chargetime.ocpp.model.firmware.DiagnosticsStatusNotificationRequest; | ||
|
||
/* | ||
ChargeTime.eu - Java-OCA-OCPP | ||
Copyright (C) 2015-2016 Thomas Volden <[email protected]> | ||
MIT License | ||
Copyright (C) 2016-2018 Thomas Volden | ||
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 DiagnosticsStatusNotificationFeature extends Feature { | ||
|
||
public DiagnosticsStatusNotificationFeature(Profile ownerProfile) { | ||
super(ownerProfile); | ||
} | ||
|
||
@Override | ||
public Class<? extends Request> getRequestType() { | ||
return DiagnosticsStatusNotificationRequest.class; | ||
} | ||
|
||
@Override | ||
public Class<? extends Confirmation> getConfirmationType() { | ||
return DiagnosticsStatusNotificationConfirmation.class; | ||
} | ||
|
||
@Override | ||
public String getAction() { | ||
return "DiagnosticsStatusNotification"; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/firmware/DiagnosticsStatus.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,37 @@ | ||
package eu.chargetime.ocpp.model.firmware; | ||
|
||
/* | ||
* ChargeTime.eu - Java-OCA-OCPP | ||
* | ||
* MIT License | ||
* | ||
* Copyright (C) 2016-2018 Thomas Volden <[email protected]> | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Accepted values used with {@link DiagnosticsStatusNotificationRequest}. | ||
*/ | ||
public enum DiagnosticsStatus { | ||
Idle, | ||
Uploaded, | ||
UploadFailed, | ||
Uploading | ||
} |
61 changes: 61 additions & 0 deletions
61
...ain/java/eu/chargetime/ocpp/model/firmware/DiagnosticsStatusNotificationConfirmation.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,61 @@ | ||
package eu.chargetime.ocpp.model.firmware; | ||
|
||
/* | ||
* ChargeTime.eu - Java-OCA-OCPP | ||
* | ||
* MIT License | ||
* | ||
* Copyright (C) 2016 Thomas Volden <[email protected]> | ||
* | ||
* 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.XmlRootElement; | ||
|
||
/** | ||
* Sent by the Charge Point to the Central System in response to an {@link DiagnosticsStatusNotificationRequest}. | ||
*/ | ||
@XmlRootElement(name = "diagnosticsStatusNotificationResponse") | ||
public class DiagnosticsStatusNotificationConfirmation implements Confirmation { | ||
|
||
public DiagnosticsStatusNotificationConfirmation() { | ||
} | ||
|
||
@Override | ||
public boolean validate() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return this == o || o != null && getClass() == o.getClass(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 5; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DiagnosticsStatusNotificationConfirmation{}" + "{isValid=" + String.valueOf(validate()) + "}"; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...src/main/java/eu/chargetime/ocpp/model/firmware/DiagnosticsStatusNotificationRequest.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,108 @@ | ||
package eu.chargetime.ocpp.model.firmware; | ||
|
||
import eu.chargetime.ocpp.PropertyConstraintException; | ||
import eu.chargetime.ocpp.model.Request; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlType; | ||
import java.util.Objects; | ||
|
||
/* | ||
* ChargeTime.eu - Java-OCA-OCPP | ||
* | ||
* MIT License | ||
* | ||
* Copyright (C) 2016-2018 Thomas Volden <[email protected]> | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Sent by the Central System to the Charge Point. | ||
*/ | ||
@XmlRootElement | ||
public class DiagnosticsStatusNotificationRequest implements Request { | ||
private DiagnosticsStatus status; | ||
|
||
public DiagnosticsStatusNotificationRequest() { } | ||
|
||
/** | ||
* Set required fields. | ||
* | ||
* @param status Diagnostics status, see {@link #setStatus(DiagnosticsStatus)}. | ||
*/ | ||
public DiagnosticsStatusNotificationRequest(DiagnosticsStatus status) { | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
public boolean validate() { | ||
return status != null; | ||
} | ||
|
||
/** | ||
* This contains the status. | ||
* | ||
* @return connector. | ||
*/ | ||
public DiagnosticsStatus getStatus() { | ||
return status; | ||
} | ||
|
||
/** | ||
* Required. This contains the identifier of the status. | ||
* | ||
* @param status DiagnosticsStatus, value != 0. | ||
* @throws PropertyConstraintException Value was zero or negative. | ||
*/ | ||
@XmlElement | ||
public void setStatus(DiagnosticsStatus status) throws PropertyConstraintException { | ||
if (status == null) | ||
throw new PropertyConstraintException("status", null); | ||
|
||
this.status = status; | ||
} | ||
|
||
@Override | ||
public boolean transactionRelated() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DiagnosticsStatusNotificationRequest that = (DiagnosticsStatusNotificationRequest) o; | ||
return status == that.status; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(status); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DiagnosticsStatusNotificationRequest{" + | ||
"status=" + status + | ||
", isValid=" + String.valueOf(validate()) + | ||
'}'; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...eu/chargetime/ocpp/model/firmware/test/DiagnosticsStatusNotificationConfirmationTest.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,54 @@ | ||
package eu.chargetime.ocpp.model.firmware.test; | ||
/* | ||
ChargeTime.eu - Java-OCA-OCPP | ||
MIT License | ||
Copyright (C) 2016-2018 Thomas Volden <[email protected]> | ||
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.firmware.DiagnosticsStatusNotificationConfirmation; | ||
import eu.chargetime.ocpp.utilities.TestUtilities; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class DiagnosticsStatusNotificationConfirmationTest extends TestUtilities { | ||
|
||
private DiagnosticsStatusNotificationConfirmation confirmation; | ||
|
||
@Before | ||
public void setup() { | ||
confirmation = new DiagnosticsStatusNotificationConfirmation(); | ||
} | ||
|
||
@Test | ||
public void validate_returnsTrue() { | ||
// When | ||
boolean result = confirmation.validate(); | ||
|
||
// Then | ||
assertThat(result, is(true)); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...java/eu/chargetime/ocpp/model/firmware/test/DiagnosticsStatusNotificationRequestTest.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,68 @@ | ||
package eu.chargetime.ocpp.model.firmware.test; | ||
/* | ||
ChargeTime.eu - Java-OCA-OCPP | ||
MIT License | ||
Copyright (C) 2016-2018 Thomas Volden <[email protected]> | ||
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.PropertyConstraintException; | ||
import eu.chargetime.ocpp.model.firmware.DiagnosticsStatus; | ||
import eu.chargetime.ocpp.model.firmware.DiagnosticsStatusNotificationRequest; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class DiagnosticsStatusNotificationRequestTest { | ||
|
||
private DiagnosticsStatusNotificationRequest request; | ||
|
||
@Before | ||
public void setup() { | ||
request = new DiagnosticsStatusNotificationRequest(); | ||
} | ||
|
||
@Test | ||
public void validate_statusIsNotSet_returnsFalse() { | ||
// When | ||
boolean result = request.validate(); | ||
|
||
// Then | ||
assertThat(result, is(false)); | ||
} | ||
|
||
@Test | ||
public void validate_statusIsSet_returnsTrue() throws PropertyConstraintException { | ||
// Given | ||
DiagnosticsStatus status = DiagnosticsStatus.Uploading; | ||
request.setStatus(status); | ||
|
||
// When | ||
boolean result = request.validate(); | ||
|
||
// Then | ||
assertThat(result, is(true)); | ||
} | ||
|
||
} |