use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.
the class ActionProviderRegistryProxy method bind.
public void bind(ServiceReference<MetacardTransformer> reference) {
LOGGER.info("New service registered [{}]", reference);
String transformerId = null;
if (reference.getProperty(Constants.SERVICE_ID) != null) {
transformerId = reference.getProperty(Constants.SERVICE_ID).toString();
// backwards compatibility
}
if (StringUtils.isBlank(transformerId) && reference.getProperty(Constants.SERVICE_SHORTNAME) != null) {
transformerId = reference.getProperty(Constants.SERVICE_SHORTNAME).toString();
}
if (StringUtils.isBlank(transformerId)) {
return;
}
String actionProviderId = ACTION_ID_PREFIX + transformerId;
List<String> attributeNames = getAttributeNames(reference);
ActionProvider provider = actionFactory.createActionProvider(actionProviderId, transformerId, attributeNames);
Dictionary<String, String> actionProviderProperties = new DictionaryMap<>();
actionProviderProperties.put(Constants.SERVICE_ID, actionProviderId);
ServiceRegistration actionServiceRegistration = getBundleContext().registerService(PROVIDER_INTERFACE_NAME, provider, actionProviderProperties);
LOGGER.info("Registered new {} [{}]", PROVIDER_INTERFACE_NAME, actionServiceRegistration);
actionProviderRegistry.put(reference, actionServiceRegistration);
}
use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.
the class UiConfigurationPropertiesFactoryTest method testProductNameDoesNotExist.
@Test
public void testProductNameDoesNotExist() throws IOException, InvalidSyntaxException {
DictionaryMap<String, Object> configProps = new DictionaryMap<>();
Configuration configuration = mock(Configuration.class);
Configuration[] configurations = { configuration };
when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
when(configuration.getProperties()).thenReturn(configProps);
UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
assertThat(props.getProductName(), is(""));
}
use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.
the class UiConfigurationPropertiesFactoryTest method testProductNameExists.
@Test
public void testProductNameExists() throws IOException, InvalidSyntaxException {
DictionaryMap<String, Object> configProps = new DictionaryMap<>();
Configuration configuration = mock(Configuration.class);
Configuration[] configurations = { configuration };
when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
when(configuration.getProperties()).thenReturn(configProps);
when(branding.getProductName()).thenReturn("Product Name");
UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
UiConfigurationPropertiesFactory.getInstance().setBranding(branding);
UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
assertThat(props.getProductName(), is("Product Name"));
}
use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.
the class UiConfigurationPropertiesFactoryTest method testInvalidTypeProperties.
@Test
public void testInvalidTypeProperties() throws IOException, InvalidSyntaxException {
DictionaryMap<String, Object> configProps = new DictionaryMap<>();
configProps.put("header", false);
configProps.put("footer", false);
configProps.put("color", false);
configProps.put("background", false);
configProps.put("systemUsageTitle", false);
configProps.put("systemUsageMessage", false);
configProps.put("systemUsageEnabled", "Unexpected text");
configProps.put("systemUsageOncePerSession", "Unexpected text");
Configuration configuration = mock(Configuration.class);
Configuration[] configurations = { configuration };
when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
when(configuration.getProperties()).thenReturn(configProps);
UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
assertAllBlankProps(props);
}
use of org.codice.ddf.configuration.DictionaryMap in project ddf by codice.
the class UiConfigurationPropertiesFactoryTest method testPropsCreatedProperly.
@Test
public void testPropsCreatedProperly() throws IOException, InvalidSyntaxException {
DictionaryMap<String, Object> configProps = new DictionaryMap<>();
configProps.put("header", "Test Header");
configProps.put("footer", "Test Footer");
configProps.put("color", "WHITE");
configProps.put("background", "RED");
configProps.put("systemUsageTitle", "Test Title");
configProps.put("systemUsageMessage", "Test Message");
configProps.put("systemUsageEnabled", true);
configProps.put("systemUsageOncePerSession", false);
Configuration configuration = mock(Configuration.class);
Configuration[] configurations = { configuration };
when(configurationAdmin.listConfigurations("(service.pid=ddf.platform.ui.config)")).thenReturn(configurations);
when(configurationAdmin.getConfiguration("ddf.platform.ui.config", null)).thenReturn(configuration);
when(configuration.getProperties()).thenReturn(configProps);
UiConfigurationPropertiesFactory.getInstance().setConfigurationAdmin(configurationAdmin);
UiConfigurationProperties props = UiConfigurationPropertiesFactory.getInstance().getProperties();
assertThat(props.getHeader(), is("Test Header"));
assertThat(props.getFooter(), is("Test Footer"));
assertThat(props.getColor(), is("WHITE"));
assertThat(props.getBackground(), is("RED"));
assertThat(props.getSystemUsageTitle(), is("Test Title"));
assertThat(props.getSystemUsageMessage(), is("Test Message"));
assertThat(props.getSystemUsageEnabled(), is(true));
assertThat(props.getSystemUsageOncePerSession(), is(false));
}
Aggregations