StorageFileHelper { StorageFile createStorageFileFromEntity(StorageFileEntity storageFileEntity, String storageUnitDirectoryPath) { String storageFilePath = storageFileEntity.getPath(); if (StringUtils.isNotBlank(storageUnitDirectoryPath)) { if (!StringUtils.startsWith(storageFilePath, storageUnitDirectoryPath)) { if (StringUtils.equals(storageFilePath, StorageFileEntity.S3_EMPTY_PARTITION)) { storageFilePath = storageUnitDirectoryPath + storageFilePath; } else { storageFilePath = StringUtils.appendIfMissing(storageUnitDirectoryPath, "/") + storageFilePath; } } } return new StorageFile(storageFilePath, storageFileEntity.getFileSizeBytes(), storageFileEntity.getRowCount()); }  List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities, String storageUnitDirectoryPath); List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities); List<StorageFile> createStorageFilesFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries); List<StorageFile> getAndValidateStorageFiles(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
        BusinessObjectDataKey businessObjectDataKey); List<StorageFile> getAndValidateStorageFilesIfPresent(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
        BusinessObjectDataKey businessObjectDataKey); List<String> getFilePathsFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries); List<String> getFilePathsFromStorageFiles(List<StorageFile> storageFiles); List<File> getFiles(List<StorageFile> storageFiles); Map<String, StorageFileEntity> getStorageFileEntitiesMap(Collection<StorageFileEntity> storageFileEntities); Map<String, StorageFile> getStorageFilesMapFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries); void validateCreateRequestStorageFiles(List<StorageFile> storageFiles); void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, StorageUnit storageUnit); void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, List<StorageFile> storageFiles); void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
        BusinessObjectDataKey businessObjectDataKey); void validateStorageFile(StorageFile storageFile, String s3BucketName, Map<String, StorageFile> actualS3Keys, boolean validateFileSize); void validateStorageFileEntity(StorageFileEntity storageFileEntity, String s3BucketName, Map<String, StorageFile> actualS3Keys,
        boolean validateFileSize); void validateStorageFilePaths(Collection<String> storageFilePaths, String s3KeyPrefix, BusinessObjectDataKey businessObjectDataKey,
        String storageName); void validateStorageUnitS3Files(StorageUnit storageUnit, List<String> actualS3Files, String s3KeyPrefix);  }
@Test public void testCreateStorageFileFromEntity() { StorageFileEntity storageFileEntity = new StorageFileEntity(); storageFileEntity.setStorageUnit(null); storageFileEntity.setPath(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME); storageFileEntity.setFileSizeBytes(FILE_SIZE); storageFileEntity.setRowCount(ROW_COUNT); assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, NO_STORAGE_DIRECTORY_PATH)); assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, BLANK_TEXT)); assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, STORAGE_DIRECTORY_PATH)); assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, STORAGE_DIRECTORY_PATH + "/")); assertEquals(new StorageFile(STRING_VALUE + "/" + STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, STRING_VALUE)); assertEquals(new StorageFile(STRING_VALUE + "/" + STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT), storageFileHelper.createStorageFileFromEntity(storageFileEntity, STRING_VALUE + "/")); StorageFileEntity emptyDirectoryStorageFileEntity = new StorageFileEntity(); emptyDirectoryStorageFileEntity.setStorageUnit(null); emptyDirectoryStorageFileEntity.setPath(StorageFileEntity.S3_EMPTY_PARTITION); emptyDirectoryStorageFileEntity.setFileSizeBytes(FILE_SIZE_0_BYTE); emptyDirectoryStorageFileEntity.setRowCount(NO_ROW_COUNT); assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + StorageFileEntity.S3_EMPTY_PARTITION, FILE_SIZE_0_BYTE, NO_ROW_COUNT), storageFileHelper.createStorageFileFromEntity(emptyDirectoryStorageFileEntity, STORAGE_DIRECTORY_PATH)); }