コード例 #1
0
  @Test
  public void testCaseConstraintNotInvoked() {
    ProcessorResult processorResult =
        processRaw(londonAddress, "country", countryIsUSACaseConstraint);
    ConstraintValidationResult result = processorResult.getFirstConstraintValidationResult();
    Assert.assertEquals(0, dictionaryValidationResult.getNumberOfWarnings());
    Assert.assertEquals(0, dictionaryValidationResult.getNumberOfErrors());
    Assert.assertEquals(ErrorLevel.INAPPLICABLE, result.getStatus());
    Assert.assertEquals(new CaseConstraintProcessor().getName(), result.getConstraintName());

    List<Constraint> constraints = processorResult.getConstraints();

    Assert.assertNotNull(constraints);
    Assert.assertEquals(0, constraints.size());
  }
コード例 #2
0
  @Test
  public void testCaseConstraintInvoked() {
    ProcessorResult processorResult =
        processRaw(noStateAddress, "country", countryIsUSACaseConstraint);

    List<Constraint> constraints = processorResult.getConstraints();

    Assert.assertNotNull(constraints);
    Assert.assertEquals(1, constraints.size());

    Constraint constraint = constraints.get(0);

    Assert.assertTrue(constraint instanceof PrerequisiteConstraint);

    PrerequisiteConstraint prerequisiteConstraint = (PrerequisiteConstraint) constraint;

    Assert.assertEquals("state", prerequisiteConstraint.getAttributePath());

    ConstraintValidationResult result = processorResult.getFirstConstraintValidationResult();
    Assert.assertEquals(0, dictionaryValidationResult.getNumberOfWarnings());
    Assert.assertEquals(0, dictionaryValidationResult.getNumberOfErrors());
    Assert.assertEquals(ErrorLevel.OK, result.getStatus());
    Assert.assertEquals(new CaseConstraintProcessor().getName(), result.getConstraintName());
  }