### Question:
CompositeCredentialsRepository { public List<T> getAllCredentials() { return Collections.unmodifiableList( allRepositories.values().stream() .map(CredentialsRepository::getAll) .flatMap(Collection::stream) .collect(Collectors.toList())); } CompositeCredentialsRepository(List<CredentialsRepository<? extends T>> repositories); void registerRepository(CredentialsRepository<? extends T> repository); T getCredentials(String credentialsName, String type); @Nullable T getFirstCredentialsWithName(String name); List<T> getAllCredentials();  }### Answer:
@Test public void TestMultiComposite() { CredentialsRepository<Credentials> repo1 = mock(CredentialsRepository.class); Credentials cred1 = mock(Credentials.class); when(repo1.getType()).thenReturn("type1"); when(repo1.getAll()).thenReturn(new HashSet<>(Arrays.asList(cred1))); CredentialsRepository<?> repo2 = mock(CredentialsRepository.class); when(repo2.getType()).thenReturn("type2"); when(repo2.getAll()).thenReturn(Collections.emptySet()); CompositeCredentialsRepository<?> composite = new CompositeCredentialsRepository<>(Arrays.asList(repo1, repo2)); assertThat(composite.getAllCredentials()).hasSize(1); }