Package org.auraframework.def

Examples of org.auraframework.def.ComponentDef


        assertNull(registry.getUid(null, DefDescriptorImpl.getInstance("unknown:soldier", ComponentDef.class)));
    }

    public void testGetUidLocalDef() throws Exception {
        MasterDefRegistryImpl registry = getDefRegistry(false);
        ComponentDef def = Mockito.spy(registry.getDef(DefDescriptorImpl.getInstance("aura:component",
                ComponentDef.class)));
        registry.invalidate(null); // clear any cached results from the preceding getDef call
        registry = getDefRegistry(false);
        registry.addLocalDef(def);
        assertNotNull(registry.getUid(null, def.getDescriptor()));
    }
View Full Code Here


        spyOnDefs(registry);

        // get def UID to trigger compileDef, etc.
        String uid = registry.getUid(null, cmpDesc);
        assertNotNull(uid);
        ComponentDef def = registry.getDef(cmpDesc);
        assertNotNull(def);
        Mockito.verify(registry, Mockito.times(1)).compileDE(Mockito.eq(cmpDesc));
        assertCompiledDef(def);

        // check all dependencies
View Full Code Here

    }

    public void testCompileDefLocalDef() throws Exception {
        // build a mock def
        String descName = String.format("%s:ghost", System.nanoTime());
        ComponentDef def = Mockito.mock(ComponentDef.class);

        Mockito.doReturn(DefDescriptorImpl.getInstance(descName, ComponentDef.class)).when(def).getDescriptor();

        // spy on MDR's registries to spy on defs
        final MasterDefRegistryImpl registry = getDefRegistry(true);
        registry.invalidate(null);
        spyOnDefs(registry);
        registry.addLocalDef(def);

        // get def UID to trigger compileDef, etc.
        String uid = registry.getUid(null, def.getDescriptor());
        assertNotNull(uid);
        Mockito.verify(registry, Mockito.times(1)).compileDE(Mockito.eq(def.getDescriptor()));
        Mockito.doReturn(true).when(def).isValid();
        assertCompiledDef(def);

        // check all dependencies
        MockUtil mockUtil = new MockUtil();
View Full Code Here

    }

    public void testGetDefCachedForChangedDefinition() throws Exception {
        DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class, "<aura:component/>");
        MasterDefRegistryImpl registry = getDefRegistry(false);
        ComponentDef def = registry.getDef(cmpDesc);
        assertNull(def.getAttributeDef("str"));

        // Definition cached for current registry
        registry.getSource(cmpDesc).addOrUpdate(
                "<aura:component><aura:attribute name='str' type='String'/></aura:component>");
        ComponentDef defNew = registry.getDef(cmpDesc);
        assertNull(defNew.getAttributeDef("str"));

        // Definition not cached for new registry
        MasterDefRegistryImpl registryNext = getDefRegistry(false);
        ComponentDef defNext = registryNext.getDef(cmpDesc);
        assertNotNull(defNext.getAttributeDef("str"));
    }
View Full Code Here

    }

    public void testGetDefCachedForRemovedDefinition() throws Exception {
        DefDescriptor<ComponentDef> cmpDesc = addSourceAutoCleanup(ComponentDef.class, "<aura:component/>", null);
        MasterDefRegistryImpl registry = getDefRegistry(false);
        ComponentDef def = registry.getDef(cmpDesc);
        assertNotNull(def);

        // Definition cached for current registry
        getAuraTestingUtil().removeSource(cmpDesc);
        ComponentDef defNew = registry.getDef(cmpDesc);
        assertNotNull(defNew);

        // Definition not cached for new registry
        MasterDefRegistryImpl registryNext = getDefRegistry(false);
        ComponentDef defNext = registryNext.getDef(cmpDesc);
        assertNull(defNext);
    }
View Full Code Here

        deleteFileOnTeardown(f);
        deleteFileOnTeardown(f.getParentFile());

        // Save file to filesystem and wait for source change to clear caches
        BuilderService builderService = Aura.getBuilderService();
        ComponentDef def = builderService.getComponentDefBuilder().setDescriptor(cmpDesc).build();
        Aura.getDefinitionService().save(def);

        // Make sure we actually have something to clear from the cache before verifying it's not in there.
        // if (!isInDefsCache(cmpDesc, mdr)) {
        //    fail("Test setup failure: def not added to MasterDefRegistry cache");
View Full Code Here

     *
     * @hierarchy Aura.Runtime.Service
     * @userStory AuraServlet: POST
     */
    public void testGetComponentDef() throws Exception {
        ComponentDef component = Aura.getDefinitionService().getDefinition("auratest:testComponent1",
                ComponentDef.class);

        Map<String, RegisterEventDef> red = component.getRegisterEventDefs();
        assertEquals(1, red.size());
        assertNotNull(red.get("testEvent"));

        Collection<EventHandlerDef> ehd = component.getHandlerDefs();
        assertEquals(0, ehd.size());
        // assertEquals("testEvent",ehd.iterator().next().getName());

        List<DefDescriptor<ModelDef>> mdd = component.getModelDefDescriptors();
        assertEquals(1, mdd.size());
        assertEquals("TestJavaModel", mdd.get(0).getName());

        List<DefDescriptor<ControllerDef>> cds = component.getControllerDefDescriptors();
        assertEquals(1, cds.size());
        assertEquals("JavaTestController", cds.get(0).getName());

        DefDescriptor<ModelDef> lmdd = component.getLocalModelDefDescriptor();
        assertEquals("TestJavaModel", lmdd.getName());

        ModelDef model = component.getModelDef();
        assertEquals("TestJavaModel", model.getName());

        ControllerDef controller = component.getControllerDef();
        assertEquals("testComponent1", controller.getName());

        DefDescriptor<RendererDef> rd = component.getRendererDescriptor();
        assertEquals("testComponent1", rd.getName());

        DefDescriptor<StyleDef> td = component.getStyleDescriptor();
        assertEquals("testComponent1", td.getName());
    }
View Full Code Here

        super.appendDependencies(dependencies);
    }

    @Override
    public void validateReferences() throws QuickFixException {
        @SuppressWarnings("unchecked")
        ComponentDef def = ((DefDescriptor<ComponentDef>) getAttributeDefRef("refDescriptor").getValue()).getDef();

        @SuppressWarnings("unchecked")
        Map<DefDescriptor<AttributeDef>, Object> lazyAttributes = (Map<DefDescriptor<AttributeDef>, Object>) getAttributeDefRef(
                "attributes").getValue();

        for (DefDescriptor<AttributeDef> at : lazyAttributes.keySet()) {
            AttributeDef other = def.getAttributeDef(at.getName());
            if (other == null) {
                throw new InvalidReferenceException(String.format("Attribute %s does not exist", at.getName()),
                        getLocation());
            }
            DefDescriptor<TypeDef> otherType = other.getTypeDef().getDescriptor();
View Full Code Here

                    ComponentDef.class);

            Map<String, Object> actionAttributes = Maps.newHashMap();
            Map<String, String> actionEventHandlers = Maps.newHashMap();

            ComponentDef componentDef = descriptor.getDef();
            if(attributes!=null) {
              for (Map.Entry<String, Object> entry : attributes.entrySet()) {
                  String key = entry.getKey();

                  AttributeDef attributeDef = componentDef.getAttributeDef(key);
                  if (attributeDef != null) {
                      String name = attributeDef.getName();
                      actionAttributes.put(name, entry.getValue());
                  } else {
                      RegisterEventDef eventDef = componentDef.getRegisterEventDefs().get(key);
                      if (eventDef != null) {
                          // Emit component.addHandler() wired to special global scope value provider
                          String name = eventDef.getAttributeName();
                          actionEventHandlers.put(name, (String) entry.getValue());
                      } else {
View Full Code Here

    public void testMismatchedComponentResourceAndTypeSpecification() throws Exception {
        String markup = "<aura:clientLibrary name='urlAndTypeMismatch' url='js://clientLibraryTest.clientLibraryTest' type='CSS'/>";
        DefDescriptor<ComponentDef> cmp = addSourceAutoCleanup(ComponentDef.class,
                String.format(baseComponentTag, "", markup));
        try {
            ComponentDef def = cmp.getDef();
            def.validateDefinition();
            fail("Should flag an error when resource type and specified type attribute do not match.");
        } catch (InvalidDefinitionException e) {
            assertEquals("ResourceDef type must match library type", e.getMessage());
        }
    }
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.