Package org.evolizer.famix.model.entities

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


 
  @Test
  public void testUndefAnonymClassInstanceCreation() {
    FamixClass unresolvedCalls = (FamixClass) fModel.getElement(fFactory.createClass("testPackage.UnresolvedCalls", null));
    FamixClass undefAnonymClass = (FamixClass) fModel.getElement(fFactory.createClass("testPackage.UnresolvedCalls$1F", null));
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.unresolvedAnonymClass()", null));
    FamixMethod oinitAnonym = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls$1F.<oinit>()", null));
    FamixMethod initAnonym = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls$1F.<init>(int,java.lang.String)", null));
    FamixMethod inUndefAnonym = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls$1F.inUndefAnonym(<undef>.String,<undef>.NotDef2)", null));
    FamixMethod inUndefAnonym2 = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls$1F.inUndefAnonym(<undef>.String)", null));
    FamixAttribute fieldInAnonym = (FamixAttribute) fModel.getElement(fFactory.createAttribute("testPackage.UnresolvedCalls$1F.fieldInAnonym", null));

    assertNotNull("FamixClass testPackage.UnresolvedCalls must exist", unresolvedCalls);
    assertNotNull("Anonym class testPackage.UnresolvedCalls$1 must exist", undefAnonymClass);
    assertNotNull("FamixMethod testPackage.UnresolvedCalls.unresolvedAnonymClass() must exist", caller);
    assertNotNull("Initializer testPackage.UnresolvedCalls$1F.<oinit>() must exist", oinitAnonym);
    assertNotNull("Constructor testPackage.UnresolvedCalls$1.<init>() must exist", initAnonym);
    assertNotNull("FamixMethod testPackage.UnresolvedCalls$1F.inUndefAnonym(<undef>.String,<undef>.NotDef2) must exist", inUndefAnonym);
    assertNotNull("FamixMethod testPackage.UnresolvedCalls$1F.inUndefAnonym(java.lang.String) must exist", inUndefAnonym2);
    assertNotNull("FamixAttribute testPackage.UnresolvedCalls$1F.fieldInAnonym must exist", fieldInAnonym);
   
    assertTrue("FamixMethod " + caller.getUniqueName() + " must contain anonym class " + undefAnonymClass.getUniqueName(), caller.getAnonymClasses().contains(undefAnonymClass));
    assertTrue("Anonym class " + undefAnonymClass.getUniqueName() + " must contain initializer " + oinitAnonym.getUniqueName(), undefAnonymClass.getMethods().contains(oinitAnonym));
    assertTrue("Anonym class " + undefAnonymClass.getUniqueName() + " must contain initializer " + initAnonym.getUniqueName(), undefAnonymClass.getMethods().contains(initAnonym));
    assertTrue("Anonym class " + undefAnonymClass.getUniqueName() + " must contain method " + inUndefAnonym.getUniqueName(), undefAnonymClass.getMethods().contains(inUndefAnonym));
    assertTrue("Anonym class " + undefAnonymClass.getUniqueName() + " must contain method " + inUndefAnonym2.getUniqueName(), undefAnonymClass.getMethods().contains(inUndefAnonym2));
    assertTrue("Anonym class " + undefAnonymClass.getUniqueName() + " must contain attribute " + fieldInAnonym.getUniqueName(), undefAnonymClass.getAttributes().contains(fieldInAnonym));
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int nrContainsInvocation = TestHelper.containsRelationTo(initAnonym, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + initAnonym.getUniqueName(), 1, nrContainsInvocation);
View Full Code Here


    }


    @Test
    public void testAnonymousClassConstructorWithArguments(){
        FamixMethod constructor = (FamixMethod)aModel.getElement(aFactory.createMethod("testPackage.ae.Test$Inner$InnerInner.<init>(int)",null));
        assertNotNull(constructor);
        FamixClass clazz = (FamixClass)aModel.getElement(aFactory.createClass("testPackage.ae.Test$Inner$InnerInner", null));
        assertNotNull(clazz);

        assertEquals(constructor.getParent(), clazz);
    }
View Full Code Here

    assertEquals("FamixAccess relationships from " + oinitAnonym.getUniqueName() + " to " + fieldInAnonym.getUniqueName(), 1, nrContainsAccess);
  }
 
  @Test
  public void testUnresolvedThisCall() {
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.<init>()", null));
    FamixMethod thisCallee  = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.<init>(int,<undef>.NotDef2)", null));
   
    assertNotNull("Caller method testPackage.UnresolvedCalls.<init>() must exist", caller);
    assertNotNull("Callee method testPackage.UnresolvedCalls.<init>(<undef>.NotDef2) must exist", thisCallee);
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int nrContainsInvocation = TestHelper.containsRelationTo(thisCallee, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + thisCallee.getUniqueName(), 1, nrContainsInvocation);
  }
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);
        assertNotNull( anonymAttribute);
        assertNotNull(anonymObjectInitializer);


        assertTrue("Anonymous class must contain initializer " + initializer.getUniqueName(), anonymClass.getMethods().contains(initializer));
        assertEquals("No or wrong parent class for initializer " + initializer.getUniqueName(),
                anonymClass, initializer.getParent());

        assertTrue(anonymClass.getMethods().contains(anonymObjectInitializer));
        assertEquals(anonymClass, anonymObjectInitializer.getParent());

        Set<FamixAssociation> lRelations = aModel.getAssociations(initializerTest);
        assertTrue("FamixMethod " + initializerTest.getUniqueName() + " must contain relationships", lRelations.size() > 0);
        int containsInvocationTo = TestHelper.containsRelationTo(initializer, lRelations);
        assertTrue("Missing invocation relationship from " + initializerTest.getUniqueName() + " to " + initializer.getUniqueName(), containsInvocationTo > 0);
View Full Code Here

    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + thisCallee.getUniqueName(), 1, nrContainsInvocation);
  }
 
  @Test
  public void testUnresolvedCallSequence() {
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.unresolvedCallSequence()", null));
    FamixMethod seq1callee1  = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Dummy.createDummy()", null));
//    FamixMethod seq1callee2  = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Dummy.foo(<undef>,java.lang.String)", null));
   
    assertNotNull("Caller method testPackage.UnresolvedCalls.unresolvedCallSequence() must exist", caller);
    assertNotNull("Callee method testPackage.Dummy.createDummy() must exist", seq1callee1);
//    assertNotNull("Callee method testPackage.Dummy.foo(<undef>,java.lang.String) must exist", seq1callee2);
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int nrContainsInvocation = TestHelper.containsRelationTo(seq1callee1, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + seq1callee1.getUniqueName(), 1, nrContainsInvocation);
//    nrContainsInvocation = TestHelper.containsRelationTo(seq1callee2, lRelations);
//    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + seq1callee2.getUniqueName(), 1, nrContainsInvocation);
  }
View Full Code Here

//    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + seq1callee2.getUniqueName(), 1, nrContainsInvocation);
  }
 
  @Test
  public void testFindCallInBaseClass() {
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.findCallInBaseClass()", null));
    FamixMethod callee  = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Dummy.foo(<undef>.NotDef,int)", null));
   
    Assert.assertNotNull("Caller method testPackage.UnresolvedCalls.findCallInBaseClass() must exist", caller);
    Assert.assertNotNull("Callee method testPackage.Dummy.foo(<undef>.NotDef,int) must exist", callee);

    Assert.assertNotNull("There must be unresolved calls for method testPackage.UnresolvedCalls.undefCallWithinClass()", fUnresolvedInvocationHandler.getUnresolvedCalls().get(caller));
   
    List<UnresolvedMethodInvocation> unresolvedCalls = fUnresolvedInvocationHandler.getUnresolvedCalls().get(caller);
    Assert.assertTrue("FamixMethod " + caller.getUniqueName() + " must contain unresolved calls ", unresolvedCalls.size() > 0);
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int nrContainsInvocation = TestHelper.containsRelationTo(callee, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + callee.getUniqueName(), 1, nrContainsInvocation);
  }
View Full Code Here

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

    @Test
    public void testSourceAnchorMethod() throws Exception {
        FamixMethod returnRef = (FamixMethod) aModel.getElement(aFactory.createMethod("testPackage.ae.Test.getRefSum()", null));

        SourceAnchor anchor = returnRef.getSourceAnchor();
        assertNotNull("Source anchor file of method " + returnRef.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of method " + returnRef.getUniqueName() + " must be", "/TestProject1/src/testPackage/ae/Test.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());
        assertTrue("Declaration of method must start with 'public Sum getRefSum()'", returnRefDecl.startsWith("public Sum getRefSum()"));
        assertEquals("Declaration in source file must equal the source attribute ", returnRefDecl, returnRef.getSource());
    }
View Full Code Here

    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + callee.getUniqueName(), 1, nrContainsInvocation);
  }

  @Test
  public void testSubtypingHandleMultipleMatches() {
    FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.handleMultipleMatches()", null));
    FamixMethod callee  = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.DummySub.foo(<undef>.NotDef)", null));
   
    Assert.assertNotNull("Caller method testPackage.UnresolvedCalls.handleMultipleMatches() must exist", caller);
    Assert.assertNotNull("Callee method testPackage.DummySub.foo(<undef>.NotDef) must exist", callee);

    Assert.assertNotNull("There must be unresolved calls for method testPackage.UnresolvedCalls.handleMultipleMatches()", fUnresolvedInvocationHandler.getUnresolvedCalls().get(caller));
   
    // determine the unresolved method call
    List<UnresolvedMethodInvocation> unresolvedCalls = fUnresolvedInvocationHandler.getUnresolvedCalls().get(caller);
    UnresolvedMethodInvocation selectedCall = null;
    for (UnresolvedMethodInvocation unresolved : unresolvedCalls) {
      if (unresolved.getStatement().equals("ds.foo(nd)")) {
        selectedCall = unresolved;
      }
    }
    Assert.assertEquals("Caller of statement ds.foo(nd) not equal ", caller, selectedCall.getCaller());
    Assert.assertNotNull("There must be an unresolved call for the statement ds.foo(nd)", selectedCall);
    Assert.assertEquals("Wrong number of matched callees for unresolved call ds.foo(nd)", 2, selectedCall.getMatchesByAllParametersType().size());
   
    Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
    int nrContainsInvocation = TestHelper.containsRelationTo(callee, lRelations);
    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + callee.getUniqueName(), 1, nrContainsInvocation);
  }
View Full Code Here

  }
 

    @Test
    public void testCallToConstructorWithUndefTemplateParameter() {
        FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.callWithTemplateParameter()",null));
        FamixMethod constructor = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedTypeParameters<T>.<init>()",null));
       
        assertNotNull("FamixModel must contain the method testPackage.UnresolvedCalls.callWithTemplateParameter()", caller);
        assertNotNull("FamixModel must contain the method testPackage.UnresolvedTypeParameters<T>.<init>()", constructor);

        Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
        int containsInvocationTo = TestHelper.containsRelationTo(constructor, lRelations);
        assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + constructor.getUniqueName(), 1, containsInvocationTo);
    }
View Full Code Here

        assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + constructor.getUniqueName(), 1, containsInvocationTo);
    }
   
    @Test
    public void testCallToMethodWithUndefTemplateParameter() {
        FamixMethod caller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedCalls.callWithTemplateParameter()",null));
        FamixMethod callee = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedTypeParameters<T>.someMethod(testPackage.UnresolvedTypeParameters$T,<undef>.NotDef2)",null));
        FamixMethod alternateCaller = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.UnresolvedTypeParameters<T>.someMethod(java.lang.String,<undef>.NotDef2)",null));
       
        assertNotNull("FamixModel must contain the method testPackage.UnresolvedCalls.callWithTemplateParameter()", caller);
        assertNotNull("FamixModel must contain the method testPackage.UnresolvedTypeParameters<T>.someMethod(testPackage.UnresolvedTypeParameters$T,<undef>.NotDef2)", callee);
        assertNotNull("FamixModel must contain the method testPackage.UnresolvedTypeParameters<T>.someMethod(java.lang.String,<undef>.NotDef2)", alternateCaller);

        Set<FamixAssociation> lRelations = fModel.getAssociations(caller);
        int containsInvocationTo = TestHelper.containsRelationTo(alternateCaller, lRelations);
        assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + alternateCaller.getUniqueName(), 1, 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.