use of java.util.Arrays.asList in project cyclops by aol.
the class SpoutsTest method mixedMergeMap.
@Test
public void mixedMergeMap() {
AtomicInteger data = new AtomicInteger(0);
AtomicBoolean complete = new AtomicBoolean(false);
AtomicReference<Throwable> error = new AtomicReference<Throwable>(null);
Spouts.range(0, 1000).mergeMap(v -> v % 2 == 0 ? Flux.just(v) : Flux.fromIterable(Arrays.asList(v))).forEach(n -> {
data.incrementAndGet();
}, e -> {
error.set(e);
}, () -> {
complete.set(true);
});
assertThat(data.get(), equalTo(1000));
assertTrue(complete.get());
assertThat(error.get(), equalTo(null));
}
use of java.util.Arrays.asList in project cyclops by aol.
the class SpoutsTest method takeWhileInclusive.
@Test
public void takeWhileInclusive() {
assertThat(Spouts.of(1, 2, 3).takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList(1, 2, 3)));
assertThat(Spouts.<Integer>of().takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList()));
assertThat(Spouts.range(1, 1_000_000).takeWhileInclusive(i -> i < 300_000).toList(), equalTo(ReactiveSeq.range(1, 300_001).toList()));
AtomicInteger count = new AtomicInteger(0);
int size = Spouts.range(1, 1_000_000).peek(i -> count.incrementAndGet()).takeWhileInclusive(i -> i < 300_000).toList().size();
assertThat(count.get(), equalTo(300_000));
assertThat(size, equalTo(300000));
}
use of java.util.Arrays.asList in project alfresco-repository by Alfresco.
the class EventsServiceImpl method secondaryAssociationCreated.
@Override
public void secondaryAssociationCreated(final ChildAssociationRef secAssociation) {
NodeInfo nodeInfo = getNodeInfo(secAssociation.getChildRef(), NodeAddedEvent.EVENT_TYPE);
if (nodeInfo.checkNodeInfo()) {
String username = AuthenticationUtil.getFullyAuthenticatedUser();
String networkId = TenantUtil.getCurrentDomain();
String name = nodeInfo.getName();
String objectId = nodeInfo.getNodeId();
String siteId = nodeInfo.getSiteId();
String txnId = AlfrescoTransactionSupport.getTransactionId();
NodeRef secParentNodeRef = secAssociation.getParentRef();
String secParentNodeName = (String) nodeService.getProperty(secAssociation.getParentRef(), ContentModel.PROP_NAME);
List<Path> secParentPath = nodeService.getPaths(secParentNodeRef, true);
List<String> nodePaths = getPaths(secParentPath, Arrays.asList(secParentNodeName, name));
List<List<String>> pathNodeIds = this.getNodeIds(secParentPath);
long timestamp = System.currentTimeMillis();
Long modificationTime = nodeInfo.getModificationTimestamp();
String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());
Set<String> aspects = nodeInfo.getAspectsAsStrings();
Map<String, Serializable> properties = nodeInfo.getProperties();
Event event = new NodeAddedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, alfrescoClient, aspects, properties);
sendEvent(event);
}
}
use of java.util.Arrays.asList in project cyclops by aol.
the class BaseSequenceTest method takeWhileInclusive.
@Test
public void takeWhileInclusive() {
assertThat(ReactiveSeq.of(1, 2, 3).takeWhileInclusive(i -> i < 0).toList(), equalTo(Arrays.asList(1)));
assertThat(ReactiveSeq.of(1, 2, 3).takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList(1, 2, 3)));
assertThat(ReactiveSeq.<Integer>of().takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList()));
assertThat(ReactiveSeq.range(1, 1_000_000).takeWhileInclusive(i -> i < 300_000).toList(), equalTo(ReactiveSeq.range(1, 300_001).toList()));
AtomicInteger count = new AtomicInteger(0);
int size = ReactiveSeq.range(1, 1_000_000).peek(i -> count.incrementAndGet()).takeWhileInclusive(i -> i < 300_000).toList().size();
assertThat(count.get(), equalTo(300_000));
assertThat(size, equalTo(300000));
}
use of java.util.Arrays.asList in project cyclops by aol.
the class BaseSequenceTest method takeWhile.
@Test
public void takeWhile() {
assertThat(ReactiveSeq.of(1, 2, 3).takeWhile(i -> i < 3).toList(), equalTo(Arrays.asList(1, 2)));
assertThat(ReactiveSeq.<Integer>of().takeWhile(i -> i < 3).toList(), equalTo(Arrays.asList()));
assertThat(ReactiveSeq.range(1, 1_000_000).takeWhile(i -> i < 300_000).toList(), equalTo(ReactiveSeq.range(1, 300_000).toList()));
AtomicInteger count = new AtomicInteger(0);
int size = ReactiveSeq.range(1, 1_000_000).peek(i -> count.incrementAndGet()).takeWhile(i -> i < 300_000).toList().size();
assertThat(count.get(), equalTo(300_000));
assertThat(size, equalTo(299999));
}
Aggregations