CaseConstraintProcessor extends MandatoryElementConstraintProcessor<CaseConstraint> { @Override public String getName() { return CONSTRAINT_NAME; }  @Override ProcessorResult process(DictionaryValidationResult result, Object value, CaseConstraint caseConstraint,
            AttributeValueReader attributeValueReader); @Override String getName(); @Override Class<? extends Constraint> getConstraintType();  }
@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()); }
@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.getPropertyName()); 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()); }