@Test void testReadLegacyInstance() { JobDataMap legacyJobDataMap = mock(JobDataMap.class); when(legacyJobDataMap.get("org.axonframework.domain.EventMessage")).thenAnswer( i -> { try (ObjectInputStream objectInputStream = new ObjectInputStream(getClass().getClassLoader().getResourceAsStream("serialized.object"))) { return objectInputStream.readObject(); } } ); Object event = testSubject.fromJobData(legacyJobDataMap); verify(legacyJobDataMap).get("org.axonframework.domain.EventMessage"); assertTrue(event instanceof EventMessage); EventMessage<?> eventMessage = (EventMessage<?>) event; assertEquals("this is the payload", eventMessage.getPayload()); assertEquals("value", eventMessage.getMetaData().get("key")); assertEquals(1, eventMessage.getMetaData().size()); }
@Override public Object fromJobData(JobDataMap jobData) { Object message = delegate.fromJobData(jobData); if (message == null) { message = jobData.get(LEGACY_EVENT_KEY); } return message; }
LegacyAwareJobDataBinder implements EventJobDataBinder { @Override public Object fromJobData(JobDataMap jobData) { Object message = delegate.fromJobData(jobData); if (message == null) { message = jobData.get(LEGACY_EVENT_KEY); } return message; } }
LegacyAwareJobDataBinder implements EventJobDataBinder { @Override public Object fromJobData(JobDataMap jobData) { Object message = delegate.fromJobData(jobData); if (message == null) { message = jobData.get(LEGACY_EVENT_KEY); } return message; } LegacyAwareJobDataBinder();  LegacyAwareJobDataBinder(EventJobDataBinder delegate); }
LegacyAwareJobDataBinder implements EventJobDataBinder { @Override public Object fromJobData(JobDataMap jobData) { Object message = delegate.fromJobData(jobData); if (message == null) { message = jobData.get(LEGACY_EVENT_KEY); } return message; } LegacyAwareJobDataBinder();  LegacyAwareJobDataBinder(EventJobDataBinder delegate); @Override JobDataMap toJobData(Object eventMessage); @Override Object fromJobData(JobDataMap jobData); }
LegacyAwareJobDataBinder implements EventJobDataBinder { @Override public Object fromJobData(JobDataMap jobData) { Object message = delegate.fromJobData(jobData); if (message == null) { message = jobData.get(LEGACY_EVENT_KEY); } return message; } LegacyAwareJobDataBinder();  LegacyAwareJobDataBinder(EventJobDataBinder delegate); @Override JobDataMap toJobData(Object eventMessage); @Override Object fromJobData(JobDataMap jobData);  }