本文整理了Java中com.englishtown.promises.Promise.inspect()
方法的一些代码示例,展示了Promise.inspect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Promise.inspect()
方法的具体详情如下:
包路径:com.englishtown.promises.Promise
类名称:Promise
方法名:inspect
暂无
代码示例来源:origin: ef-labs/vertx-cassandra
@Test
public void testReady() throws Exception {
Promise<Void> p = whenCassandraSession.ready();
State<Void> state = p.inspect();
assertEquals(HandlerState.PENDING, state.getState());
verify(cassandraSession).onReady(onReadyCaptor.capture());
onReadyCaptor.getValue().handle(Future.succeededFuture());
state = p.inspect();
assertEquals(HandlerState.FULFILLED, state.getState());
}
代码示例来源:origin: ef-labs/vertx-cassandra
@Test
public void testReadyReject() throws Exception {
Promise<Void> p = whenCassandraSession.ready();
State<Void> state = p.inspect();
assertEquals(HandlerState.PENDING, state.getState());
verify(cassandraSession).onReady(onReadyCaptor.capture());
onReadyCaptor.getValue().handle(Future.failedFuture("Test fail"));
state = p.inspect();
assertEquals(HandlerState.REJECTED, state.getState());
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_promises_should_return_pending_state_for_pending_promise() {
Promise<Object> promise = when.promise((x, y) -> {
});
assertPending(promise.inspect());
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_thenables_should_return_pending_state_for_pending_thenable() {
Thenable<Object> thenable = new Thenable<Object>() {
@Override
public <U> Thenable<U> then(Function<Object, ? extends Thenable<U>> onFulfilled, Function<Throwable, ? extends Thenable<U>> onRejected) {
return null;
}
};
Promise<Object> p = when.when(thenable);
assertPending(p.inspect());
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_promises_should_return_rejected_state_for_rejected_promise() {
Promise<Object> promise = when.reject(sentinelEx);
promise.then(fail.onFulfilled, (t) -> {
assertRejected(promise.inspect(), sentinelEx);
return null;
}).ensure(done::fulfill);
done.assertFulfilled();
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_promises_should_return_fulfilled_state_for_fulfilled_promise() {
Promise<Sentinel> promise = when.resolve(sentinel);
promise.then((x) -> {
assertFulfilled(promise.inspect(), sentinel);
return null;
}).ensure(done::fulfill);
done.assertFulfilled();
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_thenables_should_return_fulfilled_state_for_fulfilled_thenable() {
Thenable<Sentinel> thenable = new Thenable<Sentinel>() {
@Override
public <U> Thenable<U> then(Function<Sentinel, ? extends Thenable<U>> onFulfilled, Function<Throwable, ? extends Thenable<U>> onRejected) {
return onFulfilled.apply(sentinel);
}
};
Promise<Sentinel> p = when.when(thenable);
p.then((x) -> {
assertFulfilled(p.inspect(), sentinel);
return null;
}).ensure(done::fulfill);
done.assertFulfilled();
}
代码示例来源:origin: ef-labs/when.java
@Test
public void testPromise_inspect_when_inspecting_thenables_should_return_rejected_state_for_rejected_thenable() {
Thenable<Object> thenable = new Thenable<Object>() {
@Override
public <U> Thenable<U> then(Function<Object, ? extends Thenable<U>> onFulfilled, Function<Throwable, ? extends Thenable<U>> onRejected) {
return onRejected.apply(sentinelEx);
}
};
Promise<Object> p = when.when(thenable);
p.then(fail.onFulfilled, (t) -> {
assertRejected(p.inspect(), sentinelEx);
return null;
}).ensure(done::fulfill);
done.assertFulfilled();
}
内容来源于网络,如有侵权,请联系作者删除!