@Test public void upload_containing_filename_length_41_throws_illegal_argument_exception() { String result = "content data"; MockMultipartFile multiPart = new MockMultipartFile("file", result.getBytes()); String fileName = "12345678901234567890123456789012345678901"; assertEquals(41,fileName.length()); expected.expect(IllegalArgumentException.class); expected.expectMessage("40"); serviceToTest.upload(jobUUID, fileName, multiPart, ACCEPTED_CHECKSUM); }
@UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) public void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum) { notNull(jobUUID, "job uuid may not be null"); notNull(file, "file may not be null"); notNull(checkSum, "checkSum may not be null"); validateFileName(fileName); PDSJob job = assertJobFound(jobUUID,repository); assertJobIsInState(job,PDSJobStatusState.CREATED); File jobFolder = workspaceService.getUploadFolder(jobUUID); File uploadFile = new File(jobFolder, fileName); try { FileUtils.copyInputStreamToFile(file.getInputStream(), uploadFile); LOG.debug("Uploaded file {} for job {} to {}",fileName,jobUUID, uploadFile.getAbsolutePath()); } catch (IOException e) { LOG.error("Was not able to store {} for job {}, reason:", fileName, jobUUID, e.getMessage()); throw new IllegalArgumentException("Cannot store given file", e); } assertCheckSumCorrect(checkSum, uploadFile.toPath()); }
PDSFileUploadJobService { @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) public void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum) { notNull(jobUUID, "job uuid may not be null"); notNull(file, "file may not be null"); notNull(checkSum, "checkSum may not be null"); validateFileName(fileName); PDSJob job = assertJobFound(jobUUID,repository); assertJobIsInState(job,PDSJobStatusState.CREATED); File jobFolder = workspaceService.getUploadFolder(jobUUID); File uploadFile = new File(jobFolder, fileName); try { FileUtils.copyInputStreamToFile(file.getInputStream(), uploadFile); LOG.debug("Uploaded file {} for job {} to {}",fileName,jobUUID, uploadFile.getAbsolutePath()); } catch (IOException e) { LOG.error("Was not able to store {} for job {}, reason:", fileName, jobUUID, e.getMessage()); throw new IllegalArgumentException("Cannot store given file", e); } assertCheckSumCorrect(checkSum, uploadFile.toPath()); } }
PDSFileUploadJobService { @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) public void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum) { notNull(jobUUID, "job uuid may not be null"); notNull(file, "file may not be null"); notNull(checkSum, "checkSum may not be null"); validateFileName(fileName); PDSJob job = assertJobFound(jobUUID,repository); assertJobIsInState(job,PDSJobStatusState.CREATED); File jobFolder = workspaceService.getUploadFolder(jobUUID); File uploadFile = new File(jobFolder, fileName); try { FileUtils.copyInputStreamToFile(file.getInputStream(), uploadFile); LOG.debug("Uploaded file {} for job {} to {}",fileName,jobUUID, uploadFile.getAbsolutePath()); } catch (IOException e) { LOG.error("Was not able to store {} for job {}, reason:", fileName, jobUUID, e.getMessage()); throw new IllegalArgumentException("Cannot store given file", e); } assertCheckSumCorrect(checkSum, uploadFile.toPath()); }  }
PDSFileUploadJobService { @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) public void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum) { notNull(jobUUID, "job uuid may not be null"); notNull(file, "file may not be null"); notNull(checkSum, "checkSum may not be null"); validateFileName(fileName); PDSJob job = assertJobFound(jobUUID,repository); assertJobIsInState(job,PDSJobStatusState.CREATED); File jobFolder = workspaceService.getUploadFolder(jobUUID); File uploadFile = new File(jobFolder, fileName); try { FileUtils.copyInputStreamToFile(file.getInputStream(), uploadFile); LOG.debug("Uploaded file {} for job {} to {}",fileName,jobUUID, uploadFile.getAbsolutePath()); } catch (IOException e) { LOG.error("Was not able to store {} for job {}, reason:", fileName, jobUUID, e.getMessage()); throw new IllegalArgumentException("Cannot store given file", e); } assertCheckSumCorrect(checkSum, uploadFile.toPath()); }  @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum); void deleteAllUploads(UUID jobUUID); }
PDSFileUploadJobService { @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) public void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum) { notNull(jobUUID, "job uuid may not be null"); notNull(file, "file may not be null"); notNull(checkSum, "checkSum may not be null"); validateFileName(fileName); PDSJob job = assertJobFound(jobUUID,repository); assertJobIsInState(job,PDSJobStatusState.CREATED); File jobFolder = workspaceService.getUploadFolder(jobUUID); File uploadFile = new File(jobFolder, fileName); try { FileUtils.copyInputStreamToFile(file.getInputStream(), uploadFile); LOG.debug("Uploaded file {} for job {} to {}",fileName,jobUUID, uploadFile.getAbsolutePath()); } catch (IOException e) { LOG.error("Was not able to store {} for job {}, reason:", fileName, jobUUID, e.getMessage()); throw new IllegalArgumentException("Cannot store given file", e); } assertCheckSumCorrect(checkSum, uploadFile.toPath()); }  @UseCaseUserUploadsJobData(@PDSStep(name="service call",description = "uploaded file be stored in job workspace upload location. Also checksum is validated",number=2)) void upload(UUID jobUUID, String fileName, MultipartFile file, String checkSum); void deleteAllUploads(UUID jobUUID);  }