BundleEventData { public CompositeData toCompositeData() { CompositeData result = null; Map<String, Object> items = new HashMap<String, Object>(); items.put(IDENTIFIER, this.bundleId); items.put(SYMBOLIC_NAME, this.bundleSymbolicName); items.put(LOCATION, this.location); items.put(EVENT, this.eventType); try { result = new CompositeDataSupport(BUNDLE_EVENT_TYPE, items); } catch (OpenDataException e) { throw new IllegalStateException("Failed to create CompositeData for BundleEvent for Bundle [" + this.bundleId + "]", e); } return result; } private  BundleEventData();  BundleEventData(BundleEvent bundleEvent); CompositeData toCompositeData(); static BundleEventData from(CompositeData compositeData); long getBundleId(); String getLocation(); String getBundleSymbolicName(); int getEventType();  }
@Test public void testToCompositeData() throws Exception { BundleEvent event = mock(BundleEvent.class); Bundle bundle = mock(Bundle.class); when(event.getBundle()).thenReturn(bundle); when(bundle.getSymbolicName()).thenReturn("test"); when(bundle.getBundleId()).thenReturn(new Long(4)); when(bundle.getLocation()).thenReturn("location"); when(event.getType()).thenReturn(BundleEvent.INSTALLED); BundleEventData eventData = new BundleEventData(event); CompositeData eventCompositeData = eventData.toCompositeData(); assertEquals(new Long(4), (Long) eventCompositeData.get(IDENTIFIER)); assertEquals("test", (String) eventCompositeData.get(SYMBOLIC_NAME)); assertEquals(new Integer(BundleEvent.INSTALLED), (Integer) eventCompositeData.get(EVENT)); assertEquals("location", (String) eventCompositeData.get(LOCATION)); }