@@ -0,0 +1,1885 @@
+package com.rewedigital.examples.msintegration.productinformation.product;%0A%0Aimport com.rewedigital.examples.msintegration.productinformation.scheduling.ProductEventProcessingTask;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.util.concurrent.ListenableFuture;%0A%0Aimport java.time.ZonedDateTime;%0A%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class ProductEventProcessingTaskTest %7B%0A%0A    @Autowired%0A    private ProductEventProcessingTask task;%0A%0A    private ProductEventRepository repo;%0A    private ProductEventPublisher publisher;%0A%0A    private ProductEvent p1;%0A    private ProductEvent p2;%0A%0A    @Before%0A    public void setup() %7B%0A        repo = mock(ProductEventRepository.class);%0A        publisher = mock(ProductEventPublisher.class);%0A%0A        p1 = setupProductEvent(%221%22, 1L);%0A        p2 = setupProductEvent(%222%22, 1L);%0A        %0A        when(publisher.publish(any(ProductEvent.class))).thenReturn(mock(ListenableFuture.class));%0A%0A        task = new ProductEventProcessingTask(publisher, repo);%0A    %7D%0A%0A    private ProductEvent setupProductEvent(String id, long version) %7B%0A        ProductEvent p = new ProductEvent();%0A        p.setId(id);%0A        p.setKey(%22event1%22);%0A        p.setPayload(%22%7B%7D%22);%0A        p.setTime(ZonedDateTime.now());%0A        p.setType(%22product.created%22);%0A        p.setVersion(version);%0A        repo.save(p);%0A%0A        return p;%0A    %7D%0A%0A    @Test%0A    public void testProcessingNextSingleBatch() %7B%0A        when(repo.findFirstByOrderByTimeAsc()).thenReturn(p1);%0A        task.processNextMessageBatch();%0A%0A        when(repo.findFirstByOrderByTimeAsc()).thenReturn(p2);%0A        task.processNextMessageBatch();%0A%0A        when(repo.findFirstByOrderByTimeAsc()).thenReturn(null);%0A        task.processNextMessageBatch();%0A        verify(publisher, times(2)).publish(any(ProductEvent.class));%0A    %7D%0A%7D%0A

add ProductEventProcessingTest