Search in sources :

Example 1 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation in project interlok by adaptris.

the class XmlRuleValidatorTest method testMultipleContentValidation.

@Test
public void testMultipleContentValidation() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    ValidationStage vs = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new SimpleListContentValidation(CHILDREN_OF_HERA), new NotNullContentValidation());
    validator.addValidationStage(vs);
    ValidationStage vs2 = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_CRONOS, XPATH_CHILDREN_OF_RHEA, new SimpleListContentValidation(CHILDREN_OF_RHEA), new NotNullContentValidation());
    validator.addValidationStage(vs2);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
    } catch (ServiceException e) {
        fail("RuleValidationService failure when expecting success");
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 2 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation in project interlok by adaptris.

the class XmlRuleValidatorTest method testNotNullContentValidation_DataIsNull.

@Test
public void testNotNullContentValidation_DataIsNull() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    // Hades had no children; poor god.
    ValidationStage vs = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_HADES, XPATH_CHILD_NAME, new NotNullContentValidation());
    validator.addValidationStage(vs);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_FAMILY_TREE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
        fail("RuleValidationService success when expecting exception");
    } catch (ServiceException e) {
        // expected
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 3 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation in project interlok by adaptris.

the class XmlRuleValidatorTest method testListContentValidation_WithNamespace.

@Test
public void testListContentValidation_WithNamespace() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.setNamespaceContext(createNamespaceHolder());
    ValidationStage vs = new ValidationStage(XPATH_NS_ITERATION_TITAN_NAMES, XPATH_NS_TITAN_NAME, new SimpleListContentValidation(THE_TWELVE_TITANS), new NotNullContentValidation());
    validator.addValidationStage(vs);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_WITH_NAMESEPACE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
    } catch (ServiceException e) {
        fail("RuleValidationService failure when expecting success");
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 4 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation in project interlok by adaptris.

the class XmlRuleValidatorTest method testListContentValidation_WithNamespaceDataNotInList.

@Test
public void testListContentValidation_WithNamespaceDataNotInList() throws Exception {
    XmlRuleValidator validator = new XmlRuleValidator();
    validator.setNamespaceContext(createNamespaceHolder());
    ValidationStage vs = new ValidationStage(XPATH_NS_ITERATION_OLYMPIAN_NAMES, XPATH_NS_OLYMPIAN_NAME, new SimpleListContentValidation(THE_TWELVE_TITANS), new NotNullContentValidation());
    validator.addValidationStage(vs);
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(XML_WITH_NAMESEPACE);
    XmlValidationService service = new XmlValidationService(validator);
    try {
        ExampleServiceCase.execute(service, msg);
        fail("RuleValidationService success when expecting exception");
    } catch (ServiceException e) {
        // expected
        ;
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage) Test(org.junit.Test)

Example 5 with NotNullContentValidation

use of com.adaptris.transform.validate.NotNullContentValidation in project interlok by adaptris.

the class XmlRuleValidatorTest method createSample.

static XmlRuleValidator createSample() {
    XmlRuleValidator validator = new XmlRuleValidator();
    ValidationStage stage1 = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_CRONOS, XPATH_CHILDREN_OF_RHEA, new NotNullContentValidation(), new SimpleListContentValidation(CHILDREN_OF_RHEA));
    validator.addValidationStage(stage1);
    ValidationStage stage2 = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_HERA, new NotNullContentValidation(), new SimpleListContentValidation(CHILDREN_OF_HERA));
    validator.addValidationStage(stage2);
    ValidationStage stage3 = new ValidationStage(XPATH_ITERATION_CHILDREN_OF_ZEUS, XPATH_CHILDREN_OF_LETO, new NotNullContentValidation(), new NotInListContentValidation(CHILDREN_OF_HERA));
    validator.addValidationStage(stage3);
    return validator;
}
Also used : NotNullContentValidation(com.adaptris.transform.validate.NotNullContentValidation) SimpleListContentValidation(com.adaptris.transform.validate.SimpleListContentValidation) NotInListContentValidation(com.adaptris.transform.validate.NotInListContentValidation) ValidationStage(com.adaptris.transform.validate.ValidationStage)

Aggregations

NotNullContentValidation (com.adaptris.transform.validate.NotNullContentValidation)8 ValidationStage (com.adaptris.transform.validate.ValidationStage)8 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)6 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)6 ServiceException (com.adaptris.core.ServiceException)6 Test (org.junit.Test)6 SimpleListContentValidation (com.adaptris.transform.validate.SimpleListContentValidation)4 BasicXmlSchemaValidator (com.adaptris.core.transform.schema.BasicXmlSchemaValidator)1 DocumentBuilderFactoryBuilder (com.adaptris.core.util.DocumentBuilderFactoryBuilder)1 NotInListContentValidation (com.adaptris.transform.validate.NotInListContentValidation)1 KeyValuePair (com.adaptris.util.KeyValuePair)1 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)1