public StepObject(String location) { if (StringUtils.isEmpty(location)) { throw new ValidationException("Location cannnot be null!"); } this.location = location; }
public StepObject(String location) { if (StringUtils.isEmpty(location)) { throw new ValidationException("Location cannnot be null!"); } this.location = location; }
private static Trends loadTrends(File file) { try (Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) { return mapper.readValue(reader, Trends.class); } catch (JsonMappingException e) { throw new ValidationException(String.format("File '%s' could not be parsed as file with trends!", file), e); } catch (IOException e) { // IO problem - stop generating and re-throw the problem throw new ValidationException(e); } }
private static Trends loadTrends(File file) { try (Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) { return mapper.readValue(reader, Trends.class); } catch (JsonMappingException e) { throw new ValidationException(String.format("File '%s' could not be parsed as file with trends!", file), e); } catch (IOException e) { // IO problem - stop generating and re-throw the problem throw new ValidationException(e); } }
/** * Stores the regex patterns to be used for filtering out tags from the 'Tags Overview' chart * * @param patterns Regex patterns to match against tags * @throws ValidationException when any of the given strings is not a valid regex pattern. */ public void setTagsToExcludeFromChart(String... patterns) { for (String pattern : patterns) { try { tagsToExcludeFromChart.add(Pattern.compile(pattern)); } catch (PatternSyntaxException e) { throw new ValidationException(e); } } }
/** * Stores the regex patterns to be used for filtering out tags from the 'Tags Overview' chart * * @param patterns Regex patterns to match against tags * @throws ValidationException when any of the given strings is not a valid regex pattern. */ public void setTagsToExcludeFromChart(String... patterns) { for (String pattern : patterns) { try { tagsToExcludeFromChart.add(Pattern.compile(pattern)); } catch (PatternSyntaxException e) { throw new ValidationException(e); } } }
public TagObject(String tagName) { if (StringUtils.isEmpty(tagName)) { throw new ValidationException("TagName cannot be null!"); } this.tagName = tagName; this.reportFileName = Tag.generateFileName(tagName); }
public TagObject(String tagName) { if (StringUtils.isEmpty(tagName)) { throw new ValidationException("TagName cannot be null!"); } this.tagName = tagName; this.reportFileName = Tag.generateFileName(tagName); }
private void saveTrends(Trends trends, File file) { ObjectWriter objectWriter = mapper.writer().with(SerializationFeature.INDENT_OUTPUT); try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { objectWriter.writeValue(writer, trends); wasTrendsFileSaved = true; } catch (IOException e) { wasTrendsFileSaved = false; throw new ValidationException("Could not save updated trends in file: " + file.getAbsolutePath(), e); } }
private void saveTrends(Trends trends, File file) { ObjectWriter objectWriter = mapper.writer().with(SerializationFeature.INDENT_OUTPUT); try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { objectWriter.writeValue(writer, trends); wasTrendsFileSaved = true; } catch (IOException e) { wasTrendsFileSaved = false; throw new ValidationException("Could not save updated trends in file: " + file.getAbsolutePath(), e); } }
/** * Reads passed file and returns parsed features. * * @param jsonFile * JSON file that should be read * @return array of parsed features */ private Feature[] parseForFeature(String jsonFile) { try (Reader reader = new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8)) { Feature[] features = mapper.readValue(reader, Feature[].class); if (ArrayUtils.isEmpty(features)) { LOG.log(Level.INFO, String.format("File '%s' does not contain features", jsonFile)); } return features; } catch (JsonMappingException e) { throw new ValidationException(String.format("File '%s' is not proper Cucumber report!", jsonFile), e); } catch (IOException e) { // IO problem - stop generating and re-throw the problem throw new ValidationException(e); } }
/** * Reads passed file and returns parsed features. * * @param jsonFile * JSON file that should be read * @return array of parsed features */ private Feature[] parseForFeature(String jsonFile) { try (Reader reader = new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8)) { Feature[] features = mapper.readValue(reader, Feature[].class); if (ArrayUtils.isEmpty(features)) { LOG.log(Level.INFO, String.format("File '%s' does not contain features", jsonFile)); } return features; } catch (JsonMappingException e) { throw new ValidationException(String.format("File '%s' is not proper Cucumber report!", jsonFile), e); } catch (IOException e) { // IO problem - stop generating and re-throw the problem throw new ValidationException(e); } }
private void copyResources(String resourceLocation, String... resources) { for (String resource : resources) { File tempFile = new File(configuration.getReportDirectory().getAbsoluteFile(), BASE_DIRECTORY + File.separatorChar + resourceLocation + File.separatorChar + resource); // don't change this implementation unless you verified it works on Jenkins try { FileUtils.copyInputStreamToFile( this.getClass().getResourceAsStream("/" + resourceLocation + "/" + resource), tempFile); } catch (IOException e) { // based on FileUtils implementation, should never happen even is declared throw new ValidationException(e); } } }
private void generateReport() { context.put("report_file", getWebPage()); Template template = engine.getTemplate("templates/generators/" + templateFileName); File reportFile = new File(configuration.getReportDirectory(), ReportBuilder.BASE_DIRECTORY + File.separatorChar + getWebPage()); try (Writer writer = new OutputStreamWriter(new FileOutputStream(reportFile), StandardCharsets.UTF_8)) { template.merge(context, writer); } catch (IOException e) { throw new ValidationException(e); } }
private void copyResources(String resourceLocation, String... resources) { for (String resource : resources) { File tempFile = new File(configuration.getReportDirectory().getAbsoluteFile(), BASE_DIRECTORY + File.separatorChar + resourceLocation + File.separatorChar + resource); // don't change this implementation unless you verified it works on Jenkins try { FileUtils.copyInputStreamToFile( this.getClass().getResourceAsStream("/" + resourceLocation + "/" + resource), tempFile); } catch (IOException e) { // based on FileUtils implementation, should never happen even is declared throw new ValidationException(e); } } }
private void generateReport() { context.put("report_file", getWebPage()); Template template = engine.getTemplate("templates/generators/" + templateFileName); File reportFile = new File(configuration.getReportDirectory(), ReportBuilder.BASE_DIRECTORY + File.separatorChar + getWebPage()); try (Writer writer = new OutputStreamWriter(new FileOutputStream(reportFile), StandardCharsets.UTF_8)) { template.merge(context, writer); } catch (IOException e) { throw new ValidationException(e); } }
private void processClassificationFile(String file) { try { PropertiesConfiguration config = new PropertiesConfiguration(file); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); String value = config.getProperty(key).toString(); this.configuration.addClassifications(key, value); } } catch (ConfigurationException e) { throw new ValidationException(String.format("File '%s' doesn't exist or the properties file is invalid!", file), e); } }
private void storeEmbedding(Embedding embedding, File embeddingDirectory) { Path file = FileSystems.getDefault().getPath(embeddingDirectory.getAbsolutePath(), embedding.getFileId() + "." + embedding.getExtension()); byte[] decodedData = Base64.decodeBase64(embedding.getData().getBytes(StandardCharsets.UTF_8)); try { Files.write(file, decodedData); } catch (IOException e) { throw new ValidationException(e); } }
private void processClassificationFile(String file) { try { PropertiesConfiguration config = new PropertiesConfiguration(file); Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { String key = keys.next(); String value = config.getProperty(key).toString(); this.configuration.addClassifications(key, value); } } catch (ConfigurationException e) { throw new ValidationException(String.format("File '%s' doesn't exist or the properties file is invalid!", file), e); } }
private void storeEmbedding(Embedding embedding, File embeddingDirectory) { Path file = FileSystems.getDefault().getPath(embeddingDirectory.getAbsolutePath(), embedding.getFileId() + "." + embedding.getExtension()); byte[] decodedData = Base64.decodeBase64(embedding.getData().getBytes(StandardCharsets.UTF_8)); try { Files.write(file, decodedData); } catch (IOException e) { throw new ValidationException(e); } }