14-FixDeclarationRedundancyIssues

This commit is contained in:
Adrian-Devries 2025-04-24 12:54:04 +02:00
parent 7a81f0c042
commit 46fdd703c3
43 changed files with 90 additions and 50 deletions

View file

@ -191,6 +191,7 @@ public class InputFactory {
* @param name the digest algorithm * @param name the digest algorithm
* @return an {@link Input} * @return an {@link Input}
*/ */
@SuppressWarnings("unused")
public static Input read(final Source source, final String name) { public static Input read(final Source source, final String name) {
checkNotEmpty(name); checkNotEmpty(name);
return read(source, name, PSEUDO_NAME_ALGORITHM, name.getBytes()); return read(source, name, PSEUDO_NAME_ALGORITHM, name.getBytes());

View file

@ -36,6 +36,7 @@ public interface XmlError {
* @return der Schweregrad * @return der Schweregrad
* @see Severity * @see Severity
*/ */
@SuppressWarnings("unused")
Severity getSeverity(); Severity getSeverity();
/** /**
@ -53,7 +54,9 @@ public interface XmlError {
Integer getColumnNumber(); Integer getColumnNumber();
enum Severity { enum Severity {
SEVERITY_WARNING, SEVERITY_ERROR, SEVERITY_FATAL_ERROR @SuppressWarnings("unused")
SEVERITY_WARNING, SEVERITY_ERROR, @SuppressWarnings("unused")
SEVERITY_FATAL_ERROR
} }
} }

View file

@ -97,7 +97,7 @@ class CheckAssertionAction implements CheckAction {
} }
private XPathSelector createSelector(AssertionType assertion) throws SaxonApiException { private XPathSelector createSelector(AssertionType assertion) {
try { try {
final XPathCompiler compiler = getProcessor().newXPathCompiler(); final XPathCompiler compiler = getProcessor().newXPathCompiler();
assertions.getNamespace().forEach(ns -> compiler.declareNamespace(ns.getPrefix(), ns.getValue())); assertions.getNamespace().forEach(ns -> compiler.declareNamespace(ns.getPrefix(), ns.getValue()));

View file

@ -94,16 +94,22 @@ public class CommandLineApplication {
return resultStatus; return resultStatus;
} }
private static int logExecutionException(final Exception ex, final CommandLine cli, final ParseResult parseResult) { @SuppressWarnings("SameReturnValue")
private static int logExecutionException(final Exception ex, @SuppressWarnings("unused") final CommandLine cli,
@SuppressWarnings("unused") final ParseResult parseResult) {
final String message = isNotEmpty(ex.getMessage()) ? ex.getMessage() : "Es ist eine Fehler aufgetreten"; final String message = isNotEmpty(ex.getMessage()) ? ex.getMessage() : "Es ist eine Fehler aufgetreten";
Printer.writeErr(ex, message); Printer.writeErr(ex, message);
return 1; return 1;
} }
@SuppressWarnings("unused")
enum Level { enum Level {
@SuppressWarnings("unused")
INFO, WARN, DEBUG, TRACE, ERROR, OFF INFO, @SuppressWarnings("unused")
WARN, @SuppressWarnings("unused")
DEBUG, @SuppressWarnings("unused")
TRACE, @SuppressWarnings("unused")
ERROR, @SuppressWarnings("unused")
OFF
} }
} }

View file

@ -35,8 +35,7 @@ import java.util.concurrent.Callable;
* *
* @author Andreas Penski * @author Andreas Penski
*/ */
@Command(description = "Structural and semantic validation of xml files", name = "KoSIT Validator", mixinStandardHelpOptions = false, @Command(description = "Structural and semantic validation of xml files", name = "KoSIT Validator", separator = " ")
separator = " ")
@Getter @Getter
public class CommandLineOptions implements Callable<ReturnValue> { public class CommandLineOptions implements Callable<ReturnValue> {
@ -166,7 +165,7 @@ public class CommandLineOptions implements Callable<ReturnValue> {
private List<ScenarioDefinition> scenarios; private List<ScenarioDefinition> scenarios;
@Override @Override
public ReturnValue call() throws Exception { public ReturnValue call() {
configureLogging(this); configureLogging(this);
return Validator.mainProgram(this); return Validator.mainProgram(this);
} }

View file

@ -76,7 +76,7 @@ class TypeConverter {
public static class RepositoryConverter implements ITypeConverter<RepositoryDefinition> { public static class RepositoryConverter implements ITypeConverter<RepositoryDefinition> {
@Override @Override
public RepositoryDefinition convert(final String value) throws Exception { public RepositoryDefinition convert(final String value) {
return TypeConverter.convert(RepositoryDefinition.class, value); return TypeConverter.convert(RepositoryDefinition.class, value);
} }
} }
@ -89,7 +89,7 @@ class TypeConverter {
public static class ScenarioConverter implements ITypeConverter<ScenarioDefinition> { public static class ScenarioConverter implements ITypeConverter<ScenarioDefinition> {
@Override @Override
public ScenarioDefinition convert(final String value) throws Exception { public ScenarioDefinition convert(final String value) {
return TypeConverter.convert(ScenarioDefinition.class, value); return TypeConverter.convert(ScenarioDefinition.class, value);
} }
} }

View file

@ -320,6 +320,7 @@ public class Validator {
} }
@SuppressWarnings("SameParameterValue")
private static void assertFileExistance(final Path f, final String type) { private static void assertFileExistance(final Path f, final String type) {
if (!Files.isRegularFile(f)) { if (!Files.isRegularFile(f)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(

View file

@ -68,6 +68,7 @@ public class Format {
* *
* @return this {@link Format} * @return this {@link Format}
*/ */
@SuppressWarnings("unused")
public Format color(final Code textColor) { public Format color(final Code textColor) {
this.textColor = textColor; this.textColor = textColor;
return this; return this;
@ -80,6 +81,7 @@ public class Format {
* *
* @return this {@link Format} * @return this {@link Format}
*/ */
@SuppressWarnings("unused")
public Format background(final Code color) { public Format background(final Code color) {
this.background = color; this.background = color;
return this; return this;

View file

@ -61,6 +61,7 @@ public class Grid {
* *
* @param name the name of the column * @param name the name of the column
*/ */
@SuppressWarnings("unused")
public ColumnDefinition(final String name) { public ColumnDefinition(final String name) {
this(name, -1, -1, 1); this(name, -1, -1, 1);
} }
@ -147,6 +148,7 @@ public class Grid {
this.text.add(txt); this.text.add(txt);
} }
@SuppressWarnings("unused")
public Cell(final Object object, final Code... codes) { public Cell(final Object object, final Code... codes) {
this(new Text(object, codes)); this(new Text(object, codes));
} }
@ -192,6 +194,7 @@ public class Grid {
} }
@SuppressWarnings("unused")
public Cell add(final Object object, final Code... codes) { public Cell add(final Object object, final Code... codes) {
this.text.add(new Text(object, codes)); this.text.add(new Text(object, codes));
return this; return this;
@ -237,6 +240,7 @@ public class Grid {
* @param def definitions * @param def definitions
* @return this grid * @return this grid
*/ */
@SuppressWarnings("unused")
public Grid addColumn(final ColumnDefinition def) { public Grid addColumn(final ColumnDefinition def) {
this.definitions.add(def); this.definitions.add(def);
return this; return this;
@ -263,6 +267,7 @@ public class Grid {
return this; return this;
} }
@SuppressWarnings("unused")
public Grid addCell(final Text... text) { public Grid addCell(final Text... text) {
return addCell(new Cell(Arrays.asList(text))); return addCell(new Cell(Arrays.asList(text)));
} }
@ -274,6 +279,7 @@ public class Grid {
return addCell(new Cell(t)); return addCell(new Cell(t));
} }
@SuppressWarnings("UnusedReturnValue")
public Grid addCell(final Object cell) { public Grid addCell(final Object cell) {
return addCell(cell, DEFAULT_FORMAT.getTextColor()); return addCell(cell, DEFAULT_FORMAT.getTextColor());
} }

View file

@ -39,8 +39,10 @@ public enum Justify {
return StringUtils.center(string, length); return StringUtils.center(string, length);
} }
}, },
@SuppressWarnings("unused")
RIGHT { RIGHT {
@SuppressWarnings("unused")
@Override @Override
public String apply(final String string, final int length) { public String apply(final String string, final int length) {
return StringUtils.leftPad(string, length); return StringUtils.leftPad(string, length);

View file

@ -71,6 +71,7 @@ public class Line {
return add(new Text(text, codes)); return add(new Text(text, codes));
} }
@SuppressWarnings("UnusedReturnValue")
public Line add(final Object text, final Format format) { public Line add(final Object text, final Format format) {
return add(new Text(text, format)); return add(new Text(text, format));
} }
@ -107,6 +108,7 @@ public class Line {
return this.texts.stream().mapToInt(Text::getLength).sum(); return this.texts.stream().mapToInt(Text::getLength).sum();
} }
@SuppressWarnings("unused")
public static String render(final String text, final Code... codes) { public static String render(final String text, final Code... codes) {
return new Line().add(text, codes).render(); return new Line().add(text, codes).render();
} }

View file

@ -32,5 +32,6 @@ interface Builder<T> {
* @param repository the {@link ContentRepository} * @param repository the {@link ContentRepository}
* @return the result of building the object * @return the result of building the object
*/ */
@SuppressWarnings("unused")
Result<T, String> build(ContentRepository repository); Result<T, String> build(ContentRepository repository);
} }

View file

@ -174,6 +174,7 @@ public class ConfigurationBuilder {
* *
* @return a fallback configuration * @return a fallback configuration
*/ */
@SuppressWarnings("unused")
public static FallbackBuilder defaultFallback() { public static FallbackBuilder defaultFallback() {
throw new NotImplementedException("Not yet defined"); throw new NotImplementedException("Not yet defined");
} }
@ -193,6 +194,7 @@ public class ConfigurationBuilder {
* *
* @return a configuration builder for schema * @return a configuration builder for schema
*/ */
@SuppressWarnings("unused")
public static SchemaBuilder schema() { public static SchemaBuilder schema() {
return new SchemaBuilder(); return new SchemaBuilder();
} }
@ -204,6 +206,7 @@ public class ConfigurationBuilder {
* @param schema the actual precompiled schema to use * @param schema the actual precompiled schema to use
* @return a configuration builder for schema * @return a configuration builder for schema
*/ */
@SuppressWarnings("unused")
public static SchemaBuilder schema(final String name, final Schema schema) { public static SchemaBuilder schema(final String name, final Schema schema) {
return new SchemaBuilder().name(name).schema(schema); return new SchemaBuilder().name(name).schema(schema);
} }
@ -243,6 +246,7 @@ public class ConfigurationBuilder {
* *
* @return the scenario configuration builder * @return the scenario configuration builder
*/ */
@SuppressWarnings("unused")
public static ScenarioBuilder scenario() { public static ScenarioBuilder scenario() {
return scenario(null); return scenario(null);
} }
@ -350,6 +354,7 @@ public class ConfigurationBuilder {
* @param strategy the strategy * @param strategy the strategy
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public ConfigurationBuilder resolvingStrategy(final ResolvingConfigurationStrategy strategy) { public ConfigurationBuilder resolvingStrategy(final ResolvingConfigurationStrategy strategy) {
this.resolvingConfigurationStrategy = strategy; this.resolvingConfigurationStrategy = strategy;
return this; return this;
@ -372,6 +377,7 @@ public class ConfigurationBuilder {
* @param repository the repository location * @param repository the repository location
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public ConfigurationBuilder useRepository(final Path repository) { public ConfigurationBuilder useRepository(final Path repository) {
return useRepository(repository.toUri()); return useRepository(repository.toUri());
} }

View file

@ -222,6 +222,7 @@ public class ConfigurationLoader {
* @param value the parameter value object * @param value the parameter value object
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public ConfigurationLoader addParameter(final String name, final Object value) { public ConfigurationLoader addParameter(final String name, final Object value) {
this.parameters.put(name, value); this.parameters.put(name, value);
return this; return this;

View file

@ -84,6 +84,7 @@ public class FallbackBuilder implements Builder<Scenario> {
* @param source the source * @param source the source
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public FallbackBuilder source(final URI source) { public FallbackBuilder source(final URI source) {
this.internal.source(source); this.internal.source(source);
return this; return this;
@ -96,6 +97,7 @@ public class FallbackBuilder implements Builder<Scenario> {
* @param source the source * @param source the source
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public FallbackBuilder source(final Path source) { public FallbackBuilder source(final Path source) {
this.internal.source(source); this.internal.source(source);
return this; return this;

View file

@ -112,6 +112,7 @@ public class ReportBuilder implements Builder<Pair<CreateReportType, Transformat
* @param source the source * @param source the source
* @return this * @return this
*/ */
@SuppressWarnings("UnusedReturnValue")
public ReportBuilder source(final Path source) { public ReportBuilder source(final Path source) {
return source(source.toUri()); return source(source.toUri());
} }

View file

@ -112,6 +112,7 @@ public class SchematronBuilder implements Builder<Pair<ValidateWithSchematron, T
* @param source the source * @param source the source
* @return this * @return this
*/ */
@SuppressWarnings("unused")
public SchematronBuilder source(final Path source) { public SchematronBuilder source(final Path source) {
return source(source.toUri()); return source(source.toUri());
} }

View file

@ -24,7 +24,6 @@ import lombok.Getter;
import net.sf.saxon.s9api.MessageListener; import net.sf.saxon.s9api.MessageListener;
import net.sf.saxon.s9api.XdmNode; import net.sf.saxon.s9api.XdmNode;
import org.xml.sax.ErrorHandler; import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import javax.xml.transform.ErrorListener; import javax.xml.transform.ErrorListener;
@ -112,17 +111,17 @@ public class CollectingErrorEventHandler implements ValidationEventHandler, Erro
} }
@Override @Override
public void warning(final SAXParseException exception) throws SAXException { public void warning(final SAXParseException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_WARNING, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_WARNING, exception));
} }
@Override @Override
public void error(final SAXParseException exception) throws SAXException { public void error(final SAXParseException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_ERROR, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_ERROR, exception));
} }
@Override @Override
public void fatalError(final SAXParseException exception) throws SAXException { public void fatalError(final SAXParseException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_FATAL_ERROR, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_FATAL_ERROR, exception));
} }
@ -139,17 +138,17 @@ public class CollectingErrorEventHandler implements ValidationEventHandler, Erro
} }
@Override @Override
public void warning(final TransformerException exception) throws TransformerException { public void warning(final TransformerException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_WARNING, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_WARNING, exception));
} }
@Override @Override
public void error(final TransformerException exception) throws TransformerException { public void error(final TransformerException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_ERROR, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_ERROR, exception));
} }
@Override @Override
public void fatalError(final TransformerException exception) throws TransformerException { public void fatalError(final TransformerException exception) {
this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_FATAL_ERROR, exception)); this.errors.add(createError(XMLSyntaxErrorSeverity.SEVERITY_FATAL_ERROR, exception));
} }

View file

@ -145,6 +145,7 @@ public class DefaultResult implements Result {
return filterSchematronResult(FailedAssert.class); return filterSchematronResult(FailedAssert.class);
} }
@SuppressWarnings("SameParameterValue")
private <T> List<T> filterSchematronResult(final Class<T> type) { private <T> List<T> filterSchematronResult(final Class<T> type) {
return getSchematronResult() != null return getSchematronResult() != null
? getSchematronResult().stream().flatMap(e -> e.getActivePatternAndFiredRuleAndFailedAssert().stream()) ? getSchematronResult().stream().flatMap(e -> e.getActivePatternAndFiredRuleAndFailedAssert().stream())

View file

@ -71,6 +71,7 @@ public class HtmlExtractor {
return this.executable.load(); return this.executable.load();
} }
@SuppressWarnings("SameParameterValue")
private XPathExecutable createXPath(final String expression, final Map<String, String> namespaces) { private XPathExecutable createXPath(final String expression, final Map<String, String> namespaces) {
try { try {
final XPathCompiler compiler = this.processor.newXPathCompiler(); final XPathCompiler compiler = this.processor.newXPathCompiler();

View file

@ -38,10 +38,12 @@ public enum ResolvingMode {
}, },
@SuppressWarnings("unused")
STRICT_LOCAL(new StrictLocalResolvingStrategy()), STRICT_LOCAL(new StrictLocalResolvingStrategy()),
ALLOW_REMOTE(new RemoteResolvingStrategy()), ALLOW_REMOTE(new RemoteResolvingStrategy()),
@SuppressWarnings("unused")
CUSTOM(null); CUSTOM(null);
@Getter @Getter

View file

@ -40,6 +40,7 @@ interface LazyReadInput {
* *
* @return true when computed * @return true when computed
*/ */
@SuppressWarnings("unused")
boolean isHashcodeComputed(); boolean isHashcodeComputed();
/** /**

View file

@ -58,6 +58,7 @@ public final class SourceInput extends AbstractInput {
private final String digestAlgorithm; private final String digestAlgorithm;
@SuppressWarnings("unused")
public SourceInput(final StreamSource source, final String name, final String digestAlgorithm) { public SourceInput(final StreamSource source, final String name, final String digestAlgorithm) {
this(source, name, digestAlgorithm, null); this(source, name, digestAlgorithm, null);
} }
@ -99,7 +100,7 @@ public final class SourceInput extends AbstractInput {
return isStreamSource(); return isStreamSource();
} }
private boolean isConsumed() throws IOException { private boolean isConsumed() {
if (isStreamSource()) { if (isStreamSource()) {
final StreamSource ss = (StreamSource) this.source; final StreamSource ss = (StreamSource) this.source;

View file

@ -37,6 +37,7 @@ public class Result<T, E> {
private T object; private T object;
@SuppressWarnings("CanBeFinal")
private Collection<E> errors = new ArrayList<>(); private Collection<E> errors = new ArrayList<>();
/** /**

View file

@ -138,7 +138,7 @@ public class CreateReportAction implements CheckAction {
} }
@Override @Override
public boolean getFeature(final String name) throws SAXNotRecognizedException, SAXNotSupportedException { public boolean getFeature(final String name) {
if (SAX_FEATURES_NAMESPACES.equals(name)) { if (SAX_FEATURES_NAMESPACES.equals(name)) {
return true; return true;
} else if (SAX_FEATURES_NAMESPACE_PREFIXES.equals(name)) { } else if (SAX_FEATURES_NAMESPACE_PREFIXES.equals(name)) {
@ -149,7 +149,7 @@ public class CreateReportAction implements CheckAction {
} }
@Override @Override
public void setFeature(final String name, final boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { public void setFeature(final String name, final boolean value) throws SAXNotRecognizedException {
// this inverts the logic from JaxbSource pseude parser // this inverts the logic from JaxbSource pseude parser
if (name.equals(SAX_FEATURES_NAMESPACES) && !value) { if (name.equals(SAX_FEATURES_NAMESPACES) && !value) {
throw new SAXNotRecognizedException(name); throw new SAXNotRecognizedException(name);

View file

@ -73,6 +73,7 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
allowExternalSchema(schemaFactory, false, scheme); allowExternalSchema(schemaFactory, false, scheme);
} }
@SuppressWarnings("SameParameterValue")
protected void allowExternalSchema(final Validator validator, final boolean lenient, final String... schemes) { protected void allowExternalSchema(final Validator validator, final boolean lenient, final String... schemes) {
final String schemeString = String.join(",", schemes); final String schemeString = String.join(",", schemes);
setProperty(() -> validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, schemeString), lenient, format( setProperty(() -> validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, schemeString), lenient, format(
@ -93,6 +94,7 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
disableExternalEntities(schemaFactory, false); disableExternalEntities(schemaFactory, false);
} }
@SuppressWarnings("SameParameterValue")
protected void disableExternalEntities(final Validator validator, final boolean lenient) { protected void disableExternalEntities(final Validator validator, final boolean lenient) {
log.debug("Try to disable extern DTD access"); log.debug("Try to disable extern DTD access");
setProperty(() -> validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""), lenient, setProperty(() -> validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""), lenient,
@ -100,6 +102,7 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
} }
@SuppressWarnings("SameParameterValue")
protected void disableExternalEntities(final SchemaFactory schemaFactory, final boolean lenient) { protected void disableExternalEntities(final SchemaFactory schemaFactory, final boolean lenient) {
log.debug("Try to disable extern DTD access"); log.debug("Try to disable extern DTD access");
setProperty(() -> schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""), lenient, setProperty(() -> schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""), lenient,

View file

@ -26,11 +26,9 @@ import net.sf.saxon.lib.OutputURIResolver;
import net.sf.saxon.lib.ResourceCollection; import net.sf.saxon.lib.ResourceCollection;
import net.sf.saxon.lib.UnparsedTextURIResolver; import net.sf.saxon.lib.UnparsedTextURIResolver;
import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.Processor;
import net.sf.saxon.trans.XPathException;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.transform.Result; import javax.xml.transform.Result;
import javax.xml.transform.TransformerException;
import java.io.Reader; import java.io.Reader;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -51,22 +49,22 @@ public class ProcessorProvider {
} }
@Override @Override
public Result resolve(final String href, final String base) throws TransformerException { public Result resolve(final String href, final String base) {
throw new IllegalStateException(MESSAGE); throw new IllegalStateException(MESSAGE);
} }
@Override @Override
public void close(final Result result) throws TransformerException { public void close(final Result result) {
throw new IllegalStateException(MESSAGE); throw new IllegalStateException(MESSAGE);
} }
@Override @Override
public Reader resolve(final URI absoluteURI, final String encoding, final Configuration config) throws XPathException { public Reader resolve(final URI absoluteURI, final String encoding, final Configuration config) {
throw new IllegalStateException(MESSAGE); throw new IllegalStateException(MESSAGE);
} }
@Override @Override
public ResourceCollection findCollection(final XPathContext context, final String collectionURI) throws XPathException { public ResourceCollection findCollection(final XPathContext context, final String collectionURI) {
throw new IllegalStateException(MESSAGE); throw new IllegalStateException(MESSAGE);
} }
} }

View file

@ -39,7 +39,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -102,13 +101,13 @@ public class InputFactoryTest {
} }
@Test @Test
public void testInputFile() throws URISyntaxException { public void testInputFile() {
final Input input = InputFactory.read(new File(Simple.SIMPLE_VALID)); final Input input = InputFactory.read(new File(Simple.SIMPLE_VALID));
assertThat(input).isNotNull(); assertThat(input).isNotNull();
} }
@Test @Test
public void testInputPath() throws URISyntaxException { public void testInputPath() {
final Input input = InputFactory.read(Paths.get(Simple.SIMPLE_VALID)); final Input input = InputFactory.read(Paths.get(Simple.SIMPLE_VALID));
assertThat(input).isNotNull(); assertThat(input).isNotNull();
} }
@ -124,7 +123,7 @@ public class InputFactoryTest {
} }
@Test @Test
public void testEmptyInputName() throws IOException { public void testEmptyInputName() {
assertThrows(IllegalArgumentException.class, () -> { assertThrows(IllegalArgumentException.class, () -> {
final Input input = InputFactory.read(SOME_VALUE.getBytes(), ""); final Input input = InputFactory.read(SOME_VALUE.getBytes(), "");
drain(input); drain(input);

View file

@ -25,7 +25,6 @@ import de.kosit.validationtool.model.reportInput.CreateReportInput;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
@ -45,7 +44,7 @@ public class CheckAssertionActionTest {
private static final URL SAMPLE_ASSERTIONS = CheckAssertionActionTest.class.getResource("/examples/assertions/tests-xrechnung.xml"); private static final URL SAMPLE_ASSERTIONS = CheckAssertionActionTest.class.getResource("/examples/assertions/tests-xrechnung.xml");
@Before @Before
public void setup() throws IOException { public void setup() {
CommandLine.activate(); CommandLine.activate();
} }

View file

@ -106,7 +106,7 @@ public class CommandLine {
return new InputStream() { return new InputStream() {
@Override @Override
public int read() throws IOException { public int read() {
return 0; return 0;
} }
}; };
@ -124,6 +124,7 @@ public class CommandLine {
return readLines(out.getOut().toByteArray()); return readLines(out.getOut().toByteArray());
} }
@SuppressWarnings("unused")
public static List<String> getErrorLines() { public static List<String> getErrorLines() {
return readLines(error.getOut().toByteArray()); return readLines(error.getOut().toByteArray());
} }

View file

@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.text.RandomStringGenerator; import org.apache.commons.text.RandomStringGenerator;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import de.kosit.validationtool.impl.ContentRepository; import de.kosit.validationtool.impl.ContentRepository;

View file

@ -57,7 +57,7 @@ public class ContentRepositoryTest {
} }
@Test @Test
public void testCreateSchemaNotExisting() throws Exception { public void testCreateSchemaNotExisting() {
assertThrows(IllegalStateException.class, () -> this.repository.createSchema(Simple.NOT_EXISTING.toURL())); assertThrows(IllegalStateException.class, () -> this.repository.createSchema(Simple.NOT_EXISTING.toURL()));
} }

View file

@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertThrows;
import java.io.Serializable; import java.io.Serializable;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import org.junit.Before; import org.junit.Before;
@ -94,12 +93,12 @@ public class ConversionServiceTest {
} }
@Test @Test
public void testUnmarshalUnknownType() throws URISyntaxException { public void testUnmarshalUnknownType() {
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, ConversionService.class)); assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, ConversionService.class));
} }
@Test @Test
public void testUnmarshalWithoutType() throws URISyntaxException { public void testUnmarshalWithoutType() {
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, null)); assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, null));
} }

View file

@ -87,6 +87,7 @@ public class Helper {
return new ContentRepository(Helper.getTestProcessor(), strategy, Simple.REPOSITORY_URI); return new ContentRepository(Helper.getTestProcessor(), strategy, Simple.REPOSITORY_URI);
} }
@SuppressWarnings("SameReturnValue")
public static URI getSchemaLocation() { public static URI getSchemaLocation() {
return SCHEMA; return SCHEMA;
} }

View file

@ -57,12 +57,12 @@ public class RelativeUriResolverTest {
} }
@Test @Test
public void testNotExisting() throws TransformerException { public void testNotExisting() {
assertThrows(TransformerException.class, () -> this.resolver.resolve("ubl-0001", BASE.toASCIIString())); assertThrows(TransformerException.class, () -> this.resolver.resolve("ubl-0001", BASE.toASCIIString()));
} }
@Test @Test
public void testOutOfPath() throws TransformerException { public void testOutOfPath() {
assertThrows(TransformerException.class, () -> this.resolver.resolve("../results/report.xml", BASE.toASCIIString())); assertThrows(TransformerException.class, () -> this.resolver.resolve("../results/report.xml", BASE.toASCIIString()));
} }

View file

@ -121,10 +121,12 @@ public class ScenarioRepositoryTest {
assertThat(fallback).isNotSameAs(second.getFallbackScenario()); assertThat(fallback).isNotSameAs(second.getFallbackScenario());
} }
@SuppressWarnings("SameParameterValue")
private XdmNode load(final URI uri) throws IOException { private XdmNode load(final URI uri) throws IOException {
return Helper.parseDocument(this.configInstance.getContentRepository().getProcessor(), read(uri.toURL())).getObject(); return Helper.parseDocument(this.configInstance.getContentRepository().getProcessor(), read(uri.toURL())).getObject();
} }
@SuppressWarnings("SameParameterValue")
private XPathExecutable createXpath(final String expression) { private XPathExecutable createXpath(final String expression) {
return this.configInstance.getContentRepository().createXPath(expression, new HashMap<>()); return this.configInstance.getContentRepository().createXPath(expression, new HashMap<>());
} }

View file

@ -16,7 +16,6 @@
package de.kosit.validationtool.impl; package de.kosit.validationtool.impl;
import de.kosit.validationtool.impl.Helper.Simple;
import de.kosit.validationtool.model.scenarios.Scenarios; import de.kosit.validationtool.model.scenarios.Scenarios;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -62,13 +61,13 @@ public class VersioningTest {
} }
@Test @Test
public void testNewFeature() throws URISyntaxException { public void testNewFeature() {
assertThrows(ConversionService.ConversionException.class, assertThrows(ConversionService.ConversionException.class,
() -> this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema())); () -> this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
} }
@Test @Test
public void testNewVersion() throws URISyntaxException { public void testNewVersion() {
assertThrows(ConversionService.ConversionException.class, assertThrows(ConversionService.ConversionException.class,
() -> this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema())); () -> this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
} }

View file

@ -43,7 +43,7 @@ public class StreamHelperTest {
} }
@Override @Override
public int available() throws IOException { public int available() {
return 0; return 0;
} }
} }

View file

@ -41,7 +41,6 @@ import java.net.MalformedURLException;
import static de.kosit.validationtool.impl.tasks.TestBagBuilder.createBag; import static de.kosit.validationtool.impl.tasks.TestBagBuilder.createBag;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
/** /**

View file

@ -25,7 +25,6 @@ import javax.xml.XMLConstants;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
/** /**

View file

@ -23,8 +23,10 @@ import javax.xml.validation.SchemaFactory;
/** /**
* @author Andreas Penski * @author Andreas Penski
*/ */
@SuppressWarnings("unused")
public class SchemaProviderTest { public class SchemaProviderTest {
@SuppressWarnings("unused")
private final SchemaFactory schemaFactory = ResolvingMode.STRICT_RELATIVE.getStrategy().createSchemaFactory(); private final SchemaFactory schemaFactory = ResolvingMode.STRICT_RELATIVE.getStrategy().createSchemaFactory();
} }

View file

@ -35,7 +35,7 @@ import static org.junit.Assert.assertThrows;
public class StrictLocalResolvingTest { public class StrictLocalResolvingTest {
@Test @Test
public void testRemoteSchemaResolving() throws Exception { public void testRemoteSchemaResolving() {
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy(); final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
final SchemaFactory schemaFactory = s.createSchemaFactory(); final SchemaFactory schemaFactory = s.createSchemaFactory();
Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL())); Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL()));

View file

@ -35,7 +35,7 @@ import static org.junit.Assert.assertThrows;
public class StrictRelativeResolvingTest { public class StrictRelativeResolvingTest {
@Test @Test
public void testRemoteSchemaResolving() throws Exception { public void testRemoteSchemaResolving() {
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy(); final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
final SchemaFactory schemaFactory = s.createSchemaFactory(); final SchemaFactory schemaFactory = s.createSchemaFactory();
Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL())); Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL()));