@Test public void testIncorrectAnnotation() { Event e = new Event(1L, 32, "test", new LakeEvent(199)); assertEquals("java.lang.Integer cannot be cast to java.lang.Long", e.getFormattedEvent(LakeEvent.class, "test").get("Error")); Event e2 = new Event(1L, 32, "test", new LakeEvent2(199)); assertEquals("java.lang.Integer cannot be cast to java.lang.Long", e2.getFormattedEvent(LakeEvent2.class, "test").get("Error")); }
public Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { returnMap = new HashMap<String, String>(); returnMap.put("Error", "null event data or event-class does not match event-data"); return returnMap; } if (returnMap != null) return returnMap; returnMap = new HashMap<String, String>(); returnMap.put("Timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .format(timestamp)); returnMap.put("Thread Id", String.valueOf(threadId)); returnMap.put("Thread Name", String.valueOf(threadName)); customFormat(eventClass, eventData, returnMap); return returnMap; }
Event { public Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { returnMap = new HashMap<String, String>(); returnMap.put("Error", "null event data or event-class does not match event-data"); return returnMap; } if (returnMap != null) return returnMap; returnMap = new HashMap<String, String>(); returnMap.put("Timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .format(timestamp)); returnMap.put("Thread Id", String.valueOf(threadId)); returnMap.put("Thread Name", String.valueOf(threadName)); customFormat(eventClass, eventData, returnMap); return returnMap; } }
Event { public Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { returnMap = new HashMap<String, String>(); returnMap.put("Error", "null event data or event-class does not match event-data"); return returnMap; } if (returnMap != null) return returnMap; returnMap = new HashMap<String, String>(); returnMap.put("Timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .format(timestamp)); returnMap.put("Thread Id", String.valueOf(threadId)); returnMap.put("Thread Name", String.valueOf(threadName)); customFormat(eventClass, eventData, returnMap); return returnMap; } Event(long timestamp, long threadId, String threadName, Object eventData); }
Event { public Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { returnMap = new HashMap<String, String>(); returnMap.put("Error", "null event data or event-class does not match event-data"); return returnMap; } if (returnMap != null) return returnMap; returnMap = new HashMap<String, String>(); returnMap.put("Timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .format(timestamp)); returnMap.put("Thread Id", String.valueOf(threadId)); returnMap.put("Thread Name", String.valueOf(threadName)); customFormat(eventClass, eventData, returnMap); return returnMap; } Event(long timestamp, long threadId, String threadName, Object eventData); long getTimestamp(); void setTimestamp(long timestamp); long getThreadId(); void setThreadId(long threadId); String getThreadName(); void setThreadName(String threadName); Object geteventData(); void seteventData(Object eventData); @Override String toString(); Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName); }
Event { public Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName) { if (eventClass == null || !eventClass.equals(eventData.getClass())) { returnMap = new HashMap<String, String>(); returnMap.put("Error", "null event data or event-class does not match event-data"); return returnMap; } if (returnMap != null) return returnMap; returnMap = new HashMap<String, String>(); returnMap.put("Timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") .format(timestamp)); returnMap.put("Thread Id", String.valueOf(threadId)); returnMap.put("Thread Name", String.valueOf(threadName)); customFormat(eventClass, eventData, returnMap); return returnMap; } Event(long timestamp, long threadId, String threadName, Object eventData); long getTimestamp(); void setTimestamp(long timestamp); long getThreadId(); void setThreadId(long threadId); String getThreadName(); void setThreadName(String threadName); Object geteventData(); void seteventData(Object eventData); @Override String toString(); Map<String, String> getFormattedEvent(Class<?> eventClass, String moduleEventName);  }