Search in sources :

Example 1 with OutputTo

use of org.cactoos.io.OutputTo in project cactoos by yegor256.

the class TeeInputHasResultTest method failsIfInputDoesNotMatchExpectedValue.

@Test
public void failsIfInputDoesNotMatchExpectedValue() {
    final TeeInput matchable = new TeeInput(new TextOf("input"), new OutputTo(new ByteArrayOutputStream()));
    final String expected = "expected-1";
    final TeeInputHasResult matcher = new TeeInputHasResult(expected, new TextOf(expected));
    MatcherAssert.assertThat("Matcher does not compare input and expected values", matcher.matchesSafely(matchable), new IsEqual<>(false));
}
Also used : OutputTo(org.cactoos.io.OutputTo) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TeeInput(org.cactoos.io.TeeInput) Test(org.junit.Test)

Example 2 with OutputTo

use of org.cactoos.io.OutputTo in project cactoos by yegor256.

the class TeeInputHasResultTest method failsIfCopiedValueDoesNotMatchExpectedValue.

@Test
public void failsIfCopiedValueDoesNotMatchExpectedValue() {
    final String expected = "expected-2";
    final TeeInput matchable = new TeeInput(new TextOf(expected), new OutputTo(new ByteArrayOutputStream()));
    final TeeInputHasResult matcher = new TeeInputHasResult(expected, new TextOf("incorrect"));
    MatcherAssert.assertThat("Matcher does not compare copied and expected values", matcher.matchesSafely(matchable), new IsEqual<>(false));
}
Also used : OutputTo(org.cactoos.io.OutputTo) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TeeInput(org.cactoos.io.TeeInput) Test(org.junit.Test)

Example 3 with OutputTo

use of org.cactoos.io.OutputTo in project cactoos by yegor256.

the class TeeInputHasResultTest method describesMismatchOfInputAndExpected.

@Test
public void describesMismatchOfInputAndExpected() {
    final TeeInput matchable = new TeeInput(new TextOf("i"), new OutputTo(new ByteArrayOutputStream()));
    final TeeInputHasResult matcher = new TeeInputHasResult("e", new TextOf("e"));
    final StringDescription description = new StringDescription();
    matcher.matchesSafely(matchable);
    matcher.describeMismatchSafely(matchable, description);
    MatcherAssert.assertThat("Description of mismatch of input and expected incorrect", description.toString(), new IsEqual<>("TeeInput with result \"e\" and copied value \"e\""));
}
Also used : OutputTo(org.cactoos.io.OutputTo) StringDescription(org.hamcrest.StringDescription) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TeeInput(org.cactoos.io.TeeInput) Test(org.junit.Test)

Example 4 with OutputTo

use of org.cactoos.io.OutputTo in project cactoos by yegor256.

the class TeeInputHasResultTest method describesMismatchOfCopiedAndExpected.

@Test
public void describesMismatchOfCopiedAndExpected() {
    final TeeInput matchable = new TeeInput(new TextOf("i"), new OutputTo(new ByteArrayOutputStream()));
    final TeeInputHasResult matcher = new TeeInputHasResult("i", new TextOf("wrong"));
    final StringDescription description = new StringDescription();
    matcher.matchesSafely(matchable);
    matcher.describeMismatchSafely(matchable, description);
    MatcherAssert.assertThat("Description of mismatch of copied and expected incorrect", description.toString(), new IsEqual<>("TeeInput with result \"i\" and copied value \"i\""));
}
Also used : OutputTo(org.cactoos.io.OutputTo) StringDescription(org.hamcrest.StringDescription) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TeeInput(org.cactoos.io.TeeInput) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OutputTo (org.cactoos.io.OutputTo)4 TeeInput (org.cactoos.io.TeeInput)4 TextOf (org.cactoos.text.TextOf)4 Test (org.junit.Test)4 StringDescription (org.hamcrest.StringDescription)2