From 62bc4c9cefd856ddb95ec929192a15b6eb385643 Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 8 Dec 2023 00:28:31 +0300 Subject: [PATCH] Refactoring --- .../workflows/update-arlington-workflow.yml | 2 +- .../verapdf/apps/test/MultithreadingTest.java | 2 +- .../test/CallableValidatorForTest.java | 2 +- .../java/org/verapdf/apps/Applications.java | 3 - .../org/verapdf/apps/SoftwareUpdaterImpl.java | 6 +- .../verapdf/apps/utils/ApplicationUtils.java | 4 +- .../java/org/verapdf/cli/CliConstants.java | 2 - .../java/org/verapdf/cli/FormatterHelper.java | 8 +- .../main/java/org/verapdf/cli/VeraPdfCli.java | 7 +- .../cli/commands/VeraCliArgParser.java | 90 +++++++++---------- .../cli/multithread/MultiThreadProcessor.java | 12 +-- .../main/java/org/verapdf/gui/AboutPanel.java | 2 +- .../java/org/verapdf/gui/CheckerPanel.java | 41 ++++----- .../org/verapdf/gui/FeaturesConfigPanel.java | 11 +-- .../main/java/org/verapdf/gui/LogoPanel.java | 4 +- .../verapdf/gui/PDFValidationApplication.java | 10 +-- .../java/org/verapdf/gui/PartnersPanel.java | 8 +- .../java/org/verapdf/gui/PolicyPanel.java | 38 ++++---- .../java/org/verapdf/gui/SettingsPanel.java | 33 ++++--- .../java/org/verapdf/gui/ValidateWorker.java | 16 ++-- .../org/verapdf/gui/utils/DialogUtils.java | 2 +- .../org/verapdf/gui/utils/GUIConstants.java | 4 +- .../org/verapdf/apps/SoftwareUpdaterTest.java | 2 +- .../org/verapdf/apps/utils/AppUtilsTest.java | 2 +- .../verapdf/cli/VeraPdfCliProcessorTest.java | 17 ++-- .../cli/commands/VerCliFlavourTest.java | 1 - .../cli/commands/VeraCliArgParserTest.java | 2 +- .../cli/commands/VeraCliFormatTest.java | 1 - .../cli/commands/VeraCliTasksTest.java | 1 - .../org/verapdf/apps/PdfBoxGuiWrapper.java | 2 +- .../test/ProcessorImplProfileTest.java | 6 +- 31 files changed, 166 insertions(+), 175 deletions(-) diff --git a/.github/workflows/update-arlington-workflow.yml b/.github/workflows/update-arlington-workflow.yml index e812c8ef..c049cf73 100644 --- a/.github/workflows/update-arlington-workflow.yml +++ b/.github/workflows/update-arlington-workflow.yml @@ -29,7 +29,7 @@ jobs: run: | git fetch origin arlington:arlington git checkout -b test-branch arlington - - name: Configure user nameF + - name: Configure user name run: | git config user.name "Git User" git config user.email "user@test.com" diff --git a/greenfield-apps/src/test/java/org/verapdf/apps/test/MultithreadingTest.java b/greenfield-apps/src/test/java/org/verapdf/apps/test/MultithreadingTest.java index b4d1ed94..28e5a2ec 100644 --- a/greenfield-apps/src/test/java/org/verapdf/apps/test/MultithreadingTest.java +++ b/greenfield-apps/src/test/java/org/verapdf/apps/test/MultithreadingTest.java @@ -32,7 +32,7 @@ public void shouldCreateXmlReportsInGivenDirectory() throws Exception { List> futureResult = startValidation(fileToValidate, numberOfThreads); List validationResults = getValidationResult(futureResult); - Boolean isExpectedResults = compareResultsFromDifferentThreads(validationResults); + boolean isExpectedResults = compareResultsFromDifferentThreads(validationResults); assertTrue(isExpectedResults); } diff --git a/greenfield-apps/src/test/java/org/verapdf/pdfa/validation/validators/test/CallableValidatorForTest.java b/greenfield-apps/src/test/java/org/verapdf/pdfa/validation/validators/test/CallableValidatorForTest.java index fefcc2c8..c2e91dad 100644 --- a/greenfield-apps/src/test/java/org/verapdf/pdfa/validation/validators/test/CallableValidatorForTest.java +++ b/greenfield-apps/src/test/java/org/verapdf/pdfa/validation/validators/test/CallableValidatorForTest.java @@ -10,7 +10,7 @@ import java.util.concurrent.Callable; public class CallableValidatorForTest implements Callable { - private File fileToValidate; + private final File fileToValidate; public CallableValidatorForTest(File fileToValidate) { this.fileToValidate = fileToValidate; diff --git a/gui/src/main/java/org/verapdf/apps/Applications.java b/gui/src/main/java/org/verapdf/apps/Applications.java index f06e549d..fc976208 100644 --- a/gui/src/main/java/org/verapdf/apps/Applications.java +++ b/gui/src/main/java/org/verapdf/apps/Applications.java @@ -202,9 +202,6 @@ private static boolean areDirectoryFilesWritable(File directory) { if (files == null) { return Files.isWritable(directory.toPath()); } - if (files.length == 0) { - return true; - } for (String fileName : files) { if (!Files.isWritable(new File(directory + File.separator + fileName).toPath())) { return false; diff --git a/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java b/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java index 22f1dac3..59e7cc91 100644 --- a/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java +++ b/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java @@ -31,9 +31,9 @@ */ public class SoftwareUpdaterImpl implements SoftwareUpdater { - private final static Logger logger = Logger.getLogger(SoftwareUpdaterImpl.class.getCanonicalName()); - private final static String latestGF = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:greenfield-apps&core=gav&rows=20&wt=xml"; - private final static String latestPDFBox = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:pdfbox-apps&core=gav&rows=20&wt=xml"; + private static final Logger logger = Logger.getLogger(SoftwareUpdaterImpl.class.getCanonicalName()); + private static final String latestGF = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:greenfield-apps&core=gav&rows=1&wt=xml"; + private static final String latestPDFBox = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:pdfbox-apps&core=gav&rows=1&wt=xml"; private final String currentVersion = Applications.getAppDetails().getVersion(); /** diff --git a/gui/src/main/java/org/verapdf/apps/utils/ApplicationUtils.java b/gui/src/main/java/org/verapdf/apps/utils/ApplicationUtils.java index 8f6df49d..9b6c6b74 100644 --- a/gui/src/main/java/org/verapdf/apps/utils/ApplicationUtils.java +++ b/gui/src/main/java/org/verapdf/apps/utils/ApplicationUtils.java @@ -50,7 +50,7 @@ private ApplicationUtils() { * * @param toFilter * the list of files to filter, can not be null - * @return an immutable list of the filtered files, i.e. all PDF extenstions + * @return an immutable list of the filtered files, i.e. all PDF extensions * @throws IllegalArgumentException * when toFilter is null */ @@ -158,7 +158,7 @@ public static FeatureExtractorConfig mergeEnabledFeaturesFromPolicy(FeatureExtra SimpleNamespaceContext nsc = new SimpleNamespaceContext(); nsc.setPrefix(SchematronGenerator.SCH_PREFIX, SchematronGenerator.SCH_NAMESPACE); xpath.setNamespaceContext(nsc); - String path = "/" + SchematronGenerator.SCH_PREFIX + ":" + SchematronGenerator.ROOT_NAME + String path = '/' + SchematronGenerator.SCH_PREFIX + ':' + SchematronGenerator.ROOT_NAME + "/@" + SchematronGenerator.ENABLED_FEATURES_ATTRIBUTE_NAME; String value = (String) xpath.evaluate(path, document, diff --git a/gui/src/main/java/org/verapdf/cli/CliConstants.java b/gui/src/main/java/org/verapdf/cli/CliConstants.java index 4977d479..6004d0eb 100644 --- a/gui/src/main/java/org/verapdf/cli/CliConstants.java +++ b/gui/src/main/java/org/verapdf/cli/CliConstants.java @@ -3,8 +3,6 @@ */ package org.verapdf.cli; -import java.util.Arrays; -import java.util.List; /** * @author Carl Wilson diff --git a/gui/src/main/java/org/verapdf/cli/FormatterHelper.java b/gui/src/main/java/org/verapdf/cli/FormatterHelper.java index ba72f276..95e6ed86 100644 --- a/gui/src/main/java/org/verapdf/cli/FormatterHelper.java +++ b/gui/src/main/java/org/verapdf/cli/FormatterHelper.java @@ -19,7 +19,7 @@ public FormatterHelper(JCommander commander) { @Override public void appendAllParametersDetails(StringBuilder out, int indentCount, String indent, List sortedParameters) { - if (sortedParameters.size() > 0) { + if (!sortedParameters.isEmpty()) { out.append(indent).append(" Options:\n"); } @@ -33,7 +33,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin .append(" ") .append(parameter.required() ? "* " : " ") .append(pd.getNames()) - .append("\n"); + .append('\n'); if (hasDescription) { wrapDescription(out, indentCount, s(indentCount) + description); @@ -107,11 +107,11 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin out.append(possibleValues); } } - out.append("\n"); + out.append('\n'); } } private static String newLineAndIndent(int indent) { - return "\n" + s(indent); + return '\n' + s(indent); } } diff --git a/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java b/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java index 40dce45b..f3b6fe18 100644 --- a/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java +++ b/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java @@ -103,9 +103,8 @@ public static void main(final String[] args) throws VeraPDFException { try { if (!cliArgParser.isMultiprocessing()) { System.exit(singleThreadProcess(cliArgParser).value); - } else { - System.exit(MultiThreadProcessor.process(cliArgParser).value); } + System.exit(MultiThreadProcessor.process(cliArgParser).value); } catch (InterruptedException e) { logger.log(Level.WARNING, "Interrupted", e); System.exit(ExitCodes.INTERRUPTED_EXCEPTION.value); @@ -116,7 +115,7 @@ public static void main(final String[] args) throws VeraPDFException { long maxMemory = heapUsage.getMax() / MEGABYTE; long usedMemory = heapUsage.getUsed() / MEGABYTE; System.out.format(",%s\n", message); //$NON-NLS-1$ - System.out.format("Memory Use: %sM/%sM\n", Long.valueOf(usedMemory), Long.valueOf(maxMemory)); //$NON-NLS-1$ + System.out.format("Memory Use: %sM/%sM\n", usedMemory, maxMemory); //$NON-NLS-1$ System.out.format( "To increase the memory available to the JVM please assign the JAVA_OPTS environment variable.\n"); //$NON-NLS-1$ System.out.format("The examples below increase the maximum heap available to the JVM to 2GB:\n"); //$NON-NLS-1$ @@ -205,7 +204,7 @@ private static void showUpdateInfo(final ReleaseDetails details) { return; } if (!updater.isUpdateAvailable(details)) { - System.out.format(Applications.UPDATE_LATEST_VERSION, ",", details.getVersion() + "\n"); //$NON-NLS-1$ + System.out.format(Applications.UPDATE_LATEST_VERSION, ',', details.getVersion() + '\n'); //$NON-NLS-1$ return; } System.out.format( diff --git a/gui/src/main/java/org/verapdf/cli/commands/VeraCliArgParser.java b/gui/src/main/java/org/verapdf/cli/commands/VeraCliArgParser.java index 696873b1..6d9f5c2e 100644 --- a/gui/src/main/java/org/verapdf/cli/commands/VeraCliArgParser.java +++ b/gui/src/main/java/org/verapdf/cli/commands/VeraCliArgParser.java @@ -68,50 +68,50 @@ public class VeraCliArgParser { private static final Logger LOGGER = Logger.getLogger(VeraCliArgParser.class.getCanonicalName()); - final static VeraCliArgParser DEFAULT_ARGS = new VeraCliArgParser(); - final static String FLAG_SEP = "-"; //$NON-NLS-1$ - final static String OPTION_SEP = "--"; //$NON-NLS-1$ - final static String HELP_FLAG = FLAG_SEP + "h"; //$NON-NLS-1$ - final static String HELP = OPTION_SEP + "help"; //$NON-NLS-1$ - final static String VERSION = OPTION_SEP + "version"; //$NON-NLS-1$ - final static String FLAVOUR_FLAG = FLAG_SEP + "f"; //$NON-NLS-1$ - final static String FLAVOUR = OPTION_SEP + "flavour"; //$NON-NLS-1$ - final static String DEFAULT_FLAVOUR_FLAG = FLAG_SEP + "df"; //$NON-NLS-1$ - final static String DEFAULT_FLAVOUR = OPTION_SEP + "defaultflavour"; //$NON-NLS-1$ - final static String SUCCESS = OPTION_SEP + "success"; //$NON-NLS-1$ - final static String PASSED = OPTION_SEP + "passed"; //$NON-NLS-1$ - final static String LIST_FLAG = FLAG_SEP + "l"; //$NON-NLS-1$ - final static String LIST = OPTION_SEP + "list"; //$NON-NLS-1$ - final static String LOAD_PROFILE_FLAG = FLAG_SEP + "p"; //$NON-NLS-1$ - final static String LOAD_PROFILE = OPTION_SEP + "profile"; //$NON-NLS-1$ - final static String EXTRACT_FLAG = FLAG_SEP + "x"; //$NON-NLS-1$ - final static String EXTRACT = OPTION_SEP + "extract"; //$NON-NLS-1$ - final static String FORMAT = OPTION_SEP + "format"; //$NON-NLS-1$ - final static String RECURSE_FLAG = FLAG_SEP + "r"; //$NON-NLS-1$ - final static String RECURSE = OPTION_SEP + "recurse"; //$NON-NLS-1$ - final static String SERVER_MODE = OPTION_SEP + "servermode"; //$NON-NLS-1$ - final static String VERBOSE_FLAG = FLAG_SEP + "v"; //$NON-NLS-1$ - final static String VERBOSE = OPTION_SEP + "verbose"; //$NON-NLS-1$ - final static String DEBUG_FLAG = FLAG_SEP + "d"; //$NON-NLS-1$ - final static String DEBUG = OPTION_SEP + "debug"; //$NON-NLS-1$ - final static String MAX_FAILURES_DISPLAYED = OPTION_SEP + "maxfailuresdisplayed"; //$NON-NLS-1$ - final static String MAX_FAILURES = OPTION_SEP + "maxfailures"; //$NON-NLS-1$ - final static String FIX_METADATA = OPTION_SEP + "fixmetadata"; //$NON-NLS-1$ - final static String FIX_METADATA_PREFIX = OPTION_SEP + "prefix"; //$NON-NLS-1$ - final static String FIX_METADATA_FOLDER = OPTION_SEP + "savefolder"; //$NON-NLS-1$ - final static String NON_PDF_EXTENSION = OPTION_SEP + "nonpdfext"; - final static String POLICY_FILE = OPTION_SEP + "policyfile"; //$NON-NLS-1$ - final static String ADD_LOGS = OPTION_SEP + "addlogs"; //$NON-NLS-1$ - final static String DISABLE_ERROR_MESSAGES = OPTION_SEP + "disableerrormessages"; //$NON-NLS-1$ - final static String PASSWORD = OPTION_SEP + "password"; //$NON-NLS-1$ - final static String LOG_LEVEL = OPTION_SEP + "loglevel"; //$NON-NLS-1$ - final static String PROGRESS = OPTION_SEP + "progress"; //$NON-NLS-1$ - final static String PROFILES_WIKI_FLAG = FLAG_SEP + "pw"; - final static String PROFILES_WIKI = OPTION_SEP + "profilesWiki"; - final static String VALID_OFF_FLAG = FLAG_SEP + "o"; //$NON-NLS-1$ - final static String VALID_OFF = OPTION_SEP + "off"; //$NON-NLS-1$ - final static String NUMBER_OF_PROCESSES_FLAG = OPTION_SEP + "processes"; //$NON-NLS-1$ - final static String VERA_PATH_FLAG = OPTION_SEP + "verapath"; + static final VeraCliArgParser DEFAULT_ARGS = new VeraCliArgParser(); + static final String FLAG_SEP = "-"; //$NON-NLS-1$ + static final String OPTION_SEP = "--"; //$NON-NLS-1$ + static final String HELP_FLAG = FLAG_SEP + 'h'; //$NON-NLS-1$ + static final String HELP = OPTION_SEP + "help"; //$NON-NLS-1$ + static final String VERSION = OPTION_SEP + "version"; //$NON-NLS-1$ + static final String FLAVOUR_FLAG = FLAG_SEP + 'f'; //$NON-NLS-1$ + static final String FLAVOUR = OPTION_SEP + "flavour"; //$NON-NLS-1$ + static final String DEFAULT_FLAVOUR_FLAG = FLAG_SEP + "df"; //$NON-NLS-1$ + static final String DEFAULT_FLAVOUR = OPTION_SEP + "defaultflavour"; //$NON-NLS-1$ + static final String SUCCESS = OPTION_SEP + "success"; //$NON-NLS-1$ + static final String PASSED = OPTION_SEP + "passed"; //$NON-NLS-1$ + static final String LIST_FLAG = FLAG_SEP + 'l'; //$NON-NLS-1$ + static final String LIST = OPTION_SEP + "list"; //$NON-NLS-1$ + static final String LOAD_PROFILE_FLAG = FLAG_SEP + 'p'; //$NON-NLS-1$ + static final String LOAD_PROFILE = OPTION_SEP + "profile"; //$NON-NLS-1$ + static final String EXTRACT_FLAG = FLAG_SEP + 'x'; //$NON-NLS-1$ + static final String EXTRACT = OPTION_SEP + "extract"; //$NON-NLS-1$ + static final String FORMAT = OPTION_SEP + "format"; //$NON-NLS-1$ + static final String RECURSE_FLAG = FLAG_SEP + 'r'; //$NON-NLS-1$ + static final String RECURSE = OPTION_SEP + "recurse"; //$NON-NLS-1$ + static final String SERVER_MODE = OPTION_SEP + "servermode"; //$NON-NLS-1$ + static final String VERBOSE_FLAG = FLAG_SEP + 'v'; //$NON-NLS-1$ + static final String VERBOSE = OPTION_SEP + "verbose"; //$NON-NLS-1$ + static final String DEBUG_FLAG = FLAG_SEP + 'd'; //$NON-NLS-1$ + static final String DEBUG = OPTION_SEP + "debug"; //$NON-NLS-1$ + static final String MAX_FAILURES_DISPLAYED = OPTION_SEP + "maxfailuresdisplayed"; //$NON-NLS-1$ + static final String MAX_FAILURES = OPTION_SEP + "maxfailures"; //$NON-NLS-1$ + static final String FIX_METADATA = OPTION_SEP + "fixmetadata"; //$NON-NLS-1$ + static final String FIX_METADATA_PREFIX = OPTION_SEP + "prefix"; //$NON-NLS-1$ + static final String FIX_METADATA_FOLDER = OPTION_SEP + "savefolder"; //$NON-NLS-1$ + static final String NON_PDF_EXTENSION = OPTION_SEP + "nonpdfext"; + static final String POLICY_FILE = OPTION_SEP + "policyfile"; //$NON-NLS-1$ + static final String ADD_LOGS = OPTION_SEP + "addlogs"; //$NON-NLS-1$ + static final String DISABLE_ERROR_MESSAGES = OPTION_SEP + "disableerrormessages"; //$NON-NLS-1$ + static final String PASSWORD = OPTION_SEP + "password"; //$NON-NLS-1$ + static final String LOG_LEVEL = OPTION_SEP + "loglevel"; //$NON-NLS-1$ + static final String PROGRESS = OPTION_SEP + "progress"; //$NON-NLS-1$ + static final String PROFILES_WIKI_FLAG = FLAG_SEP + "pw"; + static final String PROFILES_WIKI = OPTION_SEP + "profilesWiki"; + static final String VALID_OFF_FLAG = FLAG_SEP + 'o'; //$NON-NLS-1$ + static final String VALID_OFF = OPTION_SEP + "off"; //$NON-NLS-1$ + static final String NUMBER_OF_PROCESSES_FLAG = OPTION_SEP + "processes"; //$NON-NLS-1$ + static final String VERA_PATH_FLAG = OPTION_SEP + "verapath"; public static final String USE_CONFIG = OPTION_SEP + "config"; @Parameter(names = { HELP_FLAG, HELP }, description = "Shows this message and exits.", help = true) @@ -702,7 +702,7 @@ public static List getBaseVeraPDFParameters(VeraCliArgParser cliArgParse public void checkParametersCompatibility() { if (this.format != FormatOption.MRR && this.format != FormatOption.XML && this.policyFile != null - && !this.policyFile.getAbsolutePath().equals("")) { + && !this.policyFile.getAbsolutePath().isEmpty()) { LOGGER.log(Level.WARNING, "Policy report supports only xml (mrr) output format."); this.format = FormatOption.XML; } diff --git a/gui/src/main/java/org/verapdf/cli/multithread/MultiThreadProcessor.java b/gui/src/main/java/org/verapdf/cli/multithread/MultiThreadProcessor.java index 6d566053..3702eb67 100644 --- a/gui/src/main/java/org/verapdf/cli/multithread/MultiThreadProcessor.java +++ b/gui/src/main/java/org/verapdf/cli/multithread/MultiThreadProcessor.java @@ -30,18 +30,18 @@ public class MultiThreadProcessor { private int filesQuantity; - private File veraPDFStarterPath; - private List veraPDFParameters; + private final File veraPDFStarterPath; + private final List veraPDFParameters; private OutputStream os; - private OutputStream errorStream; + private final OutputStream errorStream; - private ReportWriter reportWriter; - private MultiThreadProcessingHandler processingHandler; + private final ReportWriter reportWriter; + private final MultiThreadProcessingHandler processingHandler; private boolean isFirstReport = true; private boolean isHTMLReport; private File xmlReport; - private String wikiPath; + private final String wikiPath; private ExitCodes currentExitCode = ExitCodes.VALID; private CountDownLatch latch; diff --git a/gui/src/main/java/org/verapdf/gui/AboutPanel.java b/gui/src/main/java/org/verapdf/gui/AboutPanel.java index 55287ce1..f8c4db35 100644 --- a/gui/src/main/java/org/verapdf/gui/AboutPanel.java +++ b/gui/src/main/java/org/verapdf/gui/AboutPanel.java @@ -53,7 +53,7 @@ class AboutPanel extends JPanel { static final Logger logger = Logger.getLogger(AboutPanel.class.getCanonicalName()); - private JButton okButton; + private final JButton okButton; JDialog dialog; AboutPanel() throws IOException { diff --git a/gui/src/main/java/org/verapdf/gui/CheckerPanel.java b/gui/src/main/java/org/verapdf/gui/CheckerPanel.java index 626a667d..2840f32a 100644 --- a/gui/src/main/java/org/verapdf/gui/CheckerPanel.java +++ b/gui/src/main/java/org/verapdf/gui/CheckerPanel.java @@ -56,7 +56,7 @@ */ @SuppressWarnings("synthetic-access") class CheckerPanel extends JPanel { - private static transient ConfigManager config; + private transient ConfigManager config; /** * ID for serialisation */ @@ -67,10 +67,10 @@ class CheckerPanel extends JPanel { private static final Map FLAVOURS_MAP = new HashMap<>(); private static final String emptyString = ""; //$NON-NLS-1$ - private JFileChooser pdfChooser; - private JFileChooser xmlChooser; - private JFileChooser htmlChooser; - private JFileChooser policyChooser; + private final JFileChooser pdfChooser; + private final JFileChooser xmlChooser; + private final JFileChooser htmlChooser; + private final JFileChooser policyChooser; private List pdfsToProcess; private JTextField chosenPDF; private JTextField chosenProfile; @@ -104,7 +104,7 @@ class CheckerPanel extends JPanel { private boolean validationInProgress = false; CheckerPanel(final ConfigManager config) throws IOException { - CheckerPanel.config = config; + this.config = config; this.profilePath = FileSystems.getDefault().getPath(emptyString); this.initGui(); @@ -138,7 +138,7 @@ public void actionPerformed(final ActionEvent e) { } } CheckerPanel.this.validateWorker = new ValidateWorker(CheckerPanel.this, - CheckerPanel.this.pdfsToProcess, CheckerPanel.config, customProfile, + CheckerPanel.this.pdfsToProcess, config, customProfile, CheckerPanel.this.policy); CheckerPanel.this.progressBar.setVisible(true); CheckerPanel.this.resultLabel.setVisible(false); @@ -346,7 +346,7 @@ private void setupChooseFlavourLabel(final GridBagLayout gbl, final GridBagConst this.add(chooseFlavourLabel); } - private void setupChooseFlavourBox(final GridBagLayout gbl, final GridBagConstraints gbc) throws IOException { + private void setupChooseFlavourBox(final GridBagLayout gbl, final GridBagConstraints gbc) { Vector availableFlavours = new Vector<>(); availableFlavours.add(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT); availableFlavours.add(GUIConstants.AUTO_FLAVOUR_COMBOBOX_TEXT); @@ -401,7 +401,7 @@ private void setupChosenProfileTextField(final GridBagLayout gbl, final GridBagC if (!this.profilePath.toString().isEmpty()) { this.chosenProfile.setText(this.profilePath.toString()); } else { - this.chosenProfile.setText(GUIConstants.CHOOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT); + this.chosenProfile.setText(GUIConstants.CHOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT); } } @@ -420,8 +420,8 @@ private void setupProfileButton(final GridBagLayout gbl, final GridBagConstraint this.chooseFlavour.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent actionEvent) { - if (CheckerPanel.this.chooseFlavour.getSelectedItem() - .equals(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT)) { + if (GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT + .equals(CheckerPanel.this.chooseFlavour.getSelectedItem())) { chooseProfile.setEnabled(true); CheckerPanel.this.chosenProfile.setEnabled(true); CheckerPanel.this.targetProfile.setActive(true); @@ -740,7 +740,7 @@ private static JFileChooser getChooser(boolean allFilesAccept, String... types) private static String elementsCommaDelimited(String... elements) { StringBuilder description = new StringBuilder(elements[0]); for (int i = 1; i < elements.length; ++i) { - description.append(",").append(elements[i]); //$NON-NLS-1$ + description.append(',').append(elements[i]); //$NON-NLS-1$ } return description.toString(); } @@ -818,7 +818,7 @@ public void insertFilesInfo(List selectedFiles, String[] extensions){ } private static String getSelectedPathsMessage(List files) { - if (files != null && files.size() > 0) { + if (files != null && !files.isEmpty()) { StringBuilder builder = new StringBuilder(); for (File file : files) { builder.append(file.getAbsolutePath()).append(", "); //$NON-NLS-1$ @@ -886,9 +886,9 @@ ValidatorConfig validatorConfigFromState() { } VeraAppConfig appConfigFromState() { - AppConfigBuilder builder = Applications.createConfigBuilder(CheckerPanel.config.getApplicationConfig()); + AppConfigBuilder builder = Applications.createConfigBuilder(config.getApplicationConfig()); ProcessType selectedItem = (ProcessType) this.processTypes.getSelectedItem(); - if (isFixMetadata() && CheckerPanel.config.getApplicationConfig().getFixesFolder().isEmpty() && this.pdfsToProcess != null) { + if (isFixMetadata() && config.getApplicationConfig().getFixesFolder().isEmpty() && this.pdfsToProcess != null) { for (File pdf : pdfsToProcess) { if (FileUtils.hasExtNoCase(pdf.getName(), GUIConstants.ZIP)) { logger.log(Level.WARNING, "Fixing metadata are not supported for zip processing, if save folder isn't defined"); @@ -913,7 +913,7 @@ private PDFAFlavour getCurrentFlavour() { private boolean isExecute() { return (this.pdfsToProcess != null && (!this.profilePath.toString().isEmpty() - || !this.chooseFlavour.getSelectedItem().equals(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT)) + || !GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT.equals(this.chooseFlavour.getSelectedItem())) && (this.processTypes.getSelectedItem() != ProcessType.POLICY || this.policy != null)); } @@ -939,7 +939,7 @@ void setPolicyFile(File policy) { } } - private class ProcessingTypeRenderer extends JLabel implements ListCellRenderer { + private static class ProcessingTypeRenderer extends JLabel implements ListCellRenderer { /** * @@ -966,11 +966,11 @@ public class PanelDropTargetListener extends DropTargetAdapter { private static final String UNSUPPORTED_FLAVOUR = "Unsupported flavour error."; private static final String CASTING_ERROR = "Casting transfer to files type error."; - private int acceptableFilesCount; + private final int acceptableFilesCount; private List selectedFiles = new ArrayList<>(); - private String[] acceptableExtensions; + private final String[] acceptableExtensions; public PanelDropTargetListener(int acceptableFilesCount, String...acceptableExtensions) { this.acceptableFilesCount = acceptableFilesCount; @@ -1009,7 +1009,8 @@ private boolean isAcceptableTransferData(List selectedFiles) { // "-1" indicates that we can take any non-zero files or dirs if (acceptableFilesCount != -1 && acceptableFilesCount != selectedFiles.size()) { return false; - } else if (selectedFiles.size() == 0){ + } + if (selectedFiles.isEmpty()) { return false; } return ApplicationUtils.isLegalExtension(selectedFiles, acceptableExtensions); diff --git a/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java b/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java index 4c7de5c5..8218552c 100644 --- a/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java +++ b/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java @@ -22,6 +22,7 @@ import java.awt.event.ActionListener; import java.util.EnumMap; import java.util.EnumSet; +import java.util.Map; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -45,10 +46,10 @@ public class FeaturesConfigPanel extends JPanel { */ private static final long serialVersionUID = -6602264333993164990L; - private JButton okButton; + private final JButton okButton; boolean ok; JDialog dialog; - private EnumMap featureGrid = new EnumMap<>(FeatureObjectType.class); + private final EnumMap featureGrid = new EnumMap<>(FeatureObjectType.class); FeaturesConfigPanel() { setBorder(new EmptyBorder(GUIConstants.EMPTY_BORDER_INSETS, GUIConstants.EMPTY_BORDER_INSETS, @@ -121,9 +122,9 @@ boolean showDialog(Component parent, String title, FeatureExtractorConfig featur FeatureExtractorConfig getFeaturesConfig() { EnumSet enabledFeatures = EnumSet.noneOf(FeatureObjectType.class); - for (FeatureObjectType type : this.featureGrid.keySet()) { - if (this.featureGrid.get(type).isSelected()) { - enabledFeatures.add(type); + for (Map.Entry entry : this.featureGrid.entrySet()) { + if (entry.getValue().isSelected()) { + enabledFeatures.add(entry.getKey()); } } return FeatureFactory.configFromValues(enabledFeatures); diff --git a/gui/src/main/java/org/verapdf/gui/LogoPanel.java b/gui/src/main/java/org/verapdf/gui/LogoPanel.java index b75ebee7..7645dfd3 100644 --- a/gui/src/main/java/org/verapdf/gui/LogoPanel.java +++ b/gui/src/main/java/org/verapdf/gui/LogoPanel.java @@ -39,8 +39,8 @@ class LogoPanel extends JPanel { private static final long serialVersionUID = -3623071197419943686L; private final transient BufferedImage logo; - private int borderWidth; - private Color background; + private final int borderWidth; + private final Color background; LogoPanel(String logoName, Color backgroundColor, int borderWidth) throws IOException { this.borderWidth = borderWidth; diff --git a/gui/src/main/java/org/verapdf/gui/PDFValidationApplication.java b/gui/src/main/java/org/verapdf/gui/PDFValidationApplication.java index 3521ceb8..03292969 100644 --- a/gui/src/main/java/org/verapdf/gui/PDFValidationApplication.java +++ b/gui/src/main/java/org/verapdf/gui/PDFValidationApplication.java @@ -76,10 +76,10 @@ public class PDFValidationApplication extends JFrame { private AboutPanel aboutPanel; private SettingsPanel settingsPanel; - private FeaturesConfigPanel featuresPanel; + private final FeaturesConfigPanel featuresPanel; private CheckerPanel checkerPanel; - private VeraAppConfig config; - private PolicyPanel policyConfig; + private final VeraAppConfig config; + private final PolicyPanel policyConfig; private PDFValidationApplication(double frameScale) { setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); @@ -276,7 +276,7 @@ public void actionPerformed(ActionEvent e) { } else { JOptionPane.showMessageDialog( PDFValidationApplication.this, - String.format(Applications.UPDATE_LATEST_VERSION, "\n", details.getVersion()), + String.format(Applications.UPDATE_LATEST_VERSION, '\n', details.getVersion()), GUIConstants.CHECK_FOR_UPDATES_TEXT, JOptionPane.INFORMATION_MESSAGE); } @@ -369,7 +369,7 @@ public static void main(String[] args) { double frameScale = 1; if (args.length > 1 && "--frameScale".equals(args[0]) && args[1] != null) { try { - frameScale = Double.valueOf(args[1]); + frameScale = Double.parseDouble(args[1]); } catch (NumberFormatException e) { e.printStackTrace(); } diff --git a/gui/src/main/java/org/verapdf/gui/PartnersPanel.java b/gui/src/main/java/org/verapdf/gui/PartnersPanel.java index 345daab8..5fa272e8 100644 --- a/gui/src/main/java/org/verapdf/gui/PartnersPanel.java +++ b/gui/src/main/java/org/verapdf/gui/PartnersPanel.java @@ -47,10 +47,10 @@ class PartnersPanel extends JPanel { */ private static final long serialVersionUID = -5926089530817358566L; private final transient BufferedImage partnersLogo; - private Color background; - private JLabel consortium; - private JLabel preforma; - private JLabel version; + private final Color background; + private final JLabel consortium; + private final JLabel preforma; + private final JLabel version; PartnersPanel(String logoName, Color backgroundColor) throws IOException { try (InputStream is = getClass().getClassLoader().getResourceAsStream(logoName)) { diff --git a/gui/src/main/java/org/verapdf/gui/PolicyPanel.java b/gui/src/main/java/org/verapdf/gui/PolicyPanel.java index 86771666..3ab1f18c 100644 --- a/gui/src/main/java/org/verapdf/gui/PolicyPanel.java +++ b/gui/src/main/java/org/verapdf/gui/PolicyPanel.java @@ -51,23 +51,23 @@ public class PolicyPanel extends JPanel { private File policyFile; - private JButton okButton; + private final JButton okButton; private JDialog dialog; private boolean ok; - private JPanel mainPanel; - private JPanel assertionsPanel; - private LayoutManager mainPanelLayout; - private JScrollPane scrollPane; + private final JPanel mainPanel; + private final JPanel assertionsPanel; + private final LayoutManager mainPanelLayout; + private final JScrollPane scrollPane; - private List> featureTypes; - private List arguments; - private List> features; - private List> operations; - private List removeLineButtons; - private List layoutPanels; + private final List> featureTypes; + private final List arguments; + private final List> features; + private final List> operations; + private final List removeLineButtons; + private final List layoutPanels; - private JPanel buttonPanel; - private JButton addLineButton; + private final JPanel buttonPanel; + private final JButton addLineButton; public PolicyPanel() { setPreferredSize( @@ -87,7 +87,7 @@ public void actionPerformed(ActionEvent event) { if (PolicyPanel.this.okButton.hasFocus()) { JTextField emptyArguments = PolicyPanel.this.findEmptyNumberArguments(); if (emptyArguments == null) { - if (PolicyPanel.this.layoutPanels.size() > 0) { + if (!PolicyPanel.this.layoutPanels.isEmpty()) { org.verapdf.gui.PolicyPanel.this.ok = true; } org.verapdf.gui.PolicyPanel.this.dialog.setVisible(false); @@ -341,7 +341,7 @@ private boolean validateArgumentTextBox(JTextField argument, Feature.FeatureType if (type == Feature.FeatureType.NUMBER) { String argumentValue = argument.getText(); try { - if (argumentValue.length() > 0) { + if (!argumentValue.isEmpty()) { Double.valueOf(argumentValue); } } catch (NumberFormatException e) { @@ -372,7 +372,7 @@ private static Vector getFeatureObjectTypes() { Vector res = new Vector<>(); for (FeatureObjectType type : FeatureObjectType.values()) { List features = FeaturesStructureContainer.getFeaturesListForType(type); - if (!(features.size() == 1 && features.get(0).getFeatureName().equals(ERROR_IDS)) && features.size() != 0) { + if (!(features.size() == 1 && features.get(0).getFeatureName().equals(ERROR_IDS)) && !features.isEmpty()) { res.add(type); } } @@ -448,7 +448,7 @@ private static Insets getDefaultInsets() { return new Insets(2, 2, 2, 2); } - private class FeatureObjectTypeRenderer extends JLabel implements ListCellRenderer { + private static class FeatureObjectTypeRenderer extends JLabel implements ListCellRenderer { private static final long serialVersionUID = -8167306132255766422L; @Override @@ -472,7 +472,7 @@ private static void setOptimalSizeForComboBox(Component component) { GUIConstants.PREFERRED_POLICY_WINDOW_ELEMENT_HEIGHT)); } - private class FeatureRenderer extends JLabel implements ListCellRenderer { + private static class FeatureRenderer extends JLabel implements ListCellRenderer { private static final long serialVersionUID = 1669321048267902682L; @Override @@ -487,7 +487,7 @@ public Component getListCellRendererComponent(JList list, Fea } } - private class OperationsRenderer extends JLabel implements ListCellRenderer { + private static class OperationsRenderer extends JLabel implements ListCellRenderer { private static final long serialVersionUID = 8259625674253427340L; @Override diff --git a/gui/src/main/java/org/verapdf/gui/SettingsPanel.java b/gui/src/main/java/org/verapdf/gui/SettingsPanel.java index 3733ca6f..2044bfc4 100644 --- a/gui/src/main/java/org/verapdf/gui/SettingsPanel.java +++ b/gui/src/main/java/org/verapdf/gui/SettingsPanel.java @@ -65,23 +65,23 @@ class SettingsPanel extends JPanel { '|', '+', '\0', '%' }; private static final long serialVersionUID = -5688021756073449469L; - private JButton okButton; + private final JButton okButton; boolean ok; JDialog dialog; - private JTextField numberOfFailed; - private JTextField numberOfFailedDisplay; - private JCheckBox hidePassedRules; - private JCheckBox logs; - private JCheckBox showErrorMessages; - private JTextField fixMetadataPrefix; + private final JTextField numberOfFailed; + private final JTextField numberOfFailedDisplay; + private final JCheckBox hidePassedRules; + private final JCheckBox logs; + private final JCheckBox showErrorMessages; + private final JTextField fixMetadataPrefix; private PDFAFlavour currentDefaultFlavour; JTextField fixMetadataFolder; JFileChooser folderChooser; - private JTextField profilesWikiPath; + private final JTextField profilesWikiPath; private static final Map FLAVOURS_MAP = new HashMap<>(); private static final Map LOGGING_LEVELS_MAP = new HashMap<>(); - private JComboBox chooseDefaultFlavour; - private JComboBox chooseLoggingLevel; + private final JComboBox chooseDefaultFlavour; + private final JComboBox chooseLoggingLevel; SettingsPanel(final ConfigManager config) throws IOException { setBorder(new EmptyBorder(GUIConstants.EMPTY_BORDER_INSETS, GUIConstants.EMPTY_BORDER_INSETS, @@ -182,14 +182,13 @@ public void keyReleased(KeyEvent e) { panel.add(this.profilesWikiPath); panel.add(new JLabel("Default flavour:")); - Vector availableFlavours = new Vector<>(); SortedSet sortedFlavours = new TreeSet<>(); for (PDFAFlavour flavour : Profiles.getVeraProfileDirectory().getPDFAFlavours()) { String flavourReadableText = CheckerPanel.getFlavourReadableText(flavour); sortedFlavours.add(flavourReadableText); FLAVOURS_MAP.put(flavourReadableText, flavour); } - availableFlavours.addAll(sortedFlavours); + Vector availableFlavours = new Vector<>(sortedFlavours); this.chooseDefaultFlavour = new JComboBox<>(availableFlavours); this.chooseDefaultFlavour.setOpaque(true); ChooseFlavourRenderer renderer = new ChooseFlavourRenderer(); @@ -343,11 +342,11 @@ private static KeyAdapter getKeyAdapter(final JTextField field, final boolean fr public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if ((field.getText().length() == 6) - && ((field.getSelectedText() == null) || (field.getSelectedText().length() == 0)) + && ((field.getSelectedText() == null) || (field.getSelectedText().isEmpty())) && (c != KeyEvent.VK_BACK_SPACE) && (c != KeyEvent.VK_DELETE)) { e.consume(); } else if (c == '0' - && ((!fromZero && field.getText().length() == 0) || field.getText().startsWith("0"))) { + && ((!fromZero && field.getText().isEmpty()) || field.getText().startsWith("0"))) { e.consume(); } else if (!(((c >= '0') && (c <= '9')) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) { @@ -359,7 +358,7 @@ public void keyTyped(KeyEvent e) { public void keyReleased(KeyEvent e) { if (field.getText().startsWith("0")) { field.setText(field.getText().replaceFirst("0*", "")); - if (field.getText().length() == 0) { + if (field.getText().isEmpty()) { if (fromZero) { field.setText("0"); } else { @@ -390,12 +389,12 @@ Level getLoggingLevel() { int getFailedChecksNumber() { String str = this.numberOfFailed.getText(); - return str.length() > 0 ? Integer.parseInt(str) : -1; + return !str.isEmpty() ? Integer.parseInt(str) : -1; } int getFailedChecksDisplayNumber() { String str = this.numberOfFailedDisplay.getText(); - return str.length() > 0 ? Integer.parseInt(str) : -1; + return !str.isEmpty() ? Integer.parseInt(str) : -1; } Path getFixMetadataDirectory() { diff --git a/gui/src/main/java/org/verapdf/gui/ValidateWorker.java b/gui/src/main/java/org/verapdf/gui/ValidateWorker.java index 4c9995ff..5216a2e9 100644 --- a/gui/src/main/java/org/verapdf/gui/ValidateWorker.java +++ b/gui/src/main/java/org/verapdf/gui/ValidateWorker.java @@ -61,11 +61,11 @@ class ValidateWorker extends SwingWorker pdfs; - private ValidationProfile customProfile; - private File policy; - private CheckerPanel parent; - private ConfigManager configManager; + private final List pdfs; + private final ValidationProfile customProfile; + private final File policy; + private final CheckerPanel parent; + private final ConfigManager configManager; private File xmlReport = null; private File htmlReport = null; private ValidateWorkerSummary validateWorkerSummary = null; @@ -166,7 +166,7 @@ protected void done() { private void writeHtmlReport() { final String extension = "html"; - final String ext = "." + extension; + final String ext = '.' + extension; try { this.htmlReport = File.createTempFile("veraPDF-tempHTMLReport", ext); //$NON-NLS-1$ this.htmlReport.deleteOnExit(); @@ -203,8 +203,8 @@ private static int countFailedPolicyJobs(File xmlReport) throws XPathExpressionE return failedPolicyJobsCount; } - public class ValidateWorkerSummary { - private BatchSummary batchSummary; + public static class ValidateWorkerSummary { + private final BatchSummary batchSummary; private int policyNonCompliantJobCount = -1; public ValidateWorkerSummary(BatchSummary batchSummary, int policyNonCompliantJobCount) { diff --git a/gui/src/main/java/org/verapdf/gui/utils/DialogUtils.java b/gui/src/main/java/org/verapdf/gui/utils/DialogUtils.java index db2c390f..495da847 100644 --- a/gui/src/main/java/org/verapdf/gui/utils/DialogUtils.java +++ b/gui/src/main/java/org/verapdf/gui/utils/DialogUtils.java @@ -18,7 +18,7 @@ public final class DialogUtils { private DialogUtils() { - throw new AssertionError("Shoul'd never happen."); //$NON-NLS-1$ + throw new AssertionError("Should never happen."); //$NON-NLS-1$ } public static void errorDialog(final Component parent, final String message) { diff --git a/gui/src/main/java/org/verapdf/gui/utils/GUIConstants.java b/gui/src/main/java/org/verapdf/gui/utils/GUIConstants.java index 59a2c543..8b8cd907 100644 --- a/gui/src/main/java/org/verapdf/gui/utils/GUIConstants.java +++ b/gui/src/main/java/org/verapdf/gui/utils/GUIConstants.java @@ -68,7 +68,7 @@ public final class GUIConstants { public static final String CHOOSE_PROFILE_BUTTON_TEXT = "Choose Profile"; public static final String CHOOSE_POLICY_BUTTON_TEXT = "Choose Policy"; public static final String POLICY_TITLE = "Policy Creator"; - public static final String CHOOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT = "Validation profile not chosen"; + public static final String CHOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT = "Validation profile not chosen"; public static final String CUSTOM_PROFILE_COMBOBOX_TEXT = "Custom profile"; public static final String AUTO_FLAVOUR_COMBOBOX_TEXT = "Auto-detect"; public static final String OFF_LEVEL = "OFF"; @@ -92,7 +92,7 @@ public final class GUIConstants { public static final String SAVE_HTML_REPORT_BUTTON_TEXT = "Save HTML"; public static final String VIEW_HTML_REPORT_BUTTON_TEXT = "View HTML"; public static final String REPORT = "Report"; - public static final String ERROR_SAVING_REPORT = "Unresolvable problem occured when saving the %S report."; + public static final String ERROR_SAVING_REPORT = "Unresolvable problem occurred when saving the %S report."; public static final String IOEXCEP_OPENING_REPORT = "Could not open %s using the default Desktop application for %S file type. Please, try opening this file manually."; public static final String IOEXCEP_SAVING_REPORT = "IOException when saving the %S report."; public static final String LABEL_TEXT = " Choose a PDF and a PDF flavour or a custom validation profile, then press \"" + VALIDATE_BUTTON_TEXT + "\""; diff --git a/gui/src/test/java/org/verapdf/apps/SoftwareUpdaterTest.java b/gui/src/test/java/org/verapdf/apps/SoftwareUpdaterTest.java index 875883f1..446bcc75 100644 --- a/gui/src/test/java/org/verapdf/apps/SoftwareUpdaterTest.java +++ b/gui/src/test/java/org/verapdf/apps/SoftwareUpdaterTest.java @@ -19,7 +19,7 @@ */ public class SoftwareUpdaterTest { - SoftwareUpdater updater = Applications.softwareUpdater(); + final SoftwareUpdater updater = Applications.softwareUpdater(); /** * Test method for {@link org.verapdf.apps.SoftwareUpdaterImpl#getLatestAppsVersion()}. diff --git a/gui/src/test/java/org/verapdf/apps/utils/AppUtilsTest.java b/gui/src/test/java/org/verapdf/apps/utils/AppUtilsTest.java index 24352577..8e94862f 100644 --- a/gui/src/test/java/org/verapdf/apps/utils/AppUtilsTest.java +++ b/gui/src/test/java/org/verapdf/apps/utils/AppUtilsTest.java @@ -16,7 +16,7 @@ public class AppUtilsTest { @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + public final TemporaryFolder tempFolder = new TemporaryFolder(); @Test diff --git a/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java b/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java index afb0ca89..bdb60f23 100644 --- a/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java +++ b/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java @@ -50,7 +50,7 @@ */ @SuppressWarnings("static-method") public class VeraPdfCliProcessorTest { - private final static String APP_NAME = VeraPdfCliProcessorTest.class.getName(); + private static final String APP_NAME = VeraPdfCliProcessorTest.class.getName(); /** * Test method for @@ -65,19 +65,18 @@ public class VeraPdfCliProcessorTest { public final void testCreateProcessorFromArgsFormat() throws IOException, VeraPDFException { VeraCliArgParser parser = new VeraCliArgParser(); JCommander jCommander = initialiseJCommander(parser); - jCommander.parse(new String[] {}); + jCommander.parse(); ConfigManager manager = Applications.createConfigManager(Files.createTempDirectory("").toFile()); try (VeraPdfCliProcessor proc = VeraPdfCliProcessor.createProcessorFromArgs(parser, manager)) { assertNotNull(proc.getConfig()); - assertTrue(proc.getConfig().getFormat() == FormatOption.XML); + assertSame(proc.getConfig().getFormat(), FormatOption.XML); } for (FormatOption format : FormatOption.values()) { parser = new VeraCliArgParser(); jCommander = initialiseJCommander(parser); - jCommander.parse(new String[] { "--format", format.getOption() }); + jCommander.parse("--format", format.getOption()); try (VeraPdfCliProcessor proc = VeraPdfCliProcessor.createProcessorFromArgs(parser, manager)) { - assertTrue("Expected:" + format + " == " + proc.getConfig().getFormat(), - proc.getConfig().getFormat() == format); + assertSame("Expected:" + format + " == " + proc.getConfig().getFormat(), proc.getConfig().getFormat(), format); } } } @@ -96,13 +95,13 @@ public final void testCreateProcessorFromArgsLogPassed() throws VeraPDFException String[] argVals = new String[] { "--passed", "--success" }; VeraCliArgParser parser = new VeraCliArgParser(); JCommander jCommander = initialiseJCommander(parser); - jCommander.parse(new String[] {}); + jCommander.parse(); ConfigManager manager = Applications.createConfigManager(Files.createTempDirectory("").toFile()); try (VeraPdfCliProcessor proc = VeraPdfCliProcessor.createProcessorFromArgs(parser, manager)) { assertFalse(proc.getProcessorConfig().getValidatorConfig().isRecordPasses()); } for (String argVal : argVals) { - jCommander.parse(new String[] { argVal }); + jCommander.parse(argVal); try (VeraPdfCliProcessor proc = VeraPdfCliProcessor.createProcessorFromArgs(parser, manager)) { assertTrue(proc.getProcessorConfig().getValidatorConfig().isRecordPasses()); } @@ -215,7 +214,7 @@ public final void testCreateProcessorFromArgsFlavour() throws IOException, VeraP assertSame(PDFAFlavour.NO_FLAVOUR, proc.getProcessorConfig().getValidatorConfig().getFlavour()); } ProfileDirectory directory = Profiles.getVeraProfileDirectory(); - assertTrue(directory.getValidationProfiles().size() > 0); + assertTrue(!directory.getValidationProfiles().isEmpty()); for (String argVal : argVals) { for (ValidationProfile profile : directory.getValidationProfiles()) { jCommander.parse(argVal, profile.getPDFAFlavour().getId()); diff --git a/gui/src/test/java/org/verapdf/cli/commands/VerCliFlavourTest.java b/gui/src/test/java/org/verapdf/cli/commands/VerCliFlavourTest.java index 3a3cde85..c6581042 100644 --- a/gui/src/test/java/org/verapdf/cli/commands/VerCliFlavourTest.java +++ b/gui/src/test/java/org/verapdf/cli/commands/VerCliFlavourTest.java @@ -29,7 +29,6 @@ import org.verapdf.pdfa.flavours.PDFAFlavour; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; /** * @author Carl Wilson diff --git a/gui/src/test/java/org/verapdf/cli/commands/VeraCliArgParserTest.java b/gui/src/test/java/org/verapdf/cli/commands/VeraCliArgParserTest.java index 39859139..89f9ed02 100644 --- a/gui/src/test/java/org/verapdf/cli/commands/VeraCliArgParserTest.java +++ b/gui/src/test/java/org/verapdf/cli/commands/VeraCliArgParserTest.java @@ -39,7 +39,7 @@ */ @SuppressWarnings("static-method") public class VeraCliArgParserTest { - private final static String APP_NAME = VeraCliArgParserTest.class.getName(); + private static final String APP_NAME = VeraCliArgParserTest.class.getName(); /** * Test method for diff --git a/gui/src/test/java/org/verapdf/cli/commands/VeraCliFormatTest.java b/gui/src/test/java/org/verapdf/cli/commands/VeraCliFormatTest.java index 6ace7c01..4ec4c06d 100644 --- a/gui/src/test/java/org/verapdf/cli/commands/VeraCliFormatTest.java +++ b/gui/src/test/java/org/verapdf/cli/commands/VeraCliFormatTest.java @@ -24,7 +24,6 @@ package org.verapdf.cli.commands; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import org.junit.Test; import org.verapdf.processor.FormatOption; diff --git a/gui/src/test/java/org/verapdf/cli/commands/VeraCliTasksTest.java b/gui/src/test/java/org/verapdf/cli/commands/VeraCliTasksTest.java index b95679c2..c0b4c482 100644 --- a/gui/src/test/java/org/verapdf/cli/commands/VeraCliTasksTest.java +++ b/gui/src/test/java/org/verapdf/cli/commands/VeraCliTasksTest.java @@ -27,7 +27,6 @@ import org.junit.Test; import org.verapdf.apps.Applications; import org.verapdf.core.VeraPDFException; -import org.verapdf.features.FeatureFactory; import org.verapdf.processor.ProcessorConfig; import org.verapdf.processor.TaskType; import org.verapdf.processor.plugins.PluginsCollectionConfig; diff --git a/pdfbox-apps/src/main/java/org/verapdf/apps/PdfBoxGuiWrapper.java b/pdfbox-apps/src/main/java/org/verapdf/apps/PdfBoxGuiWrapper.java index 9b66f6b9..aa543cdf 100644 --- a/pdfbox-apps/src/main/java/org/verapdf/apps/PdfBoxGuiWrapper.java +++ b/pdfbox-apps/src/main/java/org/verapdf/apps/PdfBoxGuiWrapper.java @@ -28,7 +28,7 @@ private PdfBoxGuiWrapper() { * @param args */ public static void main(String[] args) { - // Initialiser PDF Box Foundry + // Initializer PDF Box Foundry PdfBoxFoundryProvider.initialise(); PDFValidationApplication.main(args); } diff --git a/pdfbox-apps/src/test/java/org/verapdf/processor/test/ProcessorImplProfileTest.java b/pdfbox-apps/src/test/java/org/verapdf/processor/test/ProcessorImplProfileTest.java index 6a80bf74..678d748d 100644 --- a/pdfbox-apps/src/test/java/org/verapdf/processor/test/ProcessorImplProfileTest.java +++ b/pdfbox-apps/src/test/java/org/verapdf/processor/test/ProcessorImplProfileTest.java @@ -64,7 +64,7 @@ public final void testCreateProcessorFromArgsNewProfile() JAXBException { PdfBoxFoundryProvider.initialise(); ProfileDirectory directory = Profiles.getVeraProfileDirectory(); - assertTrue(directory.getValidationProfiles().size() > 0); + assertTrue(!directory.getValidationProfiles().isEmpty()); for (ValidationProfile profile : directory.getValidationProfiles()) { File tmpProfile = File.createTempFile("verapdf", "profile"); try (OutputStream os = new FileOutputStream(tmpProfile)) { @@ -78,12 +78,12 @@ public final void testCreateProcessorFromArgsNewProfile() } private static void testWithProfileFile(final PDFAFlavour flavour, - final File profileFile) throws FileNotFoundException, IOException, JAXBException { + final File profileFile) throws IOException, JAXBException { try (InputStream is = new FileInputStream(profileFile)) { ValidationProfile profile = Profiles.profileFromXml(is); ProcessorConfig config = ProcessorFactory.fromValues(ValidatorFactory.defaultConfig(), FeatureFactory.defaultConfig(), PluginsCollectionConfig.defaultConfig(), FixerFactory.defaultConfig(), EnumSet.noneOf(TaskType.class), profile); assertEquals(flavour, ProcessorFactory.fileBatchProcessor(config).getConfig().getCustomProfile().getPDFAFlavour()); - assertTrue(profile.equals(ProcessorFactory.fileBatchProcessor(config).getConfig().getCustomProfile())); + assertEquals(profile, ProcessorFactory.fileBatchProcessor(config).getConfig().getCustomProfile()); } } }