### Question:
CertificateService { public Set<Certificate> getAllCertificates() { return Stream.concat(connectedServiceConfigRepository.stream(), matchingServiceConfigRepository.stream()) .flatMap(this::getAllCertificates) .collect(Collectors.toSet()); } @Inject  CertificateService(
            ManagedEntityConfigRepository<TransactionConfig> connectedServiceConfigRepository,
            ManagedEntityConfigRepository<MatchingServiceConfig> matchingServiceConfigRepository,
            CertificateValidityChecker certificateValidityChecker); Set<Certificate> getAllCertificates(); Certificate encryptionCertificateFor(String entityId); List<Certificate> signatureVerificationCertificatesFor(String entityId);  }### Answer:
@Test public void getAllCertificatesReturnsAllTransactionAndMatchingServiceCertificate() { final TransactionConfig transactionOneConfig = aTransactionConfigData().withEntityId(RP_ONE_ENTITY_ID) .withEnabled(true) .build(); final TransactionConfig transactionTwoConfig = aTransactionConfigData().withEntityId(RP_TWO_ENTITY_ID) .withEnabled(true) .build(); final MatchingServiceConfig matchingServiceOneConfig = aMatchingServiceConfig().withEntityId(RP_MSA_ONE_ENTITY_ID) .build(); Set<Certificate> expectedCertificateSet = new HashSet<>(); expectedCertificateSet.addAll(transactionOneConfig.getAllCertificates()); expectedCertificateSet.addAll(transactionTwoConfig.getAllCertificates()); expectedCertificateSet.addAll(matchingServiceOneConfig.getAllCertificates()); List<TransactionConfig> transactionConfigs = new ArrayList<>(); transactionConfigs.add(transactionOneConfig); transactionConfigs.add(transactionTwoConfig); List<MatchingServiceConfig> matchingServiceConfigs = new ArrayList<>(); matchingServiceConfigs.add(matchingServiceOneConfig); when(connectedServiceConfigRepository.stream()).thenReturn(transactionConfigs.stream()); when(matchingServiceConfigRepository.stream()).thenReturn(matchingServiceConfigs.stream()); final Set<Certificate> actualCertificateSet = certificateService.getAllCertificates(); assertThat(actualCertificateSet.size()).isEqualTo(6); assertThat(actualCertificateSet).containsAll(expectedCertificateSet); }