Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IsBlank operate on Text #247

Merged
merged 3 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ public void csvLineHasCorrectFormat() throws Exception {
public void textIsBlank(){
new Assertion<>(
"must be blank",
new UncheckedText(
new TextOf(
new File("file.txt")
)
).asString(),
new TextOf(
new File("file.txt")
),
new IsBlank()
).affirm();
}
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/org/llorllale/cactoos/matchers/IsBlank.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@
*/
package org.llorllale.cactoos.matchers;

import org.cactoos.Text;
import org.hamcrest.Matchers;

/**
* The matcher to check that text is empty.
*
* @since 1.0.0
*/
public final class IsBlank extends MatcherEnvelope<String> {
public final class IsBlank extends MatcherEnvelope<Text> {

/**
* Ctor.
*/
public IsBlank() {
super(
new MatcherOf<>(
text -> text.trim().isEmpty(),
desc -> desc.appendText("is blank"),
(text, desc) -> desc.appendText("was ").appendValue(text)
)
);
super(new TextMatcher(Matchers.blankString()));
}
}
11 changes: 6 additions & 5 deletions src/test/java/org/llorllale/cactoos/matchers/IsBlankTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

package org.llorllale.cactoos.matchers;

import org.cactoos.text.TextOf;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -42,7 +43,7 @@ void blank() {
new Assertion<>(
"matches empty string",
new IsBlank(),
new Matches<>("")
new Matches<>(new TextOf(""))
).affirm();
}

Expand All @@ -52,8 +53,8 @@ void notBlank() {
"does not match non-empty string",
new IsBlank(),
new Mismatches<>(
"-.$%",
"is blank",
new TextOf("-.$%"),
"a blank string",
"was \"-.$%\""
)
).affirm();
Expand All @@ -65,8 +66,8 @@ void nonBlankMessage() {
"describes itself in terms of the text being matched against",
new IsBlank(),
new Mismatches<>(
"text",
"is blank",
new TextOf("text"),
"a blank string",
"was \"text\""
)
).affirm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ void mismatches() {
).affirm();
}

@Test
void matchesFromMatcher() {
new Assertion<>(
"must match with matcher",
new TextMatcher(new IsBlank()),
new Matches<>(new TextOf(""))
).affirm();
}

@Test
void matchesFromFunc() {
new Assertion<>(
Expand Down