Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1120#discussion_r48272017
  
    --- Diff: 
usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
 ---
    @@ -124,6 +126,19 @@ public void testDslAttributeWhenReady() throws 
Exception {
         }
     
         @Test
    +    public void testDslAttributeWhenReadyPersisted() throws Exception {
    +        Entity testEntity = entityWithAttributeWhenReady();
    +        Application app2 = rebind(testEntity.getApplication());
    +        Entity e2 = Iterables.getOnlyElement( app2.getChildren() );
    +
    +        Maybe<Object> maybe = 
((EntityInternal)e2).config().getLocalRaw(TestEntity.CONF_NAME);
    +        Assert.assertTrue(maybe.isPresentAndNonNull());
    +        
Assert.assertTrue(BrooklynDslDeferredSupplier.class.isInstance(maybe.get()));
    +        BrooklynDslDeferredSupplier deferredSupplier = 
(BrooklynDslDeferredSupplier) maybe.get();
    +        Assert.assertEquals(deferredSupplier.toString(), 
"$brooklyn:entity(\"x\").attributeWhenReady(\"foo\")");
    +    }
    --- End diff --
    
    suggest also adding something like this:
    
    ```
            BrooklynMementoRawData raw = 
BrooklynPersistenceUtils.newStateMemento(app2.getManagementContext(), 
MementoCopyMode.LOCAL);
            String persistedStateForE2 = raw.getEntities().get(e2.getId());
            Matcher matcher = 
Pattern.compile(".*\\<test.confName\\>(.*)\\<\\/test.confName\\>.*", 
Pattern.DOTALL)
                        .matcher(persistedStateForE2);
            Assert.assertTrue(matcher.find());
            String testConfNamePersistedState = matcher.group(1);
            
            Assert.assertNotNull(testConfNamePersistedState);
            // should be about 200 chars long...
            Assert.assertTrue(testConfNamePersistedState.length() < 400, 
"persisted state too long: "+testConfNamePersistedState);
    ```
    
    this asserts the persisted state is as expected, and not too big.  btw this 
is what it looks like:
    
    ```
    //        <test.confName>
    //        
<org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-AttributeWhenReady>
    //          <component>
    //            <componentId>x</componentId>
    //            <scope>GLOBAL</scope>
    //          </component>
    //          <sensorName>foo</sensorName>
    //        
</org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent_-AttributeWhenReady>
    //      </test.confName>
    ```



---
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.
---

Reply via email to