Tasks { public static Task<Void> of(String name, Runnable body) { return TaskBuilder.of(name, body).dynamic(false).build(); }  static String setBlockingDetails(String description); static void resetBlockingDetails(); static Task<?> setBlockingTask(Task<?> blocker); static void resetBlockingTask(); static Task<T> create(String name, Callable<T> job); static Task<T> create(String name, Runnable job); @SuppressWarnings("rawtypes") static T withBlockingDetails(String description, Callable<T> code); @SuppressWarnings("rawtypes") static Task current(); static Task<?> getFinalProxyTarget(Task<?> task); static ValueResolver<T> resolving(Object v, TypeToken<T> type); static ValueResolver<T> resolving(Object v, Class<T> type); static ValueResolver.ResolverBuilderPretype resolving(Object v); static ValueResolver<T> resolving(ConfigBag config, ConfigKey<T> key); static T resolveValue(Object v, TypeToken<T> type, @Nullable ExecutionContext exec); static T resolveValue(Object v, Class<T> type, @Nullable ExecutionContext exec); static T resolveValue(Object v, TypeToken<T> type, @Nullable ExecutionContext exec, String contextMessage); static T resolveValue(Object v, Class<T> type, @Nullable ExecutionContext exec, String contextMessage); static Object resolveDeepValueWithoutCoercion(Object v, ExecutionContext exec, String contextMessage); static Object resolveDeepValueWithoutCoercion(Object v, ExecutionContext exec); @Deprecated static Object resolveDeepValue(Object v, Class<?> type, ExecutionContext exec, String contextMessage); @Deprecated static Object resolveDeepValue(Object v, Class<?> type, ExecutionContext exec); static T resolveValueShallow(Object v, TypeToken<T> type, @Nullable ExecutionContext exec, String contextMessage); static T resolveDeepValueCoerced(Object value, TypeToken<T> type, ExecutionContext exec, String contextMessage); @Deprecated static T resolveDeepValueExactly(Object v, TypeToken<T> type, ExecutionContext exec, String contextMessage); @Deprecated static T resolveDeepValueExactly(Object v, TypeToken<T> type, ExecutionContext exec); static void setExtraStatusDetails(String notes); static TaskBuilder<T> builder(); static Task<Void> of(String name, Runnable body); static Task<T> of(String name, Callable<T> body); static Task<List<?>> parallel(TaskAdaptable<?> ...tasks); static Task<List<?>> parallel(String name, TaskAdaptable<?> ...tasks); static Task<List<?>> parallel(Iterable<? extends TaskAdaptable<?>> tasks); static Task<List<?>> parallel(String name, Iterable<? extends TaskAdaptable<?>> tasks); static Task<List<?>> sequential(TaskAdaptable<?> ...tasks); static Task<List<?>> sequential(String name, TaskAdaptable<?> ...tasks); static TaskFactory<?> sequential(TaskFactory<?> ...taskFactories); static TaskFactory<?> sequential(String name, TaskFactory<?> ...taskFactories); static Task<List<?>> sequential(List<? extends TaskAdaptable<?>> tasks); static Task<List<?>> sequential(String name, List<? extends TaskAdaptable<?>> tasks); @SuppressWarnings("unchecked") static T tag(@Nullable Task<?> task, Class<T> type, boolean recurseHierarchy); static boolean isAncestorCancelled(Task<?> t); static boolean isQueued(TaskAdaptable<?> task); static boolean isSubmitted(TaskAdaptable<?> task); static boolean isQueuedOrSubmitted(TaskAdaptable<?> task); static boolean tryQueueing(TaskQueueingContext adder, TaskAdaptable<?> task); static Supplier<T> supplier(final TaskAdaptable<T> task); static Iterable<Task<?>> children(Task<?> task); static Iterable<Task<?>> failed(Iterable<Task<?>> subtasks); static Iterable<Task<?>> descendants(Task<?> root, final boolean parentFirst); static Throwable getError(Task<?> t); static Task<Void> fail(final String name, final Throwable optionalError); static Task<Void> warning(final String message, final Throwable optionalError); static Task<Void> warning(final String message, final Throwable optionalError, boolean logWarning); static void markInessential(); @Beta static void swallowChildrenFailures(); static void addTagDynamically(Object tag); @Beta static boolean blockUntilInternalTasksEnded(Task<?> t, Duration timeout); static boolean isInterrupted(); static TaskBuilder<Boolean> testing(Repeater repeater); static TaskBuilder<?> requiring(Repeater repeater); @Deprecated static void dumpInfo(Task<?> t); @Deprecated static void dumpInfo(Task<?> t, Writer out); @Deprecated static void dumpInfo(Task<?> t, String currentIndentation, String tab); @Deprecated static void dumpInfo(Task<?> t, Writer out, String currentIndentation, String tab);  }
@Test public void testResolvesMapWithAttributeWhenReady() throws Exception { app.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); Map<?,?> orig = ImmutableMap.of("mykey", attributeWhenReady(app, TestApplication.MY_ATTRIBUTE)); Map<String,String> expected = ImmutableMap.of("mykey", "myval"); assertResolvesValue(orig, new TypeToken<Map<String,String>>() {}, expected); }
@Test public void testResolvesSetWithAttributeWhenReady() throws Exception { app.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); Set<?> orig = ImmutableSet.of(attributeWhenReady(app, TestApplication.MY_ATTRIBUTE)); Set<String> expected = ImmutableSet.of("myval"); assertResolvesValue(orig, new TypeToken<Set<String>>() {}, expected); }
@Test public void testResolvesMapOfMapsWithAttributeWhenReady() throws Exception { app.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); Map<?,?> orig = ImmutableMap.of("mykey", ImmutableMap.of("mysubkey", attributeWhenReady(app, TestApplication.MY_ATTRIBUTE))); Map<String,Map<String,String>> expected = ImmutableMap.of("mykey", ImmutableMap.of("mysubkey", "myval")); assertResolvesValue(orig, new TypeToken<Map<String,Map<String,String>>>() {}, expected); }
@Test public void testResolvesListOfMapsWithAttributeWhenReady() throws Exception { app.sensors().set(TestApplication.MY_ATTRIBUTE, "myval"); List<?> orig = ImmutableList.copyOf(ImmutableList.of(ImmutableMap.of("mykey", attributeWhenReady(app, TestApplication.MY_ATTRIBUTE)))); Iterable<Map<String,String>> expected = ImmutableList.of(ImmutableMap.of("mykey", "myval")); assertResolvesValue(orig, new TypeToken<Iterable<Map<String,String>>>() {}, expected); }