mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
parent
5a7c6775b1
commit
ecf1e1cef4
17 changed files with 340 additions and 12 deletions
|
|
@ -20,9 +20,11 @@
|
|||
package de.kosit.validationtool.impl;
|
||||
|
||||
import static de.kosit.validationtool.api.InputFactory.read;
|
||||
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;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.REJECTED;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.SCHEMATRON_INVALID;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.UNKNOWN;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
|
@ -48,8 +50,6 @@ import de.kosit.validationtool.impl.Helper.Simple;
|
|||
*/
|
||||
public class DefaultCheckTest {
|
||||
|
||||
|
||||
|
||||
public static final int MULTI_COUNT = 5;
|
||||
|
||||
private DefaultCheck implementation;
|
||||
|
|
@ -67,6 +67,8 @@ public class DefaultCheckTest {
|
|||
assertThat(doc).isNotNull();
|
||||
assertThat(doc.getReport()).isNotNull();
|
||||
assertThat(doc.isAcceptable()).isTrue();
|
||||
assertThat(doc.isSchematronValid()).isTrue();
|
||||
assertThat(doc.isSchemaValid()).isTrue();
|
||||
assertThat(doc.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
}
|
||||
|
||||
|
|
@ -157,4 +159,37 @@ public class DefaultCheckTest {
|
|||
assertThat(result.getReportDocument()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchematronFailed() {
|
||||
final Result result = this.implementation.checkInput(read(SCHEMATRON_INVALID));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.isWellformed()).isTrue();
|
||||
assertThat(result.isSchemaValid()).isTrue();
|
||||
assertThat(result.getFailedAsserts()).isNotEmpty();
|
||||
assertThat(result.isSchematronValid()).isFalse();
|
||||
assertThat(result.isProcessingSuccessful()).isTrue();
|
||||
// acceptMatch overules schematron!!!
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
assertThat(result.isAcceptable()).isTrue();
|
||||
assertThat(result.getReport()).isNotNull();
|
||||
assertThat(result.getReportDocument()).isNotNull();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchematronFailedWithoutAcceptMatch() {
|
||||
final Result result = this.implementation.checkInput(read(FOO_SCHEMATRON_INVALID));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.isWellformed()).isTrue();
|
||||
assertThat(result.isSchemaValid()).isTrue();
|
||||
result.getFailedAsserts();
|
||||
assertThat(result.isSchematronValid()).isFalse();
|
||||
assertThat(result.getFailedAsserts()).isNotEmpty();
|
||||
assertThat(result.isProcessingSuccessful()).isTrue();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
|
||||
assertThat(result.isAcceptable()).isFalse();
|
||||
assertThat(result.getReport()).isNotNull();
|
||||
assertThat(result.getReportDocument()).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,13 +58,17 @@ public class Helper {
|
|||
|
||||
public static final URI FOO = Simple.ROOT.resolve("input/foo.xml");
|
||||
|
||||
public static final URI FOO_SCHEMATRON_INVALID = EXAMPLES.resolve("foo-schematron-invalid.xml");
|
||||
|
||||
public static final URI REJECTED = Simple.ROOT.resolve("input/withManualReject.xml");
|
||||
|
||||
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
|
||||
|
||||
public static final URI REPOSITORY_URI = ROOT.resolve("repository/");
|
||||
|
||||
public static final URI INVALID = ROOT.resolve("input/simple-invalid.xml");
|
||||
public static final URI SCHEMA_INVALID = ROOT.resolve("input/simple-schema-invalid.xml");
|
||||
|
||||
public static final URI SCHEMATRON_INVALID = ROOT.resolve("input/simple-schematron-invalid.xml");
|
||||
|
||||
public static final URI NOT_WELLFORMED = ROOT.resolve("input/simple-not-wellformed.xml");
|
||||
|
||||
|
|
@ -95,6 +99,7 @@ public class Helper {
|
|||
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
|
||||
|
||||
public static final URI SCENARIOS_ILLFORMED = ROOT.resolve("scenarios-illformed.xml");
|
||||
|
||||
}
|
||||
|
||||
public static class Resolving {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class SimpleScenarioCheckTest {
|
|||
|
||||
@Test
|
||||
public void testInvalid() throws MalformedURLException {
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.INVALID.toURL()));
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.SCHEMA_INVALID.toURL()));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
|
||||
assertThat(result.getSchemaViolations()).isNotEmpty();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class SchemaValidatorActionTest {
|
|||
|
||||
@Test
|
||||
public void testValidationFailure() throws MalformedURLException {
|
||||
final Input input = InputFactory.read(Simple.INVALID.toURL());
|
||||
final Input input = InputFactory.read(Simple.SCHEMA_INVALID.toURL());
|
||||
final CheckAction.Bag bag = createBag(input);
|
||||
this.service.check(bag);
|
||||
assertThat(bag.getSchemaValidationResult().isValid()).isFalse();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue