Search in sources :

Example 1 with ListOf

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" }));
}
Also used : ListOf(org.cactoos.list.ListOf) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Test(org.junit.Test)

Example 2 with ListOf

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();
}
Also used : HasValues(org.llorllale.cactoos.matchers.HasValues) ListOf(org.cactoos.list.ListOf) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test)

Example 3 with ListOf

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))));
}
Also used : Synced(org.cactoos.list.Synced) ExecutorService(java.util.concurrent.ExecutorService) ListOf(org.cactoos.list.ListOf) ProcNoNulls(org.cactoos.proc.ProcNoNulls) Test(org.junit.jupiter.api.Test)

Example 4 with ListOf

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))));
}
Also used : Synced(org.cactoos.list.Synced) ExecutorService(java.util.concurrent.ExecutorService) ListOf(org.cactoos.list.ListOf) ProcNoNulls(org.cactoos.proc.ProcNoNulls) Test(org.junit.jupiter.api.Test)

Aggregations

ListOf (org.cactoos.list.ListOf)4 ExecutorService (java.util.concurrent.ExecutorService)2 Synced (org.cactoos.list.Synced)2 ProcNoNulls (org.cactoos.proc.ProcNoNulls)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 TextOf (org.cactoos.text.TextOf)1 HasValues (org.llorllale.cactoos.matchers.HasValues)1