From 4c0b87e8b1e08535e4ab3ce9b0f2870a7d350773 Mon Sep 17 00:00:00 2001 From: Stefan Bechtold Date: Tue, 16 Jul 2024 00:34:31 +0200 Subject: [PATCH] add unit tests for environment metadata --- .../controller/FrontendConfigurationController.java | 1 - ...vironmentSpecificFrontendConfigurationService.java | 4 ++-- ...mentSpecificFrontendConfigurationServiceTests.java | 11 +++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/controller/FrontendConfigurationController.java b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/controller/FrontendConfigurationController.java index 12a93e3..4c2ed19 100644 --- a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/controller/FrontendConfigurationController.java +++ b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/controller/FrontendConfigurationController.java @@ -14,7 +14,6 @@ @RestController @RequestMapping(value = "/{baseSiteId}/configuration") -// @CacheControl(directive = CacheControlDirective.PUBLIC, maxAge = 360) public class FrontendConfigurationController { @Resource private FrontendConfigurationService frontendConfigurationService; diff --git a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationService.java b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationService.java index d263d4a..41cee98 100644 --- a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationService.java +++ b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/src/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationService.java @@ -10,8 +10,8 @@ import pl.jalokim.propertiestojson.util.PropertiesToJsonConverterBuilder; public class EnvironmentSpecificFrontendConfigurationService implements FrontendConfigurationService { - private static final String ENVIRONMENT_ID_CONFIGURATION_KEY = "sapcxenvconfig.environment.id"; - private static final String ENVIRONMENT_NAME_CONFIGURATION_KEY = "sapcxenvconfig.environment.name"; + static final String ENVIRONMENT_ID_CONFIGURATION_KEY = "sapcxenvconfig.environment.id"; + static final String ENVIRONMENT_NAME_CONFIGURATION_KEY = "sapcxenvconfig.environment.name"; static final String FRONTEND_CONFIGURATION_PREFIX = "sapcxenvconfig.frontend"; private ConfigurationService configurationService; diff --git a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/testsrc/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationServiceTests.java b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/testsrc/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationServiceTests.java index dd0a05a..f636102 100644 --- a/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/testsrc/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationServiceTests.java +++ b/core-customize/hybris/bin/custom/sapcxtools/sapcxenvconfig/testsrc/tools/sapcx/commerce/config/frontend/EnvironmentSpecificFrontendConfigurationServiceTests.java @@ -1,6 +1,8 @@ package tools.sapcx.commerce.config.frontend; import static org.assertj.core.api.Assertions.assertThat; +import static tools.sapcx.commerce.config.frontend.EnvironmentSpecificFrontendConfigurationService.ENVIRONMENT_ID_CONFIGURATION_KEY; +import static tools.sapcx.commerce.config.frontend.EnvironmentSpecificFrontendConfigurationService.ENVIRONMENT_NAME_CONFIGURATION_KEY; import static tools.sapcx.commerce.config.frontend.EnvironmentSpecificFrontendConfigurationService.FRONTEND_CONFIGURATION_PREFIX; import java.util.Map; @@ -96,6 +98,15 @@ public void withPropertyTreeSet_shouldCacheResult() { assertThat(end1 - start1).isGreaterThanOrEqualTo(end2 - start2); } + @Test + public void withEnvironmentConfiguration_shouldReturnEnvironmentMetadata() { + setupService(Map.of( + ENVIRONMENT_ID_CONFIGURATION_KEY, "ID", + ENVIRONMENT_NAME_CONFIGURATION_KEY, "NAME")); + assertThat(service.getEnvironmentId()).isEqualTo("ID"); + assertThat(service.getEnvironmentName()).isEqualTo("NAME"); + } + private void setupService(Map properties) { configurationService = new ConfigurationServiceFake(); properties.forEach(configurationService::setProperty);