Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BADC11DCE for ; Thu, 26 Jun 2014 10:37:41 +0000 (UTC) Received: (qmail 28575 invoked by uid 500); 26 Jun 2014 10:37:41 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 28541 invoked by uid 500); 26 Jun 2014 10:37:41 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 28503 invoked by uid 99); 26 Jun 2014 10:37:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2014 10:37:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 26 Jun 2014 10:37:41 +0000 Received: (qmail 28419 invoked by uid 99); 26 Jun 2014 10:37:16 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2014 10:37:16 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 07DF8834B5D; Thu, 26 Jun 2014 10:37:15 +0000 (UTC) From: aledsage To: dev@brooklyn.incubator.apache.org Reply-To: dev@brooklyn.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-brooklyn pull request: entity initializers to define SSH... Content-Type: text/plain Message-Id: <20140626103716.07DF8834B5D@tyr.zones.apache.org> Date: Thu, 26 Jun 2014 10:37:15 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user aledsage commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/15#discussion_r14234085 --- Diff: core/src/test/java/brooklyn/entity/effector/EffectorTaskTest.java --- @@ -112,6 +118,72 @@ public void testSyntaxTwoDouble2() throws Exception { Assert.assertEquals(app.invoke(DOUBLE_2, MutableMap.of("numberToDouble", 3)).get(), (Integer)6); } + @Test + public void testEffectorImplTaggedCorrectly() throws Exception { + Task t = app.invoke(DOUBLE_2, MutableMap.of("numberToDouble", 3)); + t.get(); + checkTags(t, app, DOUBLE_2, true); + } + + public static final Effector DOUBLE_CALL_ABSTRACT = Effectors.effector(Integer.class, "double_call") + .description("doubles the given number") + .parameter(Integer.class, "numberToDouble") + .buildAbstract(); + public static final Effector DOUBLE_CALL = Effectors.effector(DOUBLE_CALL_ABSTRACT) + .impl(new EffectorBody() { + @Override + public Integer call(ConfigBag parameters) { + final Entity parent = entity(); + final Entity child = Iterables.getOnlyElement(entity().getChildren()); + + final Effector DOUBLE_CHECK_ABSTRACT = Effectors.effector(Integer.class, "double_check") + .description("doubles the given number and checks tags, assuming double exists as an effector here") + .parameter(Integer.class, "numberToDouble") + .buildAbstract(); + Effector DOUBLE_CHECK = Effectors.effector(DOUBLE_CHECK_ABSTRACT) + .impl(new EffectorBody() { + @Override + public Integer call(ConfigBag parameters) { + Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(Tasks.current(), child, null, false)); + Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(Tasks.current(), child, DOUBLE_CHECK_ABSTRACT, false)); + Assert.assertFalse(BrooklynTaskTags.isInEffectorTask(Tasks.current(), child, DOUBLE_1, false)); + Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(Tasks.current(), parent, null, true)); + Assert.assertFalse(BrooklynTaskTags.isInEffectorTask(Tasks.current(), parent, null, false)); + Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(Tasks.current(), parent, DOUBLE_CALL_ABSTRACT, true)); + Assert.assertFalse(BrooklynTaskTags.isInEffectorTask(Tasks.current(), parent, DOUBLE_1, true)); + + return entity().invoke(DOUBLE_1, parameters.getAllConfig()).getUnchecked(); + } + }).build(); + + return child.invoke(DOUBLE_CHECK, parameters.getAllConfig()).getUnchecked(); + } + }).build(); + + + @Test + // also assert it works when the effector is defined on an entity --- End diff -- Is this a comments about what the method does (because effector does `child.invoke(DOUBLE_CHECK...)`), or is it a TODO? If a comment, then change also "also asserts it works...`, and point folk at the line of `child.invoke`. If a todo, then prepend comment with `TODO `. --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---