@Override
    public void doRun() {
        final Instant mustBeOlderThan = Instant.now().minus(maximumSearchAge);
        searchDbService.getExpiredSearches(findReferencedSearchIds(),
                mustBeOlderThan).forEach(searchDbService::delete);
    }
@Test
    public void testForReferencedSearches() {
        final ViewSummaryDTO view = ViewSummaryDTO.builder()
                .title("my-view")
                .searchId(IN_USE_SEARCH_ID)
                .build();

        when(viewService.streamAll()).thenReturn(Stream.of(view));

        final Search search = Search.builder()
                .id(IN_USE_SEARCH_ID)
                .createdAt(DateTime.now(DateTimeZone.UTC).minus(Duration.standardDays(30)))
                .build();

        when(searchDbService.streamAll()).thenReturn(Stream.of(search));

        this.searchesCleanUpJob.doRun();

        // Verify that search ids for standard views and resolved views are passed in as neverDeleteIds.
        final ArgumentCaptor<HashSet<String>> searchIdsCaptor = ArgumentCaptor.forClass((Class) Set.class);
        verify(searchDbService, times(1)).getExpiredSearches(searchIdsCaptor.capture(), any());
        assertThat(searchIdsCaptor.getValue().contains(IN_USE_SEARCH_ID)).isTrue();
        assertThat(searchIdsCaptor.getValue().contains(IN_USE_RESOLVER_SEARCH_ID)).isTrue();
        assertThat(searchIdsCaptor.getValue().contains(IN_USE_STATIC_SEARCH_ID)).isTrue();

        verify(searchDbService, never()).delete(any());
    }