Skip to content

Commit

Permalink
(yegor256#1299) Removed collection's Filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Mar 15, 2020
1 parent 90ff77d commit 4d82499
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 169 deletions.
69 changes: 0 additions & 69 deletions src/main/java/org/cactoos/collection/Filtered.java

This file was deleted.

100 changes: 0 additions & 100 deletions src/test/java/org/cactoos/collection/FilteredTest.java

This file was deleted.

56 changes: 56 additions & 0 deletions src/test/java/org/cactoos/iterable/FilteredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@
*/
package org.cactoos.iterable;

import org.cactoos.list.ListOf;
import org.cactoos.scalar.LengthOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.ScalarHasValue;

/**
* Test case for {@link Filtered}.
* @since 0.1
* @checkstyle JavadocMethodCheck (500 lines)
* @checkstyle MagicNumberCheck (500 lines)
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class FilteredTest {

Expand Down Expand Up @@ -82,4 +88,54 @@ public void filtersIterablesWithSize() {
);
}

@Test
public void filterEmptyList() {
new Assertion<>(
"Filter must work on empty collection",
new Filtered<String>(
input -> input.length() > 4,
new ListOf<>()
),
new IsEmptyIterable<>()
).affirm();
}

@Test
public void length() {
new Assertion<>(
"Size must be equal to number of items matching the filter",
new LengthOf(
new Filtered<>(
input -> input.length() >= 4,
new IterableOf<>("some", "text", "yes")
)
),
new ScalarHasValue<>(2.)
).affirm();
}

@Test
public void withItemsNotEmpty() {
new Assertion<>(
"Must not be empty with items",
new Filtered<String>(
input -> input.length() > 4,
new IterableOf<>("first", "second")
),
new IsNot<>(new IsEmptyIterable<>())
).affirm();
}

@Test
public void withoutItemsIsEmpty() {
new Assertion<>(
"Must be empty without items",
new Filtered<String>(
input -> input.length() > 16,
new IterableOf<>("third", "fourth")
),
new IsEmptyIterable<>()
).affirm();
}

}

0 comments on commit 4d82499

Please sign in to comment.