/** * Counts the number of occurrencies of the argument's value in the objects of the given iterable * 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 of objects' arguments to be counted * @param argument An argument defined using the {@link Lambda#on(Class)} method * @return A map having as values the number of occurrencies of the corresponding object's argument in the given iterable */ public static <A> Map<A, Integer> count(Object iterable, A argument) { return count(extract(iterable, argument)); }
private List<Object[]> extractStudyNamesWithIndex(List<FormGroup> allFormGroups) { List<String> studyNames = extract(allFormGroups, on(FormGroup.class).getName()); List<Object[]> studyNamesWithIndex = new ArrayList<Object[]>(); for (int i = 0; i < studyNames.size(); i++) { studyNamesWithIndex.add(new Object[]{i, studyNames.get(i)}); } return studyNamesWithIndex; }
private static List<byte[]> extractSortValues(JSONArray expectedValuesArray) { Set<SortElement> elementsOrderedByScore = new TreeSet<RedisAssertion.SortElement>(); for (Object expectedObject : expectedValuesArray) { JSONObject expectedValue = (JSONObject) expectedObject; elementsOrderedByScore.add(new SortElement((java.lang.Number) expectedValue.get(SCORE_TOKEN), toByteArray(expectedValue.get(VALUE_TOKEN)))); } return extract(elementsOrderedByScore, on(SortElement.class).getValue()); }
private static List<byte[]> extractSortValues(JSONArray expectedValuesArray) { Set<SortElement> elementsOrderedByScore = new TreeSet<RedisAssertion.SortElement>(); for (Object expectedObject : expectedValuesArray) { JSONObject expectedValue = (JSONObject) expectedObject; elementsOrderedByScore.add(new SortElement((java.lang.Number) expectedValue.get(SCORE_TOKEN), toByteArray(expectedValue.get(VALUE_TOKEN)))); } return extract(elementsOrderedByScore, on(SortElement.class).getValue()); }
/** * @return The total number of nested steps in these test outcomes. */ public int getStepCount() { return sum(extract(outcomes, on(TestOutcome.class).getNestedStepCount())).intValue(); }
/** * @return The total number of nested steps in these test outcomes. */ public int getStepCount() { return sum(extract(outcomes, on(TestOutcome.class).getNestedStepCount())).intValue(); }
@Override public boolean matchesSafely(TestOutcome testOutcome) { List<TestStep> allSteps = testOutcome.getFlattenedTestSteps(); List<TestResult> allTestResults = extract(allSteps, on(TestStep.class).getResult()); return allTestResults.equals(expectedTestResults); }
@Override public boolean matchesSafely(TestOutcome testOutcome) { List<TestStep> allSteps = testOutcome.getFlattenedTestSteps(); List<TestResult> allTestResults = extract(allSteps, on(TestStep.class).getResult()); return allTestResults.equals(expectedTestResults); }
@Override public void tryOnce() { String wrv = recoveryManager.getWRV(); if (logger.isDebugEnabled()) logger.debug("Dispatch start with bulk number: " + bulkNumber); dispatcherService.dispatch(optimizedBulk, bulkNumber, wrv, workerUuid); if (executionsActivityListener != null) { executionsActivityListener.onHalt(extract(optimizedBulk, on(ExecutionMessage.class).getExecStateId())); } if (logger.isDebugEnabled()) logger.debug("Dispatch end with bulk number: " + bulkNumber); } });
@View(name = "by_triggerGroupName", map = "function(doc) { if (doc.type === 'CouchDbTrigger') emit(doc.group, doc._id); }") public List<String> getTriggerGroupNames() { return new ArrayList<String>(new HashSet<String>(extract(db.queryView(createQuery("by_triggerGroupName").includeDocs(true), type), on(CouchDbTrigger.class).getGroup()))); }
@View(name = "by_jobGroupName", map = "function(doc) { if (doc.type === 'CouchDbJobDetail') emit(doc.group, doc._id); }") public List<String> getJobGroupNames() { return new ArrayList<String>(new HashSet<String>(extract(db.queryView(createQuery("by_jobGroupName").includeDocs(true), type), on(CouchDbJobDetail.class).getGroup()))); }
private String[] withRowDataFrom(TestOutcome outcome) { List<? extends Serializable> defaultValues = ImmutableList.of(outcome.getStoryTitle(), outcome.getTitle(), outcome.getResult(), outcome.getStartTime(), passRateFor(outcome), outcome.getDurationInSeconds()); List<String> cellValues = extract(defaultValues, on(Object.class).toString()); cellValues.addAll(extraValuesFrom(outcome)); return cellValues.toArray(OF_STRINGS); }
private String[] withRowDataFrom(TestOutcome outcome) { List<? extends Serializable> defaultValues = ImmutableList.of(outcome.getStoryTitle(), outcome.getTitle(), outcome.getResult(), outcome.getStartTime(), passRateFor(outcome), outcome.getDurationInSeconds()); List<String> cellValues = extract(defaultValues, on(Object.class).toString()); cellValues.addAll(extraValuesFrom(outcome)); return cellValues.toArray(OF_STRINGS); }
@Override public String toString() { if (!hasChildren()) { return description; } else { String childDescriptions = join(extract(children, on(TestStep.class).toString())); return description + " [" + childDescriptions + "]"; } }
@Override public String toString() { if (!hasChildren()) { return description; } else { String childDescriptions = join(extract(children, on(TestStep.class).toString())); return description + " [" + childDescriptions + "]"; } }
private TestResult overallResultFrom(List<DataTableRow> rows) { TestResultList rowResults = TestResultList.of(extract(rows, on(DataTableRow.class).getResult())); return rowResults.getOverallResult(); }
@Override public String toString() { return getTitle() + ":" + join(extract(testSteps, on(TestStep.class).toString())); }
@Override public String toString() { return getTitle() + ":" + join(extract(testSteps, on(TestStep.class).toString())); }
public List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources() { List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(), having(on(TestStep.class).needsScreenshots())); return flatten(extract(testStepsWithScreenshots, on(TestStep.class).getScreenshots())); }
public List<ScreenshotAndHtmlSource> getScreenshotAndHtmlSources() { List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(), having(on(TestStep.class).needsScreenshots())); return flatten(extract(testStepsWithScreenshots, on(TestStep.class).getScreenshots())); }