@Test public void testConvertProperties() throws Exception { Bundle bundle = mock(Bundle.class); BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundle, getClass().getClassLoader()); TypeConverter typeConverter = mock(TypeConverter.class); when(typeConverter.convertTo(Integer.class, "2")).thenReturn(2); CamelContext camelContext = mock(CamelContext.class); when(camelContext.getApplicationContextClassLoader()).thenReturn(classLoader); when(camelContext.getTypeConverter()).thenReturn(typeConverter); OsgiComponent component = new OsgiComponent(); component.setCamelContext(camelContext); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.SERVICE_ID, 1L); props.put(Constants.SERVICE_RANKING, "2"); Map<String, Object> expected = new HashMap<String, Object>(); expected.put(Constants.SERVICE_ID, 1L); expected.put(Constants.SERVICE_RANKING, 2); HashMap<String, Object> actual = new HashMap<String, Object>(props); component.convertProperties(actual); assertThat(actual, equalTo(expected)); }
protected void convertProperties(Map<String, Object> props) { if (props.containsKey(Constants.SERVICE_ID)) { props.put(Constants.SERVICE_ID, convertValue(props.get(Constants.SERVICE_ID), Long.class)); } if (props.containsKey(Constants.SERVICE_RANKING)) { props.put(Constants.SERVICE_RANKING, convertValue(props.get(Constants.SERVICE_RANKING), Integer.class)); } }
OsgiComponent extends DefaultComponent { protected void convertProperties(Map<String, Object> props) { if (props.containsKey(Constants.SERVICE_ID)) { props.put(Constants.SERVICE_ID, convertValue(props.get(Constants.SERVICE_ID), Long.class)); } if (props.containsKey(Constants.SERVICE_RANKING)) { props.put(Constants.SERVICE_RANKING, convertValue(props.get(Constants.SERVICE_RANKING), Integer.class)); } } }
OsgiComponent extends DefaultComponent { protected void convertProperties(Map<String, Object> props) { if (props.containsKey(Constants.SERVICE_ID)) { props.put(Constants.SERVICE_ID, convertValue(props.get(Constants.SERVICE_ID), Long.class)); } if (props.containsKey(Constants.SERVICE_RANKING)) { props.put(Constants.SERVICE_RANKING, convertValue(props.get(Constants.SERVICE_RANKING), Integer.class)); } }  }
OsgiComponent extends DefaultComponent { protected void convertProperties(Map<String, Object> props) { if (props.containsKey(Constants.SERVICE_ID)) { props.put(Constants.SERVICE_ID, convertValue(props.get(Constants.SERVICE_ID), Long.class)); } if (props.containsKey(Constants.SERVICE_RANKING)) { props.put(Constants.SERVICE_RANKING, convertValue(props.get(Constants.SERVICE_RANKING), Integer.class)); } }   }
OsgiComponent extends DefaultComponent { protected void convertProperties(Map<String, Object> props) { if (props.containsKey(Constants.SERVICE_ID)) { props.put(Constants.SERVICE_ID, convertValue(props.get(Constants.SERVICE_ID), Long.class)); } if (props.containsKey(Constants.SERVICE_RANKING)) { props.put(Constants.SERVICE_RANKING, convertValue(props.get(Constants.SERVICE_RANKING), Integer.class)); } }    }