Search in sources :

Example 11 with Assertion

use of org.llorllale.cactoos.matchers.Assertion in project cactoos by yegor256.

the class IoCheckedProcTest method rethrowsIoException.

@Test
void rethrowsIoException() {
    final IOException exception = new IOException("intended");
    new Assertion<>("Must rethrow original IOException", () -> {
        new IoCheckedProc<>((Proc<Integer>) i -> {
            throw exception;
        }).exec(1);
        return null;
    }, new Throws<>(exception.getMessage(), exception.getClass())).affirm();
}
Also used : Test(org.junit.jupiter.api.Test) Assertion(org.llorllale.cactoos.matchers.Assertion) IOException(java.io.IOException) Proc(org.cactoos.Proc) Throws(org.llorllale.cactoos.matchers.Throws) IOException(java.io.IOException) Throws(org.llorllale.cactoos.matchers.Throws) Test(org.junit.jupiter.api.Test)

Example 12 with Assertion

use of org.llorllale.cactoos.matchers.Assertion in project cactoos by yegor256.

the class RepeatedProcTest method runsProcMultipleTimes.

@Test
void runsProcMultipleTimes() throws Exception {
    final AtomicInteger atom = new AtomicInteger();
    final Proc<AtomicInteger> func = new RepeatedProc<>(AtomicInteger::getAndIncrement, 3);
    func.exec(atom);
    new Assertion<>("must run proc 3 times", atom.get(), new IsEqual<>(3));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Assertion(org.llorllale.cactoos.matchers.Assertion) Test(org.junit.jupiter.api.Test)

Aggregations

Assertion (org.llorllale.cactoos.matchers.Assertion)12 IOException (java.io.IOException)7 IsEqual (org.hamcrest.core.IsEqual)7 Test (org.junit.jupiter.api.Test)7 Test (org.junit.Test)5 Throws (org.llorllale.cactoos.matchers.Throws)5 Executors (java.util.concurrent.Executors)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ThreadFactory (java.util.concurrent.ThreadFactory)3 TimeUnit (java.util.concurrent.TimeUnit)3 IsApplicable (org.llorllale.cactoos.matchers.IsApplicable)3 Satisfies (org.llorllale.cactoos.matchers.Satisfies)3 EOFException (java.io.EOFException)2 IsNull (org.hamcrest.core.IsNull)2 FileNotFoundException (java.io.FileNotFoundException)1 AcceptPendingException (java.nio.channels.AcceptPendingException)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 Proc (org.cactoos.Proc)1