mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
Added custom error level to Result object.
This commit is contained in:
parent
3c6b4d2e2e
commit
9ed443ffdb
15 changed files with 211 additions and 51 deletions
|
|
@ -164,7 +164,7 @@ public class CommandlineApplicationTest {
|
|||
final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
|
||||
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.EXAMPLES).toString() };
|
||||
CommandLineApplication.mainProgram(args);
|
||||
assertThat(CommandLine.getErrorOutput()).contains("Processing 8 object(s) completed");
|
||||
assertThat(CommandLine.getErrorOutput()).contains("Processing 9 object(s) completed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package de.kosit.validationtool.impl;
|
||||
|
||||
import static de.kosit.validationtool.api.InputFactory.read;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.FOO_CUSTOM_LEVEL_ERROR;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.FOO_SCHEMATRON_INVALID;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.GARBAGE;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.NOT_WELLFORMED;
|
||||
|
|
@ -44,7 +45,8 @@ import de.kosit.validationtool.api.Input;
|
|||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.api.Result;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
|
||||
import de.kosit.validationtool.impl.model.CustomFailedAssert;
|
||||
import de.kosit.validationtool.model.scenarios.ErrorLevelType;
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
|
||||
/**
|
||||
|
|
@ -239,6 +241,8 @@ public class DefaultCheckTest {
|
|||
assertThat(result.isAcceptable()).isFalse();
|
||||
assertThat(result.getReport()).isNotNull();
|
||||
assertThat(result.getProcessingErrors()).hasSize(1);
|
||||
assertThat(result.getCustomFailedAsserts()).isNotNull();
|
||||
assertThat(result.getCustomFailedAsserts()).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -254,4 +258,19 @@ public class DefaultCheckTest {
|
|||
result = this.validCheck.checkInput(domInput);
|
||||
assertThat(result.isProcessingSuccessful()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomFailedAssertsWarning() {
|
||||
final Result result = this.errorCheck.checkInput(read(FOO_CUSTOM_LEVEL_ERROR));
|
||||
assertThat(result.isSchematronValid()).isFalse();
|
||||
assertThat(result.getFailedAsserts()).isNotEmpty();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
|
||||
assertThat(result.getCustomFailedAsserts()).isNotNull();
|
||||
assertThat(result.getCustomFailedAsserts()).hasSize(1);
|
||||
CustomFailedAssert customFailedAssert = result.getCustomFailedAsserts().get(0);
|
||||
assertThat(result.getFailedAsserts().get(0).getId()).isEqualTo(customFailedAssert.getFailedAssert().getId());
|
||||
assertThat(customFailedAssert.getCustomLevelFlag()).isEqualTo(ErrorLevelType.WARNING);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ public class Helper {
|
|||
|
||||
public static final URI FOO_SCHEMATRON_INVALID = EXAMPLES.resolve("foo-schematron-invalid.xml");
|
||||
|
||||
public static final URI FOO_CUSTOM_LEVEL_ERROR = EXAMPLES.resolve("foo-custom-level-error.xml");
|
||||
|
||||
public static final URI REJECTED = ROOT.resolve("input/withManualReject.xml");
|
||||
|
||||
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2017-2022 Koordinierungsstelle für IT-Standards (KoSIT)
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<foo xmlns="http://validator.kosit.de/test-sample">
|
||||
<inner>asldkfj</inner>
|
||||
<inner>asldkfj</inner>
|
||||
<content>
|
||||
</content>
|
||||
</foo>
|
||||
|
|
@ -52,6 +52,38 @@
|
|||
</createReport>
|
||||
</scenario>
|
||||
|
||||
<scenario>
|
||||
<name>Simple</name>
|
||||
<description>
|
||||
<p>Foo schematron error</p>
|
||||
</description>
|
||||
<namespace prefix="cri">http://www.xoev.de/de/validator/framework/1/createreportinput</namespace>
|
||||
<namespace prefix="test">http://validator.kosit.de/test-sample</namespace>
|
||||
<namespace prefix="rpt">http://validator.kosit.de/test-report</namespace>
|
||||
<match>/test:foo</match>
|
||||
|
||||
<validateWithXmlSchema>
|
||||
<resource>
|
||||
<name>Sample Schema</name>
|
||||
<location>simple.xsd</location>
|
||||
</resource>
|
||||
</validateWithXmlSchema>
|
||||
<validateWithSchematron>
|
||||
<resource>
|
||||
<name>Sample Schematron</name>
|
||||
<location>simple-schematron-error.xsl</location>
|
||||
</resource>
|
||||
</validateWithSchematron>
|
||||
<createReport>
|
||||
<resource>
|
||||
<name>Report für eRechnung</name>
|
||||
<location>report.xsl</location>
|
||||
</resource>
|
||||
<customLevel level="warning">content-2</customLevel>
|
||||
</createReport>
|
||||
<acceptMatch>count(//test:rejected) = 0</acceptMatch>
|
||||
</scenario>
|
||||
|
||||
<noScenarioReport>
|
||||
<resource>
|
||||
<name>default</name>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue