Package org.evolizer.famix.model.entities

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


    @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 testSourceAnchorFormalParameter() throws Exception {
        FamixParameter simpleParam = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Variables.m(int,int[]).param", null, 0));
        FamixParameter arrayParam = (FamixParameter) aModel.getElement(aFactory.createFormalParameter("testPackage.Variables.m(int,int[]).arrayParam", null, 1));

        SourceAnchor anchor = simpleParam.getSourceAnchor();
        assertNotNull("Source anchor file of parameter " + simpleParam.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of parameter " + simpleParam.getUniqueName() + " must be", "/TestProject1/src/testPackage/Variables.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 simpleParamDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertEquals("Declaration of parameter must be 'param'", "int param", simpleParamDecl);
        assertEquals("Declaration in source file must equal the source attribute ", simpleParamDecl, simpleParam.getSource());

        anchor = arrayParam.getSourceAnchor();
        assertNotNull("Source anchor file of parameter " + arrayParam.getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of parameter " + arrayParam.getUniqueName() + " must be", "/TestProject1/src/testPackage/Variables.java", anchor.getFile());
        assertTrue("The start must be before the end position", anchor.getStartPos() <= anchor.getEndPos());
        String arrayParamDecl = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertEquals("Declaration of parameter must be 'arrayParam'", "int[] arrayParam", arrayParamDecl);
        assertEquals("Declaration in source file must equal the source attribute ", arrayParamDecl, arrayParam.getSource());
    }
View Full Code Here

                break;
            }
        }
        assertNotNull("The class Sum must contain 1 inheritance associtaino to class Base", inheritance);

        SourceAnchor anchor = inheritance.getSourceAnchor();
        assertNotNull("Source anchor file of invocation " + inheritance.getFrom().getUniqueName() + " - " + inheritance.getTo().getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of invocation " + inheritance.getFrom().getUniqueName() + " - " + inheritance.getTo().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 extendsStatement = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertEquals("FamixInheritance of "  + inheritance.getFrom().getUniqueName() + " - " + inheritance.getTo().getUniqueName() + " must be 'Base'", "Base", extendsStatement);
    }
View Full Code Here

        Hashtable<String,String> invocationStrings = new Hashtable<String,String>();
        invocationStrings.put("s.compute()", "s.compute()");
        invocationStrings.put("((Sum) o).compute()", "((Sum) o).compute()");

        for (int i = 0; i < invocations.size(); i++) {
            SourceAnchor anchor = invocations.get(i).getSourceAnchor();
            assertNotNull("Source anchor file of invocation " + invocations.get(i).getFrom().getUniqueName() + " - " + invocations.get(i).getTo().getUniqueName() + " must not be null", anchor);
            assertEquals("Source anchor file of invocation " + invocations.get(i).getFrom().getUniqueName() + " - " + invocations.get(i).getTo().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 invokeStatement = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
            assertNotNull("FamixInvocation of "  + invocations.get(i).getFrom().getUniqueName() + " - " + invocations.get(i).getTo().getUniqueName() + " is not '" + invokeStatement + "'", invocationStrings.get(invokeStatement));
        }
    }
View Full Code Here

                accesses.add(ass);
            }
        }
        assertEquals("The method <oinit>() must contain 1 access to the attribute containerSum", 1, accesses.size());

        SourceAnchor anchor = accesses.get(0).getSourceAnchor();
        assertNotNull("Source anchor file of access " + accesses.get(0).getFrom().getUniqueName() + " - " + accesses.get(0).getTo().getUniqueName() + " must not be null", anchor);
        assertEquals("Source anchor file of access " + accesses.get(0).getFrom().getUniqueName() + " - " + accesses.get(0).getTo().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 accessStatement = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
        assertEquals("FamixAccess of "  + accesses.get(0).getFrom().getUniqueName() + " - " + accesses.get(0).getTo().getUniqueName() + " must equal 'containerSum = new Vector<Sum>()'", "containerSum = new Vector<Sum>()", accessStatement);
    }
View Full Code Here

        assertEquals("The method foo() must contain 2 access to the attribute a", 2, accesses.size());

        Hashtable<String,String> accessStrings = new Hashtable<String,String>();
        accessStrings.put("this.a", "this.a");
        for (int i = 0; i < accesses.size(); i++) {
            SourceAnchor anchor = accesses.get(i).getSourceAnchor();
            assertNotNull("Source anchor file of access " + accesses.get(i).getFrom().getUniqueName() + " - " + accesses.get(i).getTo().getUniqueName() + " must not be null", anchor);
            assertEquals("Source anchor file of access " + accesses.get(i).getFrom().getUniqueName() + " - " + accesses.get(i).getTo().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 accessStatement = fileContent.substring(anchor.getStartPos(), anchor.getEndPos());
            //            System.out.println("St: " + accessStatement + " Anchor: " + anchor);
            assertNotNull("FamixAccess of "  + accesses.get(i).getFrom().getUniqueName() + " - " + accesses.get(i).getTo().getUniqueName() + " is not '" + accessStatement + "'", accessStrings.containsKey(accessStatement));
        }
    }
View Full Code Here

TOP

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

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.