Package org.auraframework.instance

Examples of org.auraframework.instance.Component


        Map<String, Object> attributes = Maps.newHashMap();
        DefDescriptor<ComponentDef> def = addSourceAutoCleanup(ComponentDef.class, String.format(
                "<aura:component render=\"client\">" +
                        attributeInMain + attributeInMain1 +
                        "MAIN CMP%s</aura:component>", source));
        Component mainCMP = Aura.getInstanceService().getInstance(def, attributes);

        String result = "MAINCMP<br/>ParentCMP<br/>m.valueParent=defaultattributeInMain1<br/>INNERCMP--valueofattr:defaultattributeInMain,valuefrommodule:defaultattributeInMain<br/>";
        if (testModelWithCount) {
            assertEquals(2, TestReinitializeModelWithCount.getCount());
            TestReinitializeModelWithCount.clearCount();
        } else {
            assertEquals(result, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
        }
        Map<String, Object> newAttributes = Maps.newHashMap();
        newAttributes.put("attributeInMain", "new attribute In Main");
        newAttributes.put("attributeInMain1", "new attribute In Main1");
        mainCMP.getAttributes().set(newAttributes);
        mainCMP.reinitializeModel();

        if (testModelWithCount) {
            assertEquals(2, TestReinitializeModelWithCount.getCount());
            TestReinitializeModelWithCount.clearCount();
        } else {
View Full Code Here


                .format(attributeTag, "'attMainToParentContainer'", "'String'", "'defaultattribute1to2'");
        String att1to3 = String.format(attributeTag, "'attMainToParent'", "'String'", "'defaultattribute1to3'");
        DefDescriptor<ComponentDef> defDes1 = getDefDescriptor(componentTagWithModelAndAttr, model,
                "'defaultattributeinParent1'", att1to2 + att1to3, cmpString2);

        Component mainCMP = Aura.getInstanceService().getInstance(defDes1, attributes);

        String result = "<br/>ParentCMP<br/>m.valueParent=defaultattributeinParent1" +
                "<br/>ParentCMP<br/>m.valueParent=defaultattribute1to2" +
                "<br/>ParentCMP<br/>m.valueParent=defaultattribute1to3";
        if (testModelWithCount) {
            assertEquals(3, TestReinitializeModelWithCount.getCount());
            TestReinitializeModelWithCount.clearCount();
        } else {
            assertEquals(result, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
        }

        attributes.clear();
        attributes.put("attrInParent", "new attributeinParent1");
        attributes.put("attMainToParentContainer", "new attribute1to2");
        attributes.put("attMainToParent", "new attribute1to3");
        mainCMP.getAttributes().set(attributes);
        mainCMP.reinitializeModel();
        if (testModelWithCount) {
            assertEquals(3, TestReinitializeModelWithCount.getCount());
            TestReinitializeModelWithCount.clearCount();
        } else {
            assertEquals(result.replaceAll("default", "new"), getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
View Full Code Here

        String attributeSource =
                "<aura:attribute name='componentArray' type='Aura.Component[]'>" + cmpString + "</aura:attribute>";
        DefDescriptor<ComponentDef> def = addSourceAutoCleanup(ComponentDef.class, String.format(
                "<aura:component render='client'>" + attributeSource +
                        "%s</aura:component>", "'{!v.componentArray}'"));
        Component mainCMP = Aura.getInstanceService().getInstance(def, attributesMain);
        if (testModelWithCount) {
            assertEquals(1, TestReinitializeModelWithCount.getCount());
            TestReinitializeModelWithCount.clearCount();
        } else {
            String output = getRenderedBaseComponent(mainCMP);
            String result = "'<br/>ParentCMP<br/>m.valueParent=defaultattributeinParent'";
            assertEquals(result, output.replaceAll("\\s+", ""));
        }

        Map<String, Object> attributes = Maps.newHashMap();
        attributes.put("attrInParent", "newValueInParent");

        DefDescriptor<ComponentDef> newDefDes = getDefDescriptor(componentTagWithModelAndAttr, model,
                "'defaultattributeinParent'", "", "");
        Component newAttrCMP = Aura.getInstanceService().getInstance(newDefDes.getDescriptorName(), ComponentDef.class,
                attributes);
        if (testModelWithCount) {
            TestReinitializeModelWithCount.clearCount();
        }
        ArrayList<Component> newCmpList = new ArrayList<>();
View Full Code Here

     * set m.valueParent with v.attrInParent
     */
    public void testCmpWithJavaProvider() throws Exception {
        Map<String, Object> attributes = Maps.newHashMap();
        attributes.put("whatToDo", "provideTestModelParentCmp");
        Component mainCMP = Aura.getInstanceService().getInstance("test:test_Provider_Concrete", ComponentDef.class,
                attributes);
        String result = "<br/>ParentCMP<br/>m.valueParent=defaultattributeinParent";
        assertEquals(result, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
        attributes.clear();
        // now what we really have is test_Model_Parent, not test_Provider_Concrete
        // trying to change what we provide like this won't work :
        // attributes.put("whatToDo", "provideTestModelParentCmpWithNewAttr");
        attributes.put("attrInParent", "provideTestModelParentCmpWithNewAttr");
        mainCMP.getAttributes().set(attributes);
        mainCMP.reinitializeModel();
        String newresult = "<br/>ParentCMP<br/>m.valueParent=provideTestModelParentCmpWithNewAttr";
        assertEquals(newresult, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
    }
View Full Code Here

     * provideTestModelParentCmpWithNewAttr for the provider of test_Provider_Concrete
     */
    public void _testCmpWithJavaProviderChangeWhatWeProvide() throws Exception {
        Map<String, Object> attributes = Maps.newHashMap();
        attributes.put("whatToDo", "provideTestModelParentCmp");
        Component mainCMP = Aura.getInstanceService().getInstance("test:test_Provider_Concrete", ComponentDef.class,
                attributes);
        String result = "<br/>ParentCMP<br/>m.valueParent=defaultattributeinParent";
        assertEquals(result, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
        attributes.clear();
        // now what we really have is test_Model_Parent, not test_Provider_Concrete
        // trying to change what we provide like this won't work :
        attributes.put("whatToDo", "provideTestModelParentCmpWithNewAttr");
        mainCMP.getAttributes().set(attributes);
        mainCMP.reinitializeModel();
        String newresult = "<br/>ParentCMP<br/>m.valueParent=provideTestModelParentCmpWithNewAttr";
        assertEquals(newresult, getRenderedBaseComponent(mainCMP).replaceAll("\\s+", ""));
    }
View Full Code Here

        DefDescriptor<ComponentDef> def = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(
                        "<aura:component model=\"java://test.model.TestReinitializeModel\"><aura:attribute name=\"attr\" type=\"String\" default=\"defaultValue\"/>%s</aura:component>",
                        source));
        Component ifcmp = Aura.getInstanceService().getInstance(def, attributes);
        assertEquals("value from attr:defaultValue,value from model:defaultValue", getRenderedBaseComponent(ifcmp));
        Map<String, Object> attributes2 = Maps.newHashMap();
        attributes2.put("attr", "new value from component");
        ifcmp.getAttributes().set(attributes2);
        ifcmp.reinitializeModel();
        assertEquals("value from attr:new value from component,value from model:new value from component",
                getRenderedBaseComponent(ifcmp));
    }
View Full Code Here

        DefDescriptor<ComponentDef> def = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(
                        "<aura:component><aura:attribute name=\"attr_out\" type=\"String\" default=\"defaultValue\"/>%s</aura:component>",
                        sourceInnerCMP));
        Component ifcmp = Aura.getInstanceService().getInstance(def, attributes);
        assertTrue(getRenderedBaseComponent(ifcmp).contains(
                "INNER CMP -- value of attr: defaultValue , value from module: defaultValue"));
        Map<String, Object> attributes2 = Maps.newHashMap();
        attributes2.put("attr_out", "newValue");
        ifcmp.getAttributes().set(attributes2);
        ifcmp.reinitializeModel();
        assertTrue(getRenderedBaseComponent(ifcmp).contains(
                "INNER CMP -- value of attr: newValue , value from module: newValue"));
    }
View Full Code Here

        DefDescriptor<ComponentDef> def = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(
                        "<aura:component model=\"java://test.model.TestReinitializeModel\"><aura:attribute name='listToShow' type='List'/>%s</aura:component>",
                        source));
        Component iteration = Aura.getInstanceService().getInstance(def, attributes);
        assertEquals("qrs", getRenderedBaseComponent(iteration));
        // listToShow is qrs
        iteration.reinitializeModel();
        Map<String, Object> attributes2 = Maps.newHashMap();
        attributes2.put("listToShow", Lists.newArrayList("a", "b", "c"));
        iteration.getAttributes().set(attributes2);
        iteration.reinitializeModel();
        // listToShow is abc now
        assertEquals("abc", getRenderedBaseComponent(iteration));
    }
View Full Code Here

        SerializationService serializationService = Aura.getSerializationService();

        StringWriter out = new StringWriter();
        Map<String, Object> attributes = new HashMap<>();
        attributes.put("attr", "yo");
        Component c = instanceService.getInstance("test:child1", ComponentDef.class, attributes);
        serializationService.write(c, null, Component.class, out);
        goldFileJson(out.toString());
        attributes.put("invalid", "joe");
        c = instanceService.getInstance("test:child1", ComponentDef.class, attributes);
        serializationService.write(c, null, Component.class, out);
View Full Code Here

            attributes.put("def", def);
            InstanceService instanceService = Aura.getInstanceService();
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> tmplDesc = definitionService.getDefDescriptor("auradev:saveComponent",
                    ComponentDef.class);
            Component tmpl = instanceService.getInstance(tmplDesc, attributes);
            Aura.getRenderingService().render(tmpl, out);
        } catch (QuickFixException x) {
            throw new AuraError(x);
        }
    }
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.