Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ public static ConfigFile getConfigFile(String namespace, ConfigFileFormat config
return s_instance.getManager().getConfigFile(namespace, configFileFormat);
}

/**
* Get the config file instance for the appId and namespace.
*
* @param appId the appId of the config
* @param namespace the namespace of the config without file extension, e.g. "application"
* @param configFileFormat the config file format
* @return config file instance
*/
public static ConfigFile getConfigFile(String appId, String namespace,
ConfigFileFormat configFileFormat) {
return s_instance.getManager().getConfigFile(appId, namespace, configFileFormat);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

public static ConfigMonitor getConfigMonitor(){
return s_instance.getMonitor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ PropertiesCompatibleFileConfigRepository createPropertiesCompatibleFileConfigRep
String appId, String namespace, ConfigFileFormat format) {
String actualNamespaceName = trimNamespaceFormat(namespace, format);
PropertiesCompatibleConfigFile configFile = (PropertiesCompatibleConfigFile) ConfigService
.getConfigFile(actualNamespaceName, format);
.getConfigFile(appId, actualNamespaceName, format);

return new PropertiesCompatibleFileConfigRepository(configFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,34 @@ public void testMockConfigFactoryForConfigFile() throws Exception {
assertEquals(someNamespaceFileName + ":" + someConfigFileFormat.getValue(), configFile.getContent());
}

@Test
public void testGetConfigWithCustomAppId() throws Exception {
String customAppId = "customAppId";
String someNamespace = "mock";
String someKey = "someKey";
MockInjector.setInstance(ConfigFactory.class, someNamespace, new MockConfigFactory());

Config config = ConfigService.getConfig(customAppId, someNamespace);

assertEquals(customAppId + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + someNamespace + ":" + someKey,
config.getProperty(someKey, null));
}

@Test
public void testGetConfigFileWithCustomAppId() throws Exception {
String customAppId = "customAppId";
String someNamespace = "mock";
ConfigFileFormat someConfigFileFormat = ConfigFileFormat.YML;
String someNamespaceFileName =
String.format("%s.%s", someNamespace, someConfigFileFormat.getValue());
MockInjector.setInstance(ConfigFactory.class, someNamespaceFileName, new MockConfigFactory());

ConfigFile configFile = ConfigService.getConfigFile(customAppId, someNamespace, someConfigFileFormat);

assertEquals(customAppId, configFile.getAppId());
assertEquals(someNamespaceFileName, configFile.getNamespace());
}

private static class MockConfig extends AbstractConfig {
private final String m_appId;
private final String m_namespace;
Expand Down
Loading