### Question:
ProviderServiceImpl implements ProviderService { @Override public Provider getProvider(final ProviderKey providerKey) { List<org.guvnor.ala.runtime.providers.Provider> providers = runtimeProvisioningService.getProviders(0, 1000, PROVIDER_TYPE_NAME_SORT, true); Optional<Provider> result = Optional.empty(); if (providers != null) { result = providers.stream() .filter(provider -> provider.getId().equals(providerKey.getId())) .map(this::convert) .findFirst(); } return result.orElse(null); } ProviderServiceImpl(); @Inject  ProviderServiceImpl(final RuntimeProvisioningServiceBackend runtimeProvisioningService,
                               final ProviderConverterFactory providerConverterFactory); @Override Collection<Provider> getProviders(final ProviderType providerType); @Override Collection<ProviderKey> getProvidersKey(final ProviderType providerType); @Override void createProvider(final ProviderType providerType,
                               final ProviderConfiguration configuration); @Override void deleteProvider(final ProviderKey providerKey); @Override Provider getProvider(final ProviderKey providerKey);  }### Answer:
@Test public void testGetProviderExisting() { org.guvnor.ala.runtime.providers.Provider providerSpi = providersSpi.get(2); ProviderTypeKey providerTypeKey = new ProviderTypeKey(providerSpi.getProviderType().getProviderTypeName(), providerSpi.getProviderType().getVersion()); ProviderKey providerKey = new ProviderKey(providerTypeKey, providerSpi.getId()); Provider provider = service.getProvider(providerKey); assertNotNull(provider); assertEquals(providers.get(2).getKey(), provider.getKey()); }
@Test public void testGetProviderNotExisting() { ProviderTypeKey providerTypeKey = new ProviderTypeKey("not exist", "not exist"); ProviderKey providerKey = new ProviderKey(providerTypeKey, "not exist"); Provider provider = service.getProvider(providerKey); assertNull(provider); }