protected void setUpTest() {
    dashboardCopy =
        new SharedEntityInfo(
            "Dashboard for " + ADMIN_FULLNAME,
            "Copy of 'System Dashboard'",
            true,
            TestSharingPermissionUtils.createPublicPermissions(),
            null,
            null);

    groupDashboard =
        new SharedEntityInfo(
            "group_dashboard",
            null,
            true,
            new HashSet<GroupTestSharingPermission>(
                Arrays.asList(
                    new GroupTestSharingPermission(GROUP_DELETE),
                    new GroupTestSharingPermission(GROUP_ADMIN))),
            null,
            null);

    projectDashboard =
        new SharedEntityInfo(
            "project_dashboard",
            null,
            true,
            TestSharingPermissionUtils.createProjectPermissions(
                PROJECT_DELETE_ID, -1, PROJECT_DELETE_NAME, null),
            null,
            null);

    roleDashboard =
        new SharedEntityInfo(
            "role_dashboard",
            null,
            true,
            TestSharingPermissionUtils.createProjectPermissions(
                PROJECT_DELETE_ID, ROLE_DELETE_ID, PROJECT_DELETE_NAME, ROLE_DELETE_NAME),
            null,
            null);

    administration.restoreData("sharedpages/TestDashboardRelatedEntitiesDelete.xml");
    navigation.gotoAdmin();
  }
  /** Make sure that deleting a role also deletes any related shares. */
  public void testDeleteRole() {
    administration.roles().delete(ROLE_DELETE_ID);

    // deleting the role should make this a private permission.
    roleDashboard.setSharingPermissions(TestSharingPermissionUtils.createPrivatePermissions());

    navigation.dashboard().navigateToMy();
    assertions
        .getDashboardAssertions()
        .assertDashboardPages(
            Arrays.asList(dashboardCopy, groupDashboard, projectDashboard, roleDashboard),
            Table.OWNED);
  }
  /** Test that the dashboard shares are cleaned up when a group is deleted. */
  public void testDeleteGroup() {
    administration.usersAndGroups().deleteGroup(GROUP_DELETE);

    // deleting the group should remove that share permission.
    groupDashboard.setSharingPermissions(
        TestSharingPermissionUtils.createGroupPermissions(GROUP_ADMIN));

    navigation.dashboard().navigateToMy();
    assertions
        .getDashboardAssertions()
        .assertDashboardPages(
            Arrays.asList(dashboardCopy, groupDashboard, projectDashboard, roleDashboard),
            Table.OWNED);
  }