From 7858809019636436bf42ff2823f54eb5ffc13869 Mon Sep 17 00:00:00 2001 From: Ilya Kharlamov <502372+ilyakharlamov@users.noreply.github.com> Date: Mon, 21 Jan 2019 09:58:02 -0500 Subject: [PATCH] (#42) HtHead can be broken. (tests to use Assertion) --- .../java/org/cactoos/http/HtHeadTest.java | 88 +++++++++---------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/src/test/java/org/cactoos/http/HtHeadTest.java b/src/test/java/org/cactoos/http/HtHeadTest.java index d115566..b59a638 100644 --- a/src/test/java/org/cactoos/http/HtHeadTest.java +++ b/src/test/java/org/cactoos/http/HtHeadTest.java @@ -54,20 +54,19 @@ public final class HtHeadTest { public void takesHeadOutOfHttpResponse() throws IOException { new Assertion<>( "Header does not have 'text/plain'", - () -> - new TextOf( - new HtHead( - new InputOf( - new JoinedText( - "\r\n", - "HTTP/1.1 200 OK", - "Content-type: text/plain", - "", - "Hello, dude!" - ) + () -> new TextOf( + new HtHead( + new InputOf( + new JoinedText( + "\r\n", + "HTTP/1.1 200 OK", + "Content-type: text/plain", + "", + "Hello, dude!" ) ) - ), + ) + ), new EndsWith("text/plain") ).affirm(); } @@ -76,19 +75,18 @@ public void takesHeadOutOfHttpResponse() throws IOException { public void emptyHeadOfHttpResponse() throws IOException { new Assertion<>( "Text does not have an empty string", - () -> - new TextOf( - new HtHead( - new InputOf( - new JoinedText( - "\r\n", - "", - "", - "Body" - ) + () -> new TextOf( + new HtHead( + new InputOf( + new JoinedText( + "\r\n", + "", + "", + "Body" ) ) - ), + ) + ), new TextHasString("") ).affirm(); } @@ -100,20 +98,19 @@ public void largeText() throws IOException { new Random().nextBytes(bytes); new Assertion<>( "Header does not have text/plain header", - () -> - new TextOf( - new HtHead( - new InputOf( - new JoinedText( - "\r\n", - "HTTP/1.1 200 OK", - "Content-type: text/plain", - "", - new TextOf(new BytesOf(bytes)).asString() - ) + () -> new TextOf( + new HtHead( + new InputOf( + new JoinedText( + "\r\n", + "HTTP/1.1 200 OK", + "Content-type: text/plain", + "", + new TextOf(new BytesOf(bytes)).asString() ) ) - ), + ) + ), new EndsWith("text/plain") ).affirm(); } @@ -145,19 +142,18 @@ public void edgeOfTheBlockTearing() throws IOException { ).affirm(); new Assertion<>( String.format("Edge of the block tearing for size: %s", size), - () -> - new TextOf( - new HtHead( - new InputOf( - new JoinedText( - "\r\n", - block.asString(), - "", - "body here" - ) + () -> new TextOf( + new HtHead( + new InputOf( + new JoinedText( + "\r\n", + block.asString(), + "", + "body here" ) ) - ), + ) + ), Matchers.allOf( new StartsWith("HTTP"), new TextHasString("OK\r\nReferer"),