public void upgrade() {
        final List<User> users = userService.loadAll();

        for (User user : users) {
            final Map<String, Set<String>> migratableEntities = getMigratableEntities(ImmutableSet.copyOf(user.getPermissions()));
            if (!migratableEntities.isEmpty()) {
                migrateUserPermissions(user, migratableEntities);
            }
        }
    }
@Test
    void migrateSomeUserPermissions() {

        User testuser2 = userService.load("testuser2");
        assertThat(testuser2).isNotNull();

        assertThat(testuser2.getPermissions().size()).isEqualTo(6 + userSelfEditPermissionCount);
        assertThat(dbGrantService.getForGranteesOrGlobal(ImmutableSet.of(grnRegistry.ofUser(testuser2)))).isEmpty();

        migration.upgrade();

        // check created grants for testuser2
        final ImmutableSet<GrantDTO> grants = dbGrantService.getForGranteesOrGlobal(ImmutableSet.of(grnRegistry.ofUser(testuser2)));
        assertGrantInSet(grants, "grn::::dashboard:5e2afc66cd19517ec2dabadf", Capability.MANAGE);
        assertThat(grants.size()).isEqualTo(1);

        // reload user and check that all migrated permissions have been removed. (should be only two less)
        testuser2 = userService.load("testuser2");
        assertThat(testuser2).isNotNull();
        assertThat(testuser2.getPermissions().size()).isEqualTo(4 + userSelfEditPermissionCount);
    }