### Question:
SagaDefinition { @SneakyThrows public String toJson() { return new ObjectMapper().writeValueAsString(this); }  @SneakyThrows String toJson();  }### Answer:
@Test public void assertToJson() { SagaDefinition sagaDefinition = new SagaDefinition(RecoveryPolicy.SAGA_BACKWARD_RECOVERY_POLICY, sagaRequests); String actual = sagaDefinition.toJson(); String expected = "{\"policy\":\"BackwardRecovery\",\"requests\":[{\"id\":\"id\",\"datasource\":\"ds\",\"type\":\"sql\",\"transaction\":{\"sql\":null,\"params\":[]," + "\"retries\":0},\"compensation\":{\"sql\":null,\"params\":[],\"retries\":0},\"parents\":[],\"failRetryDelayMilliseconds\":10}]}"; assertThat(actual, is(expected)); }