@Test public void reportGenerator_retunrIsTrue(){ AccessingPeripheralResult access = new AccessingPeripheralResult(); access.setResultType(BPResultType.PASS); CacheControlResult cache = new CacheControlResult(); cache.setResultType(BPResultType.FAIL); List<AbstractBestPracticeResult> bpResults = new ArrayList<AbstractBestPracticeResult>(); bpResults.add(access); bpResults.add(cache); File tempFile = null; try { tempFile = folder.newFile("abc.html"); } catch (IOException e) { e.printStackTrace(); } if(tempFile != null) { tempFile.deleteOnExit(); } when(filereader.createFile(any(String.class))).thenReturn(tempFile); AROTraceData results = new AROTraceData(); PacketAnalyzerResult analyzerResult = new PacketAnalyzerResult(); TraceDirectoryResult tracedirresult = new TraceDirectoryResult(); EnergyModel energyModel = new EnergyModel(); Statistic statistic = new Statistic(); statistic.setTotalByte(123); statistic.setTotalHTTPSByte(123); tracedirresult.setTraceDirectory("temp.txt"); analyzerResult.setTraceresult(tracedirresult); analyzerResult.setEnergyModel(energyModel); analyzerResult.setStatistic(statistic); results.setAnalyzerResult(analyzerResult); results.setBestPracticeResults(bpResults); assertTrue(htmlReportImpl.reportGenerator("abc.html", results)); }
@Override public boolean reportGenerator(String resultFilePath, AROTraceData results) { if (results == null) { return false; } PacketAnalyzerResult analyzerResults = results.getAnalyzerResult(); List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults(); StringBuffer htmlString = new StringBuffer(200); htmlString.append(getHtmlHead()); htmlString.append(" <body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" <table class='table'>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(getTableHeader(analyzerResults)); htmlString.append(getTraceRows(analyzerResults)); htmlString.append(getBPSummaryRows(bpResults)); htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n"); htmlString.append(getBpRows(bpResults)); htmlString.append(" </table>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" </body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append("</html>"); try { File file = filereader.createFile(resultFilePath); PrintWriter writer = new PrintWriter(file); writer.println(htmlString.toString()); writer.close(); return true; } catch (IOException e) { LOGGER.info("IOException: "+e); } return false; }
HtmlReportImpl implements IReport { @Override public boolean reportGenerator(String resultFilePath, AROTraceData results) { if (results == null) { return false; } PacketAnalyzerResult analyzerResults = results.getAnalyzerResult(); List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults(); StringBuffer htmlString = new StringBuffer(200); htmlString.append(getHtmlHead()); htmlString.append(" <body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" <table class='table'>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(getTableHeader(analyzerResults)); htmlString.append(getTraceRows(analyzerResults)); htmlString.append(getBPSummaryRows(bpResults)); htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n"); htmlString.append(getBpRows(bpResults)); htmlString.append(" </table>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" </body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append("</html>"); try { File file = filereader.createFile(resultFilePath); PrintWriter writer = new PrintWriter(file); writer.println(htmlString.toString()); writer.close(); return true; } catch (IOException e) { LOGGER.info("IOException: "+e); } return false; } }
HtmlReportImpl implements IReport { @Override public boolean reportGenerator(String resultFilePath, AROTraceData results) { if (results == null) { return false; } PacketAnalyzerResult analyzerResults = results.getAnalyzerResult(); List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults(); StringBuffer htmlString = new StringBuffer(200); htmlString.append(getHtmlHead()); htmlString.append(" <body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" <table class='table'>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(getTableHeader(analyzerResults)); htmlString.append(getTraceRows(analyzerResults)); htmlString.append(getBPSummaryRows(bpResults)); htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n"); htmlString.append(getBpRows(bpResults)); htmlString.append(" </table>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" </body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append("</html>"); try { File file = filereader.createFile(resultFilePath); PrintWriter writer = new PrintWriter(file); writer.println(htmlString.toString()); writer.close(); return true; } catch (IOException e) { LOGGER.info("IOException: "+e); } return false; }  }
HtmlReportImpl implements IReport { @Override public boolean reportGenerator(String resultFilePath, AROTraceData results) { if (results == null) { return false; } PacketAnalyzerResult analyzerResults = results.getAnalyzerResult(); List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults(); StringBuffer htmlString = new StringBuffer(200); htmlString.append(getHtmlHead()); htmlString.append(" <body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" <table class='table'>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(getTableHeader(analyzerResults)); htmlString.append(getTraceRows(analyzerResults)); htmlString.append(getBPSummaryRows(bpResults)); htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n"); htmlString.append(getBpRows(bpResults)); htmlString.append(" </table>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" </body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append("</html>"); try { File file = filereader.createFile(resultFilePath); PrintWriter writer = new PrintWriter(file); writer.println(htmlString.toString()); writer.close(); return true; } catch (IOException e) { LOGGER.info("IOException: "+e); } return false; }  @Override boolean reportGenerator(String resultFilePath,
			AROTraceData results); String removeHtmlCharacter(String text ,String htmlCharacter); }
HtmlReportImpl implements IReport { @Override public boolean reportGenerator(String resultFilePath, AROTraceData results) { if (results == null) { return false; } PacketAnalyzerResult analyzerResults = results.getAnalyzerResult(); List<AbstractBestPracticeResult> bpResults = results.getBestPracticeResults(); StringBuffer htmlString = new StringBuffer(200); htmlString.append(getHtmlHead()); htmlString.append(" <body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" <table class='table'>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(getTableHeader(analyzerResults)); htmlString.append(getTraceRows(analyzerResults)); htmlString.append(getBPSummaryRows(bpResults)); htmlString.append("<tr><th></th><td></td></tr><tr><th>Best Practices Results</th><td></td></tr>\n"); htmlString.append(getBpRows(bpResults)); htmlString.append(" </table>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(System.getProperty(lineSeperator())); htmlString.append(" </body>"); htmlString.append(System.getProperty(lineSeperator())); htmlString.append("</html>"); try { File file = filereader.createFile(resultFilePath); PrintWriter writer = new PrintWriter(file); writer.println(htmlString.toString()); writer.close(); return true; } catch (IOException e) { LOGGER.info("IOException: "+e); } return false; }  @Override boolean reportGenerator(String resultFilePath,
			AROTraceData results); String removeHtmlCharacter(String text ,String htmlCharacter);  }