Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow listVersion 0 in SendLocalListRequest #201

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {

allprojects {
group = 'eu.chargetime.ocpp'
version = '1.0.2'
version = '1.1'
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public Integer getListVersion() {
* @param listVersion, the version number of the list
*/
public void setListVersion(Integer listVersion) {
if (listVersion < 1) {
throw new PropertyConstraintException(listVersion, "listVersion must be > 0");
if (listVersion < 0) {
throw new PropertyConstraintException(listVersion, "listVersion must be >= 0");
}
this.listVersion = listVersion;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public void setUpdateType(UpdateType updateType) {

@Override
public boolean validate() {
boolean valid = listVersion != null && (listVersion >= 1) && (updateType != null);
boolean valid = listVersion != null && (listVersion >= 0) && (updateType != null);

if (localAuthorizationList != null) {
for (AuthorizationData data : localAuthorizationList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,23 @@ public void setUp() {

@Test
public void setListVersion_asNegative_throwsPropertyConstraintException() {
testInvalidListVersion(-20);
}

@Test
public void setListVersion_asZero_throwsPropertyConstraintException() {
testInvalidListVersion(0);
testInvalidListVersion(-1);
}

private void testInvalidListVersion(int invalidVersion) {
thrownException.expect(instanceOf(PropertyConstraintException.class));
thrownException.expectMessage(
equalTo(
"Validation failed: [listVersion must be > 0]. Current Value: ["
"Validation failed: [listVersion must be >= 0]. Current Value: ["
+ invalidVersion
+ "]"));

request.setListVersion(invalidVersion);
}

@Test
public void setListVersion_isNonZeroPostive_isCorrect() {
for (int i = 1; i <= 10; i++) {
public void setListVersion_isNotNegative_isCorrect() {
for (int i = 0; i <= 10; i++) {
// When
request.setListVersion(i);
// Then
Expand Down