Skip to content

Commit

Permalink
(yegor256#918) Code review fixes, attempt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
fanifieiev committed Nov 20, 2019
1 parent 39a6c72 commit 5a70417
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 151 deletions.
145 changes: 0 additions & 145 deletions src/main/java/org/takes/misc/InputStreamsEqual.java

This file was deleted.

8 changes: 6 additions & 2 deletions src/main/java/org/takes/rq/RequestOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.cactoos.io.BytesOf;
import org.cactoos.scalar.And;
import org.cactoos.scalar.Equality;
import org.cactoos.scalar.HashCode;
import org.cactoos.scalar.Or;
import org.cactoos.scalar.Unchecked;
import org.takes.Request;
import org.takes.Scalar;
import org.takes.misc.InputStreamsEqual;

/**
* This {@link Request} implementation provides a way to build a request
Expand Down Expand Up @@ -103,7 +104,10 @@ public boolean equals(final Object that) {
this.head()
).value();
},
new InputStreamsEqual(this.body(), other.body())
() -> new Equality<>(
new BytesOf(this.body()),
new BytesOf(other.body())
).value() == 0
).value();
}
)
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/takes/rs/ResponseOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.cactoos.io.BytesOf;
import org.cactoos.scalar.And;
import org.cactoos.scalar.Equality;
import org.cactoos.scalar.HashCode;
import org.cactoos.scalar.Or;
import org.cactoos.scalar.Unchecked;
import org.takes.Response;
import org.takes.Scalar;
import org.takes.misc.InputStreamsEqual;

/**
* Response of head and body.
Expand Down Expand Up @@ -104,7 +105,10 @@ public boolean equals(final Object that) {
this.head()
).value();
},
new InputStreamsEqual(this.body(), other.body())
() -> new Equality<>(
new BytesOf(this.body()),
new BytesOf(other.body())
).value() == 0
).value();
}
)
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/takes/rs/RsPrettyJsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ public void reportsCorrectContentLength() throws Exception {
*/
@Test
public void mustEvaluateTrueEquality() throws Exception {
final String body = "{\"person\":{\"name\":\"John\"}}";
new Assertion<>(
"Must evaluate true equality",
new RsPrettyJson(
new RsWithBody("{\"person\":{\"name\":\"John\"}}")
new RsWithBody(body)
),
new IsEqual<>(
new RsPrettyJson(
new RsWithBody("{\"person\":{\"name\":\"John\"}}")
new RsWithBody(body)
)
)
).affirm();
Expand Down

0 comments on commit 5a70417

Please sign in to comment.