use of org.cactoos.list.ListOf in project cactoos by yegor256.
the class SyncIteratorTest method syncIteratorReturnsCorrectValuesWithExternalLock.
@Test
public void syncIteratorReturnsCorrectValuesWithExternalLock() {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
MatcherAssert.assertThat("Unexpected value found.", new ListOf<>(new SyncIterator<>(Arrays.asList("a", "b").iterator(), lock)).toArray(), Matchers.equalTo(new Object[] { "a", "b" }));
}
use of org.cactoos.list.ListOf in project cactoos by yegor256.
the class IteratorOfBytesTest method canBeConstructedFromText.
@Test
public void canBeConstructedFromText() throws Exception {
final Iterator<Byte> itr = new IteratorOfBytes(new TextOf("ABC"));
new Assertion<>("Must have 3 elements", new ListOf<Object>(itr.next(), itr.next(), itr.next(), itr.hasNext()), new HasValues<Object>((byte) 'A', (byte) 'B', (byte) 'C', false)).affirm();
}
use of org.cactoos.list.ListOf in project cactoos by yegor256.
the class AndInThreadsTest method worksWithExecServiceProcIterable.
@Test
void worksWithExecServiceProcIterable() throws Exception {
final List<Integer> list = new Synced<>(new ListOf<>());
final ExecutorService service = Executors.newSingleThreadExecutor();
new AndInThreads(service, new ProcNoNulls<Integer>(list::add), new ListOf<>(1, 2)).value();
MatcherAssert.assertThat(list, new IsIterableContainingInAnyOrder<>(new ListOf<>(new IsEqual<>(1), new IsEqual<>(2))));
}
use of org.cactoos.list.ListOf in project cactoos by yegor256.
the class AndInThreadsTest method worksWithExecServiceProcValues.
@Test
void worksWithExecServiceProcValues() throws Exception {
final List<Integer> list = new Synced<>(new ListOf<>());
final ExecutorService service = Executors.newSingleThreadExecutor();
new AndInThreads(service, new ProcNoNulls<Integer>(list::add), 1, 2).value();
MatcherAssert.assertThat(list, new IsIterableContainingInAnyOrder<>(new ListOf<>(new IsEqual<>(1), new IsEqual<>(2))));
}
Aggregations