use of org.osgi.util.function.Predicate in project aries by apache.
the class AsyncServiceTest method test.
@Test
public void test() throws InterruptedException {
DelayedEcho raw = new DelayedEcho();
AsyncService service = new AsyncService(null, es, ses, serviceTracker);
DelayedEcho mediated = service.mediate(raw, DelayedEcho.class);
Promise<String> promise = service.call(mediated.echo("Hello World", 1000));
final CountDownLatch latch = new CountDownLatch(1);
promise.filter(new Predicate<String>() {
@Override
public boolean test(String t) {
return "Hello World".equals(t);
}
}).then(new Success<String, Void>() {
@Override
public Promise<Void> call(Promise<String> resolved) throws Exception {
latch.countDown();
return null;
}
});
assertTrue(latch.await(5, TimeUnit.SECONDS));
}
Aggregations