Event { public EventResource getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { EventResourceBuilder edb = new EventResourceBuilder(); edb.dataFields.add(new Metadata("Error", "null event data or event-class does not match event-data")); return edb.build(); } EventResourceBuilder edb = new EventResourceBuilder(); edb.setTimeStamp(timeMs); edb.setThreadId(threadId); edb.setThreadName(threadName); edb.setModuleEventName(moduleEventName); edb.setEventInstanceId(eventInstanceId); edb.setAcked(acked); customFormat(eventClass, eventData, edb); return edb.build(); } Event(long timeMs, long threadId, String threadName,
                 Object eventData, long eventInstanceId); long getTimeMs(); long getThreadId(); String getThreadName(); Object geteventData(); long getEventInstanceId(); boolean isAcked(); void setAcked(boolean acked); @Override String toString(); EventResource getFormattedEvent(Class<?> eventClass,
                                           String moduleEventName);  }
@Test public void testIncorrectAnnotation() { Event e = new Event(1L, 32, "test", new LakeEvent(199), 11L); assertTrue(e.getFormattedEvent(LakeEvent.class, "test").getDataFields() .contains(new Metadata("Error", "java.lang.Integer cannot be cast to org.projectfloodlight.openflow.types.DatapathId"))); Event e2 = new Event(1L, 32, "test", new LakeEvent2(199), 12L); assertTrue(e2.getFormattedEvent(LakeEvent2.class, "test").getDataFields() .contains(new Metadata("Error", "java.lang.Integer cannot be cast to java.lang.Long"))); }