mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
19-FixProbableBugs
This commit is contained in:
parent
b5bd901b12
commit
64b84508ed
10 changed files with 38 additions and 19 deletions
|
|
@ -60,6 +60,7 @@ public class CheckAssertionActionTest {
|
|||
final CheckAction.Bag bag = new CheckAction.Bag(InputFactory.read(SAMPLE), new CreateReportInput());
|
||||
bag.setReport(Helper.load(SAMPLE_REPORT));
|
||||
|
||||
assert SAMPLE_ASSERTIONS != null;
|
||||
final Assertions assertions = Helper.load(SAMPLE_ASSERTIONS, Assertions.class);
|
||||
final CheckAssertionAction a = new CheckAssertionAction(assertions, TestObjectFactory.createProcessor());
|
||||
a.check(bag);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ public class SchemaBuilderTest {
|
|||
final Result<Pair<ValidateWithXmlSchema, Schema>, String> result = builder.build(Simple.createContentRepository());
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.isValid()).isTrue();
|
||||
assertThat(result.getObject().getKey().getResource().stream().map(ResourceType::getName).findFirst().get()).isEqualTo("myname");
|
||||
assertThat(result.getObject().getKey().getResource().stream().map(ResourceType::getName).findFirst().orElse(null))
|
||||
.isEqualTo("myname");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertThrows;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
|
@ -42,7 +43,7 @@ public class RelativeUriResolverTest {
|
|||
|
||||
static {
|
||||
try {
|
||||
BASE = RelativeUriResolver.class.getResource("/examples/assertions/").toURI();
|
||||
BASE = Objects.requireNonNull(RelativeUriResolver.class.getResource("/examples/assertions/")).toURI();
|
||||
} catch (final URISyntaxException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
@ -68,16 +69,20 @@ public class RelativeUriResolverTest {
|
|||
|
||||
@Test
|
||||
public void testClasspathLocal() throws URISyntaxException, TransformerException {
|
||||
this.resolver = new RelativeUriResolver(RelativeUriResolver.class.getClassLoader().getResource("loading").toURI());
|
||||
this.resolver = new RelativeUriResolver(
|
||||
Objects.requireNonNull(RelativeUriResolver.class.getClassLoader().getResource("loading")).toURI());
|
||||
final URL moz = RelativeUriResolverTest.class.getClassLoader().getResource("loading/main.xsd");
|
||||
assert moz != null;
|
||||
final Source resolved = this.resolver.resolve("./resources/reference.xsd", moz.toURI().toASCIIString());
|
||||
assertThat(resolved).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClasspathJAR() throws URISyntaxException, TransformerException {
|
||||
this.resolver = new RelativeUriResolver(RelativeUriResolver.class.getClassLoader().getResource("packaged").toURI());
|
||||
this.resolver = new RelativeUriResolver(
|
||||
Objects.requireNonNull(RelativeUriResolver.class.getClassLoader().getResource("packaged")).toURI());
|
||||
final URL moz = RelativeUriResolverTest.class.getClassLoader().getResource("packaged/main.xsd");
|
||||
assert moz != null;
|
||||
final Source resolved = this.resolver.resolve("./resources/reference.xsd", moz.toURI().toASCIIString());
|
||||
assertThat(resolved).isNotNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,25 +50,31 @@ public class VersioningTest {
|
|||
|
||||
@Test
|
||||
public void testBase() throws URISyntaxException {
|
||||
assert BASE != null;
|
||||
final Scenarios result = this.service.readXml(BASE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFrameworkIncrement() throws URISyntaxException {
|
||||
assert INCREMENT != null;
|
||||
final Scenarios result = this.service.readXml(INCREMENT.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewFeature() {
|
||||
assertThrows(ConversionService.ConversionException.class,
|
||||
() -> this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
|
||||
assertThrows(ConversionService.ConversionException.class, () -> {
|
||||
assert NEW_FEATURE != null;
|
||||
this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewVersion() {
|
||||
assertThrows(ConversionService.ConversionException.class,
|
||||
() -> this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
|
||||
assertThrows(ConversionService.ConversionException.class, () -> {
|
||||
assert NEW_VERSION != null;
|
||||
this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class SaxonSecurityTest {
|
|||
final RelativeUriResolver resolver = new RelativeUriResolver(Simple.REPOSITORY_URI);
|
||||
// TODO: Replace call to deprecated method.
|
||||
compiler.setURIResolver(resolver);
|
||||
assert resource != null;
|
||||
final XsltExecutable executable = compiler.compile(new StreamSource(resource.openStream()));
|
||||
final XsltTransformer transformer = executable.load();
|
||||
final Source document = InputFactory.read("<root/>".getBytes(), "dummy").getSource();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue