private void doTestDeleteCheckByUserGroup() {
    // UserGroup must be deleted
    UserGroup ug = mgr.find(UserGroup.class, userGroup.getKey());
    Assert.assertNull("UserGroup still available", ug);

    // UserGroupToInvisibleProduct must be deleted
    UserGroupToInvisibleProduct userGroupToInvisibleProduct =
        mgr.find(UserGroupToInvisibleProduct.class, oldUserGroupToInvisibleProduct.getKey());
    Assert.assertNull("UserGroupToInvisibleProduct still available", userGroupToInvisibleProduct);
  }
  private void doTestAdd() throws Exception {
    userGroup = mgr.find(UserGroup.class, userGroup.getKey());
    p = mgr.find(Product.class, p.getKey());

    UserGroupToInvisibleProduct uip = new UserGroupToInvisibleProduct();
    uip.setUserGroup(userGroup);
    uip.setProduct(p);

    mgr.persist(uip);
  }
  private void doTestDeleteByUserGroup() {
    userGroup = mgr.find(UserGroup.class, userGroup.getKey());
    assertNotNull("UserGroup expected", userGroup);

    List<UserGroupToInvisibleProduct> list = userGroup.getUserGroupToInvisibleProducts();
    assertNotNull(list);
    Assert.assertEquals(1, list.size());

    oldUserGroupToInvisibleProduct =
        mgr.find(UserGroupToInvisibleProduct.class, list.get(0).getKey());
    assertNotNull(oldUserGroupToInvisibleProduct);

    mgr.remove(userGroup);
  }