Skip to content

Commit

Permalink
update hostName and subDomain
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Dec 24, 2024
1 parent 0cafd32 commit aebb87a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ClientConfigDto getConfigBasedOnActiveEnv(String hostName) {
tenantClientCustomization.get().customStyles()); //
}

private Optional<TenantConfigProvider.TenantConfig> getTenantConfig(String hostname, String... tenantsFromUrl) {
private Optional<TenantConfigProvider.TenantConfig> getTenantConfig(String hostName, String... tenantsFromUrl) {
for (String tenant : tenantsFromUrl) {
Optional<TenantConfigProvider.TenantConfig> tenantConfig = tenantConfigProvider.getTenantConfigById(tenant);
if (tenantConfig.isPresent()) {
Expand All @@ -71,11 +71,11 @@ private Optional<TenantConfigProvider.TenantConfig> getTenantConfig(String hostn
}
logger.info("get config found for " + tenant + ": failed");
}
logger.info("no config found for " + hostname + ": failed");
logger.info("no config found for " + hostName + ": failed");
return Optional.empty();
}

private Optional<TenantClientCustomization> getTenantClientCustomization(String hostname,
private Optional<TenantClientCustomization> getTenantClientCustomization(String hostName,
String... tenantsFromUrl) {
for (String tenant : tenantsFromUrl) {
Optional<TenantClientCustomization> tenantCustomization = tenantClientCustomizationProvider
Expand All @@ -86,7 +86,7 @@ private Optional<TenantClientCustomization> getTenantClientCustomization(String
}
logger.info("get client customization for " + tenant + ": failed");
}
logger.info("no client customization found for " + hostname + ": failed");
logger.info("no client customization found for " + hostName + ": failed");
return Optional.empty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static Stream<Arguments> tenantConfigs() {
.of("acme.okr.puzzle.ch", "prod", "http://localhost:8544/realms/pitc", "acme_okr_staging"));
}

@DisplayName("Should throw exception on getConfigBasedOnActiveEnv() when subdomain is invalid")
@DisplayName("Should throw exception on getConfigBasedOnActiveEnv() when subDomain is invalid")
@Test
void getConfigBasedOnActiveEnvWithInvalidSubdomainThrowsException() {
assertThrowsExactly(EntityNotFoundException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,41 @@

public class ClientConfigServiceTest {

@ParameterizedTest(name = "Should be successful on getConfigBasedOnActiveEnv() when tenant is configured properly with tenant {0} and hostname {1}")
@ParameterizedTest(name = "Should be successful on getConfigBasedOnActiveEnv() when tenant is configured properly with tenant {0} and hostName {1}")
@CsvSource({ "pitc,pitc.ork.ch", "acme,acme-ork.ch" })
void getConfigBasedOnActiveEnvShouldBeSuccessfulWhenTenantIsConfiguredProperly(String tenant, String hostname) {
void getConfigBasedOnActiveEnvShouldBeSuccessfulWhenTenantIsConfiguredProperly(String tenant, String hostName) {
// arrange
TenantConfigProvider.TenantConfig tenantConfig = getTenantConfig(tenant);
TenantClientCustomization tenantCustomization = getTenantClientCustomization(tenant);
ClientConfigService service = getClientConfig(tenantConfig, tenantCustomization, tenant);

// act
ClientConfigDto configBasedOnActiveEnv = service.getConfigBasedOnActiveEnv(hostname);
ClientConfigDto configBasedOnActiveEnv = service.getConfigBasedOnActiveEnv(hostName);

// assert
assertClientConfigDto(configBasedOnActiveEnv, tenant);
}

@ParameterizedTest(name = "Should throw exception on getConfigBasedOnActiveEnv() when client customization is not found for tenant {0}, hostname {1} and subdomain {2}")
@ParameterizedTest(name = "Should throw exception on getConfigBasedOnActiveEnv() when client customization is not found for tenant {0}, hostName {1} and subDomain {2}")
@CsvSource({ "pitc,pitc.okr.ch,pitc", "acme,acme-okr.ch,acme-okr" })
void getConfigBasedOnActiveEnvShouldThrowExceptionIfClientCustomizationIsNotFound(String tenant, String hostname,
String subdomain) {
void getConfigBasedOnActiveEnvShouldThrowExceptionIfClientCustomizationIsNotFound(String tenant, String hostName,
String subDomain) {
// arrange
TenantConfigProvider.TenantConfig tenantConfig = getTenantConfig(tenant);
ClientConfigService service = getClientConfig(tenantConfig, tenant);

// act + assert
EntityNotFoundException entityNotFoundException = //
assertThrows(EntityNotFoundException.class, () -> service.getConfigBasedOnActiveEnv(hostname));
assertThrows(EntityNotFoundException.class, () -> service.getConfigBasedOnActiveEnv(hostName));

String expectedErrorMessage = "Could not find tenant client customization for subdomain:" + subdomain;
String expectedErrorMessage = "Could not find tenant client customization for subDomain:" + subDomain;
assertEquals(expectedErrorMessage, entityNotFoundException.getMessage());
}

@ParameterizedTest(name = "Should throw exception getConfigBasedOnActiveEnv when client config is not found for tenant {0}, hostname {1} and subdomain {2} ")
@ParameterizedTest(name = "Should throw exception getConfigBasedOnActiveEnv when client config is not found for tenant {0}, hostname {1} and subDomain {2} ")
@CsvSource({ "pitc,pitc.okr.ch,pitc", "acme,acme-okr.ch,acme-okr" })
void getConfigBasedOnActiveEnvShouldThrowExceptionIfClientConfigIsNotFound(String tenant, String hostname,
String subdomain) {
String subDomain) {
// arrange
TenantClientCustomization tenantCustomization = getTenantClientCustomization(tenant);
ClientConfigService service = getClientConfig(tenantCustomization, tenant);
Expand All @@ -59,7 +59,7 @@ void getConfigBasedOnActiveEnvShouldThrowExceptionIfClientConfigIsNotFound(Strin
EntityNotFoundException entityNotFoundException = //
assertThrows(EntityNotFoundException.class, () -> service.getConfigBasedOnActiveEnv(hostname));

String expectedErrorMessage = "Could not find tenant config for subdomain:" + subdomain;
String expectedErrorMessage = "Could not find tenant config for subDomain:" + subDomain;
assertEquals(expectedErrorMessage, entityNotFoundException.getMessage());
}

Expand Down

0 comments on commit aebb87a

Please sign in to comment.