Package org.auraframework.impl.expression

Examples of org.auraframework.impl.expression.PropertyReferenceImpl$Serializer


                "java://org.auraframework.impl.java.model.TestModel", ModelDef.class);
        ModelDef mDef = javaModelDefDesc.getDef();
        assertNotNull(mDef);
        Model model = mDef.newInstance();
        try {
            model.getValue(new PropertyReferenceImpl("fooBar", new Location("test", 0)));
            fail("Model should not be able to getValue of a non existing property.");
        } catch (Exception e) {
            checkExceptionStart(e, AuraExecutionException.class, "TestModel: no such property: fooBar",
                    javaModelDefDesc.getName());
        }
        try {
            model.getValue(new PropertyReferenceImpl("firstThi", new Location("test", 0)));
            fail("Model.getValue() on partial matches of property names should not be successful.");
        } catch (Exception e) {
            checkExceptionStart(e, AuraExecutionException.class, "TestModel: no such property: firstThi",
                    javaModelDefDesc.getName());
        }
View Full Code Here


    }
   
    public void testReinitializeModel() throws Exception {
        Component cmp = vendor.makeComponent("test:child1", "meh");

        PropertyReferenceImpl propRef = new PropertyReferenceImpl("value", null);
    assertEquals(null, cmp.getModel().getValue(propRef));
       
        setAttribute(cmp, "attr", "some value");

    assertEquals(null, cmp.getModel().getValue(propRef));
View Full Code Here

                String.format(baseComponentTag, "extensible='true'",
                        "<aura:attribute name='parentAttr1' type='String' default='mother'/>"
                                + "<aura:attribute name='parentAttr2' type='String' default='father'/>"
                                + "<aura:attribute name='relativeAttr' type='String' default='aunt'/>"));
        Component parentCmp = Aura.getInstanceService().getInstance(parentDesc);
        assertEquals("mother", parentCmp.getValue(new PropertyReferenceImpl("v.parentAttr1", AuraUtil
                .getExternalLocation("direct attributeset access"))));
        assertEquals("mother", parentCmp.getValue(new PropertyReferenceImpl("v.PARENTATTR1", AuraUtil
                .getExternalLocation("direct attributeset access"))));

        // 2. Attributes inherited through parent
        DefDescriptor<ComponentDef> childDesc = addSourceAutoCleanup(ComponentDef.class, String.format(
                baseComponentTag, String.format("extends='%s'", parentDesc.getDescriptorName()),
                "<aura:set attribute='parentAttr2' value='godFather'/>"));
        Component childCmp = Aura.getInstanceService().getInstance(childDesc);
        assertEquals("mother", childCmp.getValue(new PropertyReferenceImpl("v.parentAttr1", AuraUtil
                .getExternalLocation("direct attributeset access"))));
        assertEquals("mother", childCmp.getValue(new PropertyReferenceImpl("v.PARENTAttr1", AuraUtil
                .getExternalLocation("direct attributeset access"))));
        assertEquals(
                "mother",
                childCmp.getSuper().getValue(
                        new PropertyReferenceImpl("v.pARENTAttr1", AuraUtil
                                .getExternalLocation("direct attributeset access"))));
        // Override default value will not change the value on the child
        assertEquals("father", childCmp.getValue(new PropertyReferenceImpl("v.PARENTAttr2", AuraUtil
                .getExternalLocation("direct attributeset access"))));
        // Override default value will not change the value on the parent,
        // <aura:set> sets the
        // value of the parent
        assertEquals(
                "godFather",
                childCmp.getSuper().getValue(
                        new PropertyReferenceImpl("v.PARENTAttr2", AuraUtil
                                .getExternalLocation("direct attributeset access"))));
    }
View Full Code Here

        // attribute is in caps
        DefDescriptor<ComponentDef> childDesc = addSourceAutoCleanup(ComponentDef.class, String.format(
                baseComponentTag, String.format("extends='%s'", parentDesc.getDescriptorName()),
                "<aura:set attribute='PARENTATTR' value='godmother'/>"));
        Component childCmp = Aura.getInstanceService().getInstance(childDesc);
        assertEquals("mother", childCmp.getValue(new PropertyReferenceImpl("v.parentAttr", AuraUtil
                .getExternalLocation("direct attributeset access"))));
        assertEquals(
                "godmother",
                childCmp.getSuper().getValue(
                        new PropertyReferenceImpl("v.parentAttr", AuraUtil
                                .getExternalLocation("direct attributeset access"))));

        // 2. Attribute reference of facets in markup
        DefDescriptor<ComponentDef> outerCmpDesc = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(baseComponentTag, "",
                        String.format("<%s PARENTATTR='godfather'/>", parentDesc.getDescriptorName())));
        Component outerCmp = Aura.getInstanceService().getInstance(outerCmpDesc);
        Component innerCmp = extractFacetsFromComponent(outerCmp).get(0);
        assertEquals(parentDesc.getQualifiedName(), innerCmp.getDescriptor().getQualifiedName());
        assertEquals("godfather", innerCmp.getValue(new PropertyReferenceImpl("v.parentAttr", AuraUtil
                .getExternalLocation("direct attributeset access"))));

        // 3. Attribute reference of facets using aura:set
        DefDescriptor<ComponentDef> outerCmpUsingSetAttributeDesc = addSourceAutoCleanup(ComponentDef.class,
                String.format(baseComponentTag, "", String.format(
                        "<%1$s> <aura:set attribute='PARENTATTR' value='evilfather'/> </%1$s>",
                        parentDesc.getDescriptorName())));
        outerCmp = Aura.getInstanceService().getInstance(outerCmpUsingSetAttributeDesc);
        innerCmp = extractFacetsFromComponent(outerCmp).get(0);
        assertEquals(parentDesc.getQualifiedName(), innerCmp.getDescriptor().getQualifiedName());
        assertEquals("evilfather", innerCmp.getValue(new PropertyReferenceImpl("v.parentAttr", AuraUtil
                .getExternalLocation("direct attributeset access"))));

    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private ArrayList<Component> extractFacetsFromComponent(Component c) throws Exception {
        Object body = c.getValue(new PropertyReferenceImpl("v.body", AuraUtil
                .getExternalLocation("direct attributeset access")));
        if (body == null) {
            body = c.getSuper().getValue(
                    new PropertyReferenceImpl("v.body", AuraUtil.getExternalLocation("direct attributeset access")));
        }
        if (body == null) {
            return null;
        }
        assertTrue(body instanceof ArrayList);
View Full Code Here

        assertEquals(expectedValue, defaultValue);

        // Also validate that the default appropriately shows up on an instance
        // of this model.
        Model model = def.newInstance();
        Object instanceValue = model.getValue(new PropertyReferenceImpl(name, null));
        assertEquals(expectedValue, instanceValue);

        // Make sure that the instance value was cloned so that changes to the
        // instance value don't affect other instances or the default.
        // This check doesn't work well for booleans or Strings.
View Full Code Here

                ComponentDef.class,
                String.format(baseComponentTag, "",
                        "<aura:attribute name='pairAttr' type='java://org.auraframework.util.type.CustomPairType' default='HouseNo$300'/>"));
        Component cmp = Aura.getInstanceService().getInstance(cmpDesc);
        assertEquals("Failed to convert attribute default value to custom data type object.", new CustomPairType(
                "HouseNo", 300), cmp.getValue(new PropertyReferenceImpl("v.pairAttr", AuraUtil
                .getExternalLocation("direct attributeset access"))));
    }
View Full Code Here

        super(name);
    }

    public void testSerialize() throws Exception {
        EventHandlerDefImpl eventHandlerDef2 = vendor.makeEventHandlerDefWithNulls(
                vendor.makeEventDefDescriptor("auratest:testevent"), new PropertyReferenceImpl("c.foo", null),
                vendor.makeLocation("filename", 5, 5, 0));
        serializeAndGoldFile(eventHandlerDef2);
    }
View Full Code Here

TOP

Related Classes of org.auraframework.impl.expression.PropertyReferenceImpl$Serializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.