#58 Fix schematron evaluation

add tests with schematron
This commit is contained in:
Andreas Penski (init) 2020-07-28 17:05:59 +02:00
parent 5a7c6775b1
commit ecf1e1cef4
17 changed files with 340 additions and 12 deletions

View file

@ -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();
}
}