public void upgrade() {
        final Set<MigratableRole> migratableRoles = findMigratableRoles();

        migratableRoles.forEach(migratableRole -> {
            final Role role = migratableRole.role;

            final Set<String> migratedPermissions = migrateRoleToGrant(migratableRole);

            if (role.getPermissions().removeAll(migratedPermissions)) {
                LOG.debug("Updating role <{}> new permissions: <{}>", role.getName(), role.getPermissions());

                if (role.getPermissions().isEmpty()) {
                    LOG.info("Removing the now empty role <{}>", role.getName());
                    userService.dissociateAllUsersFromRole(role);
                    roleService.delete(role.getName());
                } else {
                    try {
                        roleService.save(role);
                    } catch (ValidationException e) {
                        LOG.error("Failed to update modified role <{}>", role.getName(), e);
                    }
                }
            }
        });
    }
@Test
    public void nonMigratableRole() throws NotFoundException {

        final User testuser3 = userService.load("testuser3");
        assertThat(testuser3).isNotNull();

        assertThat(roleService.load("non-migratable-role")).satisfies(role -> {
            assertThat(role.getPermissions().size()).isEqualTo(4);
        });
        assertThat(dbGrantService.getForGranteesOrGlobal(ImmutableSet.of(grnRegistry.ofUser(testuser3)))).isEmpty();
        migration.upgrade();

        assertThat(roleService.load("non-migratable-role")).satisfies(role -> {
            assertThat(role.getPermissions().size()).isEqualTo(4);
        });
        assertThat(dbGrantService.getForGranteesOrGlobal(ImmutableSet.of(grnRegistry.ofUser(testuser3)))).isEmpty();

    }