Package org.auraframework.instance

Examples of org.auraframework.instance.Component


            attributes.put("def", def);
            InstanceService instanceService = Aura.getInstanceService();
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> tmplDesc = definitionService.getDefDescriptor("auradev:saveApplication",
                    ComponentDef.class);
            Component tmpl = instanceService.getInstance(tmplDesc, attributes);
            Aura.getRenderingService().render(tmpl, out);
        } catch (QuickFixException x) {
            throw new AuraError(x);
        }
    }
View Full Code Here


      attributesA.put("attr", "attrA");
      Map<String, Object> attributesB = Maps.newHashMap();
      attributesB.put("attr", "attrB");
      Map<String, Object> attributesC = Maps.newHashMap();
      attributesC.put("attr", "attrC");
    Component sharedCmp = Aura.getInstanceService().getInstance("ifTest:testIfWithModel", ComponentDef.class,
                attributes);
      StringWriter sw = new StringWriter();
        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction(sw,"first action");
        Action b = new EmptyAction(sw,"second action");
        Action c = new EmptyAction(sw,"third action");
        Action d = new ShareCmpAction("d",a,sharedCmp,attributesA);
        Action e = new ShareCmpAction("e",b,sharedCmp,attributesB);
        Action f = new ShareCmpAction("f",c,sharedCmp,attributesC);
        List<Action> actions = Lists.newArrayList(d,e,f);
        Message message = new Message(actions);
        //run the list of actions.
        ss.run(message, Aura.getContextService().getCurrentContext(), sw, null);
       
        //sanity check, sharedCmp should have the latest attribute value.
        //this has nothing to do with the fix though
        assertEquals("attrC",sharedCmp.getAttributes().getValue("attr"));
        //Here are the checks for fix
        //returnValue of action e is going to have shared component from action d in Json format
        String returne = (String) e.getReturnValue();
        assertTrue(returne.contains("markup://ifTest:testIfWithModel"));
        assertTrue(returne.contains("\"attr\":\"attrA\""));
View Full Code Here

                "<aura:set attribute='text' value='Aura'/>");
        DefDescriptor<ComponentDef> extensionCmpDesc = addSourceAutoCleanup(ComponentDef.class, markup);
        assertNotNull(
                "Failed to retrieve definition of extension component which was setting value of inherited attribute",
                extensionCmpDesc.getDef());
        Component component = (Component) Aura.getInstanceService().getInstance(extensionCmpDesc.getQualifiedName(),
                ComponentDef.class);
        assertEquals("Attribute value set using value assignment does not match expected value.", "Aura", component
                .getSuper().getAttributes().getValue("text"));
    }
View Full Code Here

                "<aura:set attribute='innerBody'><aura:text value='Aura'/></aura:set>");
        DefDescriptor<ComponentDef> extensionCmpDesc = addSourceAutoCleanup(ComponentDef.class, markup);
        assertNotNull(
                "Failed to retrieve definition of extension component which was setting value of inherited attribute",
                extensionCmpDesc.getDef());
        Component component = (Component) Aura.getInstanceService().getInstance(extensionCmpDesc.getQualifiedName(),
                ComponentDef.class);
        Object value = component.getSuper().getAttributes().getValue("innerBody");
        assertTrue(value instanceof ArrayList);
        Object innerBodycmp = ((ArrayList<?>) value).get(0);
        assertTrue(innerBodycmp instanceof Component);
        assertEquals("Setting inherited attribute in body of <aura:set></aura:set> does not work.",
                "markup://aura:text", ((Component)innerBodycmp).getDescriptor().getQualifiedName());
View Full Code Here

     */
    public void testUsageOfComponentDefRefArray() throws Exception {
        DefDescriptor<ComponentDef> desc = addSourceAutoCleanup(ComponentDef.class, String.format(baseComponentTag, "",
                "<aura:attribute type='Aura.ComponentDefRef[]' name='attr'>" + "<test:text/>"
                        + "<aura:text value='aura'/>" + "</aura:attribute>"));
        Component cmp = (Component) Aura.getInstanceService().getInstance(desc);
        assertNotNull("Failed to create component with Aura.ComponentDefRef[] type attribute.", cmp);
        Object value = cmp.getAttributes().getValue("attr");
        assertNotNull(value);
        assertTrue(value instanceof ComponentDefRefArrayImpl);
        ComponentDefRefArrayImpl cdra = (ComponentDefRefArrayImpl) value;
        List<ComponentDefRef> cmpDefRefs = cdra.getList();
        assertEquals("Unexpected items in componentDefRef array attribute", 2, cmpDefRefs.size());
View Full Code Here

     */
    public void testEmptyBodyForComponentDefRefArray() throws Exception {
        DefDescriptor<ComponentDef> desc = addSourceAutoCleanup(ComponentDef.class, String.format(baseComponentTag, "",
                "<aura:attribute type='Aura.ComponentDefRef[]' name='attr'>" + "</aura:attribute>"));
        // Verify that it works fine
        Component cmp = (Component) Aura.getInstanceService().getInstance(desc);
        assertNotNull("Was not able to use an attribute of Aura.ComponentDefRef[] with an empty body.", cmp);
        Object value = cmp.getAttributes().getValue("attr");
        assertNull("ComponentDefRef array attribute should have had no value.", value);
    }
View Full Code Here

        // 1. Expression using outer attributes
        DefDescriptor<ComponentDef> desc = addSourceAutoCleanup(ComponentDef.class, String.format(baseComponentTag, "",
                "<aura:attribute type='String' name='outerAttr' default='emulp'/>"
                        + "<aura:attribute type='Aura.ComponentDefRef[]' name='attr'>"
                        + "<aura:text value=\"{!'aura'+ v.outerAttr}\"/>" + "</aura:attribute>"));
        Component cmp = (Component) Aura.getInstanceService().getInstance(desc);
        assertNotNull(cmp);
        Object value = cmp.getAttributes().getValue("attr");
        assertNotNull(value);
        assertTrue(value instanceof ComponentDefRefArrayImpl);
        ComponentDefRefArrayImpl cdra = (ComponentDefRefArrayImpl) value;
        List<ComponentDefRef> cmpDefRefs = cdra.getList();
        ComponentDefRef ref = cmpDefRefs.get(0);
View Full Code Here

        facetAttributes.put("value", "aura" /*
                                             * new
                                             * PropertyReferenceImpl("v.value",
                                             * null)
                                             */);
        Component facet = (Component) Aura.getInstanceService().getInstance("ui:outputText", facetAttributes,
                DefType.COMPONENT);
        attributes.put("facet", Lists.newArrayList(facet));

        return attributes;
    }
View Full Code Here

        int count = input == null ? 1 : Integer.parseInt(input);
        List<Component> cmps = new LinkedList<>();
        while (count-- > 0) {
            Object val = token + ":java:" + count;
            Map<String, Object> atts = ImmutableMap.of("value", val);
            Component cmp = Aura.getInstanceService().getInstance("auratest:text", ComponentDef.class, atts);
            cmps.add(cmp);
        }
        return cmps.toArray();
    }
View Full Code Here

    public ComponentImplTest(String name) {
        super(name);
    }

    public void testComponentAttributeMap() throws Exception {
        Component cmp = vendor.makeComponent("test:child1", "meh");
        AttributeDefRef adr = vendor.makeAttributeDefRef("attr", "some value", new Location("meh", 0));
        cmp.getAttributes().set(Collections.singleton(adr));

        assertEquals(1, cmp.getAttributes().size());

        assertEquals("some value", cmp.getAttributes().getExpression("attr"));

        try {
            AttributeDefRef adr2 = vendor.makeAttributeDefRef("badAttr", "blubber", new Location("meh", 0));
            cmp.getAttributes().set(Collections.singleton(adr2));
            fail("Should have thrown AuraException(Attribute not Defined)");
        } catch (AttributeNotFoundException expected) {
        }
    }
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.