use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class MappedWithIndexTest method failsIfIteratorExhausted.
@Test
void failsIfIteratorExhausted() {
final Iterator<Text> iterator = new MappedWithIndex<>((item, index) -> new FormattedText("%1$s X %2$s", index, item), new IterableOf<>("1").iterator());
iterator.next();
new Assertion<>("must throw NSEE", iterator::next, new Throws<>(NoSuchElementException.class)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class IoCheckedBiProcTest method executesWrappedProc.
@Test
void executesWrappedProc() throws Exception {
final AtomicInteger counter = new AtomicInteger();
new IoCheckedBiProc<>((first, second) -> counter.incrementAndGet()).exec(true, true);
new Assertion<>("Must execute wrapped proc", counter.get(), new IsEqual<>(1)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class CheckedTest method throwsIoExceptionWithModifiedMessage.
@Test
public void throwsIoExceptionWithModifiedMessage() throws Exception {
final String message = "error msg";
new Assertion<>("Must throw io exception with modified message", () -> new Checked<>(() -> {
throw new IOException("io");
}, exp -> new IOException(message, exp)).value(), new Throws<>(message, IOException.class)).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class IoCheckedFuncTest method rethrowsIoException.
@Test
void rethrowsIoException() {
final IOException exception = new IOException("intended");
new Assertion<>("Must rethrow original IOException", () -> new IoCheckedFunc<>(i -> {
throw exception;
}).apply(1), new Throws<>(exception.getMessage(), exception.getClass())).affirm();
}
use of org.llorllale.cactoos.matchers.Throws in project cactoos by yegor256.
the class AppendToTest method failsIfFileDoesNotExist.
/**
* Ensures that AppendTo is failing on a negative predicate result.
*/
@Test
public void failsIfFileDoesNotExist() throws Exception {
final File source = new File(new Randomized('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h').asString());
new Assertion<>("Can't throw exception with proper message", () -> new AppendTo(source).stream(), new Throws<>(source.getPath(), NoSuchFileException.class)).affirm();
}
Aggregations