@Test void testGetDomainWhenRootDomainIsOverriddenAndStartsWithDot() { String envName = "an-env-name"; String accountName = "an-account-name"; ReflectionTestUtils.setField(underTest, "rootDomain", ".mytest.local"); String result = underTest.getDomainName(envName, accountName); String expected = String.format("%s.%s.mytest.local", "an-env-n", accountName); assertEquals(expected, result); }
public String getDomainName(String environmentName, String accountName) { if (StringUtils.isEmpty(environmentName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(ENV_NAME_SHOULD_BE_SPECIFIED_MSG); } if (StringUtils.isEmpty(accountName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(String.format(ACCOUNT_NAME_IS_EMTPY_FORMAT, environmentName)); } LOGGER.info("Generating domain with environment name: '{}', account name: '{}' and root domain: '{}'", environmentName, accountName, rootDomain); StringBuilder sb = new StringBuilder() .append(truncateEnvironment(environmentName)) .append(DOMAIN_PART_DELIMITER) .append(accountName); if (!rootDomain.startsWith(DOMAIN_PART_DELIMITER)) { sb = sb.append(DOMAIN_PART_DELIMITER); } String result = sb.append(rootDomain).toString(); validateDomainPattern(result); LOGGER.info("Generated domain: '{}'", result); return result; }
EnvironmentBasedDomainNameProvider { public String getDomainName(String environmentName, String accountName) { if (StringUtils.isEmpty(environmentName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(ENV_NAME_SHOULD_BE_SPECIFIED_MSG); } if (StringUtils.isEmpty(accountName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(String.format(ACCOUNT_NAME_IS_EMTPY_FORMAT, environmentName)); } LOGGER.info("Generating domain with environment name: '{}', account name: '{}' and root domain: '{}'", environmentName, accountName, rootDomain); StringBuilder sb = new StringBuilder() .append(truncateEnvironment(environmentName)) .append(DOMAIN_PART_DELIMITER) .append(accountName); if (!rootDomain.startsWith(DOMAIN_PART_DELIMITER)) { sb = sb.append(DOMAIN_PART_DELIMITER); } String result = sb.append(rootDomain).toString(); validateDomainPattern(result); LOGGER.info("Generated domain: '{}'", result); return result; } }
EnvironmentBasedDomainNameProvider { public String getDomainName(String environmentName, String accountName) { if (StringUtils.isEmpty(environmentName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(ENV_NAME_SHOULD_BE_SPECIFIED_MSG); } if (StringUtils.isEmpty(accountName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(String.format(ACCOUNT_NAME_IS_EMTPY_FORMAT, environmentName)); } LOGGER.info("Generating domain with environment name: '{}', account name: '{}' and root domain: '{}'", environmentName, accountName, rootDomain); StringBuilder sb = new StringBuilder() .append(truncateEnvironment(environmentName)) .append(DOMAIN_PART_DELIMITER) .append(accountName); if (!rootDomain.startsWith(DOMAIN_PART_DELIMITER)) { sb = sb.append(DOMAIN_PART_DELIMITER); } String result = sb.append(rootDomain).toString(); validateDomainPattern(result); LOGGER.info("Generated domain: '{}'", result); return result; }  }
EnvironmentBasedDomainNameProvider { public String getDomainName(String environmentName, String accountName) { if (StringUtils.isEmpty(environmentName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(ENV_NAME_SHOULD_BE_SPECIFIED_MSG); } if (StringUtils.isEmpty(accountName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(String.format(ACCOUNT_NAME_IS_EMTPY_FORMAT, environmentName)); } LOGGER.info("Generating domain with environment name: '{}', account name: '{}' and root domain: '{}'", environmentName, accountName, rootDomain); StringBuilder sb = new StringBuilder() .append(truncateEnvironment(environmentName)) .append(DOMAIN_PART_DELIMITER) .append(accountName); if (!rootDomain.startsWith(DOMAIN_PART_DELIMITER)) { sb = sb.append(DOMAIN_PART_DELIMITER); } String result = sb.append(rootDomain).toString(); validateDomainPattern(result); LOGGER.info("Generated domain: '{}'", result); return result; }  String getDomainName(String environmentName, String accountName); String getFullyQualifiedEndpointName(String endpointName, String environmentName, String accountName); String getCommonName(String endpointName, String environmentName, String accountName); }
EnvironmentBasedDomainNameProvider { public String getDomainName(String environmentName, String accountName) { if (StringUtils.isEmpty(environmentName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(ENV_NAME_SHOULD_BE_SPECIFIED_MSG); } if (StringUtils.isEmpty(accountName)) { LOGGER.error("The required parameters hasn't been specified, environment name: {}, account name: {}", environmentName, accountName); throw new IllegalStateException(String.format(ACCOUNT_NAME_IS_EMTPY_FORMAT, environmentName)); } LOGGER.info("Generating domain with environment name: '{}', account name: '{}' and root domain: '{}'", environmentName, accountName, rootDomain); StringBuilder sb = new StringBuilder() .append(truncateEnvironment(environmentName)) .append(DOMAIN_PART_DELIMITER) .append(accountName); if (!rootDomain.startsWith(DOMAIN_PART_DELIMITER)) { sb = sb.append(DOMAIN_PART_DELIMITER); } String result = sb.append(rootDomain).toString(); validateDomainPattern(result); LOGGER.info("Generated domain: '{}'", result); return result; }  String getDomainName(String environmentName, String accountName); String getFullyQualifiedEndpointName(String endpointName, String environmentName, String accountName); String getCommonName(String endpointName, String environmentName, String accountName);  }