    @Test
    public void shouldRecordAndPublishWithPreviousEventKeyAndPublishedEventAndConcurrencyResolverFactory() throws JsonProcessingException, EventStoreException, ConcurrentEventException {

        mockCommon(intermediateEvent);

        EventKey previousEntityEventKey = new EventKey();
        ConcurrencyResolver concurrencyResolver = mock(ConcurrencyResolver.class);
        Function<EntityEvent, ConcurrencyResolver<ConcurrentEventException>> factory = entityEvent -> concurrencyResolver;

        EventKey actual = compositeRepository.recordAndPublish(previousEntityEventKey, intermediateEvent, factory);

        assertCommon(intermediateEvent);

        assertThat(actual, equalTo(eventKey));
        assertThat(previousEventKeyCaptor.getValue().isPresent(), equalTo(true));
        assertThat(previousEventKeyCaptor.getValue().get(), equalTo(previousEntityEventKey));
        assertThat(concurrencyResolverFactoryCaptor.getValue(), equalTo(factory));
    }