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;
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);
}