@Test public void saveScreenshot_should_save_file_and_return_correct_url() throws IOException { Path tempDirectory = null; try { tempDirectory = Files.createTempDirectory("ara_temp_unit_test_directory_"); when(araConfiguration.getFileHomeFolder()).thenReturn(tempDirectory.toString()); when(araConfiguration.getFileScreenshotSubFolder()).thenReturn("/directory"); when(araConfiguration.getFileHttpAccess()).thenReturn("http: when(fileNameService.generateReportFileName("Scenario Name", "png")).thenReturn("file"); byte[] screenshot = new byte[] { 0, 1, 2 }; final String url = cut.saveScreenshot(screenshot, "Scenario Name"); assertThat(url).isEqualTo("http: final String filePath = tempDirectory + "/directory/file"; assertThat(new File(filePath).length()).isEqualTo(3); } finally { if (tempDirectory != null) { FileUtils.deleteQuietly(tempDirectory.toFile()); } } }
@Override public String saveScreenshot(byte[] screenshot, String scenarioName) { try { final String subFolder = araConfiguration.getFileScreenshotSubFolder(); final String absoluteFolderPath = araConfiguration.getFileHomeFolder() + subFolder; final String fileName = fileNameService.generateReportFileName(scenarioName, "png"); final File file = new File(absoluteFolderPath + File.separator + fileName); FileUtils.writeByteArrayToFile(file, screenshot); return araConfiguration.getFileHttpAccess() + subFolder + "/" + fileName; } catch (IOException e) { log.error("Screenshot saving failed: {}", e.getMessage(), e); return null; } }
FileAssetService implements AssetService { @Override public String saveScreenshot(byte[] screenshot, String scenarioName) { try { final String subFolder = araConfiguration.getFileScreenshotSubFolder(); final String absoluteFolderPath = araConfiguration.getFileHomeFolder() + subFolder; final String fileName = fileNameService.generateReportFileName(scenarioName, "png"); final File file = new File(absoluteFolderPath + File.separator + fileName); FileUtils.writeByteArrayToFile(file, screenshot); return araConfiguration.getFileHttpAccess() + subFolder + "/" + fileName; } catch (IOException e) { log.error("Screenshot saving failed: {}", e.getMessage(), e); return null; } } }
FileAssetService implements AssetService { @Override public String saveScreenshot(byte[] screenshot, String scenarioName) { try { final String subFolder = araConfiguration.getFileScreenshotSubFolder(); final String absoluteFolderPath = araConfiguration.getFileHomeFolder() + subFolder; final String fileName = fileNameService.generateReportFileName(scenarioName, "png"); final File file = new File(absoluteFolderPath + File.separator + fileName); FileUtils.writeByteArrayToFile(file, screenshot); return araConfiguration.getFileHttpAccess() + subFolder + "/" + fileName; } catch (IOException e) { log.error("Screenshot saving failed: {}", e.getMessage(), e); return null; } }  }
FileAssetService implements AssetService { @Override public String saveScreenshot(byte[] screenshot, String scenarioName) { try { final String subFolder = araConfiguration.getFileScreenshotSubFolder(); final String absoluteFolderPath = araConfiguration.getFileHomeFolder() + subFolder; final String fileName = fileNameService.generateReportFileName(scenarioName, "png"); final File file = new File(absoluteFolderPath + File.separator + fileName); FileUtils.writeByteArrayToFile(file, screenshot); return araConfiguration.getFileHttpAccess() + subFolder + "/" + fileName; } catch (IOException e) { log.error("Screenshot saving failed: {}", e.getMessage(), e); return null; } }  @Override String saveScreenshot(byte[] screenshot, String scenarioName); @Override String saveHttpLogs(String html); }
FileAssetService implements AssetService { @Override public String saveScreenshot(byte[] screenshot, String scenarioName) { try { final String subFolder = araConfiguration.getFileScreenshotSubFolder(); final String absoluteFolderPath = araConfiguration.getFileHomeFolder() + subFolder; final String fileName = fileNameService.generateReportFileName(scenarioName, "png"); final File file = new File(absoluteFolderPath + File.separator + fileName); FileUtils.writeByteArrayToFile(file, screenshot); return araConfiguration.getFileHttpAccess() + subFolder + "/" + fileName; } catch (IOException e) { log.error("Screenshot saving failed: {}", e.getMessage(), e); return null; } }  @Override String saveScreenshot(byte[] screenshot, String scenarioName); @Override String saveHttpLogs(String html);  }