mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
#50 (fix) Validator creates invalid createReportInput xml in case of no scenrio match
This commit is contained in:
parent
610348d3bd
commit
a1a7328b8f
5 changed files with 31 additions and 3 deletions
|
|
@ -5,6 +5,10 @@ All notable changes to the Schematron Rules and this project will be documented
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## UNRELEASED
|
||||||
|
### Fixed
|
||||||
|
- Validator was creating invalid createReportInput xml in case of no scenrio match
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
### Added
|
### Added
|
||||||
- Provide access to schematron result through [Result.java](https://github.com/itplr-kosit/validator/blob/master/src/main/java/de/kosit/validationtool/api/Result.java)
|
- Provide access to schematron result through [Result.java](https://github.com/itplr-kosit/validator/blob/master/src/main/java/de/kosit/validationtool/api/Result.java)
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ public class ScenarioRepository {
|
||||||
|
|
||||||
private ScenarioType createFallback() {
|
private ScenarioType createFallback() {
|
||||||
final ScenarioType t = new ScenarioType();
|
final ScenarioType t = new ScenarioType();
|
||||||
|
t.setFallback(true);
|
||||||
t.setName("Fallback-Scenario");
|
t.setName("Fallback-Scenario");
|
||||||
final CreateReportType reportType = new CreateReportType();
|
final CreateReportType reportType = new CreateReportType();
|
||||||
reportType.setResource(this.scenarios.getNoScenarioReport().getResource());
|
reportType.setResource(this.scenarios.getNoScenarioReport().getResource());
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@ public abstract class BaseScenario {
|
||||||
private ResourceType resourceType;
|
private ResourceType resourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean fallback;
|
||||||
|
|
||||||
private XPathExecutable matchExecutable;
|
private XPathExecutable matchExecutable;
|
||||||
|
|
||||||
private XPathExecutable acceptExecutable;
|
private XPathExecutable acceptExecutable;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
package de.kosit.validationtool.impl.tasks;
|
package de.kosit.validationtool.impl.tasks;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.ScenarioRepository;
|
import de.kosit.validationtool.impl.ScenarioRepository;
|
||||||
import de.kosit.validationtool.impl.model.Result;
|
import de.kosit.validationtool.impl.model.Result;
|
||||||
|
|
@ -35,6 +36,7 @@ import net.sf.saxon.s9api.XdmNode;
|
||||||
* @author Andreas Penski
|
* @author Andreas Penski
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class ScenarioSelectionAction implements CheckAction {
|
public class ScenarioSelectionAction implements CheckAction {
|
||||||
|
|
||||||
private final ScenarioRepository repository;
|
private final ScenarioRepository repository;
|
||||||
|
|
@ -47,16 +49,21 @@ public class ScenarioSelectionAction implements CheckAction {
|
||||||
if (results.getParserResult().isValid()) {
|
if (results.getParserResult().isValid()) {
|
||||||
scenarioTypeResult = determineScenario(results.getParserResult().getObject());
|
scenarioTypeResult = determineScenario(results.getParserResult().getObject());
|
||||||
} else {
|
} else {
|
||||||
scenarioTypeResult = new Result<>(repository.getFallbackScenario());
|
scenarioTypeResult = new Result<>(this.repository.getFallbackScenario());
|
||||||
}
|
}
|
||||||
results.setScenarioSelectionResult(scenarioTypeResult);
|
results.setScenarioSelectionResult(scenarioTypeResult);
|
||||||
report.setScenario(scenarioTypeResult.getObject());
|
if (!scenarioTypeResult.getObject().isFallback()) {
|
||||||
|
report.setScenario(scenarioTypeResult.getObject());
|
||||||
|
log.error("Schenario {} identified for {}", scenarioTypeResult.getObject().getName(), results.getInput().getName());
|
||||||
|
} else {
|
||||||
|
log.error("No valid schenario configuration found for {}", results.getInput().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<ScenarioType, String> determineScenario(final XdmNode document) {
|
private Result<ScenarioType, String> determineScenario(final XdmNode document) {
|
||||||
final Result<ScenarioType, String> result = this.repository.selectScenario(document);
|
final Result<ScenarioType, String> result = this.repository.selectScenario(document);
|
||||||
if (result.isInvalid()) {
|
if (result.isInvalid()) {
|
||||||
return new Result<>(repository.getFallbackScenario());
|
return new Result<>(this.repository.getFallbackScenario());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ package de.kosit.validationtool.impl;
|
||||||
import static de.kosit.validationtool.api.InputFactory.read;
|
import static de.kosit.validationtool.api.InputFactory.read;
|
||||||
import static de.kosit.validationtool.impl.Helper.Simple.GARBAGE;
|
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.NOT_WELLFORMED;
|
||||||
|
import static de.kosit.validationtool.impl.Helper.Simple.UNKNOWN;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -115,6 +116,17 @@ public class DefaultCheckTest {
|
||||||
assertThat(result.isProcessingSuccessful()).isFalse();
|
assertThat(result.isProcessingSuccessful()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoScenario() {
|
||||||
|
final Result result = this.implementation.checkInput(read(UNKNOWN));
|
||||||
|
assertThat(result).isNotNull();
|
||||||
|
assertThat(result.isWellformed()).isTrue();
|
||||||
|
assertThat(result.isProcessingSuccessful()).isTrue();
|
||||||
|
assertThat(result.isSchemaValid()).isFalse();
|
||||||
|
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
|
||||||
|
assertThat(result.isAcceptable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotWellFormed() {
|
public void testNotWellFormed() {
|
||||||
final Result result = this.implementation.checkInput(read(NOT_WELLFORMED));
|
final Result result = this.implementation.checkInput(read(NOT_WELLFORMED));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue