### Question:
SearchableRepositorySource implements RepositorySource { public RepositoryConnection getConnection() throws RepositorySourceException { if (executeRequestsAsynchronously()) { assert executorService != null; return new ParallelConnection(executorService); } return new SynchronousConnection(); } SearchableRepositorySource( RepositorySource wrapped,
                                       SearchEngine searchEngine,
                                       ExecutorService executorService,
                                       boolean executeAsynchronously,
                                       boolean updateIndexesAsynchronously );  SearchableRepositorySource( RepositorySource wrapped,
                                       SearchEngine searchEngine ); String getName(); void close(); RepositorySourceCapabilities getCapabilities(); RepositoryConnection getConnection(); int getRetryLimit(); void initialize( final RepositoryContext context ); void setRetryLimit( int limit ); Reference getReference();  }### Answer:
@Test public void shouldReturnSynchronousConnectionIfSpecifiedInConstructor() { searchable = new SearchableRepositorySource(wrapped, searchEngine, executor, false, false); RepositoryConnection connection = searchable.getConnection(); assertThat(connection, is(notNullValue())); assertThat(connection, is(instanceOf(SearchableRepositorySource.SynchronousConnection.class))); }
@Test public void shouldReturnSynchronousConnectionIfExecutorNotProvidedInConstructor() { searchable = new SearchableRepositorySource(wrapped, searchEngine, null, false, false); RepositoryConnection connection = searchable.getConnection(); assertThat(connection, is(notNullValue())); assertThat(connection, is(instanceOf(SearchableRepositorySource.SynchronousConnection.class))); searchable = new SearchableRepositorySource(wrapped, searchEngine, null, true, true); connection = searchable.getConnection(); assertThat(connection, is(notNullValue())); assertThat(connection, is(instanceOf(SearchableRepositorySource.SynchronousConnection.class))); }
@Test public void shouldReturnParallelConnectionIfExecutorProvidedInConstructor() { searchable = new SearchableRepositorySource(wrapped, searchEngine, executor, true, false); RepositoryConnection connection = searchable.getConnection(); assertThat(connection, is(notNullValue())); assertThat(connection, is(instanceOf(SearchableRepositorySource.ParallelConnection.class))); searchable = new SearchableRepositorySource(wrapped, searchEngine, executor, true, true); connection = searchable.getConnection(); assertThat(connection, is(notNullValue())); assertThat(connection, is(instanceOf(SearchableRepositorySource.ParallelConnection.class))); }