diff --git a/src/test/java/org/cactoos/MatcherAssert.java b/src/test/java/org/cactoos/MatcherAssert.java index 7a1e0f8015..f39f31d0a9 100644 --- a/src/test/java/org/cactoos/MatcherAssert.java +++ b/src/test/java/org/cactoos/MatcherAssert.java @@ -40,15 +40,8 @@ public final class MatcherAssert { private MatcherAssert() { } - public static void assertThat(final T actual, - final Matcher matcher) { - MatcherAssert.assertThat( - "", actual, matcher - ); - } - public static void assertThat(final String desc, - final T actual, final Matcher matcher) { + final T actual, final Matcher matcher) { new Assertion<>( desc, actual, diff --git a/src/test/java/org/cactoos/func/IoCheckedBiFuncTest.java b/src/test/java/org/cactoos/func/IoCheckedBiFuncTest.java index d38f3139b9..9ec96514e6 100644 --- a/src/test/java/org/cactoos/func/IoCheckedBiFuncTest.java +++ b/src/test/java/org/cactoos/func/IoCheckedBiFuncTest.java @@ -24,9 +24,9 @@ package org.cactoos.func; import java.io.IOException; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IoCheckedBiFunc}. @@ -45,9 +45,11 @@ public void rethrowsIoException() { } ).apply(1, 2); } catch (final IOException ex) { - MatcherAssert.assertThat( - ex, Matchers.is(exception) - ); + new Assertion<>( + "", + ex, + Matchers.is(exception) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/IoCheckedFuncTest.java b/src/test/java/org/cactoos/func/IoCheckedFuncTest.java index 9400af70e0..5c41195604 100644 --- a/src/test/java/org/cactoos/func/IoCheckedFuncTest.java +++ b/src/test/java/org/cactoos/func/IoCheckedFuncTest.java @@ -25,9 +25,9 @@ import java.io.IOException; import org.cactoos.Func; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IoCheckedFunc}. @@ -47,9 +47,11 @@ public void rethrowsIoException() { } ).apply(1); } catch (final IOException ex) { - MatcherAssert.assertThat( - ex, Matchers.is(exception) - ); + new Assertion<>( + "", + ex, + Matchers.is(exception) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/IoCheckedProcTest.java b/src/test/java/org/cactoos/func/IoCheckedProcTest.java index 9ffe8e4345..663c01b389 100644 --- a/src/test/java/org/cactoos/func/IoCheckedProcTest.java +++ b/src/test/java/org/cactoos/func/IoCheckedProcTest.java @@ -24,10 +24,10 @@ package org.cactoos.func; import java.io.IOException; -import org.cactoos.MatcherAssert; import org.cactoos.Proc; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IoCheckedProc}. @@ -46,9 +46,11 @@ public void rethrowsIoException() { } ).exec(1); } catch (final IOException ex) { - MatcherAssert.assertThat( - ex, Matchers.is(exception) - ); + new Assertion<>( + "", + ex, + Matchers.is(exception) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/RepeatedTest.java b/src/test/java/org/cactoos/func/RepeatedTest.java index ce54389777..5b693eacdb 100644 --- a/src/test/java/org/cactoos/func/RepeatedTest.java +++ b/src/test/java/org/cactoos/func/RepeatedTest.java @@ -26,10 +26,10 @@ import java.security.SecureRandom; import java.util.Iterator; import org.cactoos.Func; -import org.cactoos.MatcherAssert; import org.cactoos.iterator.IteratorOf; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link Repeated}. @@ -49,10 +49,11 @@ public void runsFuncMultipleTimes() throws Exception { }, 3 ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true), Matchers.equalTo(5) - ); + ).affirm(); } @Test @@ -63,10 +64,11 @@ public void repeatsNullsResults() throws Exception { }, 2 ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true), Matchers.equalTo(null) - ); + ).affirm(); } @Test(expected = IllegalArgumentException.class) @@ -77,9 +79,10 @@ public void doesntRepeatAny() throws Exception { }, 0 ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true), Matchers.equalTo(func.apply(true)) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/SolidFuncTest.java b/src/test/java/org/cactoos/func/SolidFuncTest.java index 404699d864..3df57d667d 100644 --- a/src/test/java/org/cactoos/func/SolidFuncTest.java +++ b/src/test/java/org/cactoos/func/SolidFuncTest.java @@ -29,6 +29,7 @@ import org.cactoos.list.ListOf; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.RunsInThreads; /** @@ -44,10 +45,11 @@ public void cachesFuncResults() throws Exception { final Func func = new SolidFunc<>( input -> new SecureRandom().nextInt() ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true) + func.apply(true), Matchers.equalTo(func.apply(true) + func.apply(true)) - ); + ).affirm(); } @Test @@ -55,10 +57,11 @@ public void worksInThreads() { MatcherAssert.assertThat( "Can't work well in multiple threads", func -> { - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true), Matchers.equalTo(func.apply(true)) - ); + ).affirm(); return true; }, new RunsInThreads<>( diff --git a/src/test/java/org/cactoos/func/StickyBiFuncTest.java b/src/test/java/org/cactoos/func/StickyBiFuncTest.java index 1155449e72..aff51a98f6 100644 --- a/src/test/java/org/cactoos/func/StickyBiFuncTest.java +++ b/src/test/java/org/cactoos/func/StickyBiFuncTest.java @@ -25,9 +25,9 @@ import java.security.SecureRandom; import org.cactoos.BiFunc; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link StickyBiFunc}. @@ -41,10 +41,11 @@ public void cachesFuncResults() throws Exception { final BiFunc func = new StickyBiFunc<>( (first, second) -> new SecureRandom().nextInt() ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true, true) + func.apply(true, true), Matchers.equalTo(func.apply(true, true) + func.apply(true, true)) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/StickyFuncTest.java b/src/test/java/org/cactoos/func/StickyFuncTest.java index 9252a78e3b..8ee1eab7e9 100644 --- a/src/test/java/org/cactoos/func/StickyFuncTest.java +++ b/src/test/java/org/cactoos/func/StickyFuncTest.java @@ -25,9 +25,9 @@ import java.security.SecureRandom; import org.cactoos.Func; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link StickyFunc}. @@ -42,10 +42,11 @@ public void cachesFuncResults() throws Exception { final Func func = new StickyFunc<>( input -> new SecureRandom().nextInt() ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true) + func.apply(true), Matchers.equalTo(func.apply(true) + func.apply(true)) - ); + ).affirm(); } @Test @@ -55,15 +56,17 @@ public void cachesWithLimitedBuffer() throws Exception { ); final int first = func.apply(0); final int second = func.apply(1); - MatcherAssert.assertThat( + new Assertion<>( + "", first + second, Matchers.equalTo(func.apply(0) + func.apply(1)) - ); + ).affirm(); final int third = func.apply(-1); - MatcherAssert.assertThat( + new Assertion<>( + "", second + third, Matchers.equalTo(func.apply(1) + func.apply(-1)) - ); + ).affirm(); } @Test @@ -71,10 +74,11 @@ public void cachesWithZeroBuffer() throws Exception { final Func func = new StickyFunc<>( input -> new SecureRandom().nextInt(), 0 ); - MatcherAssert.assertThat( + new Assertion<>( + "", func.apply(true) + func.apply(true), Matchers.not(Matchers.equalTo(func.apply(true) + func.apply(true))) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/SyncFuncTest.java b/src/test/java/org/cactoos/func/SyncFuncTest.java index 9825999d31..ef83830726 100644 --- a/src/test/java/org/cactoos/func/SyncFuncTest.java +++ b/src/test/java/org/cactoos/func/SyncFuncTest.java @@ -28,6 +28,7 @@ import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.RunsInThreads; /** @@ -54,7 +55,11 @@ public void funcWorksInThreads() { threads ) ); - MatcherAssert.assertThat(list.size(), Matchers.equalTo(threads)); + new Assertion<>( + "", + list.size(), + Matchers.equalTo(threads) + ).affirm(); } @Test @@ -74,7 +79,11 @@ public void procWorksInThreads() { threads ) ); - MatcherAssert.assertThat(counter[0], Matchers.equalTo(threads)); + new Assertion<>( + "", + counter[0], + Matchers.equalTo(threads) + ).affirm(); } @Test @@ -94,7 +103,11 @@ public void callableWorksInThreads() { threads ) ); - MatcherAssert.assertThat(counter[0], Matchers.equalTo(threads)); + new Assertion<>( + "", + counter[0], + Matchers.equalTo(threads) + ).affirm(); } @Test @@ -112,6 +125,10 @@ public void runnableWorksInThreads() { threads ) ); - MatcherAssert.assertThat(counter[0], Matchers.equalTo(threads)); + new Assertion<>( + "", + counter[0], + Matchers.equalTo(threads) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/TimedFuncTest.java b/src/test/java/org/cactoos/func/TimedFuncTest.java index c975dbc57b..cfc58f92aa 100644 --- a/src/test/java/org/cactoos/func/TimedFuncTest.java +++ b/src/test/java/org/cactoos/func/TimedFuncTest.java @@ -26,11 +26,11 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; -import org.cactoos.MatcherAssert; import org.cactoos.iterable.Endless; import org.cactoos.scalar.And; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link Timed}. @@ -71,23 +71,25 @@ public void futureTaskIsCancelled() { ).apply(true); // @checkstyle IllegalCatchCheck (1 line) } catch (final Exception exp) { - MatcherAssert.assertThat( + new Assertion<>( + "", future.isCancelled(), Matchers.equalTo(true) - ); + ).affirm(); } } @Test public void functionIsExecuted() throws Exception { final long period = 3000L; - MatcherAssert.assertThat( + new Assertion<>( + "", new Timed( input -> true, period ).apply(true), Matchers.equalTo(true) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/func/UncheckedBiFuncTest.java b/src/test/java/org/cactoos/func/UncheckedBiFuncTest.java index d1fa581641..b37c2be3e5 100644 --- a/src/test/java/org/cactoos/func/UncheckedBiFuncTest.java +++ b/src/test/java/org/cactoos/func/UncheckedBiFuncTest.java @@ -25,9 +25,9 @@ import java.io.IOException; import java.io.UncheckedIOException; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link UncheckedBiFunc}. @@ -47,12 +47,13 @@ public void rethrowsCheckedToUncheckedException() { @Test public void testUncheckedBiFunc() { - MatcherAssert.assertThat( + new Assertion<>( + "", new UncheckedBiFunc<>( (fst, scd) -> true ).apply(1, 2), Matchers.equalTo(true) - ); + ).affirm(); } @Test(expected = IllegalStateException.class) diff --git a/src/test/java/org/cactoos/iterable/IterableOfBooleansTest.java b/src/test/java/org/cactoos/iterable/IterableOfBooleansTest.java index 0f9cc2b7f7..1e38fbf908 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfBooleansTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfBooleansTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfBooleans}. @@ -37,9 +37,10 @@ public final class IterableOfBooleansTest { @Test public void convertsBooleanValuesToIterable() { - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfBooleans(true, false), Matchers.contains(true, false) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/IterableOfDoublesTest.java b/src/test/java/org/cactoos/iterable/IterableOfDoublesTest.java index e1b64a82e2..4b1b5069ab 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfDoublesTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfDoublesTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfDoubles}. @@ -38,9 +38,10 @@ public final class IterableOfDoublesTest { @Test public void convertsDoubleValuesToIterable() { final double[] values = new double[]{1, 2, 3}; - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfDoubles(values), Matchers.contains(values[0], values[1], values[2]) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/IterableOfFloatsTest.java b/src/test/java/org/cactoos/iterable/IterableOfFloatsTest.java index 5dc2e8dcd0..05eac60930 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfFloatsTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfFloatsTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfFloats}. @@ -38,9 +38,10 @@ public final class IterableOfFloatsTest { @Test public void convertsFloatValuesToIterable() { final float[] values = {1, 2, 3}; - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfFloats(values), Matchers.contains(values[0], values[1], values[2]) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/IterableOfIntsTest.java b/src/test/java/org/cactoos/iterable/IterableOfIntsTest.java index 85d9da2053..34215c8c73 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfIntsTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfIntsTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfInts}. @@ -38,9 +38,10 @@ public final class IterableOfIntsTest { @Test public void convertsIntegerValuesToIterable() { final int[] values = {1, 2, 3}; - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfInts(values), Matchers.contains(values[0], values[1], values[2]) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/IterableOfLongsTest.java b/src/test/java/org/cactoos/iterable/IterableOfLongsTest.java index 8e5a6ee437..98bee35de8 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfLongsTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfLongsTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfLongs}. @@ -38,9 +38,10 @@ public final class IterableOfLongsTest { @Test public void convertsLongValuesToIterable() { final long[] values = new long[]{1, 2, 3}; - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfLongs(values), Matchers.contains(values[0], values[1], values[2]) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/IterableOfShortsTest.java b/src/test/java/org/cactoos/iterable/IterableOfShortsTest.java index e3a475cd2e..8cc9ec855f 100644 --- a/src/test/java/org/cactoos/iterable/IterableOfShortsTest.java +++ b/src/test/java/org/cactoos/iterable/IterableOfShortsTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.iterable; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link IterableOfShorts}. @@ -38,9 +38,10 @@ public final class IterableOfShortsTest { @SuppressWarnings("PMD.AvoidUsingShortType") public void convertsShortValuesToIterable() { final short[] values = new short[]{1, 2, 3}; - MatcherAssert.assertThat( + new Assertion<>( + "", new IterableOfShorts(values), Matchers.contains(values[0], values[1], values[2]) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/iterable/SolidTest.java b/src/test/java/org/cactoos/iterable/SolidTest.java index 8c8412832e..1eb50dd59e 100644 --- a/src/test/java/org/cactoos/iterable/SolidTest.java +++ b/src/test/java/org/cactoos/iterable/SolidTest.java @@ -27,6 +27,7 @@ import org.cactoos.Scalar; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.RunsInThreads; /** @@ -81,10 +82,11 @@ public void worksInThreads() { MatcherAssert.assertThat( "Can't behave as an iterable in multiple threads", list -> { - MatcherAssert.assertThat( + new Assertion<>( + "", list.iterator().next(), Matchers.equalTo(list.iterator().next()) - ); + ).affirm(); return true; }, new RunsInThreads<>(new Solid<>(1, 0, -1, -1, 2)) diff --git a/src/test/java/org/cactoos/iterable/SyncedTest.java b/src/test/java/org/cactoos/iterable/SyncedTest.java index 1af68677c8..07bd433a75 100644 --- a/src/test/java/org/cactoos/iterable/SyncedTest.java +++ b/src/test/java/org/cactoos/iterable/SyncedTest.java @@ -26,6 +26,7 @@ import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.RunsInThreads; /** @@ -41,10 +42,11 @@ public void worksInThreads() { MatcherAssert.assertThat( "Can't behave as an iterable in multiple threads", list -> { - MatcherAssert.assertThat( + new Assertion<>( + "", list.iterator().next(), Matchers.equalTo(list.iterator().next()) - ); + ).affirm(); return true; }, new RunsInThreads<>(new Synced<>(1, 0, -1, -1, 2)) diff --git a/src/test/java/org/cactoos/iterator/ImmutableTest.java b/src/test/java/org/cactoos/iterator/ImmutableTest.java index 71a64b1e09..169d8a792f 100644 --- a/src/test/java/org/cactoos/iterator/ImmutableTest.java +++ b/src/test/java/org/cactoos/iterator/ImmutableTest.java @@ -27,7 +27,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Random; -import org.cactoos.MatcherAssert; import org.cactoos.text.Randomized; import org.cactoos.text.TextOf; import org.hamcrest.core.IsEqual; @@ -58,7 +57,11 @@ public void decoratesNext() { final Iterator immutable = new Immutable<>( new IteratorOf<>(value) ); - MatcherAssert.assertThat(immutable.next(), new IsEqual<>(value)); + new Assertion<>( + "", + immutable.next(), + new IsEqual(value) + ).affirm(); } @Test @@ -67,9 +70,17 @@ public void decoratesHasNext() { final Iterator immutable = new Immutable<>( new IteratorOf<>(value) ); - MatcherAssert.assertThat(immutable.hasNext(), new IsEqual<>(true)); + new Assertion<>( + "", + immutable.hasNext(), + new IsEqual(true) + ).affirm(); immutable.next(); - MatcherAssert.assertThat(immutable.hasNext(), new IsEqual<>(false)); + new Assertion<>( + "", + immutable.hasNext(), + new IsEqual(false) + ).affirm(); } @Test diff --git a/src/test/java/org/cactoos/list/SyncedTest.java b/src/test/java/org/cactoos/list/SyncedTest.java index 765307ea4e..602abca715 100644 --- a/src/test/java/org/cactoos/list/SyncedTest.java +++ b/src/test/java/org/cactoos/list/SyncedTest.java @@ -26,6 +26,7 @@ import java.util.Collections; import org.cactoos.MatcherAssert; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.RunsInThreads; /** @@ -47,19 +48,26 @@ public void behavesAsCollection() throws Exception { @Test public void worksInThreads() { - MatcherAssert.assertThat( - list -> !list.iterator().hasNext(), - new RunsInThreads<>(new Synced<>(Collections.emptyList())) - ); - MatcherAssert.assertThat( + new Assertion<>( + "", + list1 -> !list1.iterator().hasNext(), + new RunsInThreads<>( + new Synced<>(Collections.emptyList()) + ) + ).affirm(); + new Assertion<>( + "", list -> { - MatcherAssert.assertThat( + new Assertion<>( + "", list, new BehavesAsList<>(0) - ); + ).affirm(); return true; }, - new RunsInThreads<>(new Synced<>(new ListOf<>(1, 0, -1, -1, 2))) - ); + new RunsInThreads<>( + new Synced<>(new ListOf<>(1, 0, -1, -1, 2)) + ) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/map/BehavesAsMap.java b/src/test/java/org/cactoos/map/BehavesAsMap.java index 6e83aed2e1..75ecb60eb5 100644 --- a/src/test/java/org/cactoos/map/BehavesAsMap.java +++ b/src/test/java/org/cactoos/map/BehavesAsMap.java @@ -24,8 +24,8 @@ package org.cactoos.map; import java.util.Map; -import org.cactoos.MatcherAssert; import org.hamcrest.Description; +import org.hamcrest.MatcherAssert; import org.hamcrest.TypeSafeMatcher; import org.hamcrest.collection.IsMapContaining; import org.hamcrest.core.IsCollectionContaining; diff --git a/src/test/java/org/cactoos/scalar/AndInThreadsTest.java b/src/test/java/org/cactoos/scalar/AndInThreadsTest.java index 7f0b8ee64f..741ec9ba8c 100644 --- a/src/test/java/org/cactoos/scalar/AndInThreadsTest.java +++ b/src/test/java/org/cactoos/scalar/AndInThreadsTest.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.cactoos.MatcherAssert; import org.cactoos.Scalar; import org.cactoos.func.FuncOf; import org.cactoos.func.ProcNoNulls; @@ -162,18 +161,20 @@ public void iteratesEmptyList() { @Test public void worksWithFunc() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new AndInThreads( input -> input > 0, 1, -1, 0 ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test public void worksWithIterableScalarBoolean() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new AndInThreads( new ListOf>( new Constant(true), @@ -181,7 +182,7 @@ public void worksWithIterableScalarBoolean() throws Exception { ) ).value(), Matchers.equalTo(true) - ); + ).affirm(); } @Test @@ -193,7 +194,8 @@ public void worksWithExecServiceProcValues() throws Exception { new ProcNoNulls(list::add), 1, 2 ).value(); - MatcherAssert.assertThat( + new Assertion<>( + "", list, new IsIterableContainingInAnyOrder( new ListOf>( @@ -209,7 +211,7 @@ public void worksWithExecServiceProcValues() throws Exception { ) ) ) - ); + ).affirm(); } @Test @@ -221,7 +223,8 @@ public void worksWithExecServiceProcIterable() throws Exception { new ProcNoNulls(list::add), new ListOf<>(1, 2) ).value(); - MatcherAssert.assertThat( + new Assertion<>( + "", list, new IsIterableContainingInAnyOrder( new ListOf>( @@ -237,24 +240,26 @@ public void worksWithExecServiceProcIterable() throws Exception { ) ) ) - ); + ).affirm(); } @Test public void worksWithExecServiceScalarBooleans() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new AndInThreads( Executors.newSingleThreadExecutor(), new Constant(false), new Constant(false) ).value(), Matchers.equalTo(false) - ); + ).affirm(); } @Test public void worksWithExecServiceIterableScalarBoolean() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new AndInThreads( Executors.newSingleThreadExecutor(), new ListOf>( @@ -263,17 +268,18 @@ public void worksWithExecServiceIterableScalarBoolean() throws Exception { ) ).value(), Matchers.equalTo(false) - ); + ).affirm(); } @Test public void worksWithEmptyIterableScalarBoolean() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new AndInThreads( new ListOf>() ).value(), Matchers.equalTo(true) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/scalar/AndTest.java b/src/test/java/org/cactoos/scalar/AndTest.java index 3dce7c025c..2e7e67803f 100644 --- a/src/test/java/org/cactoos/scalar/AndTest.java +++ b/src/test/java/org/cactoos/scalar/AndTest.java @@ -91,35 +91,38 @@ public void emptyIterator() throws Exception { @Test public void testFuncIterable() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new And( input -> input > 0, new IterableOf<>(1, -1, 0) ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test public void testFuncIterator() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new And( input -> input > 0, new IterableOf<>(1, -1, 0) ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test public void testFuncVarargs() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new And( input -> input > 0, -1, -2, 0 ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test diff --git a/src/test/java/org/cactoos/scalar/CheckedTest.java b/src/test/java/org/cactoos/scalar/CheckedTest.java index 90b51274ff..88063454fa 100644 --- a/src/test/java/org/cactoos/scalar/CheckedTest.java +++ b/src/test/java/org/cactoos/scalar/CheckedTest.java @@ -25,9 +25,9 @@ import java.io.FileNotFoundException; import java.io.IOException; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link Checked}. @@ -66,10 +66,11 @@ public void ioExceptionGoesOut() throws Exception { IOException::new ).value(); } catch (final IOException exp) { - MatcherAssert.assertThat( + new Assertion<>( + "", exp.getCause(), Matchers.nullValue() - ); + ).affirm(); } } @@ -83,10 +84,11 @@ public void fileNotFoundExceptionGoesOut() throws Exception { IOException::new ).value(); } catch (final FileNotFoundException exp) { - MatcherAssert.assertThat( + new Assertion<>( + "", exp.getCause(), Matchers.nullValue() - ); + ).affirm(); } } @@ -101,10 +103,11 @@ public void throwsIoExceptionWithModifiedMessage() throws Exception { exp -> new IOException(message, exp) ).value(); } catch (final IOException exp) { - MatcherAssert.assertThat( + new Assertion<>( + "", exp.getMessage(), Matchers.containsString(message) - ); + ).affirm(); } } } diff --git a/src/test/java/org/cactoos/scalar/InheritanceLevelTest.java b/src/test/java/org/cactoos/scalar/InheritanceLevelTest.java index 8ad1cc8ac9..7dc2927f6a 100644 --- a/src/test/java/org/cactoos/scalar/InheritanceLevelTest.java +++ b/src/test/java/org/cactoos/scalar/InheritanceLevelTest.java @@ -24,8 +24,8 @@ package org.cactoos.scalar; import java.io.FileNotFoundException; -import org.cactoos.MatcherAssert; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.ScalarHasValue; /** @@ -38,34 +38,37 @@ public final class InheritanceLevelTest { @Test public void twoInheritanceLevelsBetweenClasses() { - MatcherAssert.assertThat( + new Assertion<>( + "", new InheritanceLevel( FileNotFoundException.class, Exception.class ), - new ScalarHasValue<>(2) - ); + new ScalarHasValue(2) + ).affirm(); } @Test public void classesAreNotRelated() { - MatcherAssert.assertThat( + new Assertion<>( + "", new InheritanceLevel( FileNotFoundException.class, RuntimeException.class ), - new ScalarHasValue<>(Integer.MIN_VALUE) - ); + new ScalarHasValue(Integer.MIN_VALUE) + ).affirm(); } @Test public void classesAreIdentical() { - MatcherAssert.assertThat( + new Assertion<>( + "", new InheritanceLevel( FileNotFoundException.class, FileNotFoundException.class ), - new ScalarHasValue<>(0) - ); + new ScalarHasValue(0) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/scalar/MinOfTest.java b/src/test/java/org/cactoos/scalar/MinOfTest.java index f22b526140..3e6e7e0574 100644 --- a/src/test/java/org/cactoos/scalar/MinOfTest.java +++ b/src/test/java/org/cactoos/scalar/MinOfTest.java @@ -23,10 +23,10 @@ */ package org.cactoos.scalar; -import org.cactoos.MatcherAssert; import org.cactoos.list.ListOf; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link MinOf}. @@ -39,114 +39,130 @@ public final class MinOfTest { @Test public void withIntegerCollection() { - MatcherAssert.assertThat( + new Assertion<>( + "", new MinOf( new ListOf<>(1, 2, 3, 4).toArray(new Integer[4]) ).intValue(), Matchers.equalTo(1) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1, 2, 3, 4).toArray(new Integer[4]) ).longValue(), Matchers.equalTo(1L) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1, 2, 3, 4).toArray(new Integer[4]) ).doubleValue(), Matchers.equalTo(1.0d) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1, 2, 3, 4).toArray(new Integer[4]) ).floatValue(), Matchers.equalTo(1.0f) - ); + ).affirm(); } @Test public void withLongCollection() { - MatcherAssert.assertThat( + new Assertion<>( + "", new MinOf( new ListOf<>(1L, 2L, 3L, 4L).toArray(new Long[4]) ).intValue(), Matchers.equalTo(1) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1L, 2L, 3L, 4L).toArray(new Long[4]) ).longValue(), Matchers.equalTo(1L) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1L, 2L, 3L, 4L).toArray(new Long[4]) ).doubleValue(), Matchers.equalTo(1.0d) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1L, 2L, 3L, 4L).toArray(new Long[4]) ).floatValue(), Matchers.equalTo(1.0f) - ); + ).affirm(); } @Test public void withDoubleCollection() { - MatcherAssert.assertThat( + new Assertion<>( + "", new MinOf( new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4]) ).intValue(), Matchers.equalTo(1) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4]) ).longValue(), Matchers.equalTo(1L) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4]) ).doubleValue(), Matchers.equalTo(1.0d) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4]) ).floatValue(), Matchers.equalTo(1.0f) - ); + ).affirm(); } @Test public void withFloatCollection() { - MatcherAssert.assertThat( + new Assertion<>( + "", new MinOf( new ListOf<>(1.0f, 2.0f, 3.0f, 4.0f).toArray(new Float[4]) ).intValue(), Matchers.equalTo(1) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0f, 2.0f, 3.0f, 4.0f).toArray(new Float[4]) ).longValue(), Matchers.equalTo(1L) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0f, 2.0f, 3.0f, 4.0f).toArray(new Float[4]) ).doubleValue(), Matchers.equalTo(1.0d) - ); - MatcherAssert.assertThat( + ).affirm(); + new Assertion<>( + "", new MinOf( new ListOf<>(1.0f, 2.0f, 3.0f, 4.0f).toArray(new Float[4]) ).floatValue(), Matchers.equalTo(1.0f) - ); + ).affirm(); } } diff --git a/src/test/java/org/cactoos/scalar/OrTest.java b/src/test/java/org/cactoos/scalar/OrTest.java index 66c217bb91..76f7c4c805 100644 --- a/src/test/java/org/cactoos/scalar/OrTest.java +++ b/src/test/java/org/cactoos/scalar/OrTest.java @@ -31,6 +31,7 @@ import org.cactoos.iterable.IterableOf; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.ScalarHasValue; /** @@ -45,7 +46,8 @@ public final class OrTest { @Test public void allFalse() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( new False(), new False(), @@ -53,13 +55,14 @@ public void allFalse() throws Exception { new False(), new False() ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test public void oneTrue() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( new False(), new True(), @@ -67,13 +70,14 @@ public void oneTrue() throws Exception { new False(), new False() ), - new ScalarHasValue<>(true) - ); + new ScalarHasValue(true) + ).affirm(); } @Test public void allTrue() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( new IterableOf>( new True(), @@ -83,16 +87,17 @@ public void allTrue() throws Exception { new True() ) ), - new ScalarHasValue<>(true) - ); + new ScalarHasValue(true) + ).affirm(); } @Test public void emptyIterator() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or(new IterableOf>()), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test @@ -102,10 +107,11 @@ public void testProcIterable() throws Exception { (Proc) list::add, new IterableOf<>(1, 2, 3, 4) ).value(); - MatcherAssert.assertThat( + new Assertion<>( + "", list, Matchers.contains(1, 2, 3, 4) - ); + ).affirm(); } @Test @@ -115,10 +121,11 @@ public void testProcIterator() throws Exception { (Proc) list::add, new IterableOf<>(1, 2, 3, 4) ).value(); - MatcherAssert.assertThat( + new Assertion<>( + "", list, Matchers.contains(1, 2, 3, 4) - ); + ).affirm(); } @Test @@ -128,43 +135,47 @@ public void testProcVarargs() throws Exception { (Proc) list::add, 2, 3, 4 ).value(); - MatcherAssert.assertThat( + new Assertion<>( + "", list, Matchers.contains(2, 3, 4) - ); + ).affirm(); } @Test public void testFuncIterable() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( input -> input > 0, new IterableOf<>(-1, 1, 0) ), - new ScalarHasValue<>(true) - ); + new ScalarHasValue(true) + ).affirm(); } @Test public void testFuncIterator() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( input -> input > 0, new IterableOf<>(-1, 1, 0) ), - new ScalarHasValue<>(true) - ); + new ScalarHasValue(true) + ).affirm(); } @Test public void testFuncVarargs() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Or( input -> input > 0, -1, -2, 0 ), - new ScalarHasValue<>(false) - ); + new ScalarHasValue(false) + ).affirm(); } @Test diff --git a/src/test/java/org/cactoos/scalar/SumOfScalarTest.java b/src/test/java/org/cactoos/scalar/SumOfScalarTest.java index 9be7098353..ff53eadf4b 100644 --- a/src/test/java/org/cactoos/scalar/SumOfScalarTest.java +++ b/src/test/java/org/cactoos/scalar/SumOfScalarTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.scalar; -import org.cactoos.MatcherAssert; import org.hamcrest.core.IsEqual; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link SumOfScalar}. @@ -38,27 +38,30 @@ public final class SumOfScalarTest { @Test public void withListOfScalarsInt() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOfScalar(() -> 1, () -> 2, () -> 3) .value() .intValue(), - new IsEqual<>(6) - ); + new IsEqual(6) + ).affirm(); } @Test public void withEmptyList() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOfScalar().value().intValue(), - new IsEqual<>(0) - ); + new IsEqual(0) + ).affirm(); } @Test public void withListOfOneElement() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOfScalar(() -> 5).value().intValue(), - new IsEqual<>(5) - ); + new IsEqual(5) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/scalar/SumOfTest.java b/src/test/java/org/cactoos/scalar/SumOfTest.java index 695acb2f33..9c66b93c06 100644 --- a/src/test/java/org/cactoos/scalar/SumOfTest.java +++ b/src/test/java/org/cactoos/scalar/SumOfTest.java @@ -24,11 +24,11 @@ package org.cactoos.scalar; import java.util.Collection; -import org.cactoos.MatcherAssert; import org.cactoos.iterable.IterableOf; import org.cactoos.list.ListOf; import org.hamcrest.core.IsEqual; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link SumOf}. @@ -42,110 +42,122 @@ public final class SumOfTest { @Test public void withListOfNumbersInt() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(1, 2, 3).intValue(), - new IsEqual<>(6) - ); + new IsEqual(6) + ).affirm(); } @Test public void withListOfNumbersDouble() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(1.0d, 2.0d, 3.0d).doubleValue(), - new IsEqual<>(6.0d) - ); + new IsEqual(6.0d) + ).affirm(); } @Test public void withListOfNumbersFloat() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(1.0f, 2.0f, 3.0f).floatValue(), - new IsEqual<>(6.0f) - ); + new IsEqual(6.0f) + ).affirm(); } @Test public void withListOfNumbersLong() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(1L, 2L, 3L).longValue(), - new IsEqual<>(6L) - ); + new IsEqual(6L) + ).affirm(); } @Test public void withCollectionLong() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf( new IterableOf<>(1, 2, 3, 4) ).longValue(), - new IsEqual<>(10L) - ); + new IsEqual(10L) + ).affirm(); } @Test public void withCollectionInt() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf( new IterableOf<>(1L, 2L, 3L, 4L) ).intValue(), - new IsEqual<>(10) - ); + new IsEqual(10) + ).affirm(); } @Test public void withCollectionFloat() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf( new IterableOf<>(1.0f, 2.0f, 3.0f, 4.0f) ).floatValue(), - new IsEqual<>(10.0f) - ); + new IsEqual(10.0f) + ).affirm(); } @Test public void withCollectionDouble() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf( new IterableOf<>(1.0d, 2.0d, 3.0d, 4.0d) ).doubleValue(), - new IsEqual<>(10.0d) - ); + new IsEqual(10.0d) + ).affirm(); } @Test public void withIterableOfInts() { final Collection ints = new ListOf<>(1, 2, 3, 4); - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(ints).intValue(), - new IsEqual<>(10) - ); + new IsEqual(10) + ).affirm(); } @Test public void overflowIntFromLongValues() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(2_147_483_647L + 1L << 1, 10L).intValue(), - new IsEqual<>(2_147_483_647) - ); + new IsEqual(2_147_483_647) + ).affirm(); } @Test public void overflowIntFromLongValuesIncludingNegative() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf( 2_147_483_647L + 1L << 1, 10L, -(2_147_483_647L + 1L) << 1 ).intValue(), - new IsEqual<>(10) - ); + new IsEqual(10) + ).affirm(); } @Test public void overflowFloatFromLongValues() { - MatcherAssert.assertThat( + new Assertion<>( + "", new SumOf(2_147_483_647L + 1L << 1, 10L).floatValue(), - new IsEqual<>(4_294_967_300.0f) - ); + new IsEqual(4_294_967_300.0f) + ).affirm(); } } diff --git a/src/test/java/org/cactoos/scalar/TernaryTest.java b/src/test/java/org/cactoos/scalar/TernaryTest.java index 77db2d89c5..11c3d8dd8d 100644 --- a/src/test/java/org/cactoos/scalar/TernaryTest.java +++ b/src/test/java/org/cactoos/scalar/TernaryTest.java @@ -23,9 +23,9 @@ */ package org.cactoos.scalar; -import org.cactoos.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; +import org.llorllale.cactoos.matchers.Assertion; /** * Test case for {@link Ternary}. @@ -37,43 +37,47 @@ public final class TernaryTest { @Test public void conditionTrue() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Ternary<>( new True(), 6, 16 ).value(), Matchers.equalTo(6) - ); + ).affirm(); } @Test public void conditionFalse() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Ternary<>( new False(), 6, 16 ).value(), Matchers.equalTo(16) - ); + ).affirm(); } @Test public void conditionBoolean() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Ternary<>( true, 6, 16 ).value(), Matchers.equalTo(6) - ); + ).affirm(); } @Test public void conditionFunc() throws Exception { - MatcherAssert.assertThat( + new Assertion<>( + "", new Ternary<>( 5, input -> input > 3, @@ -81,6 +85,6 @@ public void conditionFunc() throws Exception { input -> input = 2 ).value(), Matchers.equalTo(8) - ); + ).affirm(); } }