use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class ReplacedTest method invalidRegex.
@Test
void invalidRegex() {
final String regex = "invalid_regex{0,";
new Assertion<>("Doesn't throw proper exception", new Replaced(new TextOf("text"), regex, "error")::asString, new Throws<>(new PatternSyntaxException("Unclosed counted closure", regex, // @checkstyle MagicNumberCheck (1 line)
16).getMessage(), PatternSyntaxException.class)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class LoggingInputStreamTest method reThrowsException.
@Test
void reThrowsException() {
final String message = "Some read exception.";
final LoggingInputStream stream = new LoggingInputStream(new InputStream() {
@Override
public int read() throws IOException {
throw new IOException(message);
}
}, this.getClass().getSimpleName());
new Assertion<>("Read doesn't throw an the exception.", () -> stream.read(), new Throws<>(message, IOException.class)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class IoCheckedBiFuncTest method rethrowsIoException.
@Test
public void rethrowsIoException() {
final IOException exception = new IOException("intended");
new Assertion<>("Must rethrow IOException", () -> new IoCheckedBiFunc<>((fst, scd) -> {
throw exception;
}).apply(1, 2), new Throws<>(exception.getMessage(), exception.getClass())).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class UncheckedTextTest method rethrowsCheckedToUncheckedException.
@Test
void rethrowsCheckedToUncheckedException() {
final String msg = "intended";
new Assertion<>("Must throw an exception when something goes wrong", new UncheckedText(() -> {
throw new IOException(msg);
})::asString, new Throws<>(new StringContains(msg), RuntimeException.class)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class IoCheckedTest method rethrowsIoException.
@Test
void rethrowsIoException() {
final IOException exception = new IOException("intended");
new Assertion<>("Must rethrow IOException", () -> new IoChecked<>(() -> {
throw exception;
}).value(), new Throws<>(exception.getMessage(), exception.getClass())).affirm();
}
Aggregations