### Question:
KettleRepositoryLocatorImpl extends RankedList<KettleRepositoryProvider> implements KettleRepositoryLocator { @Override public Repository getRepository() { return getList().stream().map( KettleRepositoryProvider::getRepository ).filter( Objects::nonNull ).findFirst() .orElse( null ); } KettleRepositoryLocatorImpl(); @Override Repository getRepository();  }### Answer:
@Test public void testGetRepositoryNone() { assertNull( kettleRepositoryLocator.getRepository() ); }
@Test public void testGetRepositorySingleNull() { KettleRepositoryProvider provider = mock( KettleRepositoryProvider.class ); kettleRepositoryLocator.itemAdded( provider, null ); assertNull( kettleRepositoryLocator.getRepository() ); verify( provider ).getRepository(); }
@Test public void testGetRepositoryMultiple() { KettleRepositoryProvider provider1 = mock( KettleRepositoryProvider.class ); KettleRepositoryProvider provider2 = mock( KettleRepositoryProvider.class ); KettleRepositoryProvider provider3 = mock( KettleRepositoryProvider.class ); KettleRepositoryProvider provider4 = mock( KettleRepositoryProvider.class ); kettleRepositoryLocator .itemAdded( provider1, Collections.singletonMap( KettleRepositoryLocatorImpl.SERVICE_RANKING, 30 ) ); kettleRepositoryLocator .itemAdded( provider2, Collections.singletonMap( KettleRepositoryLocatorImpl.SERVICE_RANKING, 40 ) ); kettleRepositoryLocator .itemAdded( provider3, Collections.singletonMap( KettleRepositoryLocatorImpl.SERVICE_RANKING, 50 ) ); kettleRepositoryLocator .itemAdded( provider4, Collections.singletonMap( KettleRepositoryLocatorImpl.SERVICE_RANKING, 20 ) ); Repository repository = mock( Repository.class ); when( provider1.getRepository() ).thenReturn( repository ); assertEquals( repository, kettleRepositoryLocator.getRepository() ); verify( provider1 ).getRepository(); verify( provider2 ).getRepository(); verify( provider3 ).getRepository(); verify( provider4, never() ).getRepository(); }