@Test public void testUpdated() throws Exception { Dictionary<String, String> properties = new Hashtable<>(); properties.put(WaveformServiceImpl.WAVEFORM_COLOR_CONFIG_KEY, "blue green 0x2A2A2A 323232CC"); properties.put(WaveformServiceImpl.WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY, "false"); properties.put(WaveformServiceImpl.WAVEFORM_SCALE_CONFIG_KEY, "lin"); ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class); EasyMock.expect(serviceRegistry.getHostRegistrations()).andReturn(new ArrayList()); EasyMock.replay(serviceRegistry); WaveformServiceImpl instance = new WaveformServiceImpl(); instance.setServiceRegistry(serviceRegistry); try { instance.updated(properties); } catch (Exception e) { fail("updated method should not throw any exceptions but has thrown: " + ExceptionUtils.getStackTrace(e)); } }
@Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties == null) { return; } logger.debug("Configuring the waveform service"); waveformJobLoad = LoadUtil.getConfiguredLoadValue(properties, WAVEFORM_JOB_LOAD_CONFIG_KEY, DEFAULT_WAVEFORM_JOB_LOAD, serviceRegistry); Object val = properties.get(WAVEFORM_SCALE_CONFIG_KEY); if (val != null) { if (StringUtils.isNotEmpty((String) val)) { if (!"lin".equals(val) && !"log".equals(val)) { logger.warn("Waveform scale configuration value '{}' is not in set of predefined values (lin, log). " + "The waveform image extraction job may fail.", val); } waveformScale = (String) val; } } val = properties.get(WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY); if (val != null) { waveformSplitChannels = Boolean.parseBoolean((String) val); } val = properties.get(WAVEFORM_COLOR_CONFIG_KEY); if (val != null && StringUtils.isNotEmpty((String) val)) { String colorValue = (String) val; if (StringUtils.isNotEmpty(colorValue) && StringUtils.isNotBlank(colorValue)) { waveformColor = StringUtils.split(colorValue, ", |:;"); } } val = properties.get(WAVEFORM_FILTER_PRE_CONFIG_KEY); if (val != null) { waveformFilterPre = StringUtils.trimToNull((String) val); } else { waveformFilterPre = null; } val = properties.get(WAVEFORM_FILTER_POST_CONFIG_KEY); if (val != null) { waveformFilterPost = StringUtils.trimToNull((String) val); } else { waveformFilterPost = null; } }
WaveformServiceImpl extends AbstractJobProducer implements WaveformService, ManagedService { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties == null) { return; } logger.debug("Configuring the waveform service"); waveformJobLoad = LoadUtil.getConfiguredLoadValue(properties, WAVEFORM_JOB_LOAD_CONFIG_KEY, DEFAULT_WAVEFORM_JOB_LOAD, serviceRegistry); Object val = properties.get(WAVEFORM_SCALE_CONFIG_KEY); if (val != null) { if (StringUtils.isNotEmpty((String) val)) { if (!"lin".equals(val) && !"log".equals(val)) { logger.warn("Waveform scale configuration value '{}' is not in set of predefined values (lin, log). " + "The waveform image extraction job may fail.", val); } waveformScale = (String) val; } } val = properties.get(WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY); if (val != null) { waveformSplitChannels = Boolean.parseBoolean((String) val); } val = properties.get(WAVEFORM_COLOR_CONFIG_KEY); if (val != null && StringUtils.isNotEmpty((String) val)) { String colorValue = (String) val; if (StringUtils.isNotEmpty(colorValue) && StringUtils.isNotBlank(colorValue)) { waveformColor = StringUtils.split(colorValue, ", |:;"); } } val = properties.get(WAVEFORM_FILTER_PRE_CONFIG_KEY); if (val != null) { waveformFilterPre = StringUtils.trimToNull((String) val); } else { waveformFilterPre = null; } val = properties.get(WAVEFORM_FILTER_POST_CONFIG_KEY); if (val != null) { waveformFilterPost = StringUtils.trimToNull((String) val); } else { waveformFilterPost = null; } } }
WaveformServiceImpl extends AbstractJobProducer implements WaveformService, ManagedService { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties == null) { return; } logger.debug("Configuring the waveform service"); waveformJobLoad = LoadUtil.getConfiguredLoadValue(properties, WAVEFORM_JOB_LOAD_CONFIG_KEY, DEFAULT_WAVEFORM_JOB_LOAD, serviceRegistry); Object val = properties.get(WAVEFORM_SCALE_CONFIG_KEY); if (val != null) { if (StringUtils.isNotEmpty((String) val)) { if (!"lin".equals(val) && !"log".equals(val)) { logger.warn("Waveform scale configuration value '{}' is not in set of predefined values (lin, log). " + "The waveform image extraction job may fail.", val); } waveformScale = (String) val; } } val = properties.get(WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY); if (val != null) { waveformSplitChannels = Boolean.parseBoolean((String) val); } val = properties.get(WAVEFORM_COLOR_CONFIG_KEY); if (val != null && StringUtils.isNotEmpty((String) val)) { String colorValue = (String) val; if (StringUtils.isNotEmpty(colorValue) && StringUtils.isNotBlank(colorValue)) { waveformColor = StringUtils.split(colorValue, ", |:;"); } } val = properties.get(WAVEFORM_FILTER_PRE_CONFIG_KEY); if (val != null) { waveformFilterPre = StringUtils.trimToNull((String) val); } else { waveformFilterPre = null; } val = properties.get(WAVEFORM_FILTER_POST_CONFIG_KEY); if (val != null) { waveformFilterPost = StringUtils.trimToNull((String) val); } else { waveformFilterPost = null; } } WaveformServiceImpl(); }
WaveformServiceImpl extends AbstractJobProducer implements WaveformService, ManagedService { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties == null) { return; } logger.debug("Configuring the waveform service"); waveformJobLoad = LoadUtil.getConfiguredLoadValue(properties, WAVEFORM_JOB_LOAD_CONFIG_KEY, DEFAULT_WAVEFORM_JOB_LOAD, serviceRegistry); Object val = properties.get(WAVEFORM_SCALE_CONFIG_KEY); if (val != null) { if (StringUtils.isNotEmpty((String) val)) { if (!"lin".equals(val) && !"log".equals(val)) { logger.warn("Waveform scale configuration value '{}' is not in set of predefined values (lin, log). " + "The waveform image extraction job may fail.", val); } waveformScale = (String) val; } } val = properties.get(WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY); if (val != null) { waveformSplitChannels = Boolean.parseBoolean((String) val); } val = properties.get(WAVEFORM_COLOR_CONFIG_KEY); if (val != null && StringUtils.isNotEmpty((String) val)) { String colorValue = (String) val; if (StringUtils.isNotEmpty(colorValue) && StringUtils.isNotBlank(colorValue)) { waveformColor = StringUtils.split(colorValue, ", |:;"); } } val = properties.get(WAVEFORM_FILTER_PRE_CONFIG_KEY); if (val != null) { waveformFilterPre = StringUtils.trimToNull((String) val); } else { waveformFilterPre = null; } val = properties.get(WAVEFORM_FILTER_POST_CONFIG_KEY); if (val != null) { waveformFilterPost = StringUtils.trimToNull((String) val); } else { waveformFilterPost = null; } } WaveformServiceImpl(); @Override void activate(ComponentContext cc); @Override void updated(Dictionary<String, ?> properties); @Override Job createWaveformImage(Track sourceTrack, int pixelsPerMinute, int minWidth, int maxWidth, int height, String color); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setWorkspace(Workspace workspace); }
WaveformServiceImpl extends AbstractJobProducer implements WaveformService, ManagedService { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties == null) { return; } logger.debug("Configuring the waveform service"); waveformJobLoad = LoadUtil.getConfiguredLoadValue(properties, WAVEFORM_JOB_LOAD_CONFIG_KEY, DEFAULT_WAVEFORM_JOB_LOAD, serviceRegistry); Object val = properties.get(WAVEFORM_SCALE_CONFIG_KEY); if (val != null) { if (StringUtils.isNotEmpty((String) val)) { if (!"lin".equals(val) && !"log".equals(val)) { logger.warn("Waveform scale configuration value '{}' is not in set of predefined values (lin, log). " + "The waveform image extraction job may fail.", val); } waveformScale = (String) val; } } val = properties.get(WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY); if (val != null) { waveformSplitChannels = Boolean.parseBoolean((String) val); } val = properties.get(WAVEFORM_COLOR_CONFIG_KEY); if (val != null && StringUtils.isNotEmpty((String) val)) { String colorValue = (String) val; if (StringUtils.isNotEmpty(colorValue) && StringUtils.isNotBlank(colorValue)) { waveformColor = StringUtils.split(colorValue, ", |:;"); } } val = properties.get(WAVEFORM_FILTER_PRE_CONFIG_KEY); if (val != null) { waveformFilterPre = StringUtils.trimToNull((String) val); } else { waveformFilterPre = null; } val = properties.get(WAVEFORM_FILTER_POST_CONFIG_KEY); if (val != null) { waveformFilterPost = StringUtils.trimToNull((String) val); } else { waveformFilterPost = null; } } WaveformServiceImpl(); @Override void activate(ComponentContext cc); @Override void updated(Dictionary<String, ?> properties); @Override Job createWaveformImage(Track sourceTrack, int pixelsPerMinute, int minWidth, int maxWidth, int height, String color); void setServiceRegistry(ServiceRegistry serviceRegistry); void setSecurityService(SecurityService securityService); void setUserDirectoryService(UserDirectoryService userDirectoryService); void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); void setWorkspace(Workspace workspace); static final String WAVEFORM_JOB_LOAD_CONFIG_KEY; static final float DEFAULT_WAVEFORM_JOB_LOAD; static final String FFMPEG_BINARY_CONFIG_KEY; static final String DEFAULT_FFMPEG_BINARY; static final String DEFAULT_WAVEFORM_SCALE; static final String WAVEFORM_SCALE_CONFIG_KEY; static final boolean DEFAULT_WAVEFORM_SPLIT_CHANNELS; static final String WAVEFORM_SPLIT_CHANNELS_CONFIG_KEY; static final String[] DEFAULT_WAVEFORM_COLOR; static final String WAVEFORM_COLOR_CONFIG_KEY; static final String DEFAULT_WAVEFORM_FILTER_PRE; static final String WAVEFORM_FILTER_PRE_CONFIG_KEY; static final String DEFAULT_WAVEFORM_FILTER_POST; static final String WAVEFORM_FILTER_POST_CONFIG_KEY; static final String COLLECTION_ID; }