private PitError createPitErrorForExceptionOnClass(final Exception ex, final ClientClasspathPlugin clazz) { return new PitError("Error getting location of class " + clazz, ex); } };
private static String createInputString(final List<String> inputArguments) { final StringBuilder sb = new StringBuilder(); FCollection.fold(append(), sb, inputArguments); return sb.toString(); }
public PitError(final String message) { super(message + info()); }
private static String info() { final RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); return "\n\nPlease copy and paste the information and the complete stacktrace below when reporting an issue\n" + "VM : " + rt.getVmName() + "\n" + "Vendor : " + rt.getVmVendor() + "\n" + "Version : " + rt.getVmVersion() + "\n" + "Uptime : " + rt.getUptime() + "\n" + "Input -> " + createInputString(rt.getInputArguments()) + "\n" + "BootClassPathSupported : " + rt.isBootClassPathSupported() + "\n"; }
private static String info() { final RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); return "\n\nPlease copy and paste the information and the complete stacktrace below when reporting an issue\n" + "VM : " + rt.getVmName() + "\n" + "Vendor : " + rt.getVmVendor() + "\n" + "Version : " + rt.getVmVersion() + "\n" + "Uptime : " + rt.getUptime() + "\n" + "Input -> " + createInputString(rt.getInputArguments()) + "\n" + "BootClassPathSupported : " + rt.isBootClassPathSupported() + "\n"; }
public static RuntimeException translateCheckedException( final String message, final Throwable ex) { return new PitError(message, ex); }
public PitError(final String message, final Throwable cause) { super(message + info(), cause); }
private static String createInputString(final List<String> inputArguments) { final StringBuilder sb = new StringBuilder(); FCollection.fold(append(), sb, inputArguments); return sb.toString(); }
public static RuntimeException translateCheckedException(final Throwable ex) { return new PitError(ex.getMessage(), ex); }
public PitError(final String message, final Throwable cause) { super(message + info(), cause); }
private static Function<String, File> stringToCanonicalFile() { return fileAsString -> { try { return new File(fileAsString).getCanonicalFile(); } catch (final IOException ex) { throw new PitError("Error transforming classpath element " + fileAsString, ex); } }; }
public PitError(final String message) { super(message + info()); }
private void reportBadPlugin(final String missingProperty, final ClientClasspathPlugin a) { final Class<?> clss = a.getClass(); throw new PitError("No implementation " + missingProperty + " in manifest of plugin jar for " + clss + " in " + clss.getProtectionDomain().getCodeSource().getLocation()); }
private static <T> T firstOrDefault(final Collection<? extends T> found, final T defaultInstance) { if (found.isEmpty()) { return defaultInstance; } if (found.size() > 1) { throw new PitError( "Multiple implementations of plugin detected on classpath"); } return found.iterator().next(); }
private static <S> S createService(final String name, final Class<S> ifc, final ClassLoader loader) { try { final Class<?> clz = Class.forName(name, true, loader); final Class<? extends S> impl = clz.asSubclass(ifc); final Constructor<? extends S> ctor = impl.getConstructor(); return ctor.newInstance(); } catch (final Exception ex) { throw new PitError("Error creating service " + ifc.getName(), ex); } }
public static <S> Collection<S> load(final Class<S> ifc, final ClassLoader loader) { try { return loadImpl(ifc, loader); } catch (final IOException ex) { throw new PitError("Error creating service " + ifc.getName(), ex); } }
private byte[] classBytes(final String className) { final Optional<byte[]> bytes = this.classByteSource.getBytes(className); if (bytes.isPresent()) { return bytes.get(); } throw new PitError("Unable to load class content for " + className); }
private ReportGenerationStrategy locateReportGenerationStrategy( String sourceDataFormat) { for (ReportGenerationStrategy strategy : this.reportGenerationStrategyList) { if (sourceDataFormat.equalsIgnoreCase(strategy.getGeneratorDataFormat())) { return strategy; } } throw new PitError("Could not locate report generator for data source [" + sourceDataFormat + "]"); }
private void checkMatrixMode(ReportOptions data) { if (data.isFullMutationMatrix() && !data.getOutputFormats().contains("XML")) { throw new PitError("Full mutation matrix is only supported in the output format XML."); } }