@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); final Path path = Paths.get(path()); if (!Files.exists(path)) { errors.put("path", "The file does not exist."); } else if (!Files.isReadable(path)) { errors.put("path", "The file cannot be read."); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); final Path path = Paths.get(path()); if (!Files.exists(path)) { errors.put("path", "The file does not exist."); } else if (!Files.isReadable(path)) { errors.put("path", "The file cannot be read."); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); if (HttpUrl.parse(url()) == null) { errors.put("url", "Unable to parse url: " + url()); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); if (StringUtils.isNotBlank(serverIps()) && !DnsClient.allIpAddressesValid(serverIps())) { errors.put(FIELD_SERVER_IPS, "Invalid server IP address and/or port. " + "Please enter one or more comma-separated IPv4 addresses with optional ports (eg. 192.168.1.1:5353, 192.168.1.244)."); } if (requestTimeout() < 1) { errors.put(FIELD_REQUEST_TIMEOUT, "Value cannot be smaller than 1"); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
private ArrayListMultimap<String, AggregateFunction<?, ?>> getAggregateFunctionMultimap() { ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap = ArrayListMultimap.create(); for (String name: summarizedColumns) { Column<?> column = temp.column(name); ColumnType type = column.type(); for (AggregateFunction<?, ?> reduction : reductions) { if (reduction.isCompatibleColumn(type)) { reductionMultimap.put(name, reduction); } } } if (reductionMultimap.isEmpty()) { throw new IllegalArgumentException("None of the aggregate functions provided apply to the summarized column type(s)."); } return reductionMultimap; }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); if (HttpUrl.parse(url()) == null) { errors.put("url", "Invalid URL."); } try { final JsonPath jsonPath = JsonPath.compile(singleValueJSONPath()); if (!jsonPath.isDefinite()) { errors.put("single_value_jsonpath", "JSONPath does not return a single value."); } } catch (InvalidPathException e) { errors.put("single_value_jsonpath", "Invalid JSONPath."); } if (multiValueJSONPath().isPresent()) { try { JsonPath.compile(multiValueJSONPath().get()); } catch (InvalidPathException e) { errors.put("multi_value_jsonpath", "Invalid JSONPath."); } } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
private String expectedMessage() { return !expected.isEmpty() ? ("Expected " + expected) : ""; }
public boolean isEmpty() { return refDiffs.isEmpty(); }
@Override public boolean isEmpty() { return stacks.isEmpty(); }
@Override public boolean isEmpty() { return stacks.isEmpty(); }
public boolean isEmpty() { return refDiffs.isEmpty(); }
private String unexpectedMessage(List<Integer> unexpectedLines) { if (unexpectedLines.isEmpty()) { return ""; } return (expected.isEmpty() ? "" : ", ") + "Unexpected at " + unexpectedLines; }
private String buildRequestParamsString(ArrayListMultimap<String, String> requestParams) { if (!requestParams.isEmpty()) { String requestParamsString = "?"; for (Map.Entry<String, String> entry : requestParams.entries()) { requestParamsString = requestParamsString + String.format("%s=%s&", entry.getKey(), entry.getValue()); } return StringUtils.strip(requestParamsString, "&"); } else { return ""; } } }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); final Path path = Paths.get(path()); if (!Files.exists(path)) { errors.put("path", "The file does not exist."); } else if (!Files.isReadable(path)) { errors.put("path", "The file cannot be read."); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); if (HttpUrl.parse(url()) == null) { errors.put("url", "Unable to parse url: " + url()); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
private void assertNoIssues(Set<AnalyzerMessage> issues, boolean bypass) { assertThat(issues).overridingErrorMessage("No issues expected but got: " + issues).isEmpty(); if (!bypass) { // make sure we do not copy&paste verifyNoIssue call when we intend to call verify assertThat(expected.isEmpty()).overridingErrorMessage("The file should not declare noncompliants when no issues are expected").isTrue(); } } }
private void assertMultipleIssue(Set<AnalyzerMessage> issues) throws AssertionError { Preconditions.checkState(!issues.isEmpty(), "At least one issue expected"); List<Integer> unexpectedLines = Lists.newLinkedList(); RemediationFunction remediationFunction = remediationFunction(issues.iterator().next()); for (AnalyzerMessage issue : issues) { validateIssue(expected, unexpectedLines, issue, remediationFunction); } if (!expected.isEmpty() || !unexpectedLines.isEmpty()) { Collections.sort(unexpectedLines); String expectedMsg = expectedMessage(); String unexpectedMsg = unexpectedMessage(unexpectedLines); Fail.fail(expectedMsg + unexpectedMsg); } }
@Override public Optional<Multimap<String, String>> validate() { final ArrayListMultimap<String, String> errors = ArrayListMultimap.create(); if (StringUtils.isNotBlank(serverIps()) && !DnsClient.allIpAddressesValid(serverIps())) { errors.put(FIELD_SERVER_IPS, "Invalid server IP address and/or port. " + "Please enter one or more comma-separated IPv4 addresses with optional ports (eg. 192.168.1.1:5353, 192.168.1.244)."); } if (requestTimeout() < 1) { errors.put(FIELD_REQUEST_TIMEOUT, "Value cannot be smaller than 1"); } return errors.isEmpty() ? Optional.empty() : Optional.of(errors); }
private ArrayListMultimap<String, AggregateFunction<?, ?>> getAggregateFunctionMultimap() { ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap = ArrayListMultimap.create(); for (String name: summarizedColumns) { Column<?> column = temp.column(name); ColumnType type = column.type(); for (AggregateFunction<?, ?> reduction : reductions) { if (reduction.isCompatibleColumn(type)) { reductionMultimap.put(name, reduction); } } } if (reductionMultimap.isEmpty()) { throw new IllegalArgumentException("None of the aggregate functions provided apply to the summarized column type(s)."); } return reductionMultimap; }
private void annotateBuilder(VariantContextBuilder builder, ArrayListMultimap<Integer, ClinVarAnnotation> matchMap, String infix) { if (matchMap.isEmpty()) return; // skip List<String> basicInfo = buildBasicInfo(builder, matchMap); if (!basicInfo.isEmpty()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "BASIC_INFO", basicInfo); List<String> varInfo = buildVarInfo(builder, matchMap); if (!varInfo.isEmpty()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "VAR_INFO", varInfo); List<String> diseaseInfo = buildDiseaseInfo(builder, matchMap); if (!diseaseInfo.isEmpty()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "DISEASE_INFO", diseaseInfo); }