public Optional<Search> getForUser(String id, SearchUser searchUser) {
        final Optional<Search> search = dbService.get(id);

        search.ifPresent(s -> checkPermission(searchUser, s));

        return search;
    }
@Test
    public void loadsSearchIfSearchIsPermittedViaViews() {
        final Search search = mockSearchWithOwner("someone else");
        final SearchUser searchUser = mock(SearchUser.class);

        final ViewDTO viewDTO = mock(ViewDTO.class);
        when(viewService.forSearch(anyString())).thenReturn(ImmutableList.of(viewDTO));
        when(searchUser.canReadView(viewDTO)).thenReturn(true);

        final Optional<Search> result = sut.getForUser(search.id(), searchUser);

        assertThat(result).isEqualTo(Optional.of(search));
    }