Package org.evolizer.famix.model.entities

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


     * Create missing fields
     */
    protected void createAttributeFromAccess() {
        String lFieldID = convertFieldID();
        if (lFieldID != null) {
            FamixAttribute lField = getFactory().createAttribute(lFieldID, null);
            lField = (FamixAttribute) getModel().addElement(lField);
            setField(lField);
        }
    }
View Full Code Here


        double value = 0d;
        SnapshotAnalyzer snapshotAnalyzer = new SnapshotAnalyzer(getCurrentSession());
        List<AbstractFamixEntity> entities = snapshotAnalyzer.getDescendants(getCurrentEntity());
        for (AbstractFamixEntity famixEntity : entities) {
            if (famixEntity instanceof FamixAttribute) {
                FamixAttribute method = (FamixAttribute) famixEntity;
                if ((method.getModifiers() & AbstractFamixEntity.MODIFIER_STATIC) != AbstractFamixEntity.MODIFIER_STATIC) {
                    value += 1d;
                }
            }
        }
View Full Code Here

    }

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

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

    }

    @Test
    public void testInnerClassAttributeContainer() {
        FamixClass innerClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.Test$Inner", null));
        FamixAttribute innerAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.Test$Inner.innerAttribute", null));

        assertTrue("Inner class must contain attribute " + innerAttribute.getUniqueName(), innerClass.getAttributes().contains(innerAttribute));
        assertEquals("No or wrong parent class for inner class attribute " + innerAttribute.getUniqueName(),
                innerClass, innerAttribute.getParent());
    }
View Full Code Here

    }

    @Test
    public void testAttributeInitialization() {
        FamixMethod testInit = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test.<oinit>()", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.Test.c", null));
        Set<FamixAssociation> lRelations = aModel.getAssociations(testInit);
        assertTrue("FamixMethod " + testInit.getUniqueName() + " must contain relationships", lRelations.size() > 0);
        int containsAccessTo = TestHelper.containsRelationTo(simpleAttribute, lRelations);
        assertTrue("Missing access relationship from " + testInit.getUniqueName() + " to " + simpleAttribute.getUniqueName(), containsAccessTo > 0);

        FamixMethod baseInit = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Base.<oinit>()", null));
        FamixAttribute baseAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Base.a", null));
        lRelations = aModel.getAssociations(baseInit);
        assertTrue("FamixMethod " + baseInit.getUniqueName() + " must contain relationships", lRelations.size() > 0);
        containsAccessTo = TestHelper.containsRelationTo(baseAttribute, lRelations);
        assertTrue("Missing access relationship from " + baseInit.getUniqueName() + " to " + baseAttribute.getUniqueName(), containsAccessTo > 0);
    }
View Full Code Here

    }

    @Test
    public void testThisAttributeAccess() {
        FamixMethod accessorMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.fieldAccess()", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.field", null));

        Set<FamixAssociation> lRelations = aModel.getAssociations(accessorMethod);
        assertTrue("FamixMethod " + accessorMethod.getUniqueName() + " must contain relationships", lRelations.size() > 0);

        int containsInvocationTo = TestHelper.containsRelationTo(simpleAttribute, lRelations);
        assertEquals("Missing access relationship from " + accessorMethod.getUniqueName() + " to " + simpleAttribute.getUniqueName(), 1, containsInvocationTo);
    }
View Full Code Here

    }

    @Test
    public void testQualifiedFieldAccess() {
        FamixMethod accessorMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.fieldAccess()", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Sum.publicField", null));

        Set<FamixAssociation> lRelations = aModel.getAssociations(accessorMethod);
        assertTrue("FamixMethod " + accessorMethod.getUniqueName() + " must contain relationships", lRelations.size() > 0);

        int containsInvocationTo = TestHelper.containsRelationTo(simpleAttribute, lRelations);
        assertEquals("Missing access relationship from " + accessorMethod.getUniqueName() + " to " + simpleAttribute.getUniqueName(), 2, containsInvocationTo);
    }
View Full Code Here

    }

    @Test
    public void testFieldAccessBySimpleName() {
        FamixMethod accessorMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.Variables.fieldAccess()", null));
        FamixAttribute simpleAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.fInit", null));

        assertNotNull("FamixModel must contain method testPackage.Variables.fieldAccess()", accessorMethod);
        assertNotNull("FamixModel must contain attribute testPackage.Variables.fInit", simpleAttribute);

        Set<FamixAssociation> lRelations = aModel.getAssociations(accessorMethod);
        assertTrue("FamixMethod " + accessorMethod.getUniqueName() + " must contain relationships", lRelations.size() > 0);

        int containsInvocationTo = TestHelper.containsRelationTo(simpleAttribute, lRelations);
        assertEquals("Missing access relationship from " + accessorMethod.getUniqueName() + " to " + simpleAttribute.getUniqueName(), 1, containsInvocationTo);
    }
View Full Code Here

    @Test
    public void testAnonymousClassConstructorWithArgumentsInvocation(){
        FamixClass anonymClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.Test$Inner$1", null));
        FamixMethod initializerTest = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test$Inner.innerMethod()", null));
        FamixMethod initializer = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test$Inner$1.<init>(int)", null));
        FamixAttribute anonymAttribute = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.ae.Test$Inner$1.x", null));
        FamixMethod anonymObjectInitializer = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.ae.Test$Inner$1.<oinit>()", null));

        assertNotNull(anonymClass);
        assertNotNull(initializerTest);
        assertNotNull(initializer);
View Full Code Here

        assertEquals("Declaration in source file must equal the source attribute ", returnRefDecl, returnRef.getSource());
    }

    @Test
    public void testSourceAnchorAttribute() throws Exception {
        FamixAttribute fMulti3 = (FamixAttribute) aModel.getElement(aFactory.createAttribute("testPackage.Variables.fMulti3", null));

        SourceAnchor anchor = fMulti3.getSourceAnchor();
        assertNotNull("Source anchor file of attribute " + fMulti3.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of attribute " + fMulti3.getUniqueName() + " must be", "/TestProject1/src/testPackage/Variables.java", anchor.getFile());
        assertTrue("The start must be before the end position", anchor.getStartPos() <= anchor.getEndPos());
        InputStream fileStream = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(anchor.getFile())).getContents();
        String fileContent = TestHelper.getFileContent(fileStream);
        String returnRefDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertEquals("Declaration of attribute must be 'fMulti3'", "fMulti3", returnRefDecl);
        assertEquals("Declaration in source file must equal the source attribute ", returnRefDecl, fMulti3.getSource());
    }
View Full Code Here

TOP

Related Classes of org.evolizer.famix.model.entities.FamixAttribute

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.