use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class TeeOutputStreamTest method copiesContentByteByByte.
@Test
@SuppressWarnings("unchecked")
void copiesContentByteByByte() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ByteArrayOutputStream copy = new ByteArrayOutputStream();
final String content = "Hello, товарищ!";
new Assertion<>("Must copy OutputStream to OutputStream byte by byte", new TextOf(new ReaderOf(new TeeInputStream(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), new TeeOutputStream(baos, copy)))).asString(), new AllOf<>(new IsEqual<String>(content), new IsEqual<String>(new String(baos.toByteArray(), StandardCharsets.UTF_8)), new IsEqual<String>(new String(copy.toByteArray(), StandardCharsets.UTF_8)))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class StickyTest method equalsItself.
@Test
void equalsItself() {
final Text random = new Randomized();
final Text sticky = new Sticky(random);
new Assertion<>("must be the same as itself", sticky, new AllOf<Text>(new IsEqual<>(sticky), new IsNot<>(new IsEqual<>(random)))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class AbbreviatedTest method abbreviatesTextThatChanges.
@Test
@SuppressWarnings("unchecked")
void abbreviatesTextThatChanges() {
final AtomicInteger counter = new AtomicInteger(0);
final Text txt = new TextOf(() -> {
final String result;
if (counter.getAndIncrement() == 0) {
result = "The quick brown fox jumps";
} else {
result = "The lazy black dog";
}
return result;
});
new Assertion<>("Must abbreviate a text that changes", new Abbreviated(txt, 15), new AllOf<>(new IsText("The quick br..."), new IsText("The lazy bla..."))).affirm();
}
Aggregations