Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
HindujaB committed Mar 26, 2024
1 parent 1dc79bc commit 3a830ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ private Optional<ConfigValue> getEnvConfigValue(Object value) {

private Map<String, String> filterConfigEnvVariables(Map<String, String> originalMap) {
Map<String, String> filteredMap = new HashMap<>();

for (Map.Entry<String, String> entry : originalMap.entrySet()) {
if (entry.getKey().startsWith(ENV_VAR_PREFIX)) {
filteredMap.put(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,19 @@ public void testEnvProviderXmlUnionType() {
Object value = configValueMap.get(unionVar).getValue();
Assert.assertEquals(xmlVal.toString(), value.toString());
}

@Test
public void testEnvProviderXmlType() {
BXml xmlVal = ValueCreator.createXmlComment(StringUtils.fromString("I am a comment"));
VariableKey xmlVar = new VariableKey(ROOT_MODULE, "xmlVar",
getIntersectionType(ROOT_MODULE, PredefinedTypes.TYPE_READONLY_XML), false);
RuntimeDiagnosticLog diagnosticLog = new RuntimeDiagnosticLog();
ConfigResolver configResolver =
new ConfigResolver(Map.ofEntries(Map.entry(ROOT_MODULE, new VariableKey[]{xmlVar})), diagnosticLog
, List.of(new EnvVarProvider(ROOT_MODULE, Map.of("BAL_CONFIG_VAR_XMLVAR",
"<!--I am a comment-->"))));
Map<VariableKey, ConfigValue> configValueMap = configResolver.resolveConfigs();
Object value = configValueMap.get(xmlVar).getValue();
Assert.assertEquals(xmlVal.toString(), value.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public Object[][] envVarDataProvider() {
{Map.of("BAL_CONFIG_VAR_MYORG_MOD_X", " hello "), "myorg", "mod", "x", PredefinedTypes.TYPE_INT,
"error: [BAL_CONFIG_VAR_MYORG_MOD_X= hello ] configurable variable 'x' is expected " +
"to be of type 'int', but found ' hello '"},
{Map.of("BAL_CONFIG_VAR_MYORG_MOD_X", " hello "), "myorg", "mod", "x",
PredefinedTypes.TYPE_FLOAT, "error: [BAL_CONFIG_VAR_MYORG_MOD_X= hello ] configurable " +
"variable 'x' is expected to be of type 'float', but found ' hello '"},
// Config int value with spaces
{Map.of("BAL_CONFIG_VAR_MYORG_MOD_X", " 123 "), "myorg", "mod", "x", PredefinedTypes.TYPE_INT,
"error: [BAL_CONFIG_VAR_MYORG_MOD_X= 123 ] configurable variable 'x' is expected " +
Expand Down

0 comments on commit 3a830ae

Please sign in to comment.