Package org.evolizer.famix.model.entities

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


        assertEquals(constructor.getParent(), clazz);
    }

    @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);
View Full Code Here


    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);
    assertTrue("FamixMethod must contain local variable multiLocal1", containsLocal1);
    assertEquals("No or wrong parent method for local variable multiLocal1", simpleMethod, multiLocal1.getParent());
View Full Code Here

    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());
   
    FamixClass clazz = (FamixClass) fModel.getElement(fFactory.createClass("<undef>.Iterator",null));
    assertNotNull("FamixModel must contain class <undef>.Iterator", clazz);
   
    assertEquals("FamixClass must be equal", clazz, withinFor.getDeclaredClass());
   
  }
View Full Code Here

    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);
    FamixClass declClass = (FamixClass) fModel.getElement(fFactory.createClass(AbstractFamixEntity.ARRAY_TYPE_NAME, null));
    assertNotNull("FamixModel must contain class " + AbstractFamixEntity.ARRAY_TYPE_NAME, declClass);
   
    assertEquals("FamixClass must be equal", declClass, lVar.getDeclaredClass());
  }
View Full Code Here

        assertTrue("Missing invocation relationship from " + initializerTest.getUniqueName() + " to " + initializer.getUniqueName(), containsInvocationTo > 0);
    }

    @Test
    public void testSourceAnchorClass() throws Exception {
        FamixClass classSum = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.Sum", null));
       
        SourceAnchor anchor = classSum.getSourceAnchor();
        assertNotNull("Source anchor file of class " + classSum.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of class " + classSum.getUniqueName() + " must be", "/TestProject1/src/testPackage/Sum.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 classSumDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertTrue("Declaration of class must start with 'public class Sum'", classSumDecl.startsWith("public class Sum"));
        assertEquals("Declaration in source file must equal the source attribute ", classSumDecl, classSum.getSource());
    }
View Full Code Here

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

    @Test
    public void testSourceAnchorInnerClass() throws Exception {
        FamixClass classHelperClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.InnerAnonym$HelperClass", null));
       
        SourceAnchor anchor = classHelperClass.getSourceAnchor();
        assertNotNull("Source anchor file of class " + classHelperClass.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of class " + classHelperClass.getUniqueName() + " must be", "/TestProject1/src/testPackage/InnerAnonym.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 classSumDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertTrue("Declaration of class must start with 'public class HelperClass'", classSumDecl.startsWith("public class HelperClass"));
        assertEquals("Declaration in source file must equal the source attribute ", classSumDecl, classHelperClass.getSource());
    }
View Full Code Here

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

    @Test
    public void testSourceAnchorAnonymousClass() throws Exception {
        FamixClass anonymClass = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.ae.Test$1", null));

        SourceAnchor anchor = anonymClass.getSourceAnchor();
        assertNotNull("Source anchor file of anonymous class " + anonymClass.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of anonymous class " + anonymClass.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 classDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertTrue("Declaration of anonymous class must start with '{\n\t\tprivate int anonymAttribute = 0'", classDecl.startsWith("{\n\t\tprivate int anonymAttribute = 0"));
        assertEquals("Declaration in source file must equal the source attribute ", classDecl, anonymClass.getSource());
    }
View Full Code Here

    }

    @Test
    public void testSourceAnchorClassInheritance() throws Exception {
        //        FamixClass interfaceBase = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.IBase", null));
        FamixClass classBase = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.Base", null));
        FamixClass classSum = (FamixClass) aModel.getElement(aFactory.createClass("testPackage.Sum", null));

        FamixAssociation inheritance = null;
        for (FamixAssociation ass : aModel.getAssociations(classSum)) {
            if (ass instanceof FamixInheritance && ass.getTo().equals(classBase)) {
                inheritance = ass;
View Full Code Here

    assertEquals("FamixInvocation relationships from " + caller.getUniqueName() + " to " + calleeClassUnknownParamUnkown.getUniqueName(), 1, nrContainsInvocation);
  }
 
  @Test
  public void testUndefClassInstanceCreationParents() {
    FamixClass classDummy = (FamixClass) fModel.getElement(fFactory.createClass("testPackage.Dummy", null));
    FamixClass classNotDef = (FamixClass) fModel.getElement(fFactory.createClass("<undef>.NotDef", null));
   
    FamixMethod calleeClassKnownParamUnkown = (FamixMethod) fModel.getElement(fFactory.createMethod("testPackage.Dummy.<init>(<undef>.NotDef)", null));
    FamixMethod calleeClassUnknown = (FamixMethod) fModel.getElement(fFactory.createMethod("<undef>.NotDef.<init>()", null));
    FamixMethod calleeClassUnknownParamUnkown = (FamixMethod) fModel.getElement(fFactory.createMethod("<undef>.NotDef.<init>(<undef>.NotDef)", null));
   
View Full Code Here

//    assertTrue("FamixClass " + classNotDef.getUniqueName() + " must contain method " + calleeClassUnknownParamUnkown.getUniqueName(), classDummy.getMethods().contains(calleeClassUnknownParamUnkown));
  }
 
  @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

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.