public <T> boolean matches(Collection<T> elements) { List<Object> allFieldValues = convert(elements, new FieldValueExtractor()); Set<Object> uniquefieldValues = new HashSet<Object>(); uniquefieldValues.addAll(allFieldValues); return (uniquefieldValues.size() == elements.size()); }
public List<NamedTestResult> getNamedTestResults() { if (namedTestResults.isEmpty()) { return Lists.newArrayList(); } else { return convert(namedTestResults.entrySet(), fromMapEntriesToNamedTestResults()); } }
/** * Converts all the object in the iterable in its String representation. * Actually it handles also Maps, Arrays and Iterator by collecting their values. * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}. * @param iterable The iterable containing the objects to be converted in strings * @return A list containing the String representation of the objects in the given iterable */ public static List<String> extractString(Object iterable) { return convert(iterable, new DefaultStringConverter()); }
/** * Projects the objects in the given iterable by converting each of them in a set of key/value pairs. * Actually it handles also Maps, Arrays and Iterator by collecting their values. * Note that this method accepts an Object in order to be used in conjunction with the {@link Lambda#forEach(Iterable)}. * @param iterable The iterable containing the objects to be projected * @param projectors The converters that define how each object should be projected * @return A list of map where each map is the result of the projection of an object in the iterable */ public static <F> List<Map<String, Object>> project(Object iterable, Converter<F, Map.Entry<String, Object>>... projectors) { return convert(iterable, new ProjectConverter<F>(projectors)); }
private List<Object> asList(String value) { String listContents = StringUtils.removeEnd(StringUtils.removeStart(value,"["),"]"); List<String> items = Lists.newArrayList(Splitter.on(",").trimResults().split(listContents)); return convert(items, toObject()); }
public <T> boolean matches(Collection<T> elements) { Comparable maximumValue = null; try { List<Comparable> fieldValues = convert(elements, toComparable()); maximumValue = max(fieldValues); } catch (Exception e) { throw new IllegalArgumentException("Could not find property value for " + fieldName); } return valueMatcher.matches(maximumValue); }
public List<String> split(String chromeSwitches) { CharMatcher trimmable = CharMatcher.anyOf(" ,;"); Splitter.on("--").trimResults().split(chromeSwitches); List<String> options = Lists.newArrayList(Splitter.on("--").omitEmptyStrings().trimResults(trimmable).split(chromeSwitches)); return convert(options, withPrefixes()); }
private List<TestTag> expectedTags() { String tagListValue = environmentVariables.getProperty(ThucydidesSystemProperty.TAGS); if (StringUtils.isNotEmpty(tagListValue)) { List<String> tagList = Lists.newArrayList(Splitter.on(",").trimResults().split(tagListValue)); return convert(tagList, fromStringValuesToTestTags()); } else { return Lists.newArrayList(); } }
@Override public void describeTo(Description description) { description.appendText("a collection of dates containing "); List<String> dates = convert(expectedDates, toReadableForm()); description.appendText("[" + join(dates) + "]"); }
private void addTagsIfPresent(JsonDeserializationContext context, JsonObject outcomeJsonObject, TestOutcome testOutcome) { Set<TestTag> tags = Sets.newHashSet(convert(context.deserialize(outcomeJsonObject.getAsJsonArray(TAGS), Set.class), toTags())); if (tags != null) { testOutcome.setTags(tags); } }
private void addTags(List<TestTag> tags, WithTags tagSet) { if (tagSet != null) { tags.addAll(convert(tagSet.value(), toTestTags())); } }
@Override public void describeTo(Description description) { description.appendText("a collection of dates containing "); List<String> dates = convert(expectedDates, toReadableForm()); description.appendText("[" + join(dates) + "]"); }
public TestResult getResultForIssue(final String issueNumber) { List<T> testOutcomesForThisIssue = testOutcomesTally.get(issueNumber); return TestResultList.overallResultFrom(convert(testOutcomesForThisIssue, toTestResults())); }
private void addTagValues(List<TestTag> tags, WithTagValuesOf tagSet) { if (tagSet != null) { tags.addAll(convert(tagSet.value(), fromStringValuesToTestTags())); } }
private void addTagValues(List<TestTag> tags, WithTagValuesOf tagSet) { if (tagSet != null) { tags.addAll(convert(tagSet.value(), fromStringValuesToTestTags())); } }
public DataTableBuilder andMappedRows(List<? extends Map<String, ? extends Object>> mappedRows) { List<List<Object>> rowData = Lists.newArrayList(); for (Map<String, ? extends Object> mappedRow : mappedRows) { rowData.add(rowDataFrom(mappedRow)); } return new DataTableBuilder(headers, convert(rowData, toDataTableRows()), title, description, descriptors); }
public DataTableBuilder andMappedRows(List<? extends Map<String, ? extends Object>> mappedRows) { List<List<Object>> rowData = Lists.newArrayList(); for (Map<String, ? extends Object> mappedRow : mappedRows) { rowData.add(rowDataFrom(mappedRow)); } return new DataTableBuilder(headers, convert(rowData, toDataTableRows()), title, description, descriptors); }
@Override public List<String> getSelectOptions() { List<WebElement> results = Collections.emptyList(); if (getElement() != null) { results = findElements(By.tagName("option")); } return convert(results, new ExtractText()); }
private SortedMap<String, NamedTestResult> findTestResults(List<String> commentLines) { List<String> testResultLines = linesStartingAtRowIn(commentLines, FIRST_TEST_RESULT_LINE); List<NamedTestResult> namedTestResults = convert(testResultLines, toNamedTestResults()); return indexByTestName(namedTestResults); }
@Override public List<String> getSelectOptions() { List<WebElement> results = Collections.emptyList(); if (getElement() != null) { results = getElement().findElements(By.tagName("option")); } return convert(results, new ExtractText()); }