@Test
  public void removePolicyWithInvitation() {
    // create a map
    final PortfolioStructureMap map =
        epFrontendManager.createAndPersistPortfolioDefaultMap(
            ident1, "Remove policies", "Description");
    final PortfolioStructure page1 =
        epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();

    // save a list of policies
    final List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();
    // invitation
    final Invitation invitation = securityManager.createAndPersistInvitation();
    invitation.setFirstName("John");
    invitation.setLastName("Doe");
    invitation.setMail("*****@*****.**");
    final EPMapPolicy invitationPolicy = new EPMapPolicy();
    invitationPolicy.setType(Type.invitation);
    invitationPolicy.setInvitation(invitation);
    policies.add(invitationPolicy);
    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();

    // remove the policy
    policies.clear();
    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();

    // check if the policies and the invitation are deleted
    final List<EPMapPolicy> deletedPolicies = epFrontendManager.getMapPolicies(map);
    assertNotNull(deletedPolicies);
    assertTrue(deletedPolicies.isEmpty());
  }
  @Test
  public void allMapPolicies() {
    // create a map
    final PortfolioStructureMap map =
        epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "Policies", "Description");
    final PortfolioStructure page1 =
        epFrontendManager.createAndPersistPortfolioPage(map, "Page policies", "Page description");
    assertNotNull(page1);
    dbInstance.commitAndCloseSession();

    // save a list of policies
    final List<EPMapPolicy> policies = new ArrayList<EPMapPolicy>();

    // user policy
    final EPMapPolicy userPolicy = new EPMapPolicy();
    userPolicy.setType(Type.user);
    userPolicy.getIdentities().add(ident2);
    userPolicy.getIdentities().add(ident3);
    policies.add(userPolicy);

    // invitation
    final Invitation invitation = securityManager.createAndPersistInvitation();
    invitation.setFirstName("John");
    invitation.setLastName("Doe");
    invitation.setMail("*****@*****.**");
    final EPMapPolicy invitationPolicy = new EPMapPolicy();
    invitationPolicy.setType(Type.invitation);
    invitationPolicy.setInvitation(invitation);
    policies.add(invitationPolicy);

    epFrontendManager.updateMapPolicies(map, policies);
    dbInstance.commitAndCloseSession();

    // check visiblity (is owner)
    assertTrue(epFrontendManager.isMapVisible(ident1, map.getOlatResource()));
    // check visibility (is in policy)
    assertTrue(epFrontendManager.isMapVisible(ident2, map.getOlatResource()));
    // check visible (is in policy)
    assertTrue(epFrontendManager.isMapVisible(ident3, map.getOlatResource()));

    // retrieved policies
    final List<EPMapPolicy> savedPolicies = epFrontendManager.getMapPolicies(map);
    assertTrue(!savedPolicies.isEmpty());
  }