public String getTotalCoveragePercentAsString(){ return getTotalCoveragePercent() + "%"; }
public void generateJsonReport(final ProjectType projectType, final String statusCode) { final ImmutableStatistics.Builder statisticsBuilder = ImmutableStatistics.builder() .projectType(projectType.getName()) .scriptCount(totalScriptNumber) .statusCode(statusCode) .durationInMillis(totalDurationInMills) .conversionRatePercent(functionsCounter.getTotalCoveragePercent()) .supportedFunctionsNoWarnCount(functionsCounter.getSupportedFunctionsNoWarnCount()) .supportedFunctionsWarnCount(functionsCounter.getSupportedFunctionsWarnCount()) .unsupportedFunctionsCount(functionsCounter.getUnsupportedFunctionsCount()); functionsCounter.getTotalOccurencePerName().entrySet().stream() .map(e -> ImmutableFunctionStat.builder().name(e.getKey()).count(e.getValue()).build()) .forEach(statisticsBuilder::addUnsupportedFunctions); final Statistics statistics = statisticsBuilder.build(); final Gson gson = new GsonBuilder() .registerTypeAdapterFactory(new GsonAdaptersFunctionStat()) .registerTypeAdapterFactory(new GsonAdaptersStatistics()) .create(); final String reportFileName = destFolder + File.separator + nlProjectName + File.separator + "statistics.json"; new File(reportFileName).getParentFile().mkdirs(); try (final Writer writer = new FileWriter(reportFileName)) { gson.toJson(statistics, writer); } catch (final IOException e) { LIVE_OUT.error("Error while generating JSON report.", e); } }