本文整理了Java中bolts.Task.forResult()
方法的一些代码示例,展示了Task.forResult()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.forResult()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:forResult
[英]Creates a completed task with the given value.
[中]创建具有给定值的已完成任务。
代码示例来源:origin: facebook/facebook-android-sdk
return Task.forResult(appLinkResults);
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseSQLiteDatabase> then(Task<Void> task) {
return Task.forResult(db);
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(T object, ParseSQLiteDatabase db) {
try {
Object value = getValue(object, key);
return Task.forResult(matchesStatelessConstraint(operator, constraint, value,
allKeyConstraints));
} catch (ParseException e) {
return Task.forError(e);
}
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(T object, ParseSQLiteDatabase db) {
Object objectValue;
try {
objectValue = getValue(object, key);
} catch (ParseException e) {
return Task.forError(e);
}
return Task.forResult(matchesEqualConstraint(queryConstraintValue, objectValue));
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public <T extends ParseObject> Task<Integer> countAsync(
ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken) {
countCalled.set(true);
return Task.forResult(null);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> setIfNeededAsync(ParseUser user) {
synchronized (mutex) {
if (!user.isCurrentUser() || currentUserMatchesDisk) {
return Task.forResult(null);
}
}
return setAsync(user);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> then(Task<Integer> task) {
boolean exists = task.getResult() == 1;
if (exists) {
return Task.forResult(true);
}
return legacy.existsAsync();
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
static Task<Void> revokeAsync(String sessionToken) {
if (sessionToken == null || !isRevocableSessionToken(sessionToken)) {
return Task.forResult(null);
}
return getSessionController().revokeAsync(sessionToken);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
private ParseCurrentConfigController mockParseCurrentConfigController() {
ParseCurrentConfigController currentConfigController = mock(ParseCurrentConfigController.class);
when(currentConfigController.setCurrentConfigAsync(any(ParseConfig.class)))
.thenReturn(Task.<Void>forResult(null));
return currentConfigController;
}
代码示例来源:origin: parse-community/Parse-SDK-Android
private <T> ParseCloudCodeController mockParseCloudCodeControllerWithResponse(final T result) {
ParseCloudCodeController controller = mock(ParseCloudCodeController.class);
when(controller.callFunctionInBackground(anyString(), anyMap(), anyString()))
.thenReturn(Task.forResult(result));
return controller;
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
/* package */ Task<Void> synchronizeAuthDataAsync(String authType) {
Map<String, String> authData;
synchronized (mutex) {
if (!isCurrentUser()) {
return Task.forResult(null);
}
authData = getAuthData(authType);
}
return synchronizeAuthDataAsync(getAuthenticationManager(), authType, authData);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
static Task<String> upgradeToRevocableSessionAsync(String sessionToken) {
if (sessionToken == null || isRevocableSessionToken(sessionToken)) {
return Task.forResult(sessionToken);
}
return getSessionController().upgradeToRevocable(sessionToken).onSuccess(new Continuation<ParseObject.State, String>() {
@Override
public String then(Task<ParseObject.State> task) {
ParseObject.State result = task.getResult();
return ParseObject.<ParseSession>from(result).getSessionToken();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testRegister() {
ParseUser user = mock(ParseUser.class);
when(controller.getAsync(false)).thenReturn(Task.forResult(user));
manager.register("test_provider", provider);
verify(controller).getAsync(false);
verify(user).synchronizeAuthDataAsync("test_provider");
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testSubscribeInBackgroundSuccess() throws Exception {
ParsePushChannelsController controller = mock(ParsePushChannelsController.class);
when(controller.subscribeInBackground(anyString())).thenReturn(Task.<Void>forResult(null));
ParseCorePlugins.getInstance().registerPushChannelsController(controller);
ParseTaskUtils.wait(ParsePush.subscribeInBackground("test"));
verify(controller, times(1)).subscribeInBackground("test");
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testUnsubscribeInBackgroundSuccess() throws Exception {
ParsePushChannelsController controller = mock(ParsePushChannelsController.class);
when(controller.unsubscribeInBackground(anyString())).thenReturn(Task.<Void>forResult(null));
ParseCorePlugins.getInstance().registerPushChannelsController(controller);
ParseTaskUtils.wait(ParsePush.unsubscribeInBackground("test"));
verify(controller, times(1)).unsubscribeInBackground("test");
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testRegisterMultipleShouldThrow() {
when(controller.getAsync(false)).thenReturn(Task.<ParseUser>forResult(null));
AuthenticationCallback provider2 = mock(AuthenticationCallback.class);
manager.register("test_provider", provider);
thrown.expect(IllegalStateException.class);
manager.register("test_provider", provider2);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testExistAsyncFromStore() throws Exception {
//noinspection unchecked
ParseObjectStore<ParseInstallation> store = mock(ParseObjectStore.class);
when(store.existsAsync()).thenReturn(Task.forResult(true));
// Create test controller
CachedCurrentInstallationController controller =
new CachedCurrentInstallationController(store, null);
assertTrue(ParseTaskUtils.wait(controller.existsAsync()));
verify(store, times(1)).existsAsync();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testGetCurrentInstallation() {
// Mock currentInstallationController to make setAsync work
ParseCurrentInstallationController controller =
mock(ParseCurrentInstallationController.class);
ParseInstallation currentInstallation = new ParseInstallation();
when(controller.getAsync()).thenReturn(Task.forResult(currentInstallation));
ParseCorePlugins.getInstance().registerCurrentInstallationController(controller);
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
assertEquals(currentInstallation, installation);
verify(controller, times(1)).getAsync();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testExistsAsyncWithInDiskCurrentUserSet() throws Exception {
ParseObjectStore<ParseUser> store =
(ParseObjectStore<ParseUser>) mock(ParseObjectStore.class);
when(store.existsAsync()).thenReturn(Task.forResult(true));
CachedCurrentUserController controller =
new CachedCurrentUserController(store);
assertTrue(ParseTaskUtils.wait(controller.existsAsync()));
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testExistsAsyncWithNoInMemoryAndInDiskCurrentUserSet() throws Exception {
ParseObjectStore<ParseUser> store =
(ParseObjectStore<ParseUser>) mock(ParseObjectStore.class);
when(store.existsAsync()).thenReturn(Task.forResult(false));
CachedCurrentUserController controller =
new CachedCurrentUserController(store);
assertFalse(ParseTaskUtils.wait(controller.existsAsync()));
}
内容来源于网络,如有侵权,请联系作者删除!