diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/AbstractTestCorpus.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/AbstractTestCorpus.java index 2953787..b472fff 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/AbstractTestCorpus.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/AbstractTestCorpus.java @@ -106,7 +106,7 @@ public InputStream getItemStream(String itemName) throws IOException { return getStreamFromReference(this.itemMap.get(itemName)); } - abstract protected InputStream getStreamFromReference(final L reference) throws IOException; + protected abstract InputStream getStreamFromReference(final L reference) throws IOException; /** * { @inheritDoc } @@ -206,7 +206,7 @@ public static File createTempFileFromCorpus(final URL downloadLoc, final String System.out.println("Downloading: " + downloadLoc + ", to temp:" + tempFile); int totalBytes = 0; try (OutputStream output = new FileOutputStream(tempFile); - InputStream corpusInput = handleRedirects(downloadLoc);) { + InputStream corpusInput = handleRedirects(downloadLoc)) { byte[] buffer = new byte[8 * 1024]; int bytesRead; while ((bytesRead = corpusInput.read(buffer)) != -1) { diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/CorpusItemIdImpl.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/CorpusItemIdImpl.java index 8816646..21fd300 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/CorpusItemIdImpl.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/CorpusItemIdImpl.java @@ -259,7 +259,7 @@ private static CorpusItemId fromCode(final Specification specification, } else { if (part.contains(" ")) { part = part.substring(part.lastIndexOf(" ") + 1); - } else if (part.equalsIgnoreCase("isartor")) { + } else if ("isartor".equalsIgnoreCase(part)) { continue; } builder.append(separator); diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RegressionTestingHelper.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RegressionTestingHelper.java index 054f510..e87bcd7 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RegressionTestingHelper.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RegressionTestingHelper.java @@ -126,7 +126,7 @@ public void getFailedPolicyComplianceFiles(Map> } public static void printResult(Map> failedFiles) { - if (failedFiles.size() > 0) { + if (!failedFiles.isEmpty()) { System.out.println("Some files is not compliant with policy: "); for (Map.Entry> entry : failedFiles.entrySet()) { System.out.println(entry.getKey()); diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetDetailsImpl.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetDetailsImpl.java index 7c6d4df..d74383c 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetDetailsImpl.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetDetailsImpl.java @@ -50,7 +50,7 @@ public class ResultSetDetailsImpl implements ResultSetDetails { @XmlElement(name = "dependency") private final Set dependencies; private ResultSetDetailsImpl() { - this(Collections. emptySet()); + this(Collections.emptySet()); } private ResultSetDetailsImpl(Set dependencies) { diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetImpl.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetImpl.java index a868369..809ff47 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetImpl.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ResultSetImpl.java @@ -219,7 +219,7 @@ public static ResultSet validateCorpus(final TestCorpus corpus, final PDFAValida } ValidationResult result = currentValidator.validate(loader); long memUsed = (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / MEGABYTE); - maxMemUse = (memUsed > maxMemUse) ? memUsed : maxMemUse; + maxMemUse = Math.max(memUsed, maxMemUse); results.add(new Result(id, result, jobTimer.stop(), memUsed)); } catch (Throwable e) { LOG.log(Level.SEVERE, String.format("Caught throwable testing %s from corpus %s", itemName, diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RuleDirectory.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RuleDirectory.java index 84da2c3..96656e2 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RuleDirectory.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/RuleDirectory.java @@ -42,7 +42,7 @@ public final class RuleDirectory implements Directory { private final Registry rules = new MapBackedRegistry<>( - Collections.emptyMap()); + Collections.emptyMap()); private final Set variables = new HashSet<>(); private final PDFAFlavour flavour; diff --git a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ZipBackedTestCorpus.java b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ZipBackedTestCorpus.java index 80bab71..af8531f 100644 --- a/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ZipBackedTestCorpus.java +++ b/veraPDF-integration/src/main/java/org/verapdf/pdfa/qa/ZipBackedTestCorpus.java @@ -42,7 +42,7 @@ * @author Carl Wilson */ public class ZipBackedTestCorpus extends AbstractTestCorpus { - private final static String PDF_SUFFIX = ".pdf"; + private static final String PDF_SUFFIX = ".pdf"; private final ZipFile zipSource; private ZipBackedTestCorpus(final CorpusDetails details, final Corpus type, final File zipSource, diff --git a/veraPDF-integration/src/test/java/org/verapdf/integration/tests/CorpusTest.java b/veraPDF-integration/src/test/java/org/verapdf/integration/tests/CorpusTest.java index b60e5d8..c2bb809 100644 --- a/veraPDF-integration/src/test/java/org/verapdf/integration/tests/CorpusTest.java +++ b/veraPDF-integration/src/test/java/org/verapdf/integration/tests/CorpusTest.java @@ -230,8 +230,8 @@ private static final EnumMap>> createEx if (expected == null) continue; expectedFailureSets.computeIfAbsent(corpus, - k -> new EnumMap>(PDFAFlavour.class)); - expectedFailureSets.get(corpus).computeIfAbsent(flavour, k -> new HashSet(expected)); + k -> new EnumMap<>(PDFAFlavour.class)); + expectedFailureSets.get(corpus).computeIfAbsent(flavour, k -> new HashSet<>(expected)); } } } catch (Exception e) { diff --git a/veraPDF-integration/src/test/java/org/verapdf/integration/tests/FeatureTest.java b/veraPDF-integration/src/test/java/org/verapdf/integration/tests/FeatureTest.java index 9c385c7..54fb0e9 100644 --- a/veraPDF-integration/src/test/java/org/verapdf/integration/tests/FeatureTest.java +++ b/veraPDF-integration/src/test/java/org/verapdf/integration/tests/FeatureTest.java @@ -173,7 +173,7 @@ private static boolean featureTreeNodesEqual(FeatureTreeNode node1, for (Map.Entry entry : node1Attrs.entrySet()) { String key = entry.getKey(); - if (!key.equals("id")) { + if (!"id".equals(key)) { if (!entry.getValue().equals(node2Attrs.get(key))) { failMessages.push("Different value of attribute " + key + " in nodes: " + node1 + " " + node2); diff --git a/veraPDF-integration/src/test/java/org/verapdf/pdfa/validation/validators/test/ValidatorTest.java b/veraPDF-integration/src/test/java/org/verapdf/pdfa/validation/validators/test/ValidatorTest.java index 37656a7..87c1348 100644 --- a/veraPDF-integration/src/test/java/org/verapdf/pdfa/validation/validators/test/ValidatorTest.java +++ b/veraPDF-integration/src/test/java/org/verapdf/pdfa/validation/validators/test/ValidatorTest.java @@ -156,22 +156,20 @@ public void testFailFastValidator() throws IOException, JAXBException, ModelPars continue; } if (index == failedMax) { - assertTrue(resultsComparisonMessage(veraCorpus + assertEquals(resultsComparisonMessage(veraCorpus .getDetails().getName(), itemName, - profile.getPDFAFlavour().toString(), - result, failFastResult), - result.equals(failFastResult)); + profile.getPDFAFlavour().toString(), + result, failFastResult), result, failFastResult); } else if ((index == (failedMax -1)) && (getMaxFailureOrdinal(result) == result.getTotalAssertions())) { - assertTrue(resultsComparisonMessage(veraCorpus - .getDetails().getName(), itemName, + assertEquals(resultsComparisonMessage(veraCorpus + .getDetails().getName(), itemName, profile.getPDFAFlavour().toString(), - result, failFastResult), - result.equals(failFastResult)); + result, failFastResult), result, failFastResult); } else if (index < failedMax) { - assertFalse(resultsComparisonMessage(veraCorpus - .getDetails().getName(), itemName, + assertNotEquals(resultsComparisonMessage(veraCorpus + .getDetails().getName(), itemName, profile.getPDFAFlavour().toString(), - result, failFastResult), result.equals(failFastResult)); + result, failFastResult), result, failFastResult); } } @@ -215,22 +213,18 @@ public void testModelConsistency() throws IOException, ValidationException, // The results of the two separate validators should be the // same (this works) - assertTrue( - resultsComparisonMessage(veraCorpus.getDetails() + assertEquals(resultsComparisonMessage(veraCorpus.getDetails() .getName(), itemName, profile .getPDFAFlavour().toString(), firstResult, - secondResult), - checkResult.equals(secondResult)); + secondResult), checkResult, secondResult); // The results of the same validator should be the same // (this doesn't) // The act of validation changes something in the // model...... - assertTrue( - resultsComparisonMessage(veraCorpus.getDetails() + assertEquals(resultsComparisonMessage(veraCorpus.getDetails() .getName(), itemName, profile .getPDFAFlavour().toString(), firstResult, - secondResult), - firstResult.equals(secondResult)); + secondResult), firstResult, secondResult); } } } @@ -260,7 +254,7 @@ private String resultsMessage(final String corpus, final String itemName, writer.write("\nSet.size()=" + results.size() + "\nResults:\n"); - if (results.size() > 0) { + if (!results.isEmpty()) { for (ValidationResult result : results) { XmlSerialiser.toXml(result, writer, true, true); }