brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: entity initializers to define SSH...
Date Thu, 26 Jun 2014 10:37:15 GMT
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<Integer> t = app.invoke(DOUBLE_2, MutableMap.of("numberToDouble",
3));
    +        t.get();
    +        checkTags(t, app, DOUBLE_2, true);
    +    }
    +
    +    public static final Effector<Integer> DOUBLE_CALL_ABSTRACT = Effectors.effector(Integer.class,
"double_call")
    +        .description("doubles the given number")
    +        .parameter(Integer.class, "numberToDouble")
    +        .buildAbstract();
    +    public static final Effector<Integer> DOUBLE_CALL = Effectors.effector(DOUBLE_CALL_ABSTRACT)
    +        .impl(new EffectorBody<Integer>() {
    +            @Override
    +            public Integer call(ConfigBag parameters) {
    +                final Entity parent = entity();
    +                final Entity child = Iterables.getOnlyElement(entity().getChildren());
    +                
    +                final Effector<Integer> 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<Integer> DOUBLE_CHECK = Effectors.effector(DOUBLE_CHECK_ABSTRACT)
    +                    .impl(new EffectorBody<Integer>() {
    +                        @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.
---

Mime
View raw message