Skip to content

Commit

Permalink
seaFloor allow null
Browse files Browse the repository at this point in the history
  • Loading branch information
QuincyCantu committed Aug 26, 2024
1 parent 3baa74f commit edbb86a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,16 @@ public boolean isValid(MarineInstrumentLocation value, ConstraintValidatorContex
Float seaFloorDepth = value.getSeaFloorDepth();
Float instrumentDepth = value.getInstrumentDepth();

if (seaFloorDepth == null || instrumentDepth == null) {
if (instrumentDepth == null) {
context.disableDefaultConstraintViolation();

if (seaFloorDepth == null) {
context.buildConstraintViolationWithTemplate("must not be null")
.addPropertyNode("seaFloorDepth")
.addConstraintViolation();
}

if (instrumentDepth == null) {
context.buildConstraintViolationWithTemplate("must not be null")
.addPropertyNode("instrumentDepth")
.addConstraintViolation();
}
context.buildConstraintViolationWithTemplate("must not be null")
.addPropertyNode("instrumentDepth")
.addConstraintViolation();

return false;
} else {
if (seaFloorDepth > instrumentDepth) {
if (seaFloorDepth != null && seaFloorDepth > instrumentDepth) {
context.disableDefaultConstraintViolation();

context.buildConstraintViolationWithTemplate("must be less than or equal to instrumentDepth")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ void testValidMarineInstrumentLocation(Float seaFloorDepth, Float instrumentDept
.findFirst().orElseThrow();
assertEquals(expectedInstrumentDepthMessage, violation.getMessage());
}

if (expectedSeaFloorDepthMessage != null) {
ConstraintViolation<MarineInstrumentLocation> violation = violations.stream()
.filter(v -> v.getPropertyPath().toString().equals("seaFloorDepth"))
.findFirst().orElseThrow();
assertEquals(expectedSeaFloorDepthMessage, violation.getMessage());
}
}

}

0 comments on commit edbb86a

Please sign in to comment.