mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
#21 Umsetzung der API Rückgabe, erste version
This commit is contained in:
parent
a424fbbcfe
commit
ab31ed71b1
21 changed files with 532 additions and 147 deletions
|
|
@ -33,17 +33,17 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import de.kosit.validationtool.api.AcceptRecommendation;
|
||||
import de.kosit.validationtool.api.CheckConfiguration;
|
||||
import de.kosit.validationtool.api.Input;
|
||||
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
import de.kosit.validationtool.api.Result;
|
||||
|
||||
/**
|
||||
* Test das Check-Interface
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class DefaultCheckTest {
|
||||
public class DefaultCheckTest extends CheckTest {
|
||||
|
||||
private static final URL SCENARIO_DEFINITION = ScenarioRepositoryTest.class.getResource("/examples/UBLReady/scenarios-2.xml");
|
||||
|
||||
|
|
@ -62,27 +62,30 @@ public class DefaultCheckTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHappyCase() throws Exception {
|
||||
final XdmNode doc = this.implementation.checkInput(read(VALID_EXAMPLE));
|
||||
public void testHappyCase() {
|
||||
final Result doc = this.implementation.checkInput(read(VALID_EXAMPLE));
|
||||
assertThat(doc).isNotNull();
|
||||
assertThat(doc.getReport()).isNotNull();
|
||||
assertThat(doc.isAcceptable()).isFalse();
|
||||
assertThat(doc.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.UNDEFINED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHappyCaseDocument() throws Exception {
|
||||
public void testHappyCaseDocument() {
|
||||
final Document doc = this.implementation.check(read(VALID_EXAMPLE));
|
||||
assertThat(doc).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCase() throws Exception {
|
||||
public void testMultipleCase() {
|
||||
final List<Input> input = IntStream.range(0, MULTI_COUNT).mapToObj(i -> read(VALID_EXAMPLE)).collect(Collectors.toList());
|
||||
final List<XdmNode> docs = this.implementation.checkInput(input);
|
||||
final List<Result> docs = this.implementation.checkInput(input);
|
||||
assertThat(docs).isNotNull();
|
||||
assertThat(docs).hasSize(MULTI_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCaseDocument() throws Exception {
|
||||
public void testMultipleCaseDocument() {
|
||||
final List<Input> input = IntStream.range(0, MULTI_COUNT).mapToObj(i -> read(VALID_EXAMPLE)).collect(Collectors.toList());
|
||||
final List<Document> docs = this.implementation.check(input);
|
||||
assertThat(docs).isNotNull();
|
||||
|
|
|
|||
|
|
@ -39,6 +39,23 @@ import net.sf.saxon.s9api.XdmNode;
|
|||
*/
|
||||
public class Helper {
|
||||
|
||||
public static class Simple {
|
||||
|
||||
public static final URI ROOT = EXAMPLES_DIR.resolve("simple/");
|
||||
|
||||
public static final URI SIMPLE_VALID = Simple.ROOT.resolve("input/simple.xml");
|
||||
|
||||
public static final URI FOO = Simple.ROOT.resolve("input/foo.xml");
|
||||
|
||||
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
|
||||
|
||||
public static final URI REPOSITORY = ROOT.resolve("repository/");
|
||||
|
||||
public static final URI INVALID = ROOT.resolve("input/simple-invalid.xml");
|
||||
|
||||
public static final URI UNKNOWN = ROOT.resolve("input/unknown.xml");
|
||||
}
|
||||
|
||||
public static final URI SOURCE_ROOT = Paths.get("src/main/resources").toUri();
|
||||
|
||||
public static final URI MODEL_ROOT = Paths.get("src/main/model").toUri();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package de.kosit.validationtool.impl;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.kosit.validationtool.api.AcceptRecommendation;
|
||||
import de.kosit.validationtool.api.CheckConfiguration;
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.api.Result;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
|
||||
/**
|
||||
* Prüft die Funktionen des Validator auf Basis eines reduzierten Szenarios.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class SimpleScenarioCheck {
|
||||
|
||||
private DefaultCheck implementation;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
final CheckConfiguration d = new CheckConfiguration(Simple.SCENARIOS);
|
||||
d.setScenarioRepository(Simple.REPOSITORY);
|
||||
this.implementation = new DefaultCheck(d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws MalformedURLException {
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.SIMPLE_VALID.toURL()));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalid() throws MalformedURLException {
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.INVALID.toURL()));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknown() throws MalformedURLException {
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.UNKNOWN.toURL()));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.UNDEFINED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutAcceptMatch() throws MalformedURLException {
|
||||
final Result result = this.implementation.checkInput(InputFactory.read(Simple.FOO.toURL()));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.UNDEFINED);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue