From 93a12eba4448ed5f87ae45de20c8a2fc9c0e7173 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 | 4 +-- .../verapdf/apps/utils/ApplicationUtils.java | 2 +- .../java/org/verapdf/cli/CliConstants.java | 2 -- .../main/java/org/verapdf/cli/VeraPdfCli.java | 2 +- .../cli/multithread/MultiThreadProcessor.java | 12 +++---- .../main/java/org/verapdf/gui/AboutPanel.java | 2 +- .../java/org/verapdf/gui/CheckerPanel.java | 24 +++++++------- .../org/verapdf/gui/FeaturesConfigPanel.java | 4 +-- .../main/java/org/verapdf/gui/LogoPanel.java | 4 +-- .../verapdf/gui/PDFValidationApplication.java | 8 ++--- .../java/org/verapdf/gui/PartnersPanel.java | 8 ++--- .../java/org/verapdf/gui/PolicyPanel.java | 32 +++++++++---------- .../java/org/verapdf/gui/SettingsPanel.java | 23 +++++++------ .../java/org/verapdf/gui/ValidateWorker.java | 14 ++++---- .../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 | 13 ++++---- .../cli/commands/VerCliFlavourTest.java | 1 - .../cli/commands/VeraCliFormatTest.java | 1 - .../cli/commands/VeraCliTasksTest.java | 1 - .../org/verapdf/apps/PdfBoxGuiWrapper.java | 2 +- .../test/ProcessorImplProfileTest.java | 4 +-- 28 files changed, 86 insertions(+), 96 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..ea4aa321 100644 --- a/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java +++ b/gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java @@ -32,8 +32,8 @@ 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 final static String latestGF = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:greenfield-apps&core=gav&rows=1&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=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..eb9186cd 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 */ 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/VeraPdfCli.java b/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java index 40dce45b..31ffee08 100644 --- a/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java +++ b/gui/src/main/java/org/verapdf/cli/VeraPdfCli.java @@ -116,7 +116,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$ 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..7e736e53 100644 --- a/gui/src/main/java/org/verapdf/gui/CheckerPanel.java +++ b/gui/src/main/java/org/verapdf/gui/CheckerPanel.java @@ -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; @@ -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); @@ -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; diff --git a/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java b/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java index 4c7de5c5..de94a11a 100644 --- a/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java +++ b/gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java @@ -45,10 +45,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, 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..9f03f420 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); @@ -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..eade291e 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( @@ -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..30676e77 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(); diff --git a/gui/src/main/java/org/verapdf/gui/ValidateWorker.java b/gui/src/main/java/org/verapdf/gui/ValidateWorker.java index 4c9995ff..b7d858b0 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; @@ -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..fd167176 100644 --- a/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java +++ b/gui/src/test/java/org/verapdf/cli/VeraPdfCliProcessorTest.java @@ -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()); } 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/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..d8236c17 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 @@ -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()); } } }