use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class NoNullsTest method addsToEmptyCollection.
@Test
void addsToEmptyCollection() {
final Collection<Integer> col = new NoNulls<>(new ListOf<>());
col.add(1);
new Assertion<>("Must not be empty after an item was added", col.isEmpty(), new IsNot<>(new IsTrue())).affirm();
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class BytesOfTest method closesInputStream.
@Test
void closesInputStream() throws Exception {
final AtomicBoolean closed = new AtomicBoolean();
final InputStream input = new ByteArrayInputStream("how are you?".getBytes());
new TextOf(new InputOf(new InputStream() {
@Override
public int read() throws IOException {
return input.read();
}
@Override
public void close() throws IOException {
input.close();
closed.set(true);
}
}), StandardCharsets.UTF_8).asString();
new Assertion<>("must close InputStream correctly", closed.get(), new IsTrue()).affirm();
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class TimedFuncTest method futureTaskIsCancelled.
@Test
@SuppressWarnings("PMD.AvoidCatchingGenericException")
public void futureTaskIsCancelled() {
final long period = 50L;
final long time = 2000L;
final Future<Boolean> future = Executors.newSingleThreadExecutor().submit(() -> {
Thread.sleep(time);
return true;
});
try {
new Timed<Boolean, Boolean>(period, input -> future).apply(true);
// @checkstyle IllegalCatchCheck (1 line)
} catch (final Exception exp) {
new Assertion<>("Must be canceled after 1 sec", future.isCancelled(), new IsTrue()).affirm();
}
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class InputOfTest method closesInputStream.
@Test
void closesInputStream() throws Exception {
final AtomicBoolean closed = new AtomicBoolean();
final InputStream input = new ByteArrayInputStream("how are you?".getBytes());
new TextOf(new InputOf(new InputStream() {
@Override
public int read() throws IOException {
return input.read();
}
@Override
public void close() throws IOException {
input.close();
closed.set(true);
}
})).asString();
new Assertion<>("must close InputStream correctly", closed.get(), new IsTrue()).affirm();
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class NoNullsTest method retainsAll.
@Test
void retainsAll() {
final Collection<Integer> col = new NoNulls<>(new ListOf<>(1, 2, 3));
new Assertion<>("NoNulls#retainAll(...) must return false for the same elements", col.retainAll(new ListOf<>(1, 2, 3)), new IsNot<>(new IsTrue())).affirm();
}
Aggregations