TierResourceValidatorImpl implements TierResourceValidator { List<String> createDependenciesForTiers(List<Tier> tiers) { List<String> dependenciesList = new ArrayList<String>(); for (Tier tier : tiers) { for (ProductRelease productRelease : tier.getProductReleases()) { Set<Metadata> metadataList = productRelease.getMetadatas(); for (Metadata metadata : metadataList) { if (metadata.getKey().startsWith("dep")) { dependenciesList.add(metadata.getValue()); } } } } return dependenciesList; }  void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName); void validateCreateAbstract(TierDto tierDto, String environmentName); void validateSecurityGroups(ClaudiaData claudiaData, TierDto tierDto); void validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto); void validateDelete(String vdc, String environmentName, String tierName); void validateTiersDependencies(String environmentName, String vdc, Set<TierDto> tierDtoList); boolean checkTierProductsInDependencyList(List<String> productDependencies,
            Map<String, String> dependenciesMap); void setTierManager(TierManager tierManager); void setEnvironmentInstanceManager(EnvironmentInstanceManager environmentInstanceManager); void setEnvironmentManager(EnvironmentManager environmentManager); QuotaClient getQuotaClient(); void setQuotaClient(QuotaClient quotaClient); void setResourceValidator(ResourceValidator resourceValidator); void setProductValidator(ProductValidator productValidator);  }
@Test public void shouldCreateAListWithDependenciesFromMetadataProducts() { TierResourceValidatorImpl tierResourceValidator = new TierResourceValidatorImpl(); List<Tier> tiers = new ArrayList<Tier>(); Tier tier1 = new Tier(); tiers.add(tier1); List<ProductRelease> products = new ArrayList<ProductRelease>(2); tier1.setProductReleases(products); ProductRelease product1 = new ProductRelease(); product1.setName("mongo"); product1.setVersion("1"); ProductRelease product2 = new ProductRelease(); product2.setName("mongoshared"); product2.setVersion("1"); products.add(product1); products.add(product2); Tier tier2 = new Tier(); tiers.add(tier2); List<ProductRelease> products2 = new ArrayList<ProductRelease>(2); tier2.setProductReleases(products2); ProductRelease product3 = new ProductRelease(); product3.setName("contexbroker"); product3.setVersion("1.0"); Set<Metadata> metadatas = new HashSet<Metadata>(2); product3.setMetadatas(metadatas); products2.add(product3); Metadata metadataDep = new Metadata(); metadatas.add(metadataDep); metadataDep.setKey("dep"); metadataDep.setValue("mongo-1"); List<String> dependenciesList = tierResourceValidator.createDependenciesForTiers(tiers); assertNotNull(dependenciesList); assertEquals(1, dependenciesList.size()); }