@Test void testIsValidDocumentWhenDocumentIsValid() { final StageLocation stageLocation = mock(StageLocation.class); when(stageLocationFactory.getLocation(DOCUMENT_ID.toString(), DOCUMENT_TYPE)) .thenReturn(Mono.just(stageLocation)); when(stageLocation.size()).thenReturn(Mono.just(MAX_FILE_SIZE_IN_BYTES - 1)); when(downloaderConfigurationProperties.getMaximumArchiveSize()).thenReturn(MAX_FILE_SIZE_IN_BYTES); final InputStream documentInputStream = mock(InputStream.class); when(stageLocation.openStream()).thenReturn(documentInputStream); when(documentDataParser.parseDocumentMetadata(DOCUMENT_ID, DOCUMENT_TYPE, documentInputStream)) .thenReturn( DocumentMetadata.builder() .build() ); final Mono<Boolean> result = underTest.isValidDocument(DOCUMENT_ID.toString(), DOCUMENT_TYPE); StepVerifier.create(result) .consumeNextWith(Assertions::assertTrue) .verifyComplete(); }
public Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType) { return stageLocationFactory.getLocation(documentId, documentType) .flatMap(stageFileLocation -> stageFileLocation.size() .map(size -> isValidFileSize(size) && isParsable(documentId, documentType, stageFileLocation)) ); }
DocumentFileValidator { public Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType) { return stageLocationFactory.getLocation(documentId, documentType) .flatMap(stageFileLocation -> stageFileLocation.size() .map(size -> isValidFileSize(size) && isParsable(documentId, documentType, stageFileLocation)) ); } }
DocumentFileValidator { public Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType) { return stageLocationFactory.getLocation(documentId, documentType) .flatMap(stageFileLocation -> stageFileLocation.size() .map(size -> isValidFileSize(size) && isParsable(documentId, documentType, stageFileLocation)) ); }  }
DocumentFileValidator { public Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType) { return stageLocationFactory.getLocation(documentId, documentType) .flatMap(stageFileLocation -> stageFileLocation.size() .map(size -> isValidFileSize(size) && isParsable(documentId, documentType, stageFileLocation)) ); }  Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType); }
DocumentFileValidator { public Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType) { return stageLocationFactory.getLocation(documentId, documentType) .flatMap(stageFileLocation -> stageFileLocation.size() .map(size -> isValidFileSize(size) && isParsable(documentId, documentType, stageFileLocation)) ); }  Mono<Boolean> isValidDocument(final String documentId, final DocumentType documentType);  }