/** * Filters all the objects in the given iterable that match the given hamcrest Matcher * @param matcher The hamcrest Matcher used to filter the given iterable * @param iterable The iterable of objects to be filtered * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher */ public static <T> List<T> filter(Matcher<?> matcher, Iterable<T> iterable) { return select(iterable, matcher); }
/** * Filters all the objects in the given array that match the given hamcrest Matcher * @param matcher The hamcrest Matcher used to filter the given array * @param array The array of objects to be filtered * @return A sublist of the given array containing all the objects that match the given hamcrest Matcher */ public static <T> List<T> filter(Matcher<?> matcher, T... array) { return select(array, matcher); }
/** * Selects all the objects in the given iterable that match the given hamcrest Matcher * @param iterable The iterable of objects to be filtered * @param matcher The hamcrest Matcher used to filter the given iterable * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher */ public static <T> List<T> select(Iterable<T> iterable, Matcher<?> matcher) { if (iterable == null) return new LinkedList<T>(); return select(iterable.iterator(), matcher); }
private int countTestRunsByResultInLast(TestResult testResult, int testRunCount, List<TestResult> testResults) { List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults); List<TestResult> successfulTestResults = select(eligableTestResults, is(testResult)); return successfulTestResults.size(); }
private int countSuccessfulTestRunsInLast(int testRunCount, List<TestResult> testResults) { List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults); List<TestResult> successfulTestResults = select(eligableTestResults, is(TestResult.SUCCESS)); return successfulTestResults.size(); }
private int countTestRunsByResultInLast(TestResult testResult, int testRunCount, List<TestResult> testResults) { List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults); List<TestResult> successfulTestResults = select(eligableTestResults, is(testResult)); return successfulTestResults.size(); }
private int countSuccessfulTestRunsInLast(int testRunCount, List<TestResult> testResults) { List<TestResult> eligableTestResults = mostRecent(testRunCount, testResults); List<TestResult> successfulTestResults = select(eligableTestResults, is(TestResult.SUCCESS)); return successfulTestResults.size(); }
/** * Selects all the objects in the given iterable that match the given hamcrest Matcher * 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 to be filtered * @param matcher The hamcrest Matcher used to filter the given iterable * @return A sublist of the given iterable containing all the objects that match the given hamcrest Matcher */ public static <T> List<T> select(Object iterable, Matcher<?> matcher) { return select((Iterator<T>)asIterator(iterable), matcher); }
void doRetain(Matcher<?> matcher) { setInner(Lambda.select(innerIterable, matcher)); }
void doRemove(Matcher<?> matcher) { setInner(Lambda.select(innerIterable, not(matcher))); }
/** * Transforms the subset of objects in this iterable that match the given Mathcer * in a single object having the same methods of a single object in this iterable. * That allows to invoke a method on each T in the collection with a single strong typed method call. * The actual class of T is inferred from the class of the first iterable's item, but you can * specify a particular class by using the overloaded method. * @return An object that proxies all the item in the iterator or null if the iterator is null or empty */ public T forEach(Matcher<?> matcher) { return Lambda.forEach((List<T>)Lambda.select(getInner(), matcher)); }
public List<Screenshot> getScreenshots() { List<Screenshot> screenshots = new ArrayList<Screenshot>(); List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(), having(on(TestStep.class).needsScreenshots())); for (TestStep currentStep : testStepsWithScreenshots) { screenshots.addAll(screenshotsIn(currentStep)); } return ImmutableList.copyOf(screenshots); }
public List<Screenshot> getScreenshots() { List<Screenshot> screenshots = new ArrayList<Screenshot>(); List<TestStep> testStepsWithScreenshots = select(getFlattenedTestSteps(), having(on(TestStep.class).needsScreenshots())); for (TestStep currentStep : testStepsWithScreenshots) { screenshots.addAll(screenshotsIn(currentStep)); } return ImmutableList.copyOf(screenshots); }
public Integer getPendingCount() { List<TestStep> allTestSteps = getLeafTestSteps(); return select(allTestSteps, having(on(TestStep.class).isPending())).size(); }
public Integer getPendingCount() { List<TestStep> allTestSteps = getLeafTestSteps(); return select(allTestSteps, having(on(TestStep.class).isPending())).size(); }
/** * Creates a new MRSUser * * @param mrsUser Instance of the User object to be saved * @return A Map containing saved user's data * @throws UserAlreadyExistsException Thrown if the user already exists */ @Override public Map<String, Object> saveUser(MRSUser mrsUser) throws UserAlreadyExistsException { MRSPerson person = mrsUser.getPerson(); List<MRSAttribute> filteredItems = select(person.getAttributes(), having(on(MRSAttribute.class).getName(), equalTo("Email"))); String email = CollectionUtils.isNotEmpty(filteredItems) ? filteredItems.get(0).getValue() : null; MRSUser userByUserName = getUserByUserName(email); if (userByUserName != null && !isSystemAdmin(userByUserName.getSystemId())) { throw new UserAlreadyExistsException(); } return save(mrsUser); }
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())); }
} else { final List<Location> locationsWithSameName = locationService.getLocations(facility.getName()); final List<Location> matchedLocation = Lambda.select(locationsWithSameName, having(on(Location.class), locationMatcher(facility))); if (CollectionUtils.isNotEmpty(matchedLocation)) { location = matchedLocation.get(0);