@Test public void testUploadWithError() throws Exception { doThrow(new RuntimeException("Exception")).when(storage).uploadContentChunk(any()); DocumentUploadChunk chunk = new DocumentUploadChunk(DOC_ID, DOC_NAME, 0, 3, Base64.getEncoder().encodeToString(PART_1.getBytes())); DocumentUploadResponse response = uploadedDocumentService.uploadContent(chunk); validateResponse(response, DocumentUploadResponse.DocumentUploadState.FINISH, false); }
@Override public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) { try { DocumentUploadSession session = getSession(chunk); if (session.isComplete()) { return merge(session); } else { return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true); } } catch (Exception ex) { logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex); return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false); } }
UploadedDocumentServiceImpl implements UploadedDocumentService,
                                                    Serializable { @Override public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) { try { DocumentUploadSession session = getSession(chunk); if (session.isComplete()) { return merge(session); } else { return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true); } } catch (Exception ex) { logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex); return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false); } } }
UploadedDocumentServiceImpl implements UploadedDocumentService,
                                                    Serializable { @Override public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) { try { DocumentUploadSession session = getSession(chunk); if (session.isComplete()) { return merge(session); } else { return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true); } } catch (Exception ex) { logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex); return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false); } } @Inject  UploadedDocumentServiceImpl(UploadedDocumentStorage storage); }
UploadedDocumentServiceImpl implements UploadedDocumentService,
                                                    Serializable { @Override public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) { try { DocumentUploadSession session = getSession(chunk); if (session.isComplete()) { return merge(session); } else { return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true); } } catch (Exception ex) { logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex); return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false); } } @Inject  UploadedDocumentServiceImpl(UploadedDocumentStorage storage); @Override DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk); @Override void removeContent(String id); @PreDestroy void clear(); }
UploadedDocumentServiceImpl implements UploadedDocumentService,
                                                    Serializable { @Override public DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk) { try { DocumentUploadSession session = getSession(chunk); if (session.isComplete()) { return merge(session); } else { return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.UPLOADING, true); } } catch (Exception ex) { logger.warn("Cannot upload chunk {}: {}", chunk.getDocumentName(), ex); return new DocumentUploadResponse(DocumentUploadResponse.DocumentUploadState.FINISH, false); } } @Inject  UploadedDocumentServiceImpl(UploadedDocumentStorage storage); @Override DocumentUploadResponse uploadContent(final DocumentUploadChunk chunk); @Override void removeContent(String id); @PreDestroy void clear();  }