@Test public void properties() throws Exception { ServiceReference reference = mock(ServiceReference.class); ServiceModel model = new ServiceModel(reference); when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(20l); when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[]{List.class.getName()}); when(reference.getProperty("foo")).thenReturn("bar"); when(reference.getPropertyKeys()).thenReturn(new String[] { Constants.SERVICE_ID, Constants.OBJECTCLASS, "foo"}); assertThat(model.getProperties()) .containsEntry(Constants.SERVICE_ID, "20") .containsEntry(Constants.OBJECTCLASS, "[" + List.class.getName() + "]") .containsEntry("foo", "bar"); }
public Map<String, String> getProperties() { Map<String, String> map = new TreeMap<>(); for (String key : this.reference.getPropertyKeys()) { Object value = this.reference.getProperty(key); if (value.getClass().isArray()) { map.put(key, Arrays.toString((Object[]) value)); } else { map.put(key, value.toString()); } } return map; }
ServiceModel { public Map<String, String> getProperties() { Map<String, String> map = new TreeMap<>(); for (String key : this.reference.getPropertyKeys()) { Object value = this.reference.getProperty(key); if (value.getClass().isArray()) { map.put(key, Arrays.toString((Object[]) value)); } else { map.put(key, value.toString()); } } return map; } }
ServiceModel { public Map<String, String> getProperties() { Map<String, String> map = new TreeMap<>(); for (String key : this.reference.getPropertyKeys()) { Object value = this.reference.getProperty(key); if (value.getClass().isArray()) { map.put(key, Arrays.toString((Object[]) value)); } else { map.put(key, value.toString()); } } return map; } ServiceModel(ServiceReference reference); }
ServiceModel { public Map<String, String> getProperties() { Map<String, String> map = new TreeMap<>(); for (String key : this.reference.getPropertyKeys()) { Object value = this.reference.getProperty(key); if (value.getClass().isArray()) { map.put(key, Arrays.toString((Object[]) value)); } else { map.put(key, value.toString()); } } return map; } ServiceModel(ServiceReference reference); static List<ServiceModel> services(BundleContext context); String getInterfaces(); long getId(); String getProvidingBundle(); Map<String, String> getProperties(); }
ServiceModel { public Map<String, String> getProperties() { Map<String, String> map = new TreeMap<>(); for (String key : this.reference.getPropertyKeys()) { Object value = this.reference.getProperty(key); if (value.getClass().isArray()) { map.put(key, Arrays.toString((Object[]) value)); } else { map.put(key, value.toString()); } } return map; } ServiceModel(ServiceReference reference); static List<ServiceModel> services(BundleContext context); String getInterfaces(); long getId(); String getProvidingBundle(); Map<String, String> getProperties();  }