Esempio n. 1
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();
  }
Esempio n. 2
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();
  }