use of javax.validation.ConstraintValidatorContext in project kie-wb-common by kiegroup.
the class TimerSettingsValueValidatorTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
validator = new TimerSettingsValueValidator();
value = new TimerSettingsValue();
context = new ConstraintValidatorContext() {
@Override
public void disableDefaultConstraintViolation() {
}
@Override
public String getDefaultConstraintMessageTemplate() {
return null;
}
@Override
public ConstraintViolationBuilder buildConstraintViolationWithTemplate(String message) {
errorMessages.add(message);
return new ConstraintViolationBuilder() {
@Override
public NodeBuilderDefinedContext addNode(String name) {
return null;
}
@Override
public ConstraintValidatorContext addConstraintViolation() {
return context;
}
};
}
};
}
use of javax.validation.ConstraintValidatorContext in project api-core by ca-cwds.
the class SystemCodeDescriptionValidatorTest method isValid_Args__Object__ConstraintValidatorContext.
@Test
public void isValid_Args__Object__ConstraintValidatorContext() throws Exception {
SystemCodeDescriptionValidator target = new SystemCodeDescriptionValidator();
String value = "";
ConstraintValidatorContext context_ = mock(ConstraintValidatorContext.class);
boolean actual = target.isValid(value, context_);
boolean expected = false;
assertThat(actual, is(equalTo(expected)));
}
use of javax.validation.ConstraintValidatorContext in project api-core by ca-cwds.
the class SystemCodeIdValidatorTest method isValid_Args__Object__ValidWhenIgnoredValue0.
@Test
public void isValid_Args__Object__ValidWhenIgnoredValue0() throws Exception {
ValidSystemCodeId anno = mock(ValidSystemCodeId.class);
when(anno.required()).thenReturn(false);
when(anno.ignoreable()).thenReturn(true);
when(anno.ignoredValue()).thenReturn(0);
when(anno.category()).thenReturn("ETHNCTYC");
target.initialize(anno);
Set<String> validCodes = new HashSet<>();
validCodes.add("0");
ConstraintValidatorContext context_ = mock(ConstraintValidatorContext.class);
ConstraintViolationBuilder builder = mock(ConstraintViolationBuilder.class);
when(builder.addPropertyNode(any())).thenReturn(mock(NodeBuilderCustomizableContext.class));
when(context_.buildConstraintViolationWithTemplate(any())).thenReturn(builder);
boolean actual = target.isValid(validCodes, context_);
boolean expected = true;
assertThat(actual, is(equalTo(expected)));
}
use of javax.validation.ConstraintValidatorContext in project api-core by ca-cwds.
the class SystemCodeIdValidatorTest method isValid_Args__Object__EmptyCollectionPassWhenIgnorableTrue.
@Test
public void isValid_Args__Object__EmptyCollectionPassWhenIgnorableTrue() throws Exception {
ValidSystemCodeId anno = mock(ValidSystemCodeId.class);
when(anno.required()).thenReturn(false);
when(anno.ignoreable()).thenReturn(true);
target.initialize(anno);
Set<String> validCodes = new HashSet<>();
ConstraintValidatorContext context_ = mock(ConstraintValidatorContext.class);
boolean actual = target.isValid(validCodes, context_);
boolean expected = true;
assertThat(actual, is(equalTo(expected)));
}
use of javax.validation.ConstraintValidatorContext in project api-core by ca-cwds.
the class SystemCodeIdValidatorTest method isValid_Args__Object__EmptyCollection.
@Test
public void isValid_Args__Object__EmptyCollection() throws Exception {
ValidSystemCodeId anno = mock(ValidSystemCodeId.class);
when(anno.required()).thenReturn(true);
target.initialize(anno);
Set<String> validCodes = new HashSet<>();
ConstraintValidatorContext context_ = mock(ConstraintValidatorContext.class);
boolean actual = target.isValid(validCodes, context_);
boolean expected = false;
assertThat(actual, is(equalTo(expected)));
}
Aggregations