Skip to content

Commit

Permalink
Fail on null
Browse files Browse the repository at this point in the history
  • Loading branch information
No3x committed Jan 10, 2019
1 parent 5053929 commit d33afe8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void initialize(ContainsLabelKeys constraintAnnotation) {
@Override
public boolean isValid(Collection<String> value, ConstraintValidatorContext context) {
if( value == null ) {
return true;
return false;
}

boolean isValid = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void testLabeledService() {
when(dockerCompose.getServices()).thenReturn(services);
violations = dockerComposeValidator.validate(dockerCompose);
ConstraintViolationSetAssert.assertThat(violations).hasViolationOnPath("services[nginx].labels");

// Test null label
services.get("nginx").labels = null;
when(dockerCompose.getServices()).thenReturn(services);
violations = dockerComposeValidator.validate(dockerCompose);
ConstraintViolationSetAssert.assertThat(violations).hasViolationOnPath("services[nginx].labels");
}

}

0 comments on commit d33afe8

Please sign in to comment.