Package org.evolizer.famix.model.entities

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


  }
 
  @Test
  public void testAssiocationAndFamixEntityConnection() throws EvolizerException{
    FamixAssociation association = new FamixAssociation();
    FamixMethod functionTo = new FamixMethod("functionTo");
    FamixMethod functionFrom = new FamixMethod("functionFrom");
    association.setFrom(functionFrom);
    association.setTo(functionTo);
   
   
    fEvolizerSession.startTransaction();
View Full Code Here


    assertEquals(new Integer(2), param.getParamIndex());
  }
 
  @Test
  public void testUnresolvedArrayParameter(){
    FamixMethod method = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test.myMethod(<undef>.Hunter[])",null));
    assertNotNull(method);
   
    FamixParameter param = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Test.myMethod(<undef>.Hunter[]).h",null,0));
    assertNotNull(param);
    assertEquals(new Integer(0), param.getParamIndex());
    FamixClass clazz = (FamixClass)aModel.getElement(aFactory.createClass(AbstractFamixEntity.ARRAY_TYPE_NAME,null));
    assertEquals(clazz, param.getDeclaredClass());
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
  }
View Full Code Here

  }
 
  @Test
  public void testFamixEntityAndPrarentConnection() throws EvolizerException{
    //Take Famix#Function as a concrete subclass of Famix#FamixEntity
    FamixMethod method = new FamixMethod("drawCircle");
    FamixMethod parentFunction = new FamixMethod("drawVisuals");
    method.setParent(parentFunction);
    method.setModifiers(1);
   
    fEvolizerSession.startTransaction();
    fEvolizerSession.saveObject(method);
    fEvolizerSession.saveObject(parentFunction);
    fEvolizerSession.endTransaction();
    fEvolizerSession.close();
   
    fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);
   
    List<FamixMethod> results = fEvolizerSession.query("from FamixMethod as f where f.uniqueName = 'drawCircle'", FamixMethod.class);
    assertEquals(1, results.size());
    FamixMethod resultFamixMethod = results.get(0);
    assertEquals("drawCircle", resultFamixMethod.getUniqueName());
    assertEquals("drawVisuals", resultFamixMethod.getParent().getUniqueName());
    assertEquals(1,resultFamixMethod.getModifiers());
  }
View Full Code Here

 
  @Test
  public void testUnresolvedReturnParameter(){
    FamixClass clazz = (FamixClass) aModel.getElement(aFactory.createClass("<undef>.Dudu",null));
    assertNotNull(clazz);
    FamixMethod method = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test.someMethod()",null));
    assertNotNull(method);
    assertEquals(clazz, method.getDeclaredReturnClass());
  }
View Full Code Here

 
  @Test
  public void testUnresolvedArrayReturnParameter(){
    FamixClass clazz = (FamixClass)aModel.getElement(aFactory.createClass(AbstractFamixEntity.ARRAY_TYPE_NAME,null));
    assertNotNull(clazz);
    FamixMethod method = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test.method()",null));
    assertNotNull(method);
    assertEquals(method.getDeclaredReturnClass(), clazz);
  }
View Full Code Here

    assertEquals(clazz, simpleAttribute.getDeclaredClass());
  }
 
  @Test
  public void testUnresolvedMethodInvocation(){
    FamixMethod caller = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test2.<init>()",null));
    assertNotNull(caller);
    FamixMethod callee = (FamixMethod)aModel.getElement(aFactory.createMethod("<undef>.Paladin.palaStats()",null));
    for(AbstractFamixEntity entity : aModel.getFamixEntities()){
      System.out.println(entity);
    }
    assertNotNull(callee);
   
    Set<FamixAssociation> callerRelations = aModel.getAssociations(caller);
    assertTrue("FamixMethod " + caller.getUniqueName() + " must contain relationships", callerRelations.size() > 0);
   
    int containsInvocationTo = TestHelper.containsRelationTo(callee, callerRelations);
    assertTrue("Missing invocation relationship from " + caller.getUniqueName() + " to " + callee.getUniqueName(), containsInvocationTo > 0);
  }
View Full Code Here

  }
 
  @Test
  public void testBehaviouralEntityProperties() throws EvolizerException{
    //Take FamixModel#FamixMethod as a concrete subclass of FamixModel#BehavioralEntity
    FamixMethod method = new FamixMethod("foo");
   
    FamixClass declaredReturnedClass = new FamixClass("someClass");
    method.setDeclaredReturnClass(declaredReturnedClass);
   
    FamixLocalVariable lVar1 = new FamixLocalVariable("counter");
    FamixLocalVariable lVar2 = new FamixLocalVariable("metricValue");
    Set<FamixLocalVariable> lVars = new HashSet<FamixLocalVariable>();
    lVars.add(lVar1);
    lVars.add(lVar2);
    method.setLocalVariables(lVars);
    lVar1.setParent(method);
    lVar2.setParent(method);
   
    FamixClass anonymClass1 = new FamixClass("anonymClass1");
    FamixClass anonymClass2 = new FamixClass("anonymClass2");
    Set<FamixClass> anonyClasses = new HashSet<FamixClass>();
    anonyClasses.add(anonymClass1);
    anonyClasses.add(anonymClass2);
    method.setAnonymClasses(anonyClasses);
    anonymClass1.setParent(method);
    anonymClass2.setParent(method);
   
    FamixParameter fPar1 = new FamixParameter("parameter1");
    FamixParameter fPar2 = new FamixParameter("parameter2");
    List<FamixParameter> fPars = new ArrayList<FamixParameter>();
    fPars.add(fPar1);
    fPars.add(fPar2);
    method.setParameters(fPars);
    fPar1.setParent(method);
    fPar2.setParent(method);
   
   
    fEvolizerSession.startTransaction();
    fEvolizerSession.saveObject(lVar1);
    fEvolizerSession.saveObject(lVar2);
    fEvolizerSession.saveObject(anonymClass1);
    fEvolizerSession.saveObject(anonymClass2);
    fEvolizerSession.saveObject(declaredReturnedClass);
    fEvolizerSession.saveObject(fPar1);
    fEvolizerSession.saveObject(fPar2);
    fEvolizerSession.saveObject(method);
    fEvolizerSession.endTransaction();
    fEvolizerSession.close();
   
   
    fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);
   
    List<FamixMethod> result = fEvolizerSession.query("from FamixMethod", FamixMethod.class);
    assertEquals(1, result.size());
    FamixMethod returnedFamixMethod = result.get(0);
    assertEquals("foo", returnedFamixMethod.getUniqueName());
   
    Set<FamixLocalVariable> returnedLVars = returnedFamixMethod.getLocalVariables();
    assertEquals(2, returnedLVars.size());
    for(Iterator<FamixLocalVariable> iter = returnedLVars.iterator();iter.hasNext();){
      FamixLocalVariable var = iter.next();
      assertTrue((var.getUniqueName().equals("counter") || var.getUniqueName().equals("metricValue")));
      assertEquals("foo", var.getParent().getUniqueName());
      assertTrue(returnedFamixMethod==var.getParent());
    }

    List<FamixParameter> returnedFormalPars = returnedFamixMethod.getParameters();
    assertEquals(2, returnedFormalPars.size());
    for(Iterator<FamixParameter> iter = returnedFamixMethod.getParameters().iterator();iter.hasNext();){
      FamixParameter par = iter.next();
      assertTrue((par.getUniqueName().equals("parameter1") || par.getUniqueName().equals("parameter2")));
      assertEquals("foo", par.getParent().getUniqueName());
      assertTrue(returnedFamixMethod==par.getParent());
    }
   
    Set<FamixClass> returnedAnonyClass = returnedFamixMethod.getAnonymClasses();
    assertEquals(2, returnedAnonyClass.size());
    for(Iterator<FamixClass> iter = returnedFamixMethod.getAnonymClasses().iterator();iter.hasNext();){
      FamixClass returnedClass = iter.next();
      assertTrue((returnedClass.getUniqueName().equals("anonymClass1") || returnedClass.getUniqueName().equals("anonymClass2")));
      assertEquals("foo", returnedClass.getParent().getUniqueName());
      assertTrue(returnedFamixMethod==returnedClass.getParent());
    }
    assertEquals("someClass", returnedFamixMethod.getDeclaredReturnClass().getUniqueName());
  }
View Full Code Here

    assertTrue("Missing invocation relationship from " + caller.getUniqueName() + " to " + callee.getUniqueName(), containsInvocationTo > 0);
  }
 
  @Test
  public void testUnresolvedMethodInvocationWithParam(){
    FamixMethod callee = (FamixMethod)aModel.getElement(aFactory.createMethod("<undef>.Paladin.heal(int,java.lang.Object,<undef>)",null));
    assertNotNull(callee);
   
    FamixMethod caller = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test2.<init>()",null));
    assertNotNull(caller);
   
    Set<FamixAssociation> callerRelations = aModel.getAssociations(caller);
    assertTrue("FamixMethod " + caller.getUniqueName() + " must contain relationships", callerRelations.size() > 0);
   
    int containsInvocationTo = TestHelper.containsRelationTo(callee, callerRelations);
    assertTrue("Missing invocation relationship from " + caller.getUniqueName() + " to " + callee.getUniqueName(), containsInvocationTo > 0);
  }
View Full Code Here

    assertTrue("Missing invocation relationship from " + caller.getUniqueName() + " to " + callee.getUniqueName(), containsInvocationTo > 0);
  }
 
  @Test
  public void testUnresolvedSuperConstructorInvocation(){
    FamixMethod caller = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.Test3.<init>()",null));
    assertNotNull(caller);
   
    FamixMethod unresolvedSuperConstructor = (FamixMethod)aModel.getElement(aFactory.createMethod("<undef>.<init>(double,java.lang.Object,<undef>,<undef>)",null));
    assertNotNull(unresolvedSuperConstructor);
   
    Set<FamixAssociation> lRelations = aModel.getAssociations(caller);
    assertTrue("FamixMethod " + caller.getUniqueName() + " must contain relationships", lRelations.size() > 0);
    int containsInvocationTo = TestHelper.containsRelationTo(unresolvedSuperConstructor, lRelations);
    assertTrue("Missing super constructor invocation relationship from " + caller.getUniqueName() + " to " + unresolvedSuperConstructor.getUniqueName(), containsInvocationTo > 0);

    lRelations = aModel.getAssociations(unresolvedSuperConstructor);
    assertTrue("FamixMethod " + unresolvedSuperConstructor.getUniqueName() + " must contain relationships", lRelations.size() > 0);
    containsInvocationTo = TestHelper.containsRelationTo(unresolvedSuperConstructor, lRelations);
    assertTrue("Missing super constructor invocation relationship from " + caller.getUniqueName() + " to " + unresolvedSuperConstructor.getUniqueName(), containsInvocationTo > 0);
  }
View Full Code Here

    }
   
    @Test
    public void testClassMethodConainer() {
        FamixClass parentClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.EnumPlanet", null));
        FamixMethod simpleMethod = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.EnumPlanet.mass()", null));

        assertNotNull("FamixModel must contain class testPackage.ae.EnumPlanet", parentClass);
        assertNotNull("FamixModel must contain method testPackage.ae.EnumPlanet.mass()", simpleMethod);
       
        assertTrue("FamixClass must contain simple method mass()", parentClass.getMethods().contains(simpleMethod));
        assertEquals("No or wrong parent class for method mass()", parentClass, simpleMethod.getParent());
    }
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.