CommitCompletedTransformer implements Function<NSQMessage, CommitCompletedEvent> { @Override public CommitCompletedEvent apply(NSQMessage nsqMessage) throws Exception { CommitCompleted payload = objectMapper.readValue(nsqMessage.getMessage(), CommitCompleted.class); LOGGER.debug("received an new CommitSuccesEvent with cid {}", payload.getHeader().getCorrelationId()); return new CommitCompletedEvent( payload.getHeader().getCorrelationId(), new EntryPointKeyVsctImpl( payload.getHeader().getApplication(), payload.getHeader().getPlatform() ) ); } CommitCompletedTransformer(ObjectMapper objectMapper); @Override CommitCompletedEvent apply(NSQMessage nsqMessage);  }
@Test public void should_transform_commit_completed_event_to_object() throws Exception { NSQMessage nsqMessage = mock(NSQMessage.class); when(nsqMessage.getMessage()).thenReturn(("" + "{" + " 'header':{" + " 'correlationId':'someCorrelationId'," + " 'application':'someApp'," + " 'platform':'somePlatform'" + " }" + "}").replaceAll("'", "\"").getBytes()); CommitCompletedEvent result = commitCompletedTransformer.apply(nsqMessage); assertThat(result).isNotNull(); assertThat(result.getCorrelationId()).isEqualTo("someCorrelationId"); assertThat(result.getKey().getID()).isEqualTo("someApp/somePlatform"); }