@Test public void shouldValidateUpdateTier() throws AlreadyExistEntityException, InfrastructureException, QuotaExceededException, InvalidEntityException, EntityNotFoundException { TierDto tierDTO = new TierDto(); tierDTO.setName("aaaa"); 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())).thenReturn(tierDTO.fromDto("vdc", "env")); tierResourceValidator.validateUpdate("vdc", "envName", tierDTO.getName(), tierDTO); }
public void validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto) throws InvalidEntityException, EntityNotFoundException { try { tierManager.load(tierName, vdc, environmentName); } catch (EntityNotFoundException e1) { throw new EntityNotFoundException(Tier.class, "The tier " + tierName + " does not exists vdc " + vdc + " environmentName " + environmentName, e1.getMessage()); } if (!tierName.equals(environmentDto.getName())) { throw new InvalidEntityException("it is not possible to change the tier Name"); } resourceValidator.validateName(environmentDto.getName()); validataDefaultTier(environmentDto); validateTierInEnvInstance(environmentName, vdc); }
TierResourceValidatorImpl implements TierResourceValidator { public void validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto) throws InvalidEntityException, EntityNotFoundException { try { tierManager.load(tierName, vdc, environmentName); } catch (EntityNotFoundException e1) { throw new EntityNotFoundException(Tier.class, "The tier " + tierName + " does not exists vdc " + vdc + " environmentName " + environmentName, e1.getMessage()); } if (!tierName.equals(environmentDto.getName())) { throw new InvalidEntityException("it is not possible to change the tier Name"); } resourceValidator.validateName(environmentDto.getName()); validataDefaultTier(environmentDto); validateTierInEnvInstance(environmentName, vdc); } }
TierResourceValidatorImpl implements TierResourceValidator { public void validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto) throws InvalidEntityException, EntityNotFoundException { try { tierManager.load(tierName, vdc, environmentName); } catch (EntityNotFoundException e1) { throw new EntityNotFoundException(Tier.class, "The tier " + tierName + " does not exists vdc " + vdc + " environmentName " + environmentName, e1.getMessage()); } if (!tierName.equals(environmentDto.getName())) { throw new InvalidEntityException("it is not possible to change the tier Name"); } resourceValidator.validateName(environmentDto.getName()); validataDefaultTier(environmentDto); validateTierInEnvInstance(environmentName, vdc); }  }
TierResourceValidatorImpl implements TierResourceValidator { public void validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto) throws InvalidEntityException, EntityNotFoundException { try { tierManager.load(tierName, vdc, environmentName); } catch (EntityNotFoundException e1) { throw new EntityNotFoundException(Tier.class, "The tier " + tierName + " does not exists vdc " + vdc + " environmentName " + environmentName, e1.getMessage()); } if (!tierName.equals(environmentDto.getName())) { throw new InvalidEntityException("it is not possible to change the tier Name"); } resourceValidator.validateName(environmentDto.getName()); validataDefaultTier(environmentDto); validateTierInEnvInstance(environmentName, vdc); }  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 validateUpdate(String vdc, String environmentName, String tierName, TierDto environmentDto) throws InvalidEntityException, EntityNotFoundException { try { tierManager.load(tierName, vdc, environmentName); } catch (EntityNotFoundException e1) { throw new EntityNotFoundException(Tier.class, "The tier " + tierName + " does not exists vdc " + vdc + " environmentName " + environmentName, e1.getMessage()); } if (!tierName.equals(environmentDto.getName())) { throw new InvalidEntityException("it is not possible to change the tier Name"); } resourceValidator.validateName(environmentDto.getName()); validataDefaultTier(environmentDto); validateTierInEnvInstance(environmentName, vdc); }  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);  }