Search in sources :

Example 11 with ValidationResult

use of org.xmlunit.validation.ValidationResult in project syndesis by syndesisio.

the class UnifiedXmlDataShapeGeneratorShapeValidityTest method shouldGenerateValidOutputSchemasets.

@Test
public void shouldGenerateValidOutputSchemasets() throws IOException {
    final DataShape output = generator.createShapeFromResponse(specificationContent, swagger, operation);
    if (output.getKind() != DataShapeKinds.XML_SCHEMA) {
        return;
    }
    final Validator validator = Validator.forLanguage(Languages.W3C_XML_SCHEMA_NS_URI);
    try (InputStream in = UnifiedXmlDataShapeGenerator.class.getResourceAsStream("/swagger/atlas-xml-schemaset-model-v2.xsd")) {
        validator.setSchemaSource(new StreamSource(in));
        final String outputSpecification = output.getSpecification();
        final ValidationResult result = validator.validateInstance(source(outputSpecification));
        // 
        assertThat(result.isValid()).as("Non valid output XML schemaset was generated for specification: %s, operation: %s, errors: %s", specification, operation.getOperationId(), // 
        StreamSupport.stream(result.getProblems().spliterator(), false).map(ValidationProblem::toString).collect(// 
        Collectors.joining("\n"))).isTrue();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) ValidationResult(org.xmlunit.validation.ValidationResult) DataShape(io.syndesis.common.model.DataShape) JAXPValidator(org.xmlunit.validation.JAXPValidator) Validator(org.xmlunit.validation.Validator) Test(org.junit.Test)

Example 12 with ValidationResult

use of org.xmlunit.validation.ValidationResult in project syndesis by syndesisio.

the class UnifiedXmlDataShapeGeneratorShapeValidityTest method shouldGenerateValidInputSchemasets.

@Test
public void shouldGenerateValidInputSchemasets() {
    final DataShape input = generator.createShapeFromRequest(specificationContent, swagger, operation);
    if (input.getKind() != DataShapeKinds.XML_SCHEMA) {
        return;
    }
    final String inputSpecification = input.getSpecification();
    final ValidationResult result = VALIDATOR.validateInstance(source(inputSpecification));
    // 
    assertThat(result.isValid()).as("Non valid input XML schemaset was generated for specification: %s, operation: %s, errors: %s", specification, operation.getOperationId(), // 
    StreamSupport.stream(result.getProblems().spliterator(), false).map(ValidationProblem::toString).collect(// 
    Collectors.joining("\n"))).isTrue();
}
Also used : ValidationResult(org.xmlunit.validation.ValidationResult) DataShape(io.syndesis.common.model.DataShape) Test(org.junit.Test)

Aggregations

ValidationResult (org.xmlunit.validation.ValidationResult)12 Test (org.junit.Test)11 Validator (org.xmlunit.validation.Validator)9 StreamSource (javax.xml.transform.stream.StreamSource)7 ValidationProblem (org.xmlunit.validation.ValidationProblem)7 FileInputStream (java.io.FileInputStream)6 File (java.io.File)5 FileOutputStream (java.io.FileOutputStream)5 FileWriter (java.io.FileWriter)5 InputStreamReader (java.io.InputStreamReader)5 Files (java.nio.file.Files)5 Arrays (java.util.Arrays)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 QName (javax.xml.namespace.QName)5 Source (javax.xml.transform.Source)5 Assert.assertFalse (org.junit.Assert.assertFalse)5 Assert.assertTrue (org.junit.Assert.assertTrue)5 DMNMarshaller (org.kie.dmn.api.marshalling.DMNMarshaller)5 Definitions (org.kie.dmn.model.api.Definitions)5