Package org.auraframework.instance

Examples of org.auraframework.instance.Component


        } catch (AttributeNotFoundException expected) {
        }
    }

    public void testSerialize() throws Exception {
        Component testComponent = vendor.makeComponent("test:parent", "fuh");
        testComponent.getClass();
        serializeAndGoldFile(testComponent);
    }
View Full Code Here


        testComponent.getClass();
        serializeAndGoldFile(testComponent);
    }
   
    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));
   
    cmp.reinitializeModel();
        assertEquals("some value", cmp.getModel().getValue(propRef));
       
        setAttribute(cmp, "attr", "some other value");
    cmp.reinitializeModel();
        assertEquals("some other value", cmp.getModel().getValue(propRef));
    }
View Full Code Here

        // On even count get team and on odd count get players
        if (currentCount.intValue() % 2 == 0) {
            Map<String, Object> attr = Maps.newHashMap();
            attr.put("name", "Giants");
            attr.put("city", "San Francisco");
            Component cmp = Aura.getInstanceService()
                    .getInstance("auraStorageTest:teamFacet", ComponentDef.class, attr);
            ret.add(cmp);
        } else {
            Map<String, Object> attr = Maps.newHashMap();
            attr.put("name", "Posey");
            attr.put("nickName", "Buster");
            Component cmp = Aura.getInstanceService().getInstance("auraStorageTest:playerFacet", ComponentDef.class,
                    attr);
            ret.add(cmp);
            attr.put("name", "PSandavol");
            attr.put("nickName", "Panda");
            cmp = Aura.getInstanceService().getInstance("auraStorageTest:playerFacet", ComponentDef.class, attr);
View Full Code Here

        DefDescriptor<ComponentDef> parentDesc = addSourceAutoCleanup(ComponentDef.class,
                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

        // name of the
        // 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

                ComponentDef.class,
                String.format(
                        baseComponentTag,
                        "",
                        "<aura:attribute name='default' type='String' default='innie'/><aura:attribute name='both' type='String' default='outie' serializeTo='BOTH'/><aura:attribute name='server' type='String' default='lint' serializeTo='SERVER'/><aura:attribute name='none' type='String' default='holy' serializeTo='NONE'/>"));
        Component cmp = Aura.getInstanceService().getInstance(desc);
        Map<?, ?> attSet = (Map<?, ?>) new JsonReader().read(toJson(cmp.getAttributes()));
        Map<?, ?> attSetValues = (Map<?, ?>) ((Map<?, ?>) attSet.get("value")).get("values");
        assertEquals(2, attSetValues.size());
        assertEquals("innie", attSetValues.get("default"));
        assertEquals("outie", attSetValues.get("both"));

        // set has no attributes with serializeTo == BOTH
        desc = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(
                        baseComponentTag,
                        "",
                        "<aura:attribute name='server' type='String' default='lint' serializeTo='SERVER'/><aura:attribute name='none' type='String' default='holy' serializeTo='NONE'/>"));
        cmp = Aura.getInstanceService().getInstance(desc);
        attSet = (Map<?, ?>) new JsonReader().read(toJson(cmp.getAttributes()));
        attSetValues = (Map<?, ?>) ((Map<?, ?>) attSet.get("value")).get("values");
        assertEquals(0, attSetValues.size());
    }
View Full Code Here

    public void testCustomDataTypeConversion() throws Exception {
        DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(
                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

     */
    public void testBasicProviderScenario() throws Exception {
        Map<String, Object> attributes = Maps.newHashMap();

        attributes.put("implNumber", "3");
        Component component = Aura.getInstanceService().getInstance("test:test_Provider_Interface", ComponentDef.class,
                attributes);
        assertEquals("Java Provider: Failed to retrieve the right implementation for the interface.", component
                .getDescriptor().getQualifiedName(), "markup://test:test_Provider_providerImpl3");

        // Verify that the attributes passed off to the interface were inherited
        // by the component provided by the provider
        assertEquals("Failed to initialize attributes on the component",
                component.getAttributes().getExpression("implNumber"), "3");
        assertEquals("Failed to pass of arguments and its values from the interface to the provided component",
                component.getAttributes().getExpression("defaultAttr"), "meh");
        this.serializeAndGoldFile(component, "_providerImpl3");

        attributes.put("implNumber", "1");
        component = Aura.getInstanceService().getInstance("test:test_Provider_Interface", ComponentDef.class,
                attributes);
        assertEquals("Java Provider: Failed to retrieve the right implementation for the interface.", component
                .getDescriptor().getQualifiedName(), "markup://test:test_Provider_providerImpl1");
        // Verify that the attributes passed off to the interface were inherited
        // by the component provided by the provider
        assertEquals("Failed to initialize attributes on the component",
                component.getAttributes().getExpression("implNumber"), "1");

        assertEquals("Implementing component does not have its attributes",
                component.getAttributes().getExpression("ComponentSpecificAttr"), "iammine");
        this.serializeAndGoldFile(component, "_providerImpl1");

        // Request a component which is using the interface
        // test:test_Provider_Interface
        component = Aura.getInstanceService().getInstance("test:test_Provider_Component", ComponentDef.class, null);
        assertEquals("Java Provider: Failed to retrieve the component using the test interface.", component
                .getDescriptor().getQualifiedName(), "markup://test:test_Provider_Component");
        this.serializeAndGoldFile(component, "_component");
    }
View Full Code Here

    public void testConcreteProviderInjection() throws Exception {
        Map<String, Object> attributes = Maps.newHashMap();

        attributes.put("whatToDo", "replace");
        Component component = Aura.getInstanceService().getInstance("test:test_Provider_Concrete", ComponentDef.class,
                attributes);
        assertEquals("Java Provider: Failed to retrieve the right implementation for the interface.", component
                .getDescriptor().getQualifiedName(), "markup://test:test_Provider_Concrete_Sub");
    }
View Full Code Here

    public void testConcreteProviderNull() throws Exception {
        Map<String, Object> attributes = Maps.newHashMap();

        attributes.put("whatToDo", "label");
        Component component = Aura.getInstanceService().getInstance("test:test_Provider_Concrete", ComponentDef.class,
                attributes);
        assertEquals("Java Provider: Failed to retrieve the right implementation for the interface.", component
                .getDescriptor().getQualifiedName(), "markup://test:test_Provider_Concrete");
    }
View Full Code Here

TOP

Related Classes of org.auraframework.instance.Component

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.