Examples of FamixAttribute


Examples of org.evolizer.famix.model.entities.FamixAttribute

        setDataType(getCurrType());
//        getModel().addElement(getDataType());
    }

    private void createAttributes() {
        FamixAttribute lField = null;
       
        IVariableBinding lVariableBinding = getASTNode().resolveVariable();
        if (lVariableBinding != null) {
            String lFieldID = null;
            int lModifiers = lVariableBinding.getModifiers();
            String lSimpleName = lVariableBinding.getName();
            lFieldID = getCurrType().getUniqueName() + AbstractFamixEntity.NAME_DELIMITER + lSimpleName;
           
            lField = getFactory().createAttribute(lFieldID, null);
            lField = (FamixAttribute) getModel().addElement(lField);
            lField.setModifiers(lModifiers);
            lField.setSourceAnchor(getSourceAnchor());
            lField.setParent(getCurrType());
            getCurrType().getAttributes().add(lField);
            lField.setDeclaredClass(getDataType());
        } else {
            sLogger.error("Could not create attribute from enum constant declaration " + getASTNode().toString());
        }
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testAttributeType() {
        FamixClass classInt = (FamixClass) aModel.getElement(aFactory.createClass("int", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.a", null));
        assertEquals("Declared class of " + simpleAttribute.getUniqueName() + " must be int",
                simpleAttribute.getDeclaredClass(), classInt);
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testRefAttributeType() {
        FamixClass classSum = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.Sum", null));
        FamixAttribute refAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.refSum", null));
        assertEquals("Declared class of " + refAttribute.getUniqueName() + " must be testPackage.Sum",
                refAttribute.getDeclaredClass(), classSum);

    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testParameterizedAttributeType() {
        FamixClass classVector = (FamixClass) aModel.getElement(aFactory.createClass("java.util.Vector<E>", null));
        FamixAttribute paramAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.containerSum", null));
        assertEquals("Declared class of " + paramAttribute.getUniqueName() + " must be java.util.Vector<E>",
                paramAttribute.getDeclaredClass(), classVector);

    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testArrayAttributeType() {
        FamixClass classArray = (FamixClass) aModel.getElement(aFactory.createClass("<Array>", null));
        FamixAttribute arrayAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.arraySum", null));
        assertEquals("Declared class of " + arrayAttribute.getUniqueName() + " must be " + classArray.getUniqueName(),
                arrayAttribute.getDeclaredClass(), classArray);
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

                arrayAttribute.getDeclaredClass(), classArray);
    }

    @Test
    public void testAttributeModifiers() {
        FamixAttribute staticFinalAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.st", null));
        assertEquals("Type string of " + staticFinalAttribute.getUniqueName() + " must have modifier PRIVATE",
                staticFinalAttribute.getModifiers() & Modifier.PRIVATE, Modifier.PRIVATE);
        assertEquals("Type string of " + staticFinalAttribute.getUniqueName() + " must have modifier STATIC",
                staticFinalAttribute.getModifiers() & Modifier.STATIC, Modifier.STATIC);
        assertEquals("Type string of " + staticFinalAttribute.getUniqueName() + " must have modifier FINAL",
                staticFinalAttribute.getModifiers() & Modifier.FINAL, Modifier.FINAL);
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testClassAttributeContainer() {
        FamixClass parentClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.mass", null));

        assertNotNull("FamixModel must contain class testPackage.ae.EnumPlanet", parentClass);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.mass", simpleAttribute);

        assertTrue("FamixClass must contain simple attribute mass", parentClass.getAttributes().contains(simpleAttribute));
        assertEquals("No or wrong parent class for attribute mass", parentClass, simpleAttribute.getParent());
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }

    @Test
    public void testEnumConstantContainer() {
        FamixClass parentClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet", null));
        FamixAttribute enumConstantMERCURY = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.MERCURY", null));
        FamixAttribute enumConstantVENUS = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.VENUS", null));

        assertNotNull("FamixModel must contain class testPackage.ae.EnumPlanet", parentClass);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.MERCURY", enumConstantMERCURY);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.VENUS", enumConstantVENUS);

        assertTrue("FamixClass must contain simple attribute " + enumConstantMERCURY.getUniqueName(), parentClass.getAttributes().contains(enumConstantMERCURY));
        assertEquals("No or wrong parent class for attribute " + enumConstantMERCURY.getUniqueName(), parentClass, enumConstantMERCURY.getParent());
       
        assertTrue("FamixClass must contain simple attribute " + enumConstantVENUS.getUniqueName(), parentClass.getAttributes().contains(enumConstantVENUS));
        assertEquals("No or wrong parent class for attribute " + enumConstantVENUS.getUniqueName(), parentClass, enumConstantVENUS.getParent());

        assertEquals("Type of attribute MERCURY must be " + parentClass.getUniqueName(), parentClass, enumConstantMERCURY.getDeclaredClass());
        assertEquals("Type of attribute VENUS must be " + parentClass.getUniqueName(), parentClass, enumConstantVENUS.getDeclaredClass());
       
        assertEquals("Modifier of attribute " + enumConstantMERCURY.getUniqueName() + " must be " +  AbstractFamixEntity.MODIFIER_PUBLIC, AbstractFamixEntity.MODIFIER_PUBLIC, enumConstantMERCURY.getModifiers() & AbstractFamixEntity.MODIFIER_PUBLIC);
        assertEquals("Modifier of attribute " + enumConstantMERCURY.getUniqueName() + " must be " +  AbstractFamixEntity.MODIFIER_FINAL, AbstractFamixEntity.MODIFIER_FINAL, enumConstantMERCURY.getModifiers() & AbstractFamixEntity.MODIFIER_FINAL);
        assertEquals("Modifier of attribute " + enumConstantMERCURY.getUniqueName() + " must be " +  AbstractFamixEntity.MODIFIER_STATIC, AbstractFamixEntity.MODIFIER_STATIC, enumConstantMERCURY.getModifiers() & AbstractFamixEntity.MODIFIER_STATIC);
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }
   
    @Test
    public void testAccessEnumConstant() {
        FamixMethod methodDoSomething = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.UseEnumPlanet.doSomething(double)", null));
        FamixAttribute enumConstantEARTH = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.EARTH", null));

        assertNotNull("FamixModel must contain method testPackage.ae.UseEnumPlanet.doSomething(double)", methodDoSomething);
        assertNotNull("FamixModel must contain atrribute class testPackage.ae.EnumPlanet.EARTH", enumConstantEARTH);
       
        Set<FamixAssociation> lRelations = aModel.getAssociations(methodDoSomething);
        int nrAccessesTo = TestHelper.containsRelationTo(enumConstantEARTH, lRelations);
        assertEquals("Missing oaccess from " + methodDoSomething.getUniqueName() + " to " + enumConstantEARTH.getUniqueName(), 1, nrAccessesTo);
    }
View Full Code Here

Examples of org.evolizer.famix.model.entities.FamixAttribute

    }
   
    @Test
    public void testAccessStaticViaEnumConstant() {
        FamixMethod methodDoSomething = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.UseEnumPlanet.doSomething(double)", null));
        FamixAttribute enumConstantMARS = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.MARS", null));
        FamixAttribute staticAttributeG = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.EnumPlanet.G", null));

        assertNotNull("FamixModel must contain method testPackage.ae.UseEnumPlanet.doSomething(double)", methodDoSomething);
        assertNotNull("FamixModel must contain atrribute class testPackage.ae.EnumPlanet.MARS", enumConstantMARS);
        assertNotNull("FamixModel must contain atrribute class testPackage.ae.EnumPlanet.G", staticAttributeG);
       
        Set<FamixAssociation> lRelations = aModel.getAssociations(methodDoSomething);
        int nrAccessesTo = TestHelper.containsRelationTo(enumConstantMARS, lRelations);
        assertEquals("Missing access to " + methodDoSomething.getUniqueName() + " to " + enumConstantMARS.getUniqueName(), 1, nrAccessesTo);

        lRelations = aModel.getAssociations(methodDoSomething);
        nrAccessesTo = TestHelper.containsRelationTo(staticAttributeG, lRelations);
        assertEquals("Missing access to " + methodDoSomething.getUniqueName() + " to " + staticAttributeG.getUniqueName(), 1, nrAccessesTo);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.