Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/390#discussion_r85111300
--- Diff:
camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/dsl/DslTest.java
---
@@ -198,9 +275,44 @@ public ParentTestWorker(TestApplication parent,
BrooklynDslDeferredSupplier<?> d
}
@Override
- protected void postResolve(Maybe<?> actualValue) {
+ protected void postResolve(TestEntity entity, Maybe<?>
actualValue) {
assertEquals(actualValue.get(), parent);
}
}
+ static Maybe<?> execDslImmediately(final
BrooklynDslDeferredSupplier<?> dsl, final Class<?> type, final Entity context,
boolean execInTask) throws Exception {
+ // Exec'ing immediately will call DSL in current thread. It needs
to find the context entity,
+ // and does this using
BrooklynTaskTags.getTargetOrContextEntity(Tasks.current()).
+ // If we are not in a task executed by the context entity, then
this lookup will fail.
+ Callable<Maybe<?>> job = new Callable<Maybe<?>>() {
+ public Maybe<?> call() throws Exception {
+ return Tasks.resolving(dsl).as(type)
+ .context(context)
+ .description("Computing "+dsl)
+ .immediately(true)
+ .getMaybe();
+ }
+ };
+ if (execInTask) {
+ Task<Maybe<?>> task =
((EntityInternal)context).getExecutionContext().submit(job);
+ task.get(Asserts.DEFAULT_LONG_TIMEOUT);
+ assertTrue(task.isDone());
+ return task.get();
+
+ } else {
+ return job.call();
+ }
+ }
+
+ static Maybe<?> execDslRealRealyQuick(BrooklynDslDeferredSupplier<?>
dsl, Class<?> type, Entity context) {
--- End diff --
typo(?) `execDslRealRealQuick` or even better `execDslReallyReallyQuick`,
old-fashioned believer in adverbs that I am.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---