mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
Merge branch 'branch-1.2.x'
# Conflicts: # CHANGELOG.md # src/main/java/de/kosit/validationtool/impl/model/BaseScenario.java # src/test/java/de/kosit/validationtool/impl/DefaultCheckTest.java
This commit is contained in:
commit
e0bd3ec8ab
6 changed files with 35 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -36,3 +36,6 @@ src/generated
|
|||
.settings
|
||||
.vscode
|
||||
*.code-workspace
|
||||
|
||||
# Testing stuff
|
||||
xrechnung
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Inputs are NOT read into memory (e.g. Byte-Array) prior processing within the validator. This reduces memory consumption.
|
||||
|
||||
## 1.2.0
|
||||
## UNRELEASED
|
||||
### Fixed
|
||||
- Validator was creating invalid createReportInput xml in case of no scenrio match
|
||||
|
||||
## 1.2.0
|
||||
### 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)
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ public class ScenarioRepository {
|
|||
|
||||
private ScenarioType createFallback() {
|
||||
final ScenarioType t = new ScenarioType();
|
||||
t.setFallback(true);
|
||||
t.setName("Fallback-Scenario");
|
||||
t.setMatch("count(/)<0");
|
||||
final CreateReportType reportType = new CreateReportType();
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ public abstract class BaseScenario {
|
|||
private ResourceType resourceType;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean fallback;
|
||||
|
||||
private XPathExecutable matchExecutable;
|
||||
|
||||
private XPathExecutable acceptExecutable;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package de.kosit.validationtool.impl.tasks;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import de.kosit.validationtool.impl.ScenarioRepository;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
|
|
@ -35,6 +36,7 @@ import net.sf.saxon.s9api.XdmNode;
|
|||
* @author Andreas Penski
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ScenarioSelectionAction implements CheckAction {
|
||||
|
||||
private final ScenarioRepository repository;
|
||||
|
|
@ -47,16 +49,21 @@ public class ScenarioSelectionAction implements CheckAction {
|
|||
if (results.getParserResult().isValid()) {
|
||||
scenarioTypeResult = determineScenario(results.getParserResult().getObject());
|
||||
} else {
|
||||
scenarioTypeResult = new Result<>(repository.getFallbackScenario());
|
||||
scenarioTypeResult = new Result<>(this.repository.getFallbackScenario());
|
||||
}
|
||||
results.setScenarioSelectionResult(scenarioTypeResult);
|
||||
report.setScenario(scenarioTypeResult.getObject());
|
||||
if (!scenarioTypeResult.getObject().isFallback()) {
|
||||
report.setScenario(scenarioTypeResult.getObject());
|
||||
log.info("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) {
|
||||
final Result<ScenarioType, String> result = this.repository.selectScenario(document);
|
||||
if (result.isInvalid()) {
|
||||
return new Result<>(repository.getFallbackScenario());
|
||||
return new Result<>(this.repository.getFallbackScenario());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ 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.NOT_WELLFORMED;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.REJECTED;
|
||||
import static de.kosit.validationtool.impl.Helper.Simple.UNKNOWN;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -120,6 +121,17 @@ public class DefaultCheckTest {
|
|||
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
|
||||
public void testNotWellFormed() {
|
||||
final Result result = this.implementation.checkInput(read(NOT_WELLFORMED));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue