@Test
public void testCorrectConfigInjection() {
String key = "myKey";
Config config = ConfigFactory.parseMap(ImmutableMap.of(
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, TestFactory.NAME, "key1"), "value1",
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, TestFactory.NAME, "key2"), "value2",
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, TestFactory.NAME, GobblinScopeTypes.CONTAINER.name(), "key2"), "value2scope",
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, TestFactory.NAME, key, "key2"), "value2key",
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, TestFactory.NAME, GobblinScopeTypes.CONTAINER.name(), key, "key2"), "value2scopekey"
));
SharedResourcesBrokerImpl<GobblinScopeTypes> topBroker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(config,
GobblinScopeTypes.GLOBAL.defaultScopeInstance());
KeyedScopedConfigViewImpl<GobblinScopeTypes, TestResourceKey> configView =
topBroker.getConfigView(GobblinScopeTypes.CONTAINER, new TestResourceKey(key), TestFactory.NAME);
Assert.assertEquals(configView.getScope(), GobblinScopeTypes.CONTAINER);
Assert.assertEquals(configView.getKey().toConfigurationKey(), key);
Assert.assertEquals(configView.getKeyedConfig().getString("key2"), "value2key");
Assert.assertEquals(configView.getScopedConfig().getString("key2"), "value2scope");
Assert.assertEquals(configView.getKeyedScopedConfig().getString("key2"), "value2scopekey");
Assert.assertEquals(configView.getFactorySpecificConfig().getString("key1"), "value1");
Assert.assertEquals(configView.getFactorySpecificConfig().getString("key2"), "value2");
Assert.assertEquals(configView.getConfig().getString("key2"), "value2scopekey");
Assert.assertEquals(configView.getConfig().getString("key1"), "value1");
configView =
topBroker.getConfigView(GobblinScopeTypes.TASK, new TestResourceKey(key), TestFactory.NAME);
Assert.assertEquals(configView.getConfig().getString("key2"), "value2key");
}