PlanetSubscriptionData sub1 = new PlanetSubscriptionData();
sub1.setFeedURL("test_url1");
planet.saveSubscription(sub1);
PlanetGroupData group = new PlanetGroupData();
group.setDescription("test_group_desc");
group.setHandle("test_handle");
group.setTitle("test_title");
planet.saveGroup(group);
TestUtils.endSession(true);
}
{ // retrieve subscriptions and add to group
PlanetSubscriptionData sub = planet.getSubscription("test_url");
PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
PlanetGroupData group = planet.getGroup("test_handle");
group.getSubscriptions().add(sub);
sub.getGroups().add(group);
group.getSubscriptions().add(sub1);
sub1.getGroups().add(group);
planet.saveSubscription(sub);
planet.saveSubscription(sub1);
planet.saveGroup(group);
TestUtils.endSession(true);
}
{ // get group and remove one subscription
PlanetSubscriptionData sub = planet.getSubscription("test_url");
PlanetGroupData group = planet.getGroup("test_handle");
group.getSubscriptions().remove(sub);
TestUtils.endSession(true);
}
{ // get group and check it's subscriptions, remove it
PlanetGroupData group = planet.getGroup("test_handle");
Set subs = group.getSubscriptions();
assertEquals(1, subs.size());
planet.deleteGroup(group);
TestUtils.endSession(true);
}
{ // make sure group gone, subs still there, then remove them too
PlanetGroupData group = planet.getGroup("test_handle");
assertNull(group);
PlanetSubscriptionData sub = planet.getSubscription("test_url");
assertNotNull(sub);
PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
assertNotNull(sub1);