@Test
void testWhenPersistingAValidDocument() {

    final DocumentArchivingContext documentArchivingContext = createDocumentArchivingContext();
    final DocumentCreationContext documentCreationContext = DocumentCreationContext.builder()
            .build();
    when(documentCreationContextFactory.newContext(documentArchivingContext))
            .thenReturn(Mono.just(documentCreationContext));
    final DocumentEntity documentEntity = DocumentEntity.builder()
            .build();
    when(documentEntityFactory.newDocumentEntity(documentCreationContext))
            .thenReturn(Mono.just(documentEntity));
    final Mono<DocumentEntity> result = underTest.archiveDocument(documentArchivingContext);
    StepVerifier.create(result)
            .consumeNextWith(documentEntity1 -> assertThat(documentEntity1, is(documentEntity)))
            .verifyComplete();
    verify(vaultDocumentStorage).persistDocument(eq(documentEntity), documentContent.capture());
    assertThat(documentContent.getValue(), is(CONTENT));
    verify(documentCreationContextFactory).newContext(documentArchivingContext);
    verify(documentEntityFactory).newDocumentEntity(documentCreationContext);
}