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 appliesSearchExecutionState() {
        final Search search = makeSearch();

        final SearchUser searchUser = TestSearchUser.builder()
                .withUser(testUser -> testUser.withUsername("frank-drebin"))
                .build();

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

        final AbsoluteRange absoluteRange = AbsoluteRange.create("2022-05-18T10:00:00.000Z", "2022-05-19T10:00:00.000Z");
        final ExecutionState executionState = ExecutionState.builder()
                .setGlobalOverride(ExecutionStateGlobalOverride.builder().timerange(absoluteRange).build())
                .build();
        this.searchExecutor.executeSync("search1", searchUser, executionState);

        verify(queryEngine, times(1)).execute(searchJobCaptor.capture(), anySet(), any());

        final SearchJob executedJob = searchJobCaptor.getValue();

        assertThat(executedJob.getSearch().queries())
                .are(new Condition<>(query -> query.timerange().equals(absoluteRange), "timeranges are applied through execution state"));
    }