@Test public void testMergedHistoryEventIsConverted() { Map<String, Object> mergedHistoryMap = (Map<String, Object>) historyList.get(1); assertEquals( "Merged history event should have a type of " + HistoryEvents.MERGED_TYPE, HistoryEvents.MERGED_TYPE, mergedHistoryMap.get(fields.getHistoryType())); } }
private Map<String, Object> createEventMap(HistoryEvent historyEvent) { Map<String, Object> linkedHistoryMap = new IgnoreEmptyKeyMapDecorator<>(new LinkedHashMap<>()); if (historyEvent.getRecordable().getInternalId() != entityInternalId) { // Only save the internal id as a reference to entities which aren't this one. linkedHistoryMap.put( fields.getHistoryRecordable(), historyEvent.getRecordable().getInternalId()); } linkedHistoryMap.put(fields.getHistoryAction(), historyEvent.getAction()); linkedHistoryMap.put(fields.getHistoryType(), historyEvent.getEventType()); linkedHistoryMap.put(fields.getHistoryParameters(), historyEvent.getParameters()); linkedHistoryMap.put(fields.getHistoryReferrer(), historyEvent.getReferrer()); linkedHistoryMap.put(fields.getHistoryTimestamp(), historyEvent.getTimestamp()); return linkedHistoryMap; }
@Test public void testHistoryEventIsConvertedToMap() { Map<String, Object> nonMergedHistoryMap = (Map<String, Object>) historyList.get(0); Map<String, String> nonMergedHistoryParameters = (Map<String, String>) nonMergedHistoryMap.get(fields.getHistoryParameters()); assertEquals( "Linked history map should have an action", ACTION, nonMergedHistoryMap.get(fields.getHistoryAction())); assertEquals( "Linked history map should have an event type", EVENT_TYPE, nonMergedHistoryMap.get(fields.getHistoryType())); assertEquals( "History parameters should have kwy1-value1", "value1", nonMergedHistoryParameters.get("key1")); assertEquals( "Linked history map should have referrer", REFERRER, nonMergedHistoryMap.get(fields.getHistoryReferrer())); assertEquals( "Linked history map should have timestamp", currentTimeMillis, nonMergedHistoryMap.get(fields.getHistoryTimestamp())); }