}
/** BGContextManagerImpl:copyBGContext() * */
public void testCopyBGContext() {
BGContextManager bgcm = BGContextManagerImpl.getInstance();
BGContext c1 = bgcm.createAndPersistBGContext("c1name", "c1desc", BusinessGroup.TYPE_LEARNINGROUP, null, true);
BGContext c2 = bgcm.createAndPersistBGContext("c2name", "c2desc", BusinessGroup.TYPE_RIGHTGROUP, id1, false);
DBFactory.getInstance().closeSession(); // simulate user clicks
BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
BusinessGroup g1 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g1", null, new Integer(0),
new Integer(10), false, false, c1);
BusinessGroup g2 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_LEARNINGROUP, null, "g2", null, new Integer(0),
new Integer(10), false, false, c1);
BusinessGroup g3 = bgm.createAndPersistBusinessGroup(BusinessGroup.TYPE_RIGHTGROUP, null, "g3", null, new Integer(0),
new Integer(10), false, false, c2);
DBFactory.getInstance().closeSession(); // simulate user clicks
Manager secm = ManagerFactory.getManager();
secm.addIdentityToSecurityGroup(id1, g1.getPartipiciantGroup());
secm.addIdentityToSecurityGroup(id1, g1.getOwnerGroup());
secm.addIdentityToSecurityGroup(id2, g1.getPartipiciantGroup());
secm.addIdentityToSecurityGroup(id3, g1.getOwnerGroup());
secm.addIdentityToSecurityGroup(id1, g3.getPartipiciantGroup());
secm.addIdentityToSecurityGroup(id2, g3.getPartipiciantGroup());
DBFactory.getInstance().closeSession(); // simulate user clicks
BGRightManagerImpl rm = BGRightManagerImpl.getInstance();
rm.addBGRight(CourseRights.RIGHT_ARCHIVING, g3);
rm.addBGRight(CourseRights.RIGHT_COURSEEDITOR, g3);
DBFactory.getInstance().closeSession(); // simulate user clicks
BGAreaManager am = BGAreaManagerImpl.getInstance();
BGArea a1 = am.createAndPersistBGAreaIfNotExists("a1-copy", "desca1", c1);
BGArea a2 = am.createAndPersistBGAreaIfNotExists("a2-copy", null, c1);
am.addBGToBGArea(g1, a1);
am.addBGToBGArea(g2, a1);
am.addBGToBGArea(g1, a2);
DBFactory.getInstance().closeSession(); // simulate user clicks
BGContext c1copy = bgcm.copyAndAddBGContextToResource(c1.getName(), course1, c1);
DBFactory.getInstance().closeSession(); // simulate user clicks
try {
bgcm.copyAndAddBGContextToResource(c2.getName(), course1, c2);
fail("expecting exeption");
} catch (AssertException e) {