public void upgrade() {
        viewService.streamAll().forEach(view -> {
            final Optional<User> user = view.owner().map(userService::load);
            if (user.isPresent() && !user.get().isLocalAdmin()) {
                final GRNType grnType = ViewDTO.Type.DASHBOARD.equals(view.type()) ? GRNTypes.DASHBOARD : GRNTypes.SEARCH;
                final GRN target = grnType.toGRN(view.id());

                ensureGrant(user.get(), target);
            }
        });
    }
@Test
    @DisplayName("migrate existing owner")
    void migrateExistingOwner() {

        final GRN testuserGRN = GRNTypes.USER.toGRN("testuser");
        final GRN dashboard = GRNTypes.DASHBOARD.toGRN("54e3deadbeefdeadbeef0002");

        final User testuser = mock(User.class);
        when(testuser.getName()).thenReturn("testuser");
        when(testuser.getId()).thenReturn("testuser");

        final User adminuser = mock(User.class);
        when(adminuser.isLocalAdmin()).thenReturn(true);

        when(userService.load("testuser")).thenReturn(testuser);
        when(userService.load("admin")).thenReturn(adminuser);

        migration.upgrade();
        assertThat(grantService.hasGrantFor(testuserGRN, Capability.OWN, dashboard)).isTrue();
    }