@Test(expected = InvalidEntityException.class) public void shouldValidateStrangeCharacteresEnvironment() throws AlreadyExistEntityException, InvalidEntityException, InfrastructureException, QuotaExceededException, EntityNotFoundException, InvalidEnvironmentInstanceException { TierDto tierDto = new TierDto(); tierDto.setName("name.name"); when(tierManager.load(anyString(), anyString(), anyString())).thenThrow( new EntityNotFoundException(Tier.class, "tier", tierDto.getName())); ClaudiaData claudiaData = mock(ClaudiaData.class); tierResourceValidator.validateCreate(claudiaData, tierDto, "vdc", "envName"); }
public void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName) throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(environmentDto.getName(), vdc, environmentName); log.error("The tier " + environmentDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + environmentDto.getName() + " already exists in vdc " + vdc + " and environmentName " + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); validateCreateTier(claudiaData, environmentDto); } }
TierResourceValidatorImpl implements TierResourceValidator { public void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName) throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(environmentDto.getName(), vdc, environmentName); log.error("The tier " + environmentDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + environmentDto.getName() + " already exists in vdc " + vdc + " and environmentName " + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); validateCreateTier(claudiaData, environmentDto); } } }
TierResourceValidatorImpl implements TierResourceValidator { public void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName) throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(environmentDto.getName(), vdc, environmentName); log.error("The tier " + environmentDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + environmentDto.getName() + " already exists in vdc " + vdc + " and environmentName " + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); validateCreateTier(claudiaData, environmentDto); } }  }
TierResourceValidatorImpl implements TierResourceValidator { public void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName) throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(environmentDto.getName(), vdc, environmentName); log.error("The tier " + environmentDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + environmentDto.getName() + " already exists in vdc " + vdc + " and environmentName " + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); validateCreateTier(claudiaData, environmentDto); } }  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); }
TierResourceValidatorImpl implements TierResourceValidator { public void validateCreate(ClaudiaData claudiaData, TierDto environmentDto, String vdc, String environmentName) throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(environmentDto.getName(), vdc, environmentName); log.error("The tier " + environmentDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + environmentDto.getName() + " already exists in vdc " + vdc + " and environmentName " + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); validateCreateTier(claudiaData, environmentDto); } }  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);  }