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
|
.settings
|
||||||
.vscode
|
.vscode
|
||||||
*.code-workspace
|
*.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.
|
- 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
|
### 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");
|
||||||
t.setMatch("count(/)<0");
|
t.setMatch("count(/)<0");
|
||||||
final CreateReportType reportType = new CreateReportType();
|
final CreateReportType reportType = new CreateReportType();
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ public abstract class BaseScenario {
|
||||||
private ResourceType resourceType;
|
private ResourceType resourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlTransient
|
||||||
|
@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);
|
||||||
|
if (!scenarioTypeResult.getObject().isFallback()) {
|
||||||
report.setScenario(scenarioTypeResult.getObject());
|
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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.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.REJECTED;
|
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 static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -120,6 +121,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