TierResourceValidatorImpl implements TierResourceValidator { public void validateCreateAbstract(TierDto tierDto, String environmentName) throws InvalidEntityException, AlreadyExistEntityException, InvalidEnvironmentInstanceException { try { tierManager.load(tierDto.getName(), "", environmentName); log.error("The tier " + tierDto.getName() + " already exists in "); throw new AlreadyExistEntityException("The tier " + tierDto.getName() + " already exists in environment" + environmentName); } catch (EntityNotFoundException e) { log.debug("Entity not found. It is possible to create it "); resourceValidator.validateName(tierDto.getName()); validataDefaultTier(tierDto); productValidator.validateAttributes(tierDto); } }  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 shouldValidateAbstractTier() throws EntityNotFoundException, InvalidEntityException, AlreadyExistEntityException, InvalidEnvironmentInstanceException { TierDto tierDTO = new TierDto(); tierDTO.setName("tier1"); tierDTO.setInitialNumberInstances(new Integer(1)); tierDTO.setMaximumNumberInstances(new Integer(1)); tierDTO.setMinimumNumberInstances(new Integer(1)); tierDTO.setImage("image"); tierDTO.setFlavour("flavor"); when(tierManager.load(anyString(), anyString(), anyString())).thenThrow( new EntityNotFoundException(Tier.class, "tier", tierDTO.getName())); tierResourceValidator.validateCreateAbstract(tierDTO, "en"); }