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