Skip to content

Commit

Permalink
Merge pull request #243 from mmauksch/issue231-StopTransaction-valida…
Browse files Browse the repository at this point in the history
…tioncrash

validate via test and use suggested fix from #231
  • Loading branch information
TVolden authored Aug 18, 2023
2 parents 89afc40 + c3e438c commit 62353f4
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 62353f4

Please sign in to comment.