Package org.evolizer.famix.model.entities

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


        assertEquals("Modifier of attribute " + enumConstantMERCURY.getUniqueName() + " must be " +  AbstractFamixEntity.MODIFIER_STATIC, AbstractFamixEntity.MODIFIER_STATIC, enumConstantMERCURY.getModifiers() & AbstractFamixEntity.MODIFIER_STATIC);
    }
   
    @Test
    public void testEnumSubtyping() {
        FamixClass interfaceClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.IEnumPlanet", null));
        FamixClass baseClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet", null));

        Set<FamixAssociation> lRelations = aModel.getAssociations(baseClass);
        assertTrue("FamixClass " + baseClass.getUniqueName() + " must contain relationships", lRelations.size() > 0);
        int containsInheritsTo = TestHelper.containsRelationTo(interfaceClass, lRelations);
        assertTrue("Missing inheritance relationship in class" + baseClass.getUniqueName() + " to " + interfaceClass.getUniqueName(), containsInheritsTo > 0);

        lRelations = aModel.getAssociations(interfaceClass);
        assertTrue("FamixClass " + interfaceClass.getUniqueName() + " must contain relationships", lRelations.size() > 0);
        containsInheritsTo = TestHelper.containsRelationTo(interfaceClass, lRelations);
        assertTrue("Missing inheritance relationship in sub class " + baseClass.getUniqueName() + " to " + interfaceClass.getUniqueName(), containsInheritsTo > 0);    
    }
View Full Code Here


    }
   
    @Test
    public void testMethodAnonymousClassContainer() {
        FamixMethod initializer = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet.<oinit>()", null));
        FamixClass anonymClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet$1", null));

        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.<oinit>()", initializer);
        assertNotNull("FamixModel must contain anonymous class testPackage.ae.EnumPlanet$1", anonymClass);

        assertTrue("FamixMethod must contain anonymous class", initializer.getAnonymClasses().contains(anonymClass));
        assertEquals("No or wrong parent method for anonymous class", initializer, anonymClass.getParent());
    }
View Full Code Here

        assertEquals("No or wrong parent method for anonymous class", initializer, anonymClass.getParent());
    }
   
    @Test
    public void testAnonymousClassInheritance() {
        FamixClass baseClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet", null));
        FamixClass anonymClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet$1", null));

        assertNotNull("FamixModel must contain class testPackage.ae.EnumPlanet", baseClass);
        assertNotNull("FamixModel must contain anonymous class testPackage.ae.EnumPlanet$1", anonymClass);
       
        Set<FamixAssociation> lRelations = aModel.getAssociations(baseClass);
        int nrInheritsFrom = TestHelper.containsRelationTo(baseClass, lRelations);
        assertEquals("Missing inheritance relationship from " + baseClass.getUniqueName() + " to " + anonymClass.getUniqueName(), 1, nrInheritsFrom);

        lRelations = aModel.getAssociations(anonymClass);
        nrInheritsFrom = TestHelper.containsRelationTo(baseClass, lRelations);
        assertEquals("Missing inheritance relationship from " + baseClass.getUniqueName() + " to " + anonymClass.getUniqueName(), 1, nrInheritsFrom);
    }
View Full Code Here

        assertEquals("Missing invocation from " + methodDoSomething.getUniqueName() + " to " + methodSurfaceWeight.getUniqueName(), 1, nrInvocationsTo);
    }
   
    @Test
    public void testInvokeSuperMethodFromAnonymousClass() {
        FamixClass anonymClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet$1", null));
        FamixMethod newMethodMass = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet$1.mass()", null));
        FamixMethod superMethodMass = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet.mass()", null));

        assertNotNull("FamixModel must contain anonymous class testPackage.ae.EnumPlanet$1", anonymClass);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet$1.mass()", newMethodMass);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.mass()", superMethodMass);

        assertTrue("FamixClass must contain method", anonymClass.getMethods().contains(newMethodMass));
        assertEquals("No or wrong parent class of method ", anonymClass, newMethodMass.getParent());
       
        Set<FamixAssociation> lRelations = aModel.getAssociations(newMethodMass);
        int nrInvocationsTo = TestHelper.containsRelationTo(superMethodMass, lRelations);
        assertEquals("Missing invocation from " + newMethodMass.getUniqueName() + " to " + superMethodMass.getUniqueName(), 1, nrInvocationsTo);
View Full Code Here

            // int nop = famixPackage.getPackages().size();
            // result = result + "\nSubpackages: " + nop;
            int noc = famixPackage.getClasses().size();
            result = result + "\nClasses: " + noc;
        } else if (entity instanceof FamixClass) {
            FamixClass famixClass = (FamixClass) entity;
            int nom = famixClass.getMethods().size();
            result = result + "\nMethods: " + nom;
            int noa = famixClass.getAttributes().size();
            result = result + "\nAttributes: " + noa;
            int noic = famixClass.getInnerClasses().size();
            result = result + "\nInner classes: " + noic;
        }
        return result;
    }
View Full Code Here

                addCurrTypeToTypeReminder();
                addCurrMethodToMethodReminder();
            }

            // Insert this enum type
            FamixClass lCurrType = getClass(getTypeBinding(), null, false);
            lCurrType.setModifiers(getTypeBinding().getModifiers() | AbstractFamixEntity.MODIFIER_ENUM);
            lCurrType.setSourceAnchor(getSourceAnchor(getASTNode()));

            getModel().addElement(lCurrType);
            setCurrType(lCurrType);

            initAnonymousClassCounter();
            setCurrMethod(addObjectInitMethod(lCurrType));

            addParentLink();

            if (getTypeBinding().isTopLevel()) {
                lCurrType.setSource(fCurrSource);
            }

            addInheritanceLinks();
        } catch (NullPointerException e) {
            sLogger.error("Error processing enum declaration "
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public void addInheritanceLinks() {
        List<Type> superInterfaces = getASTNode().superInterfaceTypes();
        for (Type superInterface : superInterfaces) {
            FamixClass lInterface = getClass(superInterface.resolveBinding(), superInterface, false);
            lInterface = (FamixClass) getModel().addElement(lInterface);
            lInterface.setModifiers(lInterface.getModifiers() | AbstractFamixEntity.MODIFIER_INTERFACE);
            FamixAssociation subtyping = getFactory().createSubtyping(getCurrType(), lInterface);
            subtyping.setSourceAnchor(getSourceAnchor());
            getModel().addRelation(subtyping);
        }
    }
View Full Code Here

        ITypeBinding lTypeBinding = null;
        if (declType != null) {
            lTypeBinding = declType.resolveBinding();
        }
        FamixClass lDataType = getClass(lTypeBinding, declType, false);
        lDataType = (FamixClass) getModel().addElement(lDataType);
        setDataType(lDataType);
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected double calculate() {
        double value = 0d;
        FamixClass famixClass = (FamixClass) getCurrentEntity();
        for (FamixAttribute attribute: famixClass.getAttributes()) {
            if ((attribute.getModifiers() & AbstractFamixEntity.MODIFIER_STATIC) == AbstractFamixEntity.MODIFIER_STATIC) {
                value += 1d;
            }
        }
       
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected double calculate() {
        double value = 0d;
        FamixClass famixClass = (FamixClass) getCurrentEntity();
        for (FamixAttribute attribute: famixClass.getAttributes()) {
            if ((attribute.getModifiers() & AbstractFamixEntity.MODIFIER_STATIC) != AbstractFamixEntity.MODIFIER_STATIC) {
                value += 1d;
            }
        }
       
View Full Code Here

TOP

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

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.