BGContext c1 = cm.createAndAddBGContextToResource("c1name", course1, BusinessGroup.TYPE_LEARNINGROUP, null, true);
cm.createAndAddBGContextToResource("c2name", course1, BusinessGroup.TYPE_LEARNINGROUP, id1, false);
cm.createAndAddBGContextToResource("c3name", course1, BusinessGroup.TYPE_RIGHTGROUP, id2, false);
DBFactory.getInstance().closeSession(); // simulate user clicks
assertTrue(cm.findBGContextsForResource(course1, true, true).size() == 3);
assertTrue(cm.findBGContextsForResource(course1, true, false).size() == 1);
assertTrue(cm.findBGContextsForResource(course1, false, true).size() == 2);
assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_LEARNINGROUP, true, true).size() == 2);
assertTrue(cm.findBGContextsForResource(course1, BusinessGroup.TYPE_RIGHTGROUP, true, true).size() == 1);