ServiceEventData { public CompositeData toCompositeData() { CompositeData result = null; Map<String, Object> items = new HashMap<String, Object>(); items.put(IDENTIFIER, this.serviceId); items.put(OBJECT_CLASS, this.serviceInterfaces); items.put(BUNDLE_IDENTIFIER, this.bundleId); items.put(BUNDLE_LOCATION, this.bundleLocation); items.put(BUNDLE_SYMBOLIC_NAME, this.bundleSymbolicName); items.put(EVENT, this.eventType); try { result = new CompositeDataSupport(SERVICE_EVENT_TYPE, items); } catch (OpenDataException e) { throw new IllegalStateException("Failed to create CompositeData for ServiceEvent for Service [" + this.serviceId + "]", e); } return result; } private  ServiceEventData();  ServiceEventData(ServiceEvent serviceEvent); CompositeData toCompositeData(); static ServiceEventData from(CompositeData compositeData); long getServiceId(); String[] getServiceInterfaces(); long getBundleId(); String getBundleLocation(); String getBundleSymbolicName(); int getEventType();  }
@Test public void testToCompositeData() throws Exception { ServiceEvent event = mock(ServiceEvent.class); ServiceReference reference = mock(ServiceReference.class); Bundle bundle = mock(Bundle.class); when(event.getType()).thenReturn(ServiceEvent.REGISTERED); when(event.getServiceReference()).thenReturn(reference); when(reference.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(44)); when(reference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] {"org.apache.aries.jmx.Mock"}); when(reference.getBundle()).thenReturn(bundle); when(bundle.getBundleId()).thenReturn(new Long(1)); when(bundle.getLocation()).thenReturn("string"); when(bundle.getSymbolicName()).thenReturn("org.apache.aries.jmx.core"); ServiceEventData eventData = new ServiceEventData(event); CompositeData data = eventData.toCompositeData(); assertEquals(new Long(44), data.get(IDENTIFIER)); assertEquals(new Long(1), data.get(BUNDLE_IDENTIFIER)); assertEquals("string", data.get(BUNDLE_LOCATION)); assertEquals("org.apache.aries.jmx.core", data.get(BUNDLE_SYMBOLIC_NAME)); assertArrayEquals(new String[] {"org.apache.aries.jmx.Mock" }, (String[]) data.get(OBJECT_CLASS)); assertEquals(ServiceEvent.REGISTERED, data.get(EVENT)); }