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

validate via test and use suggested fix from #231 #243

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String getIdTag() {
*/
@XmlElement
public void setIdTag(String idTag) {
if (!ModelUtil.validate(idTag, 20)) {
if (idTag != null && !ModelUtil.validate(idTag, 20)) {
throw new PropertyConstraintException(idTag.length(), "Exceeded limit of 20 chars");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public void setIdTag_moreThan20Chars_throwsPropertyConstraintException() {
request.setIdTag(aString(42));
}

@Test
public void setIdTag_nullGiven_doesNotRaiseException() {
request.setIdTag(null);
Assert.assertNull(request.getIdTag());
}
@Test
public void setIdTag_nullGiven_passesValidation() {
request.setMeterStop(2);
request.setTransactionId(5);
request.setTimestamp(ZonedDateTime.now());
request.setIdTag(null);
Assert.assertTrue(request.validate());
}

@Test
public void setMeterStop_anInteger_meterStopIsSet() {
// Given
Expand Down
Loading