Exemplo n.º 1
0
  @Test
  public void should_return_false_and_add_violation_for_invalid_individual_fullname() {

    Tracker.insert(Tracker.VALIDATION_VERSION, VALIDATOR_VERSION);
    when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(builder);
    when(builder.addPropertyNode(anyString())).thenReturn(node);
    when(node.addConstraintViolation()).thenReturn(null);
    when(validationAdapter.check(any(Field.class))).thenReturn(new Error());

    Assert.assertFalse(validator.isValid(INVALID_NAME, context));
    Mockito.verify(node, Mockito.times(1)).addConstraintViolation();
  }
Exemplo n.º 2
0
  @Test
  public void should_return_true_if_individual_fullname_is_null() {

    Tracker.insert(Tracker.VALIDATION_VERSION, VALIDATOR_VERSION);
    when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(builder);
    when(builder.addPropertyNode(anyString())).thenReturn(node);
    when(node.addConstraintViolation()).thenReturn(null);
    when(validationAdapter.check(any(Field.class))).thenReturn(null);

    Assert.assertTrue(validator.isValid(null, context));
    Mockito.verify(node, Mockito.times(0)).addConstraintViolation();
  }
Exemplo n.º 3
0
 @BeforeMethod
 public void init() {
   MockitoAnnotations.initMocks(this);
   Tracker.insert(Tracker.VALIDATION_VERSION, ValidationConstants.VALIDATION_VERSION);
 }