Package org.auraframework.def

Examples of org.auraframework.def.ComponentDef


        Map<String, Map<String, String>> componentDetails;

        for (DefDescriptor<ComponentDef> descriptor : descriptors) {
            component = new TreeMap<String, Map<String, Map<String, String>>>();
            try {
                ComponentDef compDef = descriptor.getDef();
                String compName = descriptor.getNamespace() + ":" + compDef.getName();
                if (components.containsKey(compName)) {
                    continue;
                }

                Map<DefDescriptor<AttributeDef>, AttributeDef> attDefs = compDef.getAttributeDefs();
                if (attDefs != null && attDefs.size() > 0) {
                    componentDetails = new TreeMap<String, Map<String, String>>();
                    for (DefDescriptor<AttributeDef> attDef : attDefs.keySet()) {
                        Map<String, String> attributePros = new TreeMap<String, String>();
                        attributePros.put("type", attDefs.get(attDef).getTypeDef().getName());
                        String desc = attDefs.get(attDef).getDescription();
                        if (desc != null) {
                            attributePros.put(DESCRIPTION_KEY, desc);
                        }
                        componentDetails.put(attDef.getName(), attributePros);
                    }
                    component.put(ATTRIBUTES_KEY, componentDetails);
                }

                Map<String, RegisterEventDef> eventDefs = compDef.getRegisterEventDefs();
                if (eventDefs != null && eventDefs.size() > 0) {
                    componentDetails = new TreeMap<String, Map<String, String>>();
                    for (String eventDef : eventDefs.keySet()) {
                        Map<String, String> eventPros = new TreeMap<String, String>();
                        eventPros.put(TYPE_KEY, "Action");
                        String desc = eventDefs.get(eventDef).getDescription();
                        if (desc != null) {
                            eventPros.put(DESCRIPTION_KEY, desc);
                        }
                        componentDetails.put(eventDef, eventPros);

                    }
                    component.put(EVENTS_KEY, componentDetails);
                }

                Collection<EventHandlerDef> handlerDefs = compDef.getHandlerDefs();
                if (handlerDefs != null && handlerDefs.size() > 0) {
                    componentDetails = new TreeMap<String, Map<String, String>>();
                    for (EventHandlerDef handlerDef : handlerDefs) {
                        Map<String, String> eventHandlerProps = new TreeMap<String, String>();
                        String desc = handlerDef.getDescription();
                        if (desc != null) {
                            eventHandlerProps.put(DESCRIPTION_KEY, desc);
                        }
                        componentDetails.put(handlerDef.getName(), eventHandlerProps);

                    }
                    component.put(HANDLERS_KEY, componentDetails);
                }

                String desc = compDef.getDescription();
                if (desc != null) {
                    componentDetails = new TreeMap<String, Map<String, String>>();
                    componentDetails.put(desc, new TreeMap<String, String>());
                    component.put(DESCRIPTION_KEY, componentDetails);
                }

                String support = compDef.getSupport().toString();
                if (support != null) {
                    componentDetails = new TreeMap<String, Map<String, String>>();
                    componentDetails.put(support, new TreeMap<String, String>());
                    component.put(SUPPORT_KEY, componentDetails);
                }
View Full Code Here


        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='click' type='aura:click' description='The Description' access='global'/></aura:component>",
                "myID", Format.XML);
        ComponentDef def2 = parser.parse(descriptor, source);
        RegisterEventDef red = def2.getRegisterEventDefs().get("click");
        assertNotNull(red);
        assertEquals("click", red.getName());
        assertTrue(red.isGlobal());
    }
View Full Code Here

        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='aura:click' description='The Description' access='fakeAccessLevel'/></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraException because access level isn't public or global");
        } catch (InvalidDefinitionException e) {

        }
    }
View Full Code Here

        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='aura:click' description='The Description' access='global'>invalidtext</aura:registerevent></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraException because text is between aura:registerevent tags");
        } catch (InvalidDefinitionException e) {

        }
    }
View Full Code Here

        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,"<aura:component><aura:registerevent name='wheresthetype'/></aura:component>",
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing type for event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "type attribute is required on registerevent");
        }
    }
View Full Code Here

        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                String.format("<aura:component><aura:registerevent type='%s'/></aura:component>",eventDesc.getDescriptorName()),
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing name for component event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "name is a required attribute on tag registerevent");
        }
    }
View Full Code Here

        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                String.format("<aura:component><aura:registerevent type='%s'/></aura:component>",eventDesc.getDescriptorName()),
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing name for application event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "name is a required attribute on tag registerevent");
        }
    }
View Full Code Here

                Format.XML);
        assertDefaultType(source, "When empty type specified, JS should be the default");
    }

    private void assertDefaultType(StringSource<ComponentDef> source, String errorMsg) throws Exception {
        ComponentDef cmpDef = parser.parse(descriptor, source);
        List<ClientLibraryDef> libraries = cmpDef.getClientLibraries();
        assertEquals(1, libraries.size());
        assertEquals(Type.JS, libraries.get(0).getType());
    }
View Full Code Here

    public void testInvalidTypeInLibraryTag() throws Exception {
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:clientLibrary name='HTML5Shiv' type='fooBar' /></aura:component>", "myID",
                Format.XML);

        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have failed on encountering bad type attribute");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Missing valid type");
        }
    }
View Full Code Here

    public void testCommaSeparatedTypesInLibraryTag() throws Exception {
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:clientLibrary name='HTML5Shiv' type='JS, CSS' /></aura:component>", "myID",
                Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should accept only valid types for type attribute.");
        } catch (Exception e) {
            checkExceptionFull(e, InvalidDefinitionException.class, "Missing valid type");
        }
    }
View Full Code Here

TOP

Related Classes of org.auraframework.def.ComponentDef

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.