ServiceEventData { public static ServiceEventData from(CompositeData compositeData) throws IllegalArgumentException { ServiceEventData serviceEventData = new ServiceEventData(); if ( compositeData == null ) { throw new IllegalArgumentException("Argument compositeData cannot be null"); } if (!compositeData.getCompositeType().equals(SERVICE_EVENT_TYPE)) { throw new IllegalArgumentException("Invalid CompositeType [" + compositeData.getCompositeType() + "]"); } serviceEventData.serviceId = (Long) compositeData.get(IDENTIFIER); serviceEventData.serviceInterfaces = (String[]) compositeData.get(OBJECT_CLASS); serviceEventData.bundleId = (Long) compositeData.get(BUNDLE_IDENTIFIER); serviceEventData.bundleLocation = (String) compositeData.get(BUNDLE_LOCATION); serviceEventData.bundleSymbolicName = (String) compositeData.get(BUNDLE_SYMBOLIC_NAME); serviceEventData.eventType = (Integer) compositeData.get(EVENT); return serviceEventData; } 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 testFrom() throws Exception { Map<String, Object> items = new HashMap<String, Object>(); items.put(IDENTIFIER, new Long(7)); items.put(BUNDLE_IDENTIFIER, new Long(67)); items.put(BUNDLE_LOCATION, "string"); items.put(BUNDLE_SYMBOLIC_NAME, "test"); items.put(OBJECT_CLASS, new String[] {"org.apache.aries.jmx.Mock" }); items.put(EVENT, ServiceEvent.MODIFIED); CompositeData compositeData = new CompositeDataSupport(SERVICE_EVENT_TYPE, items); ServiceEventData event = ServiceEventData.from(compositeData); assertEquals(7, event.getServiceId()); assertEquals(67, event.getBundleId()); assertArrayEquals(new String[] {"org.apache.aries.jmx.Mock" }, event.getServiceInterfaces()); assertEquals("test", event.getBundleSymbolicName()); assertEquals("string", event.getBundleLocation()); assertEquals(ServiceEvent.MODIFIED, event.getEventType()); }