/** Tests {@link SecurityManager#canPostActivity(PortalContainer, Identity, Identity)}. */
  public void testCanPostActivity() {
    boolean demoPostToDemo =
        SecurityManager.canPostActivity(getContainer(), demoIdentity, demoIdentity);
    assertTrue("demoPostToDemo must be true", demoPostToDemo);
    boolean demoPostToJohn =
        SecurityManager.canPostActivity(getContainer(), demoIdentity, johnIdentity);
    assertFalse("demoPostToJohn must be false", demoPostToJohn);
    // demo is connected to mary => they can post activity to each other's activity stream
    relationshipManager.inviteToConnect(demoIdentity, maryIdentity);
    boolean demoPostToMary =
        SecurityManager.canPostActivity(getContainer(), demoIdentity, maryIdentity);
    boolean maryPostToDemo =
        SecurityManager.canPostActivity(getContainer(), maryIdentity, demoIdentity);
    assertFalse("demoPostToMary must be false", demoPostToMary);
    assertFalse("maryPostToDemo must be false", maryPostToDemo);
    relationshipManager.confirm(maryIdentity, demoIdentity);
    tearDownRelationshipList.add(relationshipManager.get(demoIdentity, maryIdentity));
    demoPostToMary = SecurityManager.canPostActivity(getContainer(), demoIdentity, maryIdentity);
    maryPostToDemo = SecurityManager.canPostActivity(getContainer(), maryIdentity, demoIdentity);
    assertTrue("demoPostToMary must be true", demoPostToMary);
    assertTrue("maryPostToDemo must be true", maryPostToDemo);
    // checks user posts to space
    createSpaces(1);
    Space createdSpace = tearDownSpaceList.get(0);
    Identity spaceIdentity =
        identityManager.getOrCreateIdentity(
            SpaceIdentityProvider.NAME, createdSpace.getPrettyName(), false);
    assertNotNull("spaceIdentity must not be null", spaceIdentity);

    // demo, mary could post activity to this space's activity stream

    boolean demoPostToSpace =
        SecurityManager.canPostActivity(getContainer(), demoIdentity, spaceIdentity);
    assertTrue("demoPostToSpace must be true", demoPostToSpace);
    boolean maryPostToSpace =
        SecurityManager.canPostActivity(getContainer(), maryIdentity, spaceIdentity);
    assertTrue("maryPostToSpace must be false", maryPostToSpace);

    // john could not
    boolean johnPostToSpace =
        SecurityManager.canPostActivity(getContainer(), johnIdentity, spaceIdentity);
    assertFalse("johnPostToSpace must be false", johnPostToSpace);
  }