Package org.evolizer.famix.model.entities

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


     *
     * @return The called FAMIX method, otherwise null.
     */
    @Override
    public FamixMethod createMethodFromInvocation() {
        FamixMethod lMethod = null;
        int successfullResolvingCounter = countResolvedArguments();

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


  }
 
 
  @Test
  public void testMethodParameters(){
    FamixMethod method = (FamixMethod)fModel.getElement(fFactory.createMethod("testPackage.Test.myMethod(int,double,<undef>.Warlock)",null));
    assertNotNull(method);
    assertEquals(3, method.getParameters().size());
   
    FamixParameter param = (FamixParameter) fModel.getElement(fFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).i",null,0));
    assertNotNull(param);
    assertEquals(new Integer(0), param.getParamIndex());
   
    FamixClass clazz = (FamixClass) fModel.getElement(fFactory.createClass("int",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
   
    param = (FamixParameter) fModel.getElement(fFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).d",null,1));
    clazz = (FamixClass) fModel.getElement(fFactory.createClass("double",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertNotNull(param);
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
    assertEquals(new Integer(1), param.getParamIndex());
   
    param = (FamixParameter) fModel.getElement(fFactory.createFormalParameter("testPackage.Test.myMethod(int,double,<undef>.Warlock).zorf",null,2));
    clazz = (FamixClass) fModel.getElement(fFactory.createClass("<undef>.Warlock",null));
    assertEquals(clazz, param.getDeclaredClass());
    assertNotNull(param);
    assertTrue(method.getParameters().contains(param));
    assertEquals(method, param.getParent());
    assertEquals(new Integer(2), param.getParamIndex());
  }
View Full Code Here

    assertEquals(new Integer(2), param.getParamIndex());
  }
 
  @Test
  public void testUnresolvedArrayParameter(){
    FamixMethod method = (FamixMethod)fModel.getElement(fFactory.createMethod("testPackage.Test.myMethod(<undef>.Hunter[])",null));
    assertNotNull(method);
   
    FamixParameter param = (FamixParameter) fModel.getElement(fFactory.createFormalParameter("testPackage.Test.myMethod(<undef>.Hunter[]).h",null,0));
    assertNotNull(param);
    assertEquals(new Integer(0), param.getParamIndex());
    FamixClass clazz = (FamixClass)fModel.getElement(fFactory.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 testUnresolvedReturnParameter(){
    FamixClass clazz = (FamixClass) fModel.getElement(fFactory.createClass("<undef>.Dudu",null));
    assertNotNull(clazz);
    FamixMethod method = (FamixMethod)fModel.getElement(fFactory.createMethod("testPackage.Test.someMethod()",null));
    assertNotNull(method);
    assertEquals(clazz, method.getDeclaredReturnClass());
  }
View Full Code Here

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

    assertEquals(clazz, simpleAttribute.getDeclaredClass());
  }
 
  @Test
  public void testMethodLocalVariableContainsSimple() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel most contain method testPackage.Test3.gather()", simpleMethod);
    FamixLocalVariable simpleLocal = fFactory.createLocalVariable("testPackage.Test3.gather().a", null);
    simpleLocal.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 203, 204));
    simpleLocal = (FamixLocalVariable) fModel.getElement(simpleLocal);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().a", simpleLocal);
   
    assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
    boolean containsLocal = containsLocalVariable(simpleMethod, simpleLocal);
    assertTrue("FamixMethod must contain local variable simpleLocal", containsLocal);
    assertEquals("No or wrong parent method for local variable simpleLocal", simpleMethod, simpleLocal.getParent());
   
    FamixClass clazz = (FamixClass) fModel.getElement(fFactory.createClass("<undef>.EliteBoss",null));
View Full Code Here

    assertEquals("FamixClass must be equal", clazz, simpleLocal.getDeclaredClass());
  }
 
  @Test
  public void testMethodLocalVariableContainsMulti() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel must contain method testPackage.Test3.gather()", simpleMethod);
   
    FamixLocalVariable multiLocal1 = fFactory.createLocalVariable("testPackage.Test3.gather().gigs1",simpleMethod);
    multiLocal1.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 249, 254));
    multiLocal1 = (FamixLocalVariable) fModel.getElement(multiLocal1);
    FamixLocalVariable multiLocal2 = fFactory.createLocalVariable("testPackage.Test3.gather().gigs2",simpleMethod);
    multiLocal2.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 257, 262));
    multiLocal2 = (FamixLocalVariable) fModel.getElement(multiLocal2);
   
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().gigs1", multiLocal1);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().gigs2", multiLocal2);
   
    assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);
   
    FamixClass clazz = (FamixClass)fModel.getElement(fFactory.createClass("<undef>.Gigs",null));
    assertNotNull("FamixModel must contain class <undef>.Gigs", clazz);
   
    boolean containsLocal1 = containsLocalVariable(simpleMethod, multiLocal1);
View Full Code Here

    assertEquals("FamixClass must be equla", clazz, multiLocal2.getDeclaredClass());
  }
 
  @Test
  public void testMethodLocalVariableContainsWithinFor() {
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test4.iterate()",null));
    assertNotNull("FamixModel must contain method testPackage.Test4.iterate()", simpleMethod);
   
    FamixLocalVariable withinFor = fFactory.createLocalVariable("testPackage.Test4.iterate().iter",simpleMethod);
    withinFor.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test4.java", 152, 173));
    withinFor = (FamixLocalVariable) fModel.getElement(withinFor);
    assertNotNull("FamixModel must contain local variable testPackage.Test4.iterate().iter", withinFor);
   
    assertTrue("FamixMethod must contain local variable", simpleMethod.getLocalVariables().size() > 0);

    boolean containsLocal = containsLocalVariable(simpleMethod, withinFor);
    assertTrue("FamixMethod must contain local variable nrs within for loop", containsLocal);
    assertEquals("No or wrong parent method for local variable nrs within for loop", simpleMethod, withinFor.getParent());
   
View Full Code Here

   
  }
 
  @Test
  public void testArrayLocalVariable(){
    FamixMethod simpleMethod = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Test3.gather()",null));
    assertNotNull("FamixModel must contain method testPackage.Test3.gather()", simpleMethod);
    FamixLocalVariable lVar = fFactory.createLocalVariable("testPackage.Test3.gather().items", simpleMethod);
    lVar.setSourceAnchor(new SourceAnchor("/TestProject/src/testPackage/Test3.java", 216, 235));
    lVar = (FamixLocalVariable)fModel.getElement(lVar);
    assertNotNull("FamixModel must contain local variable testPackage.Test3.gather().items", lVar);
View Full Code Here

    assertEquals("FamixClass must be equal", declClass, lVar.getDeclaredClass());
  }
 
  @Test
  public void testNestedCalls() {
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.NestedCalls.sum()",null));
    FamixMethod callee = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.NestedCalls.add10(int)",null));

    assertNotNull("FamixModel must contain the method testPackage.NestedCalls.sum()", caller);
    assertNotNull("FamixModel must contain the method testPackage.NestedCalls.add10(int)", callee);
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int containsInvocationTo = TestHelper.containsRelationTo(callee, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + callee.getUniqueName(), 4, containsInvocationTo);
  }
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.