diff --git a/src/main/java/org/cactoos/io/package-info.java b/src/main/java/org/cactoos/io/package-info.java index 9aa77480ec..8d234f100b 100644 --- a/src/main/java/org/cactoos/io/package-info.java +++ b/src/main/java/org/cactoos/io/package-info.java @@ -26,5 +26,9 @@ * Input/Output. * * @since 0.1 + * @todo #1033:30min Continue replacing usage of MatcherAssert.assertThat with + * Assertion from cactoos-matchers. Once there is no more usage of + * MatcherAssert.assertThat, add the signature of MatcherAssert.assertThat to + * forbidden-apis.txt */ package org.cactoos.io; diff --git a/src/test/java/org/cactoos/TextTest.java b/src/test/java/org/cactoos/TextTest.java index e684d7b7f2..cae9640840 100644 --- a/src/test/java/org/cactoos/TextTest.java +++ b/src/test/java/org/cactoos/TextTest.java @@ -25,7 +25,6 @@ import org.cactoos.text.NoNulls; import org.cactoos.text.TextOf; -import org.hamcrest.MatcherAssert; import org.junit.Test; import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.TextHasString; @@ -65,13 +64,13 @@ public void failForNullResult() { @Test public void okForNoNulls() { final String message = "Hello"; - MatcherAssert.assertThat( - "Can't work with null text", - new NoNulls( + new Assertion<>( + "Must work with NoNulls", + () -> new NoNulls( new TextOf(message) ), new TextHasString(message) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/io/LSInputOfTest.java b/src/test/java/org/cactoos/io/LSInputOfTest.java index 9721d2110c..8448eefade 100644 --- a/src/test/java/org/cactoos/io/LSInputOfTest.java +++ b/src/test/java/org/cactoos/io/LSInputOfTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.io; -import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link LSInputOf}. @@ -38,41 +38,41 @@ public final class LSInputOfTest { @Test public void readsSimpleInput() { - MatcherAssert.assertThat( + new Assertion<>( "Can't read simple input", - new LSInputOf( + () -> new LSInputOf( new InputOf("hello, world!") ).getStringData(), Matchers.endsWith("world!") - ); + ).affirm(); } @Test public void readsBiggerInput() { final int size = 400_000; - MatcherAssert.assertThat( + new Assertion<>( "Can't read bigger input", - new LSInputOf( + () -> new LSInputOf( new InputOf( new SlowInputStream(size) ) ).getStringData().length(), Matchers.equalTo(size) - ); + ).affirm(); } @Test public void countsBytesInBiggerInput() { final int size = 300_000; - MatcherAssert.assertThat( + new Assertion<>( "Can't count bytes in a bigger input", - new LSInputOf( + () -> new LSInputOf( new InputOf( new SlowInputStream(size) ) ).getStringData().length(), Matchers.equalTo(size) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/io/TeeInputFromReaderTest.java b/src/test/java/org/cactoos/io/TeeInputFromReaderTest.java index c2281f1213..9956d8e132 100644 --- a/src/test/java/org/cactoos/io/TeeInputFromReaderTest.java +++ b/src/test/java/org/cactoos/io/TeeInputFromReaderTest.java @@ -27,10 +27,10 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import org.cactoos.text.TextOf; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.TeeInputHasResult; /** @@ -54,8 +54,9 @@ public void copiesFromReaderToFile() throws IOException { final String input = "Hello, товарищ file #1 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader to file.", + () -> new TeeInput( new ReaderOf(input), output ), @@ -63,7 +64,7 @@ public void copiesFromReaderToFile() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -71,8 +72,9 @@ public void copiesFromReaderWithSizeToFile() throws IOException { final String input = "Hello, товарищ file #2 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with size to file.", + () -> new TeeInput( new ReaderOf(input), output, input.length() @@ -81,7 +83,7 @@ public void copiesFromReaderWithSizeToFile() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -89,8 +91,9 @@ public void copiesFromReaderWithCharsetToFile() throws IOException { final String input = "Hello, товарищ file #3 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset to file.", + () -> new TeeInput( new ReaderOf(input), output, StandardCharsets.UTF_8 @@ -99,7 +102,7 @@ public void copiesFromReaderWithCharsetToFile() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -107,8 +110,9 @@ public void copiesFromReaderWithCharsetAndSizeToFile() throws IOException { final String input = "Hello, товарищ file #4 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset and size to file.", + () -> new TeeInput( new ReaderOf(input), output, StandardCharsets.UTF_8, @@ -118,7 +122,7 @@ public void copiesFromReaderWithCharsetAndSizeToFile() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -126,8 +130,9 @@ public void copiesFromReaderWithCharsetByNameToFile() throws IOException { final String input = "Hello, товарищ file #5 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name to file.", + () -> new TeeInput( new ReaderOf(input), output, StandardCharsets.UTF_8.name() @@ -136,7 +141,7 @@ public void copiesFromReaderWithCharsetByNameToFile() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -145,8 +150,9 @@ public void copiesFromReaderWithCharsetByNameAndSizeToFile() final String input = "Hello, товарищ file #6 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name and size to file.", + () -> new TeeInput( new ReaderOf(input), output, StandardCharsets.UTF_8.name(), @@ -156,7 +162,7 @@ public void copiesFromReaderWithCharsetByNameAndSizeToFile() input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -164,8 +170,9 @@ public void copiesFromReaderToPath() throws IOException { final String input = "Hello, товарищ path #1 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader to path.", + () -> new TeeInput( new ReaderOf(input), output.toPath() ), @@ -173,7 +180,7 @@ public void copiesFromReaderToPath() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -181,8 +188,9 @@ public void copiesFromReaderWithSizeToPath() throws IOException { final String input = "Hello, товарищ path #2 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with size to path", + () -> new TeeInput( new ReaderOf(input), output.toPath(), input.length() @@ -191,7 +199,7 @@ public void copiesFromReaderWithSizeToPath() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -199,8 +207,9 @@ public void copiesFromReaderWithCharsetToPath() throws IOException { final String input = "Hello, товарищ path #3 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset to path.", + () -> new TeeInput( new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8 @@ -209,7 +218,7 @@ public void copiesFromReaderWithCharsetToPath() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -217,8 +226,9 @@ public void copiesFromReaderWithCharsetAndSizeToPath() throws IOException { final String input = "Hello, товарищ path #4 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset and size to path.", + () -> new TeeInput( new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8, @@ -228,7 +238,7 @@ public void copiesFromReaderWithCharsetAndSizeToPath() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -236,8 +246,9 @@ public void copiesFromReaderWithCharsetByNameToPath() throws IOException { final String input = "Hello, товарищ path #5 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name to path.", + () -> new TeeInput( new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8.name() @@ -246,7 +257,7 @@ public void copiesFromReaderWithCharsetByNameToPath() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -255,8 +266,9 @@ public void copiesFromReaderWithCharsetByNameAndSizeToPath() final String input = "Hello, товарищ path #6 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name and size to path.", + () -> new TeeInput( new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8.name(), @@ -266,7 +278,7 @@ public void copiesFromReaderWithCharsetByNameAndSizeToPath() input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -274,8 +286,9 @@ public void copiesFromReaderToOutput() throws IOException { final String input = "Hello, товарищ output #1 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output) ), @@ -283,7 +296,7 @@ public void copiesFromReaderToOutput() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -291,8 +304,9 @@ public void copiesFromReaderWithSizeToOutput() throws IOException { final String input = "Hello, товарищ output #2 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with size to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output), input.length() @@ -301,7 +315,7 @@ public void copiesFromReaderWithSizeToOutput() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -309,8 +323,9 @@ public void copiesFromReaderWithCharsetToOutput() throws IOException { final String input = "Hello, товарищ output #3 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output), StandardCharsets.UTF_8 @@ -319,7 +334,7 @@ public void copiesFromReaderWithCharsetToOutput() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -328,8 +343,9 @@ public void copiesFromReaderWithCharsetAndSizeToOutput() final String input = "Hello, товарищ output #4 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset and size to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output), StandardCharsets.UTF_8, @@ -339,7 +355,7 @@ public void copiesFromReaderWithCharsetAndSizeToOutput() input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -347,8 +363,9 @@ public void copiesFromReaderWithCharsetByNameToOutput() throws IOException { final String input = "Hello, товарищ output #5 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output), StandardCharsets.UTF_8.name() @@ -357,7 +374,7 @@ public void copiesFromReaderWithCharsetByNameToOutput() throws IOException { input, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -366,8 +383,9 @@ public void copiesFromReaderWithCharsetByNameAndSizeToOutput() final String input = "Hello, товарищ output #6 äÄ üÜ öÖ and ß"; final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from reader with charset by name and size to output.", + () -> new TeeInput( new ReaderOf(input), new OutputTo(output), StandardCharsets.UTF_8.name(), @@ -377,6 +395,6 @@ public void copiesFromReaderWithCharsetByNameAndSizeToOutput() input, new TextOf(output) ) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/io/TeeInputFromUriTest.java b/src/test/java/org/cactoos/io/TeeInputFromUriTest.java index 7cd4c78798..f21cd99260 100644 --- a/src/test/java/org/cactoos/io/TeeInputFromUriTest.java +++ b/src/test/java/org/cactoos/io/TeeInputFromUriTest.java @@ -28,10 +28,10 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import org.cactoos.text.TextOf; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.TeeInputHasResult; /** @@ -59,8 +59,9 @@ public void copiesFromUriToPath() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URI to path.", + () -> new TeeInput( input.toURI(), output ), @@ -68,7 +69,7 @@ public void copiesFromUriToPath() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -81,8 +82,9 @@ public void copiesFromUriToFile() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URI to file.", + () -> new TeeInput( input.toURI(), output ), @@ -90,7 +92,7 @@ public void copiesFromUriToFile() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -103,8 +105,9 @@ public void copiesFromUriToOutput() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URI to output.", + () -> new TeeInput( input.toURI(), new OutputTo(output) ), @@ -112,6 +115,6 @@ public void copiesFromUriToOutput() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/io/TeeInputFromUrlTest.java b/src/test/java/org/cactoos/io/TeeInputFromUrlTest.java index 905957494a..e85f6e4b28 100644 --- a/src/test/java/org/cactoos/io/TeeInputFromUrlTest.java +++ b/src/test/java/org/cactoos/io/TeeInputFromUrlTest.java @@ -28,10 +28,10 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import org.cactoos.text.TextOf; -import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.TeeInputHasResult; /** @@ -59,8 +59,9 @@ public void copiesFromUrlToPath() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URL to path.", + () -> new TeeInput( input .toURI() .toURL(), @@ -70,7 +71,7 @@ public void copiesFromUrlToPath() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -83,8 +84,9 @@ public void copiesFromUrlToFile() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URL to file.", + () -> new TeeInput( input .toURI() .toURL(), @@ -94,7 +96,7 @@ public void copiesFromUrlToFile() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } @Test @@ -107,8 +109,9 @@ public void copiesFromUrlToOutput() throws IOException { message.getBytes(StandardCharsets.UTF_8) ); final File output = this.folder.newFile(); - MatcherAssert.assertThat( - new TeeInput( + new Assertion<>( + "Must copy from URL to output.", + () -> new TeeInput( input .toURI() .toURL(), @@ -118,6 +121,6 @@ public void copiesFromUrlToOutput() throws IOException { message, new TextOf(output) ) - ); + ).affirm(); } }