assertTrue ("t2 holds two source refs (to s2 and s3)", t2refs.size() == 2);
}
public void testAddAndDeleteReference() {
OLATResource oressource = OLATResourceManager.getInstance().findOrPersistResourceable(OresHelper.createOLATResourceableInstance("type1", new Long(123)));
OLATResource orestarget = OLATResourceManager.getInstance().findOrPersistResourceable(OresHelper.createOLATResourceableInstance("type2targ", new Long(456)));
String udata = "üserdätä";
// add a reference
ReferenceManager.getInstance().addReference(oressource, orestarget, udata);
DBFactory.getInstance().closeSession();
OLATResource orestarget2 = OLATResourceManager.getInstance().findOrPersistResourceable(OresHelper.createOLATResourceableInstance("type2targ", new Long(456)));
List refs = ReferenceManager.getInstance().getReferencesTo(orestarget2);
assertTrue("only one reference may exist", refs.size() == 1);
for (Iterator it_refs = refs.iterator(); it_refs.hasNext();) {
ReferenceImpl ref = (ReferenceImpl) it_refs.next();
ReferenceManager.getInstance().delete(ref);
}
DBFactory.getInstance().closeSession();
// now make sure the reference was deleted
OLATResource orestarget3 = OLATResourceManager.getInstance().findOrPersistResourceable(OresHelper.createOLATResourceableInstance("type2targ", new Long(456)));
List norefs = ReferenceManager.getInstance().getReferencesTo(orestarget3);
assertTrue("reference should now be deleted", norefs.size() == 0);
}