Package org.auraframework.impl.root

Examples of org.auraframework.impl.root.AttributeDefImpl


    public void testGetAttributeDefs() throws Exception {
        DefDescriptor<EventDef> desc = DefDescriptorImpl.getInstance("fake:event", EventDef.class);
        Map<DefDescriptor<AttributeDef>, AttributeDef> atts = new HashMap<>();
        DefDescriptor<TypeDef> type = DefDescriptorImpl.getInstance("String", TypeDef.class);
        DefDescriptor<TypeDef> type2 = DefDescriptorImpl.getInstance("Integer", TypeDef.class);
        AttributeDefImpl att1 = new AttributeDefImpl(DefDescriptorImpl.getInstance("testString", AttributeDef.class),
                null, type, null, true, AttributeDef.SerializeToType.BOTH, null, null);
        AttributeDefImpl att2 = new AttributeDefImpl(DefDescriptorImpl.getInstance("testInt", AttributeDef.class),
                null, type2, null, true, AttributeDef.SerializeToType.BOTH, null, null);
        atts.put(att1.getDescriptor(), att1);
        atts.put(att2.getDescriptor(), att2);
        EventDefImpl def = vendor.makeEventDefWithNulls(desc, EventType.COMPONENT, atts, null, null);

        Map<DefDescriptor<AttributeDef>, AttributeDef> returnedAttributes = def.getAttributeDefs();
        Map<DefDescriptor<AttributeDef>, AttributeDef> expectedAttributes = new Hashtable<>();
        expectedAttributes.put(att1.getDescriptor(), att1);
        expectedAttributes.put(att2.getDescriptor(), att2);
        assertEquals(expectedAttributes, returnedAttributes);
    }
View Full Code Here


        componentXmlReader = getXmlReader(componentSource);
        cdh = new ComponentDefHandler(null, componentSource, componentXmlReader);
    }

    public void testGetElement() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='mystring' type='java://String' default='testing'/>");
        assertEquals("mystring", ad.getName());
        assertEquals("String", ad.getTypeDef().getName());
        assertEquals("testing", ad.getDefaultValue().getValue());
    }
View Full Code Here

        assertEquals("String", ad.getTypeDef().getName());
        assertEquals("testing", ad.getDefaultValue().getValue());
    }

    public void testDefaultValueExpression() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='mystring' type='java://String' default='{!blah.some.expression}'/>");
        assertEquals("mystring", ad.getName());
        assertEquals("String", ad.getTypeDef().getName());
        Object value = ad.getDefaultValue().getValue();
        assertTrue("Expected a PropertyReference for default", value instanceof PropertyReference);
        assertEquals("blah.some.expression", ((PropertyReference) value).toString());
    }
View Full Code Here

        assertTrue("Expected a PropertyReference for default", value instanceof PropertyReference);
        assertEquals("blah.some.expression", ((PropertyReference) value).toString());
    }

    public void testDefaultValueEmptyString() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='emptyString' type='java://String' default=''/>");
        assertEquals("emptyString", ad.getName());
        assertNotNull("Expected attribute to have a default value.", ad.getDefaultValue());
        assertEquals("Attribute does not reflect empty string as default value.", "", ad.getDefaultValue().getValue());
    }
View Full Code Here

        assertNotNull("Expected attribute to have a default value.", ad.getDefaultValue());
        assertEquals("Attribute does not reflect empty string as default value.", "", ad.getDefaultValue().getValue());
    }

    public void testDefaultValueWhitespace() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='spaces' type='java://String' default='    '/>");
        assertEquals("spaces", ad.getName());
        assertNotNull("Expected attribute to have a default value.", ad.getDefaultValue());
        assertEquals("Attribute does not reflect spaces as default value.", " ", ad.getDefaultValue().getValue());
    }
View Full Code Here

        assertNotNull("Expected attribute to have a default value.", ad.getDefaultValue());
        assertEquals("Attribute does not reflect spaces as default value.", " ", ad.getDefaultValue().getValue());
    }

    public void testGetElementWithTextBetweenTags() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='mystring' type='Aura.Component[]'>valid Text which is really a defref</aura:attribute>");
        assertEquals("mystring", ad.getName());
        assertEquals("Component[]", ad.getTypeDef().getName());
        assertTrue(ad.getDefaultValue().getValue() instanceof List);
        List<?> l = (List<?>) ad.getDefaultValue().getValue();
        assertEquals(1, l.size());
        ComponentDefRef cdr = (ComponentDefRef) l.get(0);
        AttributeDefRef adr = cdr.getAttributeDefRef("value");
        assertNotNull(adr);
        assertEquals("valid Text which is really a defref", adr.getValue());
View Full Code Here

                    "Invalid attribute \"other:default\"");
        }
    }

    public void testRequired() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='required' type='String' required='true'/>");
        assertEquals(true, ad.isRequired());
    }
View Full Code Here

        AttributeDefImpl ad = getElement("<aura:attribute name='required' type='String' required='true'/>");
        assertEquals(true, ad.isRequired());
    }

    public void testRequiredDefault() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='required' type='String'/>");
        assertEquals(false, ad.isRequired());
    }
View Full Code Here

        AttributeDefImpl ad = getElement("<aura:attribute name='required' type='String'/>");
        assertEquals(false, ad.isRequired());
    }

    public void testSerializeTo() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='lower' type='String' serializeTo='server'/>");
        assertEquals(SerializeToType.SERVER, ad.getSerializeTo());
    }
View Full Code Here

        AttributeDefImpl ad = getElement("<aura:attribute name='lower' type='String' serializeTo='server'/>");
        assertEquals(SerializeToType.SERVER, ad.getSerializeTo());
    }

    public void testSerializeToMixedCase() throws Exception {
        AttributeDefImpl ad = getElement("<aura:attribute name='mixed' type='String' serializeTo='nONe'/>");
        assertEquals(SerializeToType.NONE, ad.getSerializeTo());
    }
View Full Code Here

TOP

Related Classes of org.auraframework.impl.root.AttributeDefImpl

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.