anonyClasses.add(anonymClass2);
method.setAnonymClasses(anonyClasses);
anonymClass1.setParent(method);
anonymClass2.setParent(method);
FamixParameter fPar1 = new FamixParameter("parameter1");
FamixParameter fPar2 = new FamixParameter("parameter2");
List<FamixParameter> fPars = new ArrayList<FamixParameter>();
fPars.add(fPar1);
fPars.add(fPar2);
method.setParameters(fPars);
fPar1.setParent(method);
fPar2.setParent(method);
fEvolizerSession.startTransaction();
fEvolizerSession.saveObject(lVar1);
fEvolizerSession.saveObject(lVar2);
fEvolizerSession.saveObject(anonymClass1);
fEvolizerSession.saveObject(anonymClass2);
fEvolizerSession.saveObject(declaredReturnedClass);
fEvolizerSession.saveObject(fPar1);
fEvolizerSession.saveObject(fPar2);
fEvolizerSession.saveObject(method);
fEvolizerSession.endTransaction();
fEvolizerSession.close();
fEvolizerSession = fSessionHandler.getCurrentSession(fDBUrl);
List<FamixMethod> result = fEvolizerSession.query("from FamixMethod", FamixMethod.class);
assertEquals(1, result.size());
FamixMethod returnedFamixMethod = result.get(0);
assertEquals("foo", returnedFamixMethod.getUniqueName());
Set<FamixLocalVariable> returnedLVars = returnedFamixMethod.getLocalVariables();
assertEquals(2, returnedLVars.size());
for(Iterator<FamixLocalVariable> iter = returnedLVars.iterator();iter.hasNext();){
FamixLocalVariable var = iter.next();
assertTrue((var.getUniqueName().equals("counter") || var.getUniqueName().equals("metricValue")));
assertEquals("foo", var.getParent().getUniqueName());
assertTrue(returnedFamixMethod==var.getParent());
}
List<FamixParameter> returnedFormalPars = returnedFamixMethod.getParameters();
assertEquals(2, returnedFormalPars.size());
for(Iterator<FamixParameter> iter = returnedFamixMethod.getParameters().iterator();iter.hasNext();){
FamixParameter par = iter.next();
assertTrue((par.getUniqueName().equals("parameter1") || par.getUniqueName().equals("parameter2")));
assertEquals("foo", par.getParent().getUniqueName());
assertTrue(returnedFamixMethod==par.getParent());
}
Set<FamixClass> returnedAnonyClass = returnedFamixMethod.getAnonymClasses();
assertEquals(2, returnedAnonyClass.size());
for(Iterator<FamixClass> iter = returnedFamixMethod.getAnonymClasses().iterator();iter.hasNext();){