@Test public void testGetMessage() throws Exception { final String baseMessage = "baseMessage"; final Exception baseError = new Exception(baseMessage); final Function<String, String> expectMessage = prefix -> prefix + baseError.getClass().getName() + ": " + baseError.getMessage(); AbortedScanException aseNoPackage = new AbortedScanException(baseError); assertEquals("no package has base message", expectMessage.apply(""), aseNoPackage.getMessage()); File file = TestPackageUtil.prepareTestPackage("package_1.0.zip"); AbortedScanException aseFile = new AbortedScanException(baseError, file); assertEquals("file package package has prefix", expectMessage.apply("(Failed package: " + file.getAbsolutePath() + ") "), aseFile.getMessage()); final URL url = file.toURI().toURL(); AbortedScanException aseUrl = new AbortedScanException(baseError, url); assertEquals("url package package has prefix", expectMessage.apply("(Failed package: " + url.toString() + ") "), aseUrl.getMessage()); Node node = mock(Node.class); final String path = "/etc/packages/correct/path"; when(node.getPath()).thenReturn(path); AbortedScanException aseNode = new AbortedScanException(baseError, node); assertEquals("node package package has prefix", expectMessage.apply("(Failed package: " + path + ") "), aseNode.getMessage()); }
@Override public String getMessage() { return getFailedPackageMessage() + super.getMessage(); }
AbortedScanException extends Exception { @Override public String getMessage() { return getFailedPackageMessage() + super.getMessage(); } }
AbortedScanException extends Exception { @Override public String getMessage() { return getFailedPackageMessage() + super.getMessage(); } AbortedScanException(final Throwable cause, final File currentPackageFile);  AbortedScanException(final Throwable cause, final URL currentPackageUrl);  AbortedScanException(final Throwable cause, final Node currentPackageNode);  AbortedScanException(Throwable cause); }
AbortedScanException extends Exception { @Override public String getMessage() { return getFailedPackageMessage() + super.getMessage(); } AbortedScanException(final Throwable cause, final File currentPackageFile);  AbortedScanException(final Throwable cause, final URL currentPackageUrl);  AbortedScanException(final Throwable cause, final Node currentPackageNode);  AbortedScanException(Throwable cause); @SuppressWarnings("WeakerAccess") Optional<URL> getCurrentPackageUrl(); Optional<File> getCurrentPackageFile(); @SuppressWarnings("WeakerAccess") Optional<Node> getCurrentPackageNode(); @Override String getMessage(); @SuppressWarnings({"WeakerAccess", "OptionalGetWithoutIsPresent"}) String getFailedPackageMessage(); }
AbortedScanException extends Exception { @Override public String getMessage() { return getFailedPackageMessage() + super.getMessage(); } AbortedScanException(final Throwable cause, final File currentPackageFile);  AbortedScanException(final Throwable cause, final URL currentPackageUrl);  AbortedScanException(final Throwable cause, final Node currentPackageNode);  AbortedScanException(Throwable cause); @SuppressWarnings("WeakerAccess") Optional<URL> getCurrentPackageUrl(); Optional<File> getCurrentPackageFile(); @SuppressWarnings("WeakerAccess") Optional<Node> getCurrentPackageNode(); @Override String getMessage(); @SuppressWarnings({"WeakerAccess", "OptionalGetWithoutIsPresent"}) String getFailedPackageMessage();  }