public List<Search> getAllForUser(SearchPermissions searchPermissions, Predicate<ViewDTO> viewReadPermission) {
        return dbService.streamAll()
                .filter(s -> hasReadPermissionFor(searchPermissions, viewReadPermission, s))
                .collect(Collectors.toList());
    }
@Test
    public void includesSearchesPermittedViaResolvedView() {
        Search permittedSearch = Search.builder().id(UUID.randomUUID().toString()).owner("someone else").build();
        allSearchesInDb.add(permittedSearch);
        when(dbService.get(permittedSearch.id())).thenReturn(Optional.of(permittedSearch));
        final SearchUser searchUser = mock(SearchUser.class);
        final ViewDTO viewDTO = mock(ViewDTO.class);
        when(searchUser.canReadView(viewDTO)).thenReturn(true);

        // Prepare test ViewResolver that returns a view that should be permitted.
        final SearchDomain searchDomain = new SearchDomain(dbService, executionGuard, viewService,
                testViewResolvers(viewDTO));

        List<Search> result = searchDomain.getAllForUser(searchUser, searchUser::canReadView);
        assertThat(result).containsExactly(permittedSearch);
    }