@Test
public void testCreateStorageFileFromEntity()
{

    // Create a storage file entity.
    StorageFileEntity storageFileEntity = new StorageFileEntity();
    storageFileEntity.setStorageUnit(null);
    storageFileEntity.setPath(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME);
    storageFileEntity.setFileSizeBytes(FILE_SIZE);
    storageFileEntity.setRowCount(ROW_COUNT);
    // Create storage file from entity when directory path is not specified (passed as null).
    assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, NO_STORAGE_DIRECTORY_PATH));
    // Create storage file from entity when directory path is passed as blank text.
    assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, BLANK_TEXT));
    // Create storage file from entity when directory path is matching
    // the beginning of storage file path and directory path has no '/' trailing character.
    assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, STORAGE_DIRECTORY_PATH));
    // Create storage file from entity when directory path is matching
    // the beginning of storage file path and directory path has '/' trailing character.
    assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, STORAGE_DIRECTORY_PATH + "/"));
    // Create storage file from entity when directory path is not matching
    // the beginning of storage file path and directory path has no '/' trailing character.
    assertEquals(new StorageFile(STRING_VALUE + "/" + STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, STRING_VALUE));
    // Create storage file from entity when directory path is not matching
    // the beginning of storage file path and directory path has '/' trailing character.
    assertEquals(new StorageFile(STRING_VALUE + "/" + STORAGE_DIRECTORY_PATH + "/" + FILE_NAME, FILE_SIZE, ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(storageFileEntity, STRING_VALUE + "/"));
    // Create a storage file entity with storage file representing an empty S3 directory.
    StorageFileEntity emptyDirectoryStorageFileEntity = new StorageFileEntity();
    emptyDirectoryStorageFileEntity.setStorageUnit(null);
    emptyDirectoryStorageFileEntity.setPath(StorageFileEntity.S3_EMPTY_PARTITION);
    emptyDirectoryStorageFileEntity.setFileSizeBytes(FILE_SIZE_0_BYTE);
    emptyDirectoryStorageFileEntity.setRowCount(NO_ROW_COUNT);
    // Create storage file from entity when directory path is not matching the beginning of storage file path and storage file represents an empty S3 directory.
    assertEquals(new StorageFile(STORAGE_DIRECTORY_PATH + StorageFileEntity.S3_EMPTY_PARTITION, FILE_SIZE_0_BYTE, NO_ROW_COUNT),
        storageFileHelper.createStorageFileFromEntity(emptyDirectoryStorageFileEntity, STORAGE_DIRECTORY_PATH));
}