S3FileMapper { @Nullable public S3File transform(String filename) { S3File trans = null; File transmissionFile = getFile(filename); if (transmissionFile != null && transmissionFile.exists()) { String md5Checksum = fileHelper.getMd5Base64(transmissionFile); String md5Hex = fileHelper.hexMd5(transmissionFile); trans = new S3File(transmissionFile, isFilePublic(filename), getDir(filename), getAction(filename), md5Checksum, md5Hex); } return trans; } @Inject  S3FileMapper(FlowFileBrowser fileBrowser, FileHelper fileHelper); @Nullable S3File transform(String filename);  }
@Test public void shouldReturnNullForNullFilename() { S3FileMapper s3FileMapper = new S3FileMapper(mockFileBrowser, mockFileHelper); S3File file = s3FileMapper.transform(null); assertNull(file); }
@Test public void shouldReturnNullForEmptyFilename() { S3FileMapper s3FileMapper = new S3FileMapper(mockFileBrowser, mockFileHelper); S3File file = s3FileMapper.transform(""); assertNull(file); }
@Test public void shouldReturnNullForNonExistingFilename() { S3FileMapper s3FileMapper = new S3FileMapper(mockFileBrowser, mockFileHelper); given(mockFileBrowser.getInternalFile(anyString(), anyString())).willReturn(mockFile); given(mockFile.exists()).willReturn(false); S3File file = s3FileMapper.transform("data.zip"); assertNull(file); }