Skip to content

Commit

Permalink
validate via test and use suggested fix from #231
Browse files Browse the repository at this point in the history
  • Loading branch information
mmauksch committed Aug 17, 2023
1 parent 89afc40 commit c3e438c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit c3e438c

Please sign in to comment.