test_class.declarator: LOCAL_TEMP_PATH = Paths.get(System.getProperty("java.io.tmpdir"), "herd-helper-test", RANDOM_SUFFIX)
test_class.modifier: private static final
test_class.original_string: private static final Path LOCAL_TEMP_PATH = Paths.get(System.getProperty("java.io.tmpdir"), "herd-helper-test", RANDOM_SUFFIX);
test_class.type: Path
test_class.var_name: LOCAL_TEMP_PATH
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/StorageFileHelperTest.java
test_class.identifier: StorageFileHelperTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testValidateRegisteredS3FilesActualFileNoExists() throws IOException
      {
          // Create two lists of expected and actual storage files, with one expected file not being added to the list of actual files.
          List<StorageFile> testExpectedFiles = Collections.singletonList(new StorageFile(TARGET_S3_KEY, FILE_SIZE, ROW_COUNT_1000));
          List<S3ObjectSummary> testActualFiles = new ArrayList<>();
  
          // Try to validate S3 files when expected S3 file does not exist.
          try
          {
              storageFileHelper.validateRegisteredS3Files(testExpectedFiles, testActualFiles, STORAGE_NAME,
                  new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE,
                      SUBPARTITION_VALUES, DATA_VERSION));
              fail("Should throw an ObjectNotFoundException when the registered S3 file does not exist.");
          }
          catch (ObjectNotFoundException e)
          {
              assertEquals(String.format("Registered file \"%s\" does not exist in \"%s\" storage.", TARGET_S3_KEY, STORAGE_NAME), e.getMessage());
          }
      }
test_case.class_method_signature: StorageFileHelperTest.testValidateRegisteredS3FilesActualFileNoExists()
test_case.full_signature: @Test public void testValidateRegisteredS3FilesActualFileNoExists()
test_case.identifier: testValidateRegisteredS3FilesActualFileNoExists
test_case.invocations: singletonList validateRegisteredS3Files fail assertEquals format getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testValidateRegisteredS3FilesActualFileNoExists()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(StorageFileHelper.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(StorageFileHelper.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: businessObjectDataHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDataHelper businessObjectDataHelper;
focal_class.type: BusinessObjectDataHelper
focal_class.var_name: businessObjectDataHelper
focal_class.declarator: jsonHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private JsonHelper jsonHelper;
focal_class.type: JsonHelper
focal_class.var_name: jsonHelper
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/StorageFileHelper.java
focal_class.identifier: StorageFileHelper
focal_class.class_method_signature: StorageFileHelper.createStorageFileFromEntity(StorageFileEntity storageFileEntity, String storageUnitDirectoryPath)
focal_class.full_signature:  StorageFile createStorageFileFromEntity(StorageFileEntity storageFileEntity, String storageUnitDirectoryPath)
focal_class.identifier: createStorageFileFromEntity
focal_class.parameters: (StorageFileEntity storageFileEntity, String storageUnitDirectoryPath)
focal_class.return: StorageFile
focal_class.signature: StorageFile createStorageFileFromEntity(StorageFileEntity storageFileEntity, String storageUnitDirectoryPath)
focal_class.class_method_signature: StorageFileHelper.createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities, String storageUnitDirectoryPath)
focal_class.full_signature: public List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities, String storageUnitDirectoryPath)
focal_class.identifier: createStorageFilesFromEntities
focal_class.modifiers: public
focal_class.parameters: (Collection<StorageFileEntity> storageFileEntities, String storageUnitDirectoryPath)
focal_class.return: List<StorageFile>
focal_class.signature: List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities, String storageUnitDirectoryPath)
focal_class.class_method_signature: StorageFileHelper.createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities)
focal_class.full_signature: public List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities)
focal_class.identifier: createStorageFilesFromEntities
focal_class.modifiers: public
focal_class.parameters: (Collection<StorageFileEntity> storageFileEntities)
focal_class.return: List<StorageFile>
focal_class.signature: List<StorageFile> createStorageFilesFromEntities(Collection<StorageFileEntity> storageFileEntities)
focal_class.class_method_signature: StorageFileHelper.createStorageFilesFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.full_signature: public List<StorageFile> createStorageFilesFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.identifier: createStorageFilesFromS3ObjectSummaries
focal_class.modifiers: public
focal_class.parameters: (List<S3ObjectSummary> s3ObjectSummaries)
focal_class.return: List<StorageFile>
focal_class.signature: List<StorageFile> createStorageFilesFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.class_method_signature: StorageFileHelper.getAndValidateStorageFiles(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.full_signature: public List<StorageFile> getAndValidateStorageFiles(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.identifier: getAndValidateStorageFiles
focal_class.modifiers: public
focal_class.parameters: (StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.return: List<StorageFile>
focal_class.signature: List<StorageFile> getAndValidateStorageFiles(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.class_method_signature: StorageFileHelper.getAndValidateStorageFilesIfPresent(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.full_signature: public List<StorageFile> getAndValidateStorageFilesIfPresent(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.identifier: getAndValidateStorageFilesIfPresent
focal_class.modifiers: public
focal_class.parameters: (StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.return: List<StorageFile>
focal_class.signature: List<StorageFile> getAndValidateStorageFilesIfPresent(StorageUnitEntity storageUnitEntity, String s3KeyPrefix, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.class_method_signature: StorageFileHelper.getFilePathsFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.full_signature: public List<String> getFilePathsFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.identifier: getFilePathsFromS3ObjectSummaries
focal_class.modifiers: public
focal_class.parameters: (List<S3ObjectSummary> s3ObjectSummaries)
focal_class.return: List<String>
focal_class.signature: List<String> getFilePathsFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.class_method_signature: StorageFileHelper.getFilePathsFromStorageFiles(List<StorageFile> storageFiles)
focal_class.full_signature: public List<String> getFilePathsFromStorageFiles(List<StorageFile> storageFiles)
focal_class.identifier: getFilePathsFromStorageFiles
focal_class.modifiers: public
focal_class.parameters: (List<StorageFile> storageFiles)
focal_class.return: List<String>
focal_class.signature: List<String> getFilePathsFromStorageFiles(List<StorageFile> storageFiles)
focal_class.class_method_signature: StorageFileHelper.getFiles(List<StorageFile> storageFiles)
focal_class.full_signature: public List<File> getFiles(List<StorageFile> storageFiles)
focal_class.identifier: getFiles
focal_class.modifiers: public
focal_class.parameters: (List<StorageFile> storageFiles)
focal_class.return: List<File>
focal_class.signature: List<File> getFiles(List<StorageFile> storageFiles)
focal_class.class_method_signature: StorageFileHelper.getStorageFileEntitiesMap(Collection<StorageFileEntity> storageFileEntities)
focal_class.full_signature: public Map<String, StorageFileEntity> getStorageFileEntitiesMap(Collection<StorageFileEntity> storageFileEntities)
focal_class.identifier: getStorageFileEntitiesMap
focal_class.modifiers: public
focal_class.parameters: (Collection<StorageFileEntity> storageFileEntities)
focal_class.return: Map<String, StorageFileEntity>
focal_class.signature: Map<String, StorageFileEntity> getStorageFileEntitiesMap(Collection<StorageFileEntity> storageFileEntities)
focal_class.class_method_signature: StorageFileHelper.getStorageFilesMapFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.full_signature: public Map<String, StorageFile> getStorageFilesMapFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.identifier: getStorageFilesMapFromS3ObjectSummaries
focal_class.modifiers: public
focal_class.parameters: (List<S3ObjectSummary> s3ObjectSummaries)
focal_class.return: Map<String, StorageFile>
focal_class.signature: Map<String, StorageFile> getStorageFilesMapFromS3ObjectSummaries(List<S3ObjectSummary> s3ObjectSummaries)
focal_class.class_method_signature: StorageFileHelper.validateCreateRequestStorageFiles(List<StorageFile> storageFiles)
focal_class.full_signature: public void validateCreateRequestStorageFiles(List<StorageFile> storageFiles)
focal_class.identifier: validateCreateRequestStorageFiles
focal_class.modifiers: public
focal_class.parameters: (List<StorageFile> storageFiles)
focal_class.return: void
focal_class.signature: void validateCreateRequestStorageFiles(List<StorageFile> storageFiles)
focal_class.class_method_signature: StorageFileHelper.validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, StorageUnit storageUnit)
focal_class.full_signature: public void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, StorageUnit storageUnit)
focal_class.identifier: validateDownloadedS3Files
focal_class.modifiers: public
focal_class.parameters: (String baseDirectory, String s3KeyPrefix, StorageUnit storageUnit)
focal_class.return: void
focal_class.signature: void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, StorageUnit storageUnit)
focal_class.class_method_signature: StorageFileHelper.validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, List<StorageFile> storageFiles)
focal_class.full_signature: public void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, List<StorageFile> storageFiles)
focal_class.identifier: validateDownloadedS3Files
focal_class.modifiers: public
focal_class.parameters: (String baseDirectory, String s3KeyPrefix, List<StorageFile> storageFiles)
focal_class.return: void
focal_class.signature: void validateDownloadedS3Files(String baseDirectory, String s3KeyPrefix, List<StorageFile> storageFiles)
focal_class.class_method_signature: StorageFileHelper.validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.full_signature: public void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.identifier: validateRegisteredS3Files
focal_class.modifiers: public
focal_class.parameters: (List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.return: void
focal_class.signature: void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_class.class_method_signature: StorageFileHelper.validateStorageFile(StorageFile storageFile, String s3BucketName, Map<String, StorageFile> actualS3Keys, boolean validateFileSize)
focal_class.full_signature: public void validateStorageFile(StorageFile storageFile, String s3BucketName, Map<String, StorageFile> actualS3Keys, boolean validateFileSize)
focal_class.identifier: validateStorageFile
focal_class.modifiers: public
focal_class.parameters: (StorageFile storageFile, String s3BucketName, Map<String, StorageFile> actualS3Keys, boolean validateFileSize)
focal_class.return: void
focal_class.signature: void validateStorageFile(StorageFile storageFile, String s3BucketName, Map<String, StorageFile> actualS3Keys, boolean validateFileSize)
focal_class.class_method_signature: StorageFileHelper.validateStorageFileEntity(StorageFileEntity storageFileEntity, String s3BucketName, Map<String, StorageFile> actualS3Keys,
          boolean validateFileSize)
focal_class.full_signature: public void validateStorageFileEntity(StorageFileEntity storageFileEntity, String s3BucketName, Map<String, StorageFile> actualS3Keys,
          boolean validateFileSize)
focal_class.identifier: validateStorageFileEntity
focal_class.modifiers: public
focal_class.parameters: (StorageFileEntity storageFileEntity, String s3BucketName, Map<String, StorageFile> actualS3Keys,
          boolean validateFileSize)
focal_class.return: void
focal_class.signature: void validateStorageFileEntity(StorageFileEntity storageFileEntity, String s3BucketName, Map<String, StorageFile> actualS3Keys,
          boolean validateFileSize)
focal_class.class_method_signature: StorageFileHelper.validateStorageFilePaths(Collection<String> storageFilePaths, String s3KeyPrefix, BusinessObjectDataKey businessObjectDataKey,
          String storageName)
focal_class.full_signature: public void validateStorageFilePaths(Collection<String> storageFilePaths, String s3KeyPrefix, BusinessObjectDataKey businessObjectDataKey,
          String storageName)
focal_class.identifier: validateStorageFilePaths
focal_class.modifiers: public
focal_class.parameters: (Collection<String> storageFilePaths, String s3KeyPrefix, BusinessObjectDataKey businessObjectDataKey,
          String storageName)
focal_class.return: void
focal_class.signature: void validateStorageFilePaths(Collection<String> storageFilePaths, String s3KeyPrefix, BusinessObjectDataKey businessObjectDataKey,
          String storageName)
focal_class.class_method_signature: StorageFileHelper.validateStorageUnitS3Files(StorageUnit storageUnit, List<String> actualS3Files, String s3KeyPrefix)
focal_class.full_signature: public void validateStorageUnitS3Files(StorageUnit storageUnit, List<String> actualS3Files, String s3KeyPrefix)
focal_class.identifier: validateStorageUnitS3Files
focal_class.modifiers: public
focal_class.parameters: (StorageUnit storageUnit, List<String> actualS3Files, String s3KeyPrefix)
focal_class.return: void
focal_class.signature: void validateStorageUnitS3Files(StorageUnit storageUnit, List<String> actualS3Files, String s3KeyPrefix)
focal_method.body: public void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
      {
          // Get a set of actual S3 file paths.
          Set<String> actualS3FilePaths = new HashSet<>(getFilePathsFromS3ObjectSummaries(s3ObjectSummaries));
  
          // Validate existence and file size for all expected files.
          for (StorageFile expectedStorageFile : expectedStorageFiles)
          {
              if (!actualS3FilePaths.contains(expectedStorageFile.getFilePath()))
              {
                  throw new ObjectNotFoundException(
                      String.format("Registered file \"%s\" does not exist in \"%s\" storage.", expectedStorageFile.getFilePath(), storageName));
              }
          }
  
          // Get a set of expected file paths.
          Set<String> expectedFilePaths = new HashSet<>(getFilePathsFromStorageFiles(expectedStorageFiles));
  
          // Create a JSON representation of the business object data key.
          String businessObjectDataKeyAsJson = jsonHelper.objectToJson(businessObjectDataKey);
  
          // Validate that no other files in S3 bucket except for expected storage files have the same S3 key prefix.
          // Please note that this validation ignores (does not fail on) any unregistered zero byte S3 files.
          for (S3ObjectSummary s3ObjectSummary : s3ObjectSummaries)
          {
              if (!expectedFilePaths.contains(s3ObjectSummary.getKey()))
              {
                  // Ignore unregistered zero byte S3 files.
                  if (s3ObjectSummary.getSize() == 0)
                  {
                      LOGGER.info("Ignoring unregistered zero byte S3 file. s3Key=\"{}\" storageName=\"{}\" businessObjectDataKey={}", s3ObjectSummary.getKey(),
                          storageName, businessObjectDataKeyAsJson);
                  }
                  else
                  {
                      throw new IllegalStateException(String
                          .format("Found unregistered non-empty S3 file \"%s\" in \"%s\" storage. Business object data {%s}", s3ObjectSummary.getKey(),
                              storageName, businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));
                  }
              }
          }
      }
focal_method.class_method_signature: StorageFileHelper.validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_method.full_signature: public void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_method.identifier: validateRegisteredS3Files
focal_method.invocations: getFilePathsFromS3ObjectSummaries contains getFilePath format getFilePath getFilePathsFromStorageFiles objectToJson contains getKey getSize info getKey format getKey businessObjectDataKeyToString
focal_method.modifiers: public
focal_method.parameters: (List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)
focal_method.return: void
focal_method.signature: void validateRegisteredS3Files(List<StorageFile> expectedStorageFiles, List<S3ObjectSummary> s3ObjectSummaries, String storageName,
          BusinessObjectDataKey businessObjectDataKey)