// Path: nakadi-producer/src/test/java/org/zalando/nakadiproducer/util/Fixture.java
// public static final String PUBLISHER_EVENT_TYPE = "wholesale.some-publisher-change-event";
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/flowid/FlowIdComponent.java
// public interface FlowIdComponent {
//     String getXFlowIdValue();
// 
//     void startTraceIfNoneExists();
// }
// 
// Path: nakadi-producer/src/test/java/org/zalando/nakadiproducer/util/Fixture.java
// public class Fixture {
// 
//     public static final String PUBLISHER_EVENT_TYPE = "wholesale.some-publisher-change-event";
//     public static final String PUBLISHER_DATA_TYPE = "nakadi:some-publisher";
// 
//     public static MockPayload mockPayload(Integer id, String code, Boolean isActive,
//                                           MockPayload.SubClass more, List<MockPayload.SubListItem> items) {
//         return MockPayload.builder()
//                 .id(id)
//                 .code(code)
//                 .isActive(isActive)
//                 .more(more)
//                 .items(items)
//                 .build();
//     }
// 
//     public static MockPayload mockPayload(Integer id, String code) {
//         return mockPayload(id, code, true, mockSubClass(), mockSubList(3));
//     }
// 
//     public static List<Snapshot> mockSnapshotList(Integer size) {
//         final List<Snapshot> list = new ArrayList<>();
//         for (int i = 0; i < size; i++) {
//             list.add(new Snapshot(i, PUBLISHER_DATA_TYPE, mockPayload(i + 1, "code" + i, true,
//                     mockSubClass("some info " + i), mockSubList(3, "some detail for code" + i))));
//         }
//         return list;
//     }
// 
//     public static MockPayload.SubClass mockSubClass(String info) {
//         return MockPayload.SubClass.builder().info(info).build();
//     }
// 
//     private static MockPayload.SubClass mockSubClass() {
//         return mockSubClass("Info something");
//     }
// 
//     private static MockPayload.SubListItem mockSubListItem(String detail) {
//         return MockPayload.SubListItem.builder().detail(detail).build();
//     }
// 
//     public static List<MockPayload.SubListItem> mockSubList(Integer size, String detail) {
//         final List<MockPayload.SubListItem> items = new ArrayList<>();
//         for (int i = 0; i < size; i++) {
//             items.add(mockSubListItem(detail + i));
//         }
//         return items;
//     }
// 
//     private static List<MockPayload.SubListItem> mockSubList(Integer size) {
//         return mockSubList(size, "Detail something ");
//     }
// 
// }
// 
// Path: nakadi-producer-spring-boot-starter/src/test/java/org/zalando/nakadiproducer/util/MockPayload.java
// @ToString
// @Getter
// @Setter
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder(toBuilder = true)
// public class MockPayload {
//     private Integer id;
// 
//     private String code;
// 
//     @Builder.Default
//     private boolean isActive = true;
// 
//     private SubClass more;
// 
//     private List<SubListItem> items;
// 
//     @Builder(toBuilder = true)
//     @Getter
//     @Setter
//     @ToString
//     @AllArgsConstructor
//     @NoArgsConstructor
//     public static class SubClass {
//         private String info;
//     }
// 
//     @Builder(toBuilder = true)
//     @Getter
//     @Setter
//     @ToString
//     @AllArgsConstructor
//     @NoArgsConstructor
//     public static class SubListItem {
//         private String detail;
//     }
// }


import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.zalando.nakadiproducer.util.Fixture.PUBLISHER_EVENT_TYPE;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.zalando.nakadiproducer.flowid.FlowIdComponent;
import org.zalando.nakadiproducer.util.Fixture;
import org.zalando.nakadiproducer.util.MockPayload;
import com.fasterxml.jackson.databind.ObjectMapper;
        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "U")));
        assertThat(eventLogCapture.getValue().getEventType(), is(PUBLISHER_EVENT_TYPE));
        assertThat(eventLogCapture.getValue().getFlowId(), is(TRACE_ID));
        assertThat(eventLogCapture.getValue().getLockedBy(), is(nullValue()));
        assertThat(eventLogCapture.getValue().getLockedUntil(), is(nullValue()));

    }

    @Test
    public void testFireDeleteEvent() throws Exception {

        eventLogWriter.fireDeleteEvent(PUBLISHER_EVENT_TYPE, PUBLISHER_DATA_TYPE, eventPayload);

        verify(eventLogRepository).persist(eventLogCapture.capture());

        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "D")));
        assertThat(eventLogCapture.getValue().getEventType(), is(PUBLISHER_EVENT_TYPE));
        assertThat(eventLogCapture.getValue().getFlowId(), is(TRACE_ID));
        assertThat(eventLogCapture.getValue().getLockedBy(), is(nullValue()));
        assertThat(eventLogCapture.getValue().getLockedUntil(), is(nullValue()));
    }

    @Test
    public void testFireSnapshotEvent() throws Exception {

        eventLogWriter.fireSnapshotEvent(PUBLISHER_EVENT_TYPE, PUBLISHER_DATA_TYPE, eventPayload);

        verify(eventLogRepository).persist(eventLogCapture.capture());

        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "S")));
// Path: nakadi-producer/src/test/java/org/zalando/nakadiproducer/util/Fixture.java
// public static final String PUBLISHER_EVENT_TYPE = "wholesale.some-publisher-change-event";
// 
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/flowid/FlowIdComponent.java
// public interface FlowIdComponent {
//     String getXFlowIdValue();
// 
//     void startTraceIfNoneExists();
// }
// 
// Path: nakadi-producer/src/test/java/org/zalando/nakadiproducer/util/Fixture.java
// public class Fixture {
// 
//     public static final String PUBLISHER_EVENT_TYPE = "wholesale.some-publisher-change-event";
//     public static final String PUBLISHER_DATA_TYPE = "nakadi:some-publisher";
// 
//     public static MockPayload mockPayload(Integer id, String code, Boolean isActive,
//                                           MockPayload.SubClass more, List<MockPayload.SubListItem> items) {
//         return MockPayload.builder()
//                 .id(id)
//                 .code(code)
//                 .isActive(isActive)
//                 .more(more)
//                 .items(items)
//                 .build();
//     }
// 
//     public static MockPayload mockPayload(Integer id, String code) {
//         return mockPayload(id, code, true, mockSubClass(), mockSubList(3));
//     }
// 
//     public static List<Snapshot> mockSnapshotList(Integer size) {
//         final List<Snapshot> list = new ArrayList<>();
//         for (int i = 0; i < size; i++) {
//             list.add(new Snapshot(i, PUBLISHER_DATA_TYPE, mockPayload(i + 1, "code" + i, true,
//                     mockSubClass("some info " + i), mockSubList(3, "some detail for code" + i))));
//         }
//         return list;
//     }
// 
//     public static MockPayload.SubClass mockSubClass(String info) {
//         return MockPayload.SubClass.builder().info(info).build();
//     }
// 
//     private static MockPayload.SubClass mockSubClass() {
//         return mockSubClass("Info something");
//     }
// 
//     private static MockPayload.SubListItem mockSubListItem(String detail) {
//         return MockPayload.SubListItem.builder().detail(detail).build();
//     }
// 
//     public static List<MockPayload.SubListItem> mockSubList(Integer size, String detail) {
//         final List<MockPayload.SubListItem> items = new ArrayList<>();
//         for (int i = 0; i < size; i++) {
//             items.add(mockSubListItem(detail + i));
//         }
//         return items;
//     }
// 
//     private static List<MockPayload.SubListItem> mockSubList(Integer size) {
//         return mockSubList(size, "Detail something ");
//     }
// 
// }
// 
// Path: nakadi-producer-spring-boot-starter/src/test/java/org/zalando/nakadiproducer/util/MockPayload.java
// @ToString
// @Getter
// @Setter
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder(toBuilder = true)
// public class MockPayload {
//     private Integer id;
// 
//     private String code;
// 
//     @Builder.Default
//     private boolean isActive = true;
// 
//     private SubClass more;
// 
//     private List<SubListItem> items;
// 
//     @Builder(toBuilder = true)
//     @Getter
//     @Setter
//     @ToString
//     @AllArgsConstructor
//     @NoArgsConstructor
//     public static class SubClass {
//         private String info;
//     }
// 
//     @Builder(toBuilder = true)
//     @Getter
//     @Setter
//     @ToString
//     @AllArgsConstructor
//     @NoArgsConstructor
//     public static class SubListItem {
//         private String detail;
//     }
// }


// Path: nakadi-producer/src/test/java/org/zalando/nakadiproducer/eventlog/impl/EventLogWriterTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.zalando.nakadiproducer.util.Fixture.PUBLISHER_EVENT_TYPE;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.zalando.nakadiproducer.flowid.FlowIdComponent;
import org.zalando.nakadiproducer.util.Fixture;
import org.zalando.nakadiproducer.util.MockPayload;
import com.fasterxml.jackson.databind.ObjectMapper;

        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "U")));
        assertThat(eventLogCapture.getValue().getEventType(), is(PUBLISHER_EVENT_TYPE));
        assertThat(eventLogCapture.getValue().getFlowId(), is(TRACE_ID));
        assertThat(eventLogCapture.getValue().getLockedBy(), is(nullValue()));
        assertThat(eventLogCapture.getValue().getLockedUntil(), is(nullValue()));

    }

    @Test
    public void testFireDeleteEvent() throws Exception {

        eventLogWriter.fireDeleteEvent(PUBLISHER_EVENT_TYPE, PUBLISHER_DATA_TYPE, eventPayload);

        verify(eventLogRepository).persist(eventLogCapture.capture());

        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "D")));
        assertThat(eventLogCapture.getValue().getEventType(), is(PUBLISHER_EVENT_TYPE));
        assertThat(eventLogCapture.getValue().getFlowId(), is(TRACE_ID));
        assertThat(eventLogCapture.getValue().getLockedBy(), is(nullValue()));
        assertThat(eventLogCapture.getValue().getLockedUntil(), is(nullValue()));
    }

    @Test
    public void testFireSnapshotEvent() throws Exception {

        eventLogWriter.fireSnapshotEvent(PUBLISHER_EVENT_TYPE, PUBLISHER_DATA_TYPE, eventPayload);

        verify(eventLogRepository).persist(eventLogCapture.capture());

        assertThat(eventLogCapture.getValue().getEventBodyData(), is(DATA_CHANGE_BODY_DATA.replace("{DATA_OP}", "S")));
        assertThat(eventLogCapture.getValue().getEventType(), is(PUBLISHER_EVENT_TYPE));