private void generateReports ( String outputDirectory ) { logger . entering ( outputDirectory ) ; ClassLoader localClassLoader = this . getClass ( ) . getClassLoader ( ) ; try ( BufferedWriter writer = new BufferedWriter ( new FileWriter ( outputDirectory + File . separator + "index.html" ) ) ; BufferedWriter jsonWriter = new BufferedWriter ( new FileWriter ( outputDirectory + File . separator + "report.json" ) ) ; BufferedReader templateReader = new BufferedReader ( new InputStreamReader ( localClassLoader . getResourceAsStream ( "templates/RuntimeReporter/index.html" ) ) ) ; ) { JsonObject reporter = buildJSONReport ( ) ; Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; String jsonReport = gson . toJson ( reporter ) ; jsonWriter . write ( jsonReport ) ; jsonWriter . newLine ( ) ; generateHTMLReport ( writer , templateReader , jsonReport ) ; } catch ( IOException | JsonParseException e ) { logger . log ( Level . SEVERE , e . getMessage ( ) , e ) ; throw new ReporterException ( e ) ; } logger . exiting ( ) ; }
Generate JSON report and HTML report