Skip to content

Commit

Permalink
#881 rev comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatavuk committed May 29, 2018
1 parent d51aa6b commit d4538f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 4 additions & 9 deletions src/main/java/org/cactoos/collection/CollectionEnvelope.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.cactoos.scalar.And;
import org.cactoos.scalar.Folded;
import org.cactoos.scalar.InheritanceLevel;
import org.cactoos.scalar.Or;
import org.cactoos.scalar.SumOfIntScalar;
import org.cactoos.scalar.UncheckedScalar;

Expand Down Expand Up @@ -151,14 +150,10 @@ public String toString() {
public final boolean equals(final Object other) {
return new UncheckedScalar<>(
new And(
new Or(
() -> new InheritanceLevel(
other.getClass(), Collection.class
).value() > -1,
() -> new InheritanceLevel(
other.getClass(), CollectionEnvelope.class
).value() > -1
),
() -> other != null,
() -> new InheritanceLevel(
other.getClass(), CollectionEnvelope.class
).value() > -1,
() -> {
final Collection<?> compared = (Collection<?>) other;
return this.size() == compared.size();
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/cactoos/collection/CollectionEnvelopeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* Iterator for IterableEnvelope `iterator()` method.
* @checkstyle JavadocMethodCheck (500 lines)
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods"})
public final class CollectionEnvelopeTest {
@Test(expected = UnsupportedOperationException.class)
public void returnsIteratorWithUnsupportedRemove() {
Expand Down Expand Up @@ -120,6 +120,15 @@ public void equalToEmptyCollection() {
);
}

@Test
public void notEqualToNull() {
MatcherAssert.assertThat(
"Empty collection equal to null",
new CollectionOf<>(),
new IsNot<>(new IsEqual<>(null))
);
}

@Test
public void hashCodeEqual() {
MatcherAssert.assertThat(
Expand Down

0 comments on commit d4538f8

Please sign in to comment.