Skip to content

Commit

Permalink
(yegor256#1033) Replace some usages of assertThat with Assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
vzurauskas committed Apr 21, 2019
1 parent 4a76741 commit f341664
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 90 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/cactoos/io/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
9 changes: 4 additions & 5 deletions src/test/java/org/cactoos/TextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
20 changes: 10 additions & 10 deletions src/test/java/org/cactoos/io/LSInputOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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();
}

}
Loading

0 comments on commit f341664

Please sign in to comment.