Repository: yegor256/cactoos
Pull request #67 (2017-05-31 12:56:41)

66: side effect testing
as per #66 
 
  * `FuncAsMatcher` added
  * reasons added to all test methods


Patch:
diff --git a/src/main/java/org/cactoos/ScalarHasValue.java b/src/main/java/org/cactoos/ScalarHasValue.java
index 5b0d4118..e0fedaaa 100644
--- a/src/main/java/org/cactoos/ScalarHasValue.java
+++ b/src/main/java/org/cactoos/ScalarHasValue.java
@@ -49,7 +49,7 @@ public final class ScalarHasValue<T> extends TypeSafeMatcher<Scalar<T>> {
      * @param text The text to match against
      */
     public ScalarHasValue(final T text) {
-        this(new IsEqual<T>(text));
+        this(new IsEqual<>(text));
     }
 
     /**
diff --git a/src/main/java/org/cactoos/func/FuncAsMatcher.java b/src/main/java/org/cactoos/func/FuncAsMatcher.java
new file mode 100644
index 00000000..85f44845
--- /dev/null
+++ b/src/main/java/org/cactoos/func/FuncAsMatcher.java
@@ -0,0 +1,71 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.func;
+
+import org.cactoos.Func;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Func as Matcher.
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @param <T> Type of object to match
+ * @since 0.2
+ */
+public final class FuncAsMatcher<T> extends TypeSafeMatcher<T> {
+
+    /**
+     * The func.
+     */
+    private final Func<T, Boolean> func;
+
+    /**
+     * Ctor.
+     * @param fnc The func
+     */
+    public FuncAsMatcher(final Func<T, Boolean> fnc) {
+        super();
+        this.func = fnc;
+    }
+
+    @Override
+    @SuppressWarnings("PMD.AvoidCatchingGenericException")
+    public boolean matchesSafely(final T item) {
+        try {
+            return this.func.apply(item);
+            // @checkstyle IllegalCatchCheck (1 line)
+        } catch (final Exception ex) {
+            throw new AssertionError(ex);
+        }
+    }
+
+    @Override
+    public void describeTo(final Description description) {
+        description.appendText(this.func.toString());
+    }
+}
diff --git a/src/main/java/org/cactoos/io/TextAsInput.java b/src/main/java/org/cactoos/io/BytesAsInput.java
similarity index 64%
rename from src/main/java/org/cactoos/io/TextAsInput.java
rename to src/main/java/org/cactoos/io/BytesAsInput.java
index 186c450a..6717756b 100644
--- a/src/main/java/org/cactoos/io/TextAsInput.java
+++ b/src/main/java/org/cactoos/io/BytesAsInput.java
@@ -26,13 +26,11 @@ package org.cactoos.io;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
+import org.cactoos.Bytes;
 import org.cactoos.Input;
-import org.cactoos.Text;
-import org.cactoos.text.StringAsText;
 
 /**
- * Text as Input.
+ * Bytes as Input.
  *
  * <p>There is no thread-safety guarantee.
  *
@@ -40,50 +38,25 @@ import org.cactoos.text.StringAsText;
  * @version $Id$
  * @since 0.1
  */
-public final class TextAsInput implements Input {
+public final class BytesAsInput implements Input {
 
     /**
      * The source.
      */
-    private final Text source;
-
-    /**
-     * Text charset.
-     */
-    private final Charset charset;
-
-    /**
-     * New {@link TextAsInput} with default charset.
-     *
-     * @param text The text
-     */
-    public TextAsInput(final String text) {
-        this(new StringAsText(text));
-    }
+    private final Bytes source;
 
     /**
      * Ctor.
-     * @param text The text
-     */
-    public TextAsInput(final Text text) {
-        this(text, Charset.defaultCharset());
-    }
-
-    /**
-     * New {@link TextAsInput} with specified charset.
-     *
-     * @param text The text
-     * @param charset Text charset
+     * @param bytes The bytes
      */
-    public TextAsInput(final Text text, final Charset charset) {
-        this.source = text;
-        this.charset = charset;
+    public BytesAsInput(final Bytes bytes) {
+        this.source = bytes;
     }
 
     @Override
     public InputStream open() throws IOException {
         return new ByteArrayInputStream(
-            this.source.asString().getBytes(this.charset)
+            this.source.asBytes()
         );
     }
 
diff --git a/src/main/java/org/cactoos/io/DeadInput.java b/src/main/java/org/cactoos/io/DeadInput.java
index 685338d9..4d3a2b8c 100644
--- a/src/main/java/org/cactoos/io/DeadInput.java
+++ b/src/main/java/org/cactoos/io/DeadInput.java
@@ -26,7 +26,7 @@ package org.cactoos.io;
 import java.io.IOException;
 import java.io.InputStream;
 import org.cactoos.Input;
-import org.cactoos.text.StringAsText;
+import org.cactoos.text.EmptyBytes;
 
 /**
  * Input with no data.
@@ -41,7 +41,7 @@ public final class DeadInput implements Input {
 
     @Override
     public InputStream open() throws IOException {
-        return new TextAsInput(new StringAsText("")).open();
+        return new BytesAsInput(new EmptyBytes()).open();
     }
 
 }
diff --git a/src/main/java/org/cactoos/text/EmptyBytes.java b/src/main/java/org/cactoos/text/EmptyBytes.java
new file mode 100644
index 00000000..75408374
--- /dev/null
+++ b/src/main/java/org/cactoos/text/EmptyBytes.java
@@ -0,0 +1,44 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Yegor Bugayenko
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package org.cactoos.text;
+
+import org.cactoos.Bytes;
+
+/**
+ * Bytes with no data.
+ *
+ * <p>There is no thread-safety guarantee.
+ *
+ * @author Yegor Bugayenko (yegor256@gmail.com)
+ * @version $Id$
+ * @since 0.2
+ */
+public final class EmptyBytes implements Bytes {
+
+    @Override
+    public byte[] asBytes() {
+        return new byte[] {};
+    }
+
+}
diff --git a/src/main/java/org/cactoos/text/TextAsBytes.java b/src/main/java/org/cactoos/text/TextAsBytes.java
index 4cef689d..b382557b 100644
--- a/src/main/java/org/cactoos/text/TextAsBytes.java
+++ b/src/main/java/org/cactoos/text/TextAsBytes.java
@@ -25,6 +25,7 @@ package org.cactoos.text;
 
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import org.cactoos.Bytes;
 import org.cactoos.Text;
 
@@ -49,22 +50,30 @@ public final class TextAsBytes implements Bytes {
      */
     private final Charset charset;
 
+    /**
+     * Ctor.
+     * @param text The source
+     */
+    public TextAsBytes(final String text) {
+        this(new StringAsText(text));
+    }
+
     /**
      * Ctor.
      * @param text The source
      */
     public TextAsBytes(final Text text) {
-        this(text, Charset.defaultCharset());
+        this(text, StandardCharsets.UTF_8);
     }
 
     /**
      * Ctor.
      * @param text The source
-     * @param charset The charset
+     * @param cset The charset
      */
-    public TextAsBytes(final Text text, final Charset charset) {
+    public TextAsBytes(final Text text, final Charset cset) {
         this.source = text;
-        this.charset = charset;
+        this.charset = cset;
     }
 
     @Override


Test patch:
diff --git a/src/test/java/org/cactoos/func/FuncWithCallbackTest.java b/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
index 53b1c48e..e4103ed4 100644
--- a/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
+++ b/src/test/java/org/cactoos/func/FuncWithCallbackTest.java
@@ -35,16 +35,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.2
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class FuncWithCallbackTest {
 
-    /**
-     * FuncWithCallback can use main func.
-     * @throws Exception If some problem inside
-     */
     @Test
     public void usesMainFunc() throws Exception {
         MatcherAssert.assertThat(
+            "Can't use the main function if no exception",
             new FuncWithCallback<>(
                 (Func<Integer, String>) input -> "It's success",
                 ex -> "In case of failure..."
@@ -53,13 +51,10 @@ public final class FuncWithCallbackTest {
         );
     }
 
-    /**
-     * FuncWithCallback can use a callback.
-     * @throws Exception If some problem inside
-     */
     @Test
     public void usesCallback() throws Exception {
         MatcherAssert.assertThat(
+            "Can't use the callback in case of exception",
             new FuncWithCallback<>(
                 (Func<Integer, String>) input -> {
                     throw new IOException("Failure");
diff --git a/src/test/java/org/cactoos/io/FileAsInputTest.java b/src/test/java/org/cactoos/io/FileAsInputTest.java
index 461f0b24..ffba1b0b 100644
--- a/src/test/java/org/cactoos/io/FileAsInputTest.java
+++ b/src/test/java/org/cactoos/io/FileAsInputTest.java
@@ -23,14 +23,13 @@
  */
 package org.cactoos.io;
 
-import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import org.cactoos.TextHasString;
 import org.cactoos.text.BytesAsText;
-import org.cactoos.text.StringAsText;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.Test;
 
 /**
@@ -39,60 +38,24 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class FileAsInputTest {
 
-    /**
-     * FileAsInput can read file content.
-     * @throws IOException If some problem inside
-     */
     @Test
     public void readsSimpleFileContent() throws IOException {
-        final File temp = File.createTempFile("cactoos-1", "txt-1");
-        temp.deleteOnExit();
+        final Path temp = Files.createTempFile("cactoos-1", "txt-1");
         final String content = "Hello, товарищ!";
+        Files.write(temp, content.getBytes(StandardCharsets.UTF_8));
         MatcherAssert.assertThat(
+            "Can't read file content",
             new BytesAsText(
                 new InputAsBytes(
-                    new TeeInput(
-                        new TextAsInput(
-                            new StringAsText(content),
-                            StandardCharsets.UTF_8
-                        ),
-                        new FileAsOutput(temp)
-                    )
+                    new FileAsInput(temp.toFile())
                 )
             ),
             new TextHasString(content)
         );
     }
 
-    /**
-     * FileAsInput can read file content.
-     * @throws IOException If some problem inside
-     */
-    @Test
-    public void readsFileContent() throws IOException {
-        final File temp = File.createTempFile("cactoos", "txt");
-        temp.deleteOnExit();
-        MatcherAssert.assertThat(
-            new BytesAsText(
-                new InputAsBytes(
-                    new TeeInput(
-                        new TextAsInput(
-                            new StringAsText("Hello, друг!"),
-                            StandardCharsets.UTF_8
-                        ),
-                        new FileAsOutput(temp)
-                    )
-                )
-            ),
-            new TextHasString(
-                Matchers.allOf(
-                    Matchers.startsWith("Hello, "),
-                    Matchers.endsWith("друг!")
-                )
-            )
-        );
-    }
 }
diff --git a/src/test/java/org/cactoos/io/InputAsBytesTest.java b/src/test/java/org/cactoos/io/InputAsBytesTest.java
index b5e8e71f..9268b174 100644
--- a/src/test/java/org/cactoos/io/InputAsBytesTest.java
+++ b/src/test/java/org/cactoos/io/InputAsBytesTest.java
@@ -26,6 +26,7 @@ package org.cactoos.io;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import org.cactoos.text.StringAsText;
+import org.cactoos.text.TextAsBytes;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.junit.Test;
@@ -36,22 +37,20 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class InputAsBytesTest {
 
-    /**
-     * InputAsBytes can read input.
-     *
-     * @throws IOException If some problem inside
-     */
     @Test
     public void readsInputIntoBytes() throws IOException {
         MatcherAssert.assertThat(
+            "Can't read bytes from Input",
             new String(
                 new InputAsBytes(
-                    new TextAsInput(
-                        new StringAsText("Hello, друг!"),
-                        StandardCharsets.UTF_8
+                    new BytesAsInput(
+                        new TextAsBytes(
+                            new StringAsText("Hello, друг!")
+                        )
                     )
                 ).asBytes(),
                 StandardCharsets.UTF_8
@@ -63,19 +62,16 @@ public final class InputAsBytesTest {
         );
     }
 
-    /**
-     * InputAsBytes can read input with small buffer.
-     *
-     * @throws IOException If some problem inside
-     */
     @Test
     public void readsInputIntoBytesWithSmallBuffer() throws IOException {
         MatcherAssert.assertThat(
+            "Can't read bytes from Input with a small reading buffer",
             new String(
                 new InputAsBytes(
-                    new TextAsInput(
-                        new StringAsText("Hello, товарищ!"),
-                        StandardCharsets.UTF_8
+                    new BytesAsInput(
+                        new TextAsBytes(
+                            new StringAsText("Hello, товарищ!")
+                        )
                     ),
                     2
                 ).asBytes(),
diff --git a/src/test/java/org/cactoos/io/LengthOfInputTest.java b/src/test/java/org/cactoos/io/LengthOfInputTest.java
index 45d81481..1e34a08b 100644
--- a/src/test/java/org/cactoos/io/LengthOfInputTest.java
+++ b/src/test/java/org/cactoos/io/LengthOfInputTest.java
@@ -23,8 +23,10 @@
  */
 package org.cactoos.io;
 
+import java.nio.charset.StandardCharsets;
 import org.cactoos.ScalarHasValue;
 import org.cactoos.text.StringAsText;
+import org.cactoos.text.TextAsBytes;
 import org.hamcrest.MatcherAssert;
 import org.junit.Test;
 
@@ -33,31 +35,32 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class LengthOfInputTest {
 
-    /**
-     * LengthOfInput can calculate length.
-     */
     @Test
     public void calculatesLength() {
         final String text = "What's up, друг?";
         MatcherAssert.assertThat(
+            "Can't calculate the length of Input",
             new LengthOfInput(
-                new TextAsInput(
-                    new StringAsText(text)
+                new BytesAsInput(
+                    new TextAsBytes(
+                        new StringAsText(text)
+                    )
                 )
             ),
-            new ScalarHasValue<>((long) text.getBytes().length)
+            new ScalarHasValue<>(
+                (long) text.getBytes(StandardCharsets.UTF_8).length
+            )
         );
     }
 
-    /**
-     * LengthOfInput can calculate zero length.
-     */
     @Test
     public void calculatesZeroLength() {
         MatcherAssert.assertThat(
+            "Can't calculate the length of an empty input",
             new LengthOfInput(new DeadInput()),
             new ScalarHasValue<>(0L)
         );
diff --git a/src/test/java/org/cactoos/io/ResourceAsInputTest.java b/src/test/java/org/cactoos/io/ResourceAsInputTest.java
index b078db6a..d2b9e10f 100644
--- a/src/test/java/org/cactoos/io/ResourceAsInputTest.java
+++ b/src/test/java/org/cactoos/io/ResourceAsInputTest.java
@@ -34,17 +34,14 @@ import org.junit.Test;
  * @author Kirill (g4s8.public@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class ResourceAsInputTest {
 
-    /**
-     * Test built-in resource.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void readResourceTest() throws Exception {
         MatcherAssert.assertThat(
+            "Can't read bytes from a classpath resource",
             Arrays.copyOfRange(
                 new InputAsBytes(
                     new ResourceAsInput(
diff --git a/src/test/java/org/cactoos/io/TeeInputTest.java b/src/test/java/org/cactoos/io/TeeInputTest.java
index 8ad6661b..78e684c5 100644
--- a/src/test/java/org/cactoos/io/TeeInputTest.java
+++ b/src/test/java/org/cactoos/io/TeeInputTest.java
@@ -24,10 +24,16 @@
 package org.cactoos.io;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import org.cactoos.TextHasString;
+import org.cactoos.func.FuncAsMatcher;
 import org.cactoos.text.BytesAsText;
+import org.cactoos.text.StringAsText;
+import org.cactoos.text.TextAsBytes;
 import org.hamcrest.MatcherAssert;
-import org.hamcrest.Matchers;
 import org.junit.Test;
 
 /**
@@ -35,26 +41,64 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
+ * @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
  */
 public final class TeeInputTest {
 
-    /**
-     * TeeInput can copy content.
-     */
     @Test
     public void copiesContent() {
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final String content = "Hello, товарищ!";
         MatcherAssert.assertThat(
+            "Can't copy Input to Output and return Input",
             new BytesAsText(
                 new InputAsBytes(
                     new TeeInput(
-                        new TextAsInput("Hello, world!"),
+                        new BytesAsInput(
+                            new TextAsBytes(content)
+                        ),
                         new OutputStreamAsOutput(baos)
                     )
                 )
             ),
-            new TextHasString(Matchers.containsString("world"))
+            new TextHasString(
+                new FuncAsMatcher<>(
+                    str -> new String(
+                        baos.toByteArray(), StandardCharsets.UTF_8
+                    ).equals(str)
+                )
+            )
         );
     }
 
+    @Test
+    public void copiesToFile() throws IOException {
+        final Path temp = Files.createTempFile("cactoos", "txt");
+        MatcherAssert.assertThat(
+            "Can't copy Input to File and return content",
+            new BytesAsText(
+                new InputAsBytes(
+                    new TeeInput(
+                        new BytesAsInput(
+                            new TextAsBytes(
+                                new StringAsText("Hello, друг!")
+                            )
+                        ),
+                        new FileAsOutput(temp.toFile())
+                    )
+                )
+            ),
+            new TextHasString(
+                new FuncAsMatcher<>(
+                    str -> str.equals(
+                        new String(
+                            Files.readAllBytes(temp),
+                            StandardCharsets.UTF_8
+                        )
+                    )
+                )
+            )
+        );
+    }
 }
diff --git a/src/test/java/org/cactoos/io/UrlAsInputTest.java b/src/test/java/org/cactoos/io/UrlAsInputTest.java
index 6d3ff172..3a011ccf 100644
--- a/src/test/java/org/cactoos/io/UrlAsInputTest.java
+++ b/src/test/java/org/cactoos/io/UrlAsInputTest.java
@@ -37,16 +37,14 @@ import org.takes.tk.TkHtml;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class UrlAsInputTest {
 
-    /**
-     * UrlAsInput can read file content.
-     * @throws IOException If some problem inside
-     */
     @Test
     public void readsFileContent() throws IOException {
         MatcherAssert.assertThat(
+            "Can't read bytes from a file-system URL",
             new InputAsBytes(
                 new UrlAsInput(
                     this.getClass().getResource(
@@ -58,14 +56,11 @@ public final class UrlAsInputTest {
         );
     }
 
-    /**
-     * UrlAsInput can read real URL.
-     * @throws IOException If some problem inside
-     */
     @Test
     public void readsRealUrl() throws IOException {
         new FtRemote(new TkHtml("<html>How are you?</html>")).exec(
             home -> MatcherAssert.assertThat(
+                "Can't fetch bytes from the URL",
                 new BytesAsText(
                     new InputAsBytes(
                         new UrlAsInput(
diff --git a/src/test/java/org/cactoos/list/AllOfTest.java b/src/test/java/org/cactoos/list/AllOfTest.java
index 51e29095..a440ace2 100644
--- a/src/test/java/org/cactoos/list/AllOfTest.java
+++ b/src/test/java/org/cactoos/list/AllOfTest.java
@@ -28,6 +28,7 @@ import java.util.LinkedList;
 import java.util.List;
 import org.cactoos.Func;
 import org.cactoos.ScalarHasValue;
+import org.cactoos.func.FuncAsMatcher;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.junit.Test;
@@ -37,33 +38,37 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class AllOfTest {
 
-    /**
-     * AllOf can test all items in the list.
-     */
     @Test
     public void iteratesList() {
         final List<String> list = new LinkedList<>();
         MatcherAssert.assertThat(
+            "Can't iterate a list with a procedure",
             new AllOf(
                 new TransformedIterable<>(
                     new ArrayAsIterable<>("hello", "world"),
                     (Func.Quiet<String>) list::add
                 )
             ),
-            new ScalarHasValue<>(true)
+            new ScalarHasValue<>(
+                Matchers.allOf(
+                    Matchers.equalTo(true),
+                    new FuncAsMatcher<>(
+                        value -> list.size() == 2
+                    )
+                )
+            )
         );
     }
 
-    /**
-     * AllOf can test all items in the list.
-     */
     @Test
     public void iteratesEmptyList() {
         final List<String> list = new LinkedList<>();
         MatcherAssert.assertThat(
+            "Can't iterate a list",
             new AllOf(
                 new IterableAsBooleans<>(
                     Collections.emptyList(),
@@ -73,7 +78,9 @@ public final class AllOfTest {
             new ScalarHasValue<>(
                 Matchers.allOf(
                     Matchers.equalTo(true),
-                    Matchers.equalTo(list.isEmpty())
+                    new FuncAsMatcher<>(
+                        value -> list.isEmpty()
+                    )
                 )
             )
         );
diff --git a/src/test/java/org/cactoos/list/AnyOfTest.java b/src/test/java/org/cactoos/list/AnyOfTest.java
index 95abae2b..884478e1 100644
--- a/src/test/java/org/cactoos/list/AnyOfTest.java
+++ b/src/test/java/org/cactoos/list/AnyOfTest.java
@@ -32,15 +32,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class AnyOfTest {
 
-    /**
-     * AnyOf can test any item in the list.
-     */
     @Test
     public void iteratesList() {
         MatcherAssert.assertThat(
+            "Can't iterate a list",
             new AnyOf(
                 new TransformedIterable<>(
                     new ArrayAsIterable<>("a", "file", "is", "corrupt"),
diff --git a/src/test/java/org/cactoos/list/ConcatenatedIterableTest.java b/src/test/java/org/cactoos/list/ConcatenatedIterableTest.java
index 90f5d979..4cd4662c 100644
--- a/src/test/java/org/cactoos/list/ConcatenatedIterableTest.java
+++ b/src/test/java/org/cactoos/list/ConcatenatedIterableTest.java
@@ -32,16 +32,15 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class ConcatenatedIterableTest {
 
-    /**
-     * ConcatenatedIterable can concatenate two lists.
-     */
     @Test
     @SuppressWarnings("unchecked")
     public void transformsList() {
         MatcherAssert.assertThat(
+            "Can't concatenate iterables together",
             new LengthOfIterable(
                 new ConcatenatedIterable<>(
                     new ArrayAsIterable<>("hello", "world", "друг"),
diff --git a/src/test/java/org/cactoos/list/FilteredIterableTest.java b/src/test/java/org/cactoos/list/FilteredIterableTest.java
index 6b0626b2..cac211c5 100644
--- a/src/test/java/org/cactoos/list/FilteredIterableTest.java
+++ b/src/test/java/org/cactoos/list/FilteredIterableTest.java
@@ -32,15 +32,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class FilteredIterableTest {
 
-    /**
-     * FilteredIterable can filter a list.
-     */
     @Test
     public void filtersList() {
         MatcherAssert.assertThat(
+            "Can't calculate the length of an iterable",
             new LengthOfIterable(
                 new FilteredIterable<>(
                     new ArrayAsIterable<>(
@@ -54,12 +53,10 @@ public final class FilteredIterableTest {
         );
     }
 
-    /**
-     * FilteredIterable can filter an empty list.
-     */
     @Test
     public void filtersEmptyList() {
         MatcherAssert.assertThat(
+            "Can't calculate the length of an empty iterable",
             new LengthOfIterable(
                 new FilteredIterable<>(
                     new ArrayAsIterable<String>(),
diff --git a/src/test/java/org/cactoos/list/FirstOfTest.java b/src/test/java/org/cactoos/list/FirstOfTest.java
index 5991c070..0ee7e79a 100644
--- a/src/test/java/org/cactoos/list/FirstOfTest.java
+++ b/src/test/java/org/cactoos/list/FirstOfTest.java
@@ -36,17 +36,14 @@ import org.junit.Test;
  * @author Kirill (g4s8.public@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class FirstOfTest {
 
-    /**
-     * Get first element in collection.
-     *
-     * @throws Exception if failed.
-     */
     @Test
     public void firstElementTest() throws Exception {
         MatcherAssert.assertThat(
+            "Can't take the first item from the iterable",
             new FirstOf<>(
                 // @checkstyle MagicNumber (1 line)
                 Arrays.asList(1, 2, 3)
@@ -55,11 +52,6 @@ public final class FirstOfTest {
         );
     }
 
-    /**
-     * Throws exception if collection is empty.
-     *
-     * @throws Exception expected exception
-     */
     @Test(expected = IOException.class)
     public void failForEmptyCollectionTest() throws Exception {
         new FirstOf<>(Collections.emptyList()).asValue();
diff --git a/src/test/java/org/cactoos/list/IterableAsListTest.java b/src/test/java/org/cactoos/list/IterableAsListTest.java
index d7bba757..53ccd5a1 100644
--- a/src/test/java/org/cactoos/list/IterableAsListTest.java
+++ b/src/test/java/org/cactoos/list/IterableAsListTest.java
@@ -34,18 +34,15 @@ import org.junit.Test;
  * @author Kirill (g4s8.public@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class IterableAsListTest {
 
-    /**
-     * Test element by index.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void elementAtIndexTest() throws Exception {
         final int num = 345;
         MatcherAssert.assertThat(
+            "Can't convert an iterable to a list",
             new IterableAsList<>(
                 // @checkstyle MagicNumber (2 lines)
                 new ArrayAsIterable<>(0, 1, 2, num, 3, 4)
@@ -54,15 +51,11 @@ public final class IterableAsListTest {
         );
     }
 
-    /**
-     * Test size of list.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void sizeTest() throws Exception {
         final int size = 42;
         MatcherAssert.assertThat(
+            "Can't build a list with a certain size",
             new IterableAsList<>(
                 Collections.nCopies(size, 0)
             ),
@@ -70,14 +63,10 @@ public final class IterableAsListTest {
         );
     }
 
-    /**
-     * Test empty IterableAsList.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void emptyTest() throws Exception {
         MatcherAssert.assertThat(
+            "Can't convert an empty iterable to an empty list",
             new IterableAsList<>(
                 Collections.emptyList()
             ).size(),
@@ -85,22 +74,12 @@ public final class IterableAsListTest {
         );
     }
 
-    /**
-     * Test low bound of list.
-     *
-     * @throws Exception if failed
-     */
     @Test(expected = IndexOutOfBoundsException.class)
     public void lowBoundTest() throws Exception {
         // @checkstyle MagicNumber (1 line)
         new IterableAsList<>(Collections.nCopies(10, 0)).get(-1);
     }
 
-    /**
-     * Test high bound of list.
-     *
-     * @throws Exception if failed
-     */
     @Test(expected = IndexOutOfBoundsException.class)
     public void highBoundTest() throws Exception {
         // @checkstyle MagicNumber (1 line)
diff --git a/src/test/java/org/cactoos/list/RepeatTest.java b/src/test/java/org/cactoos/list/RepeatTest.java
index 334b6ac2..b459d49c 100644
--- a/src/test/java/org/cactoos/list/RepeatTest.java
+++ b/src/test/java/org/cactoos/list/RepeatTest.java
@@ -33,19 +33,16 @@ import org.junit.Test;
  * @author Kirill (g4s8.public@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class RepeatTest {
 
-    /**
-     * Test all elements are same.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void allSameTest() throws Exception {
         final int size = 42;
         final int element = 11;
         MatcherAssert.assertThat(
+            "Can't generate an iterable with fixed size",
             new LengthOfIterable(
                 new FilteredIterable<>(
                     new Repeat<>(
@@ -59,14 +56,10 @@ public final class RepeatTest {
         );
     }
 
-    /**
-     * Test empty 'repeat' size.
-     *
-     * @throws Exception if failed
-     */
     @Test
     public void emptyTest() throws Exception {
         MatcherAssert.assertThat(
+            "Can't generate an empty iterable",
             new LengthOfIterable(
                 new Repeat<>(0, 0)
             ),
diff --git a/src/test/java/org/cactoos/list/TransformedIterableTest.java b/src/test/java/org/cactoos/list/TransformedIterableTest.java
index 0e7bc2ff..b2e8cf11 100644
--- a/src/test/java/org/cactoos/list/TransformedIterableTest.java
+++ b/src/test/java/org/cactoos/list/TransformedIterableTest.java
@@ -37,16 +37,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class TransformedIterableTest {
 
-    /**
-     * TransformedIterable can transform a list.
-     * @throws IOException If fails
-     */
     @Test
     public void transformsList() throws IOException {
         MatcherAssert.assertThat(
+            "Can't transform an iterable",
             new TransformedIterable<String, Text>(
                 new ArrayAsIterable<>(
                     "hello", "world", "друг"
@@ -57,13 +55,10 @@ public final class TransformedIterableTest {
         );
     }
 
-    /**
-     * TransformedIterable can transform an empty list.
-     * @throws IOException If fails
-     */
     @Test
-    public void transformsEmptyList() throws IOException {
+    public void transformsEmptyList() {
         MatcherAssert.assertThat(
+            "Can't transform an empty iterable",
             new TransformedIterable<String, Text>(
                 Collections.emptyList(),
                 input -> new UpperText(new StringAsText(input))
diff --git a/src/test/java/org/cactoos/text/BytesAsTextTest.java b/src/test/java/org/cactoos/text/BytesAsTextTest.java
index 020b6fdd..f71f9476 100644
--- a/src/test/java/org/cactoos/text/BytesAsTextTest.java
+++ b/src/test/java/org/cactoos/text/BytesAsTextTest.java
@@ -33,15 +33,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.2
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class BytesAsTextTest {
 
-    /**
-     * BytesAsText converts bytes to String.
-     */
     @Test
     public void convertsBytesToText() {
         MatcherAssert.assertThat(
+            "Can't convert bytes to text",
             new BytesAsText(
                 new ArrayAsBytes(
                     new byte[]{'H', 'e', 'l', 'l', 'o'}
diff --git a/src/test/java/org/cactoos/text/FormattedTextTest.java b/src/test/java/org/cactoos/text/FormattedTextTest.java
index 5ee3d56c..13e305f9 100644
--- a/src/test/java/org/cactoos/text/FormattedTextTest.java
+++ b/src/test/java/org/cactoos/text/FormattedTextTest.java
@@ -34,15 +34,14 @@ import org.junit.Test;
  * @author Andriy Kryvtsun (kontiky@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class FormattedTextTest {
 
-    /**
-     * FormattedText produces correct text.
-     */
     @Test
     public void formatsText() {
         MatcherAssert.assertThat(
+            "Can't format a text",
             new FormattedText(
                 "%d. Formatted %s", 1, "text"
             ),
@@ -50,12 +49,10 @@ public final class FormattedTextTest {
         );
     }
 
-    /**
-     * Format with locale.
-     */
     @Test
     public void formatsWithLocale() {
         MatcherAssert.assertThat(
+            "Can't format a text with Locale",
             new FormattedText(
                 // @checkstyle MagicNumber (1 line)
                 "%,d", Locale.GERMAN, 1234567890
diff --git a/src/test/java/org/cactoos/text/IsBlankTest.java b/src/test/java/org/cactoos/text/IsBlankTest.java
index ac85048f..77926a31 100644
--- a/src/test/java/org/cactoos/text/IsBlankTest.java
+++ b/src/test/java/org/cactoos/text/IsBlankTest.java
@@ -32,15 +32,14 @@ import org.junit.Test;
  * @author Andriy Kryvtsun (kontiky@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class IsBlankTest {
 
-    /**
-     * IsBlank can detect empty string.
-     */
     @Test
     public void determinesEmptyText() {
         MatcherAssert.assertThat(
+            "Can't determine an empty text",
             new IsBlank(
                 new StringAsText("")
             ),
@@ -48,12 +47,10 @@ public final class IsBlankTest {
         );
     }
 
-    /**
-     * IsBlank can detect blank string.
-     */
     @Test
     public void determinesBlankText() {
         MatcherAssert.assertThat(
+            "Can't determine an empty text with spaces",
             new IsBlank(
                 new StringAsText("  ")
             ),
@@ -61,12 +58,10 @@ public final class IsBlankTest {
         );
     }
 
-    /**
-     * IsBlank can detect non blank string.
-     */
     @Test
     public void determinesNotBlankText() {
         MatcherAssert.assertThat(
+            "Can't detect a nonempty text",
             new IsBlank(
                 new StringAsText("not empty")
             ),
diff --git a/src/test/java/org/cactoos/text/TextAsBytesTest.java b/src/test/java/org/cactoos/text/TextAsBytesTest.java
index f17d0383..d45c1687 100644
--- a/src/test/java/org/cactoos/text/TextAsBytesTest.java
+++ b/src/test/java/org/cactoos/text/TextAsBytesTest.java
@@ -25,8 +25,8 @@ package org.cactoos.text;
 
 import java.io.IOException;
 import org.cactoos.Text;
+import org.cactoos.io.BytesAsInput;
 import org.cactoos.io.InputAsBytes;
-import org.cactoos.io.TextAsInput;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.junit.Test;
@@ -37,20 +37,19 @@ import org.junit.Test;
  * @author Vseslav Sekorin (vssekorin@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class TextAsBytesTest {
 
-    /**
-     * TextAsBytes can convert with default encoding.
-     *
-     * @throws IOException If some problem inside
-     */
     @Test
     public void asBytes() throws IOException {
         final Text text = new StringAsText("Hello!");
         MatcherAssert.assertThat(
+            "Can't convert text into bytes",
             new InputAsBytes(
-                new TextAsInput(text)
+                new BytesAsInput(
+                    new TextAsBytes(text)
+                )
             ).asBytes(),
             Matchers.equalTo(
                 new TextAsBytes(text).asBytes()
diff --git a/src/test/java/org/cactoos/text/ThrowableAsBytesTest.java b/src/test/java/org/cactoos/text/ThrowableAsBytesTest.java
index 423799b7..0bf958e8 100644
--- a/src/test/java/org/cactoos/text/ThrowableAsBytesTest.java
+++ b/src/test/java/org/cactoos/text/ThrowableAsBytesTest.java
@@ -35,15 +35,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.2
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class ThrowableAsBytesTest {
 
-    /**
-     * ThrowableAsBytes prints stacktrace.
-     */
     @Test
     public void printsStackTrace() {
         MatcherAssert.assertThat(
+            "Can't print exception stacktrace",
             new BytesAsText(
                 new ThrowableAsBytes(
                     new IOException(
diff --git a/src/test/java/org/cactoos/text/TrimmedTextTest.java b/src/test/java/org/cactoos/text/TrimmedTextTest.java
index b72ae584..2225c1c4 100644
--- a/src/test/java/org/cactoos/text/TrimmedTextTest.java
+++ b/src/test/java/org/cactoos/text/TrimmedTextTest.java
@@ -32,15 +32,15 @@ import org.junit.Test;
  * @author Vseslav Sekorin (vssekorin@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class TrimmedTextTest {
-    /**
-     * TrimmedText can process text.
-     */
+
     @Test
     public void convertsText() {
         MatcherAssert.assertThat(
-            new TrimmedText(new StringAsText("  Hello!    ")),
+            "Can't trim a text",
+            new TrimmedText(new StringAsText("  Hello!   \t ")),
             new TextHasString("Hello!")
         );
     }
diff --git a/src/test/java/org/cactoos/text/UpperTextTest.java b/src/test/java/org/cactoos/text/UpperTextTest.java
index a109d32e..cf574ac6 100644
--- a/src/test/java/org/cactoos/text/UpperTextTest.java
+++ b/src/test/java/org/cactoos/text/UpperTextTest.java
@@ -32,15 +32,14 @@ import org.junit.Test;
  * @author Yegor Bugayenko (yegor256@gmail.com)
  * @version $Id$
  * @since 0.1
+ * @checkstyle JavadocMethodCheck (500 lines)
  */
 public final class UpperTextTest {
 
-    /**
-     * UpperText can process text.
-     */
     @Test
     public void convertsText() {
         MatcherAssert.assertThat(
+            "Can't upper case a text",
             new UpperText(new StringAsText("Hello!")),
             new TextHasString("HELLO!")
         );