#21 Umbau NoScenarioMatch, als Fallback match

This commit is contained in:
Andreas Penski (init) 2019-05-17 16:11:02 +02:00 committed by Andreas Penski
parent b350334a04
commit cadedaf062
8 changed files with 55 additions and 45 deletions

View file

@ -66,7 +66,7 @@ public class ScenarioRepositoryTest {
t.setName("Test");
t.initialize(this.content, true);
def.getScenario().add(t);
this.repository = new ScenarioRepository(ObjectFactory.createProcessor(), this.content);
this.repository = new ScenarioRepository(this.content);
this.repository.initialize(def);
}
@ -80,9 +80,14 @@ public class ScenarioRepositoryTest {
@Test
public void testNonMatch() throws Exception {
this.repository.getScenarios().getScenario().clear();
final ScenarioType fallback = new ScenarioType();
fallback.setName("fallback");
this.repository.setFallbackScenario(fallback);
final Result<ScenarioType, String> scenario = this.repository.selectScenario(load(SAMPLE));
assertThat(scenario).isNotNull();
assertThat(scenario.isValid()).isFalse();
assertThat(scenario.getObject().getName()).isEqualTo("fallback");
}
@Test
@ -92,9 +97,13 @@ public class ScenarioRepositoryTest {
t.setName("Test");
t.initialize(this.content, true);
this.repository.getScenarios().getScenario().add(t);
final ScenarioType fallback = new ScenarioType();
fallback.setName("fallback");
this.repository.setFallbackScenario(fallback);
final Result<ScenarioType, String> scenario = this.repository.selectScenario(load(SAMPLE));
assertThat(scenario).isNotNull();
assertThat(scenario.isValid()).isFalse();
assertThat(scenario.getObject().getName()).isEqualTo("fallback");
}
private static XdmNode load(final URL url) throws IOException {
@ -105,7 +114,7 @@ public class ScenarioRepositoryTest {
@Test
public void loadFromJar() throws URISyntaxException {
this.content = new ContentRepository(ObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
this.repository = new ScenarioRepository(ObjectFactory.createProcessor(), this.content);
this.repository = new ScenarioRepository(this.content);
final CheckConfiguration conf = new CheckConfiguration(
ScenarioRepository.class.getClassLoader().getResource("xrechnung/scenarios.xml").toURI());
this.repository.initialize(conf);

View file

@ -49,7 +49,7 @@ public class SimpleScenarioCheck {
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);
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
}
@Test
@ -58,4 +58,5 @@ public class SimpleScenarioCheck {
assertThat(result).isNotNull();
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.UNDEFINED);
}
}