Skip to content

Commit

Permalink
add unit tests for environment metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
bechte committed Jul 15, 2024
1 parent 051413e commit 4c0b87e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

@RestController
@RequestMapping(value = "/{baseSiteId}/configuration")
// @CacheControl(directive = CacheControlDirective.PUBLIC, maxAge = 360)
public class FrontendConfigurationController {
@Resource
private FrontendConfigurationService frontendConfigurationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String, String> properties) {
configurationService = new ConfigurationServiceFake();
properties.forEach(configurationService::setProperty);
Expand Down

0 comments on commit 4c0b87e

Please sign in to comment.