public SearchJob executeSync(String searchId, SearchUser searchUser, ExecutionState executionState) {
        return searchDomain.getForUser(searchId, searchUser)
                .map(s -> executeSync(s, searchUser, executionState))
                .orElseThrow(() -> new NotFoundException("No search found with id <" + searchId + ">."));
    }
@Test
    public void checksUserPermissionsForSearch() {
        final Search search = Search.builder()
                .queries(ImmutableSet.of(
                        Query.builder()
                                .filter(StreamFilter.ofId("forbidden_stream"))
                                .build()
                ))
                .build();
        final SearchUser searchUser = TestSearchUser.builder()
                .denyStream("forbidden_stream")
                .build();

        when(searchDomain.getForUser(eq("search1"), eq(searchUser))).thenReturn(Optional.of(search));

        assertThatExceptionOfType(MissingStreamPermissionException.class)
                .isThrownBy(() -> this.searchExecutor.executeSync("search1", searchUser, ExecutionState.empty()));
    }