mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
64 lines
2.3 KiB
Java
64 lines
2.3 KiB
Java
package de.kosit.validationtool.impl;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
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 SimpleScenarioCheckTest {
|
|
|
|
private DefaultCheck implementation;
|
|
|
|
@Before
|
|
public void setup() {
|
|
final CheckConfiguration d = new CheckConfiguration(Simple.SCENARIOS);
|
|
d.setScenarioRepository(Simple.REPOSITORY_URI);
|
|
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);
|
|
assertThat(result.getSchemaViolations()).isNotEmpty();
|
|
}
|
|
|
|
@Test
|
|
public void testUnknown() throws MalformedURLException {
|
|
final Result result = this.implementation.checkInput(InputFactory.read(Simple.UNKNOWN.toURL()));
|
|
assertThat(result).isNotNull();
|
|
assertThat(result.isProcessingSuccessful()).isTrue();
|
|
assertThat(result.isAcceptable()).isFalse();
|
|
assertThat(result.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.REJECT);
|
|
|
|
}
|
|
|
|
@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.ACCEPTABLE);
|
|
}
|
|
|
|
}
|