@Test void testNewContext() { final UUID id = UUID.randomUUID(); final byte[] content = {0, 1, 2, 3}; final DocumentArchivingContext documentArchivingContext = DocumentArchivingContext.builder() .id(id) .content(content) .contentLength(4) .source("unknown") .type(DocumentType.PDF) .versionNumber(123) .build(); when(checksumProvider.checksum(content)) .thenReturn(Mono.just("textchecksum")); when(compressionConfigurationProperties.getAlgorithm()) .thenReturn(DocumentCompression.GZIP); final Mono<DocumentCreationContext> result = underTest.newContext(documentArchivingContext); StepVerifier.create(result) .consumeNextWith(documentCreationContext -> { assertThat(documentCreationContext.getId(), is(id)); assertThat(documentCreationContext.getFileSize(), is(4L)); assertThat(documentCreationContext.getSource(), is("unknown")); assertThat(documentCreationContext.getType(), is(DocumentType.PDF)); assertThat(documentCreationContext.getChecksum(), is("textchecksum")); assertThat(documentCreationContext.getVersionNumber(), is(123)); assertThat(documentCreationContext.getCompression(), is(DocumentCompression.GZIP)); assertThat(documentCreationContext.getStatus(), is(DocumentStatus.DOWNLOADED)); }) .verifyComplete(); }
public Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext) { return Mono.just(documentArchivingContext) .flatMap(archivingContext -> checksumProvider.checksum(archivingContext.getContent())) .map(checksum -> DocumentCreationContext.builder() .id(documentArchivingContext.getId()) .vault(documentArchivingContext.getVault()) .type(documentArchivingContext.getType()) .status(DocumentStatus.DOWNLOADED) .source(documentArchivingContext.getSource()) .versionNumber(documentArchivingContext.getVersionNumber()) .compression(compressionConfigurationProperties.getAlgorithm()) .checksum(checksum) .fileSize(documentArchivingContext.getContentLength()) .build() ); }
DocumentCreationContextFactory { public Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext) { return Mono.just(documentArchivingContext) .flatMap(archivingContext -> checksumProvider.checksum(archivingContext.getContent())) .map(checksum -> DocumentCreationContext.builder() .id(documentArchivingContext.getId()) .vault(documentArchivingContext.getVault()) .type(documentArchivingContext.getType()) .status(DocumentStatus.DOWNLOADED) .source(documentArchivingContext.getSource()) .versionNumber(documentArchivingContext.getVersionNumber()) .compression(compressionConfigurationProperties.getAlgorithm()) .checksum(checksum) .fileSize(documentArchivingContext.getContentLength()) .build() ); } }
DocumentCreationContextFactory { public Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext) { return Mono.just(documentArchivingContext) .flatMap(archivingContext -> checksumProvider.checksum(archivingContext.getContent())) .map(checksum -> DocumentCreationContext.builder() .id(documentArchivingContext.getId()) .vault(documentArchivingContext.getVault()) .type(documentArchivingContext.getType()) .status(DocumentStatus.DOWNLOADED) .source(documentArchivingContext.getSource()) .versionNumber(documentArchivingContext.getVersionNumber()) .compression(compressionConfigurationProperties.getAlgorithm()) .checksum(checksum) .fileSize(documentArchivingContext.getContentLength()) .build() ); }  }
DocumentCreationContextFactory { public Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext) { return Mono.just(documentArchivingContext) .flatMap(archivingContext -> checksumProvider.checksum(archivingContext.getContent())) .map(checksum -> DocumentCreationContext.builder() .id(documentArchivingContext.getId()) .vault(documentArchivingContext.getVault()) .type(documentArchivingContext.getType()) .status(DocumentStatus.DOWNLOADED) .source(documentArchivingContext.getSource()) .versionNumber(documentArchivingContext.getVersionNumber()) .compression(compressionConfigurationProperties.getAlgorithm()) .checksum(checksum) .fileSize(documentArchivingContext.getContentLength()) .build() ); }  Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext); }
DocumentCreationContextFactory { public Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext) { return Mono.just(documentArchivingContext) .flatMap(archivingContext -> checksumProvider.checksum(archivingContext.getContent())) .map(checksum -> DocumentCreationContext.builder() .id(documentArchivingContext.getId()) .vault(documentArchivingContext.getVault()) .type(documentArchivingContext.getType()) .status(DocumentStatus.DOWNLOADED) .source(documentArchivingContext.getSource()) .versionNumber(documentArchivingContext.getVersionNumber()) .compression(compressionConfigurationProperties.getAlgorithm()) .checksum(checksum) .fileSize(documentArchivingContext.getContentLength()) .build() ); }  Mono<DocumentCreationContext> newContext(final DocumentArchivingContext documentArchivingContext);  }