mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
Bug fix for building scenario with schematron.
This commit is contained in:
parent
5184f86c5e
commit
71a705c39d
4 changed files with 25 additions and 2 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package de.kosit.validationtool.impl;
|
package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public class Scenario {
|
||||||
private Transformation reportTransformation;
|
private Transformation reportTransformation;
|
||||||
|
|
||||||
public List<Transformation> getSchematronValidations() {
|
public List<Transformation> getSchematronValidations() {
|
||||||
return this.schematronValidations == null ? Collections.emptyList() : this.schematronValidations;
|
return this.schematronValidations == null ? new ArrayList<>() : this.schematronValidations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,25 @@ public class ScenarioBuilderTest {
|
||||||
assertThat(configuration.getNamespace()).isEmpty();
|
assertThat(configuration.getNamespace()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigureWithSchematron() {
|
||||||
|
final ContentRepository repository = Simple.createContentRepository();
|
||||||
|
final XPathExecutable match = repository.createXPath("//*", null);
|
||||||
|
final XPathExecutable accept = repository.createXPath("//*", null);
|
||||||
|
final ScenarioBuilder builder = createScenario();
|
||||||
|
builder.getNamespaces().clear();
|
||||||
|
|
||||||
|
builder.match(match);
|
||||||
|
builder.acceptWith(accept);
|
||||||
|
final Result<Scenario, String> result = builder.build(repository);
|
||||||
|
assertThat(result.isValid()).isTrue();
|
||||||
|
final ScenarioType configuration = result.getObject().getConfiguration();
|
||||||
|
assertThat(configuration.getMatch()).isNotEmpty();
|
||||||
|
assertThat(configuration.getAcceptMatch()).isNotEmpty();
|
||||||
|
assertThat(configuration.getNamespace()).isEmpty();
|
||||||
|
assertThat(configuration.getValidateWithSchematron()).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicAttributes() {
|
public void testBasicAttributes() {
|
||||||
final ContentRepository repository = Simple.createContentRepository();
|
final ContentRepository repository = Simple.createContentRepository();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import static de.kosit.validationtool.config.ConfigurationBuilder.fallback;
|
||||||
import static de.kosit.validationtool.config.ConfigurationBuilder.report;
|
import static de.kosit.validationtool.config.ConfigurationBuilder.report;
|
||||||
import static de.kosit.validationtool.config.ConfigurationBuilder.scenario;
|
import static de.kosit.validationtool.config.ConfigurationBuilder.scenario;
|
||||||
import static de.kosit.validationtool.config.ConfigurationBuilder.schema;
|
import static de.kosit.validationtool.config.ConfigurationBuilder.schema;
|
||||||
|
import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -46,6 +47,7 @@ public class TestConfigurationFactory {
|
||||||
|
|
||||||
public static ScenarioBuilder createScenario() {
|
public static ScenarioBuilder createScenario() {
|
||||||
return scenario("simple").validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
|
return scenario("simple").validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
|
||||||
|
.validate(schematron("Sample Schematron").source(Simple.SCHEMATRON))
|
||||||
.with(report("Report für eRechnung").source("report.xsl")).acceptWith("count(//test:rejected) = 0")
|
.with(report("Report für eRechnung").source("report.xsl")).acceptWith("count(//test:rejected) = 0")
|
||||||
.declareNamespace("cri", "http://www.xoev.de/de/validator/framework/1/createreportinput")
|
.declareNamespace("cri", "http://www.xoev.de/de/validator/framework/1/createreportinput")
|
||||||
.declareNamespace("rpt", "http://validator.kosit.de/test-report")
|
.declareNamespace("rpt", "http://validator.kosit.de/test-report")
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,8 @@ public class Helper {
|
||||||
|
|
||||||
public static final URI SCHEMA = REPOSITORY_URI.resolve("simple.xsd");
|
public static final URI SCHEMA = REPOSITORY_URI.resolve("simple.xsd");
|
||||||
|
|
||||||
|
public static final URI SCHEMATRON = REPOSITORY_URI.resolve("simple-schematron-error.xsl");
|
||||||
|
|
||||||
public static final ContentRepository createContentRepository() {
|
public static final ContentRepository createContentRepository() {
|
||||||
final ResolvingConfigurationStrategy strategy = ResolvingMode.STRICT_RELATIVE.getStrategy();
|
final ResolvingConfigurationStrategy strategy = ResolvingMode.STRICT_RELATIVE.getStrategy();
|
||||||
return new ContentRepository(Helper.getTestProcessor(), strategy, Simple.REPOSITORY_URI);
|
return new ContentRepository(Helper.getTestProcessor(), strategy, Simple.REPOSITORY_URI);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue