Package org.evolizer.famix.model.entities

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


        assertTrue("Missing inheritance relationship in sub class " + baseClass.getUniqueName() + " to " + interfaceClass.getUniqueName(), containsInheritsTo > 0);    
    }
   
    @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("Missing inheritance relationship from " + baseClass.getUniqueName() + " to " + anonymClass.getUniqueName(), 1, nrInheritsFrom);
    }
   
    @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

        assertEquals("Missing oaccess from " + methodDoSomething.getUniqueName() + " to " + enumConstantEARTH.getUniqueName(), 1, nrAccessesTo);
    }
   
    @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

        assertEquals("Missing access to " + methodDoSomething.getUniqueName() + " to " + staticAttributeG.getUniqueName(), 1, nrAccessesTo);
    }
   
    @Test
    public void testInvoceEnumMethod() {
        FamixMethod methodDoSomething = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.UseEnumPlanet.doSomething(double)", null));
        FamixMethod methodSurfaceGravity = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet.surfaceGravity()", null));
        FamixMethod methodSurfaceWeight = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet.surfaceWeight(double)", null));
  
        assertNotNull("FamixModel must contain method testPackage.ae.UseEnumPlanet.doSomething(double)", methodDoSomething);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.surfaceGravity()", methodSurfaceGravity);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.surfaceWeight(double)", methodSurfaceWeight);
       
        Set<FamixAssociation> lRelations = aModel.getAssociations(methodDoSomething);
        int nrInvocationsTo = TestHelper.containsRelationTo(methodSurfaceGravity, lRelations);
        assertEquals("Missing invocation from " + methodDoSomething.getUniqueName() + " to " + methodSurfaceGravity.getUniqueName(), 1, nrInvocationsTo);

        lRelations = aModel.getAssociations(methodDoSomething);
        nrInvocationsTo = TestHelper.containsRelationTo(methodSurfaceWeight, lRelations);
        assertEquals("Missing invocation from " + methodDoSomething.getUniqueName() + " to " + methodSurfaceWeight.getUniqueName(), 1, nrInvocationsTo);
    }
View Full Code Here

    }
   
    @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

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

        boolean isContainerEntityNode = false;
        if (entity instanceof IHierarchicalElement) {
            IHierarchicalElement<? extends AbstractFamixEntity> parentEntity = (IHierarchicalElement<? extends AbstractFamixEntity>) entity;
            if (!parentEntity.getChildren().isEmpty()) {
                if (entity instanceof org.evolizer.famix.model.entities.FamixMethod) {
                    FamixMethod method = (FamixMethod) entity;
                    if (!method.getAnonymClasses().isEmpty()) {
                        isContainerEntityNode = true;
                    }
                } else {
                    isContainerEntityNode = true;
                }
View Full Code Here

     *
     * @return The called super constructor, otherwise null.
     */
    @Override
    public FamixMethod createMethodFromInvocation() {
        FamixMethod lSuperConstructor = null;
        int successfullResolvingCounter = countResolvedArguments();

        if ((getMethodBinding() != null) && (successfullResolvingCounter == getArguments().size())) {
            lSuperConstructor = createMethod();
        } else {
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected double calculate() {
        double value = 0d;
        FamixMethod method = (FamixMethod) getCurrentEntity();
        value = method.getParameters().size();
        return value;
    }
View Full Code Here

        boolean visitChildren = true;
        setASTNode(methodDeclaration);
        addCurrMethodToMethodReminder();

        try {
            FamixMethod lCurrMethod = createMethod();
            lCurrMethod = (FamixMethod) getModel().addElement(lCurrMethod);

            int lModifiers = getASTNode().getModifiers();
            lCurrMethod.setModifiers(lModifiers);
            lCurrMethod.setSourceAnchor(getSourceAnchor());
            if (getCurrType().getMethods().contains(lCurrMethod)) {
                getCurrType().getMethods().remove(lCurrMethod); // always use the declared method object
            }
            getCurrType().getMethods().add(lCurrMethod);
            lCurrMethod.setParent(getCurrType());
            setCurrMethod(lCurrMethod);

            createMethodParameters();
            handleMethodReturnType();
        } catch (NullPointerException e) {
View Full Code Here

TOP

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

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.