test_class.file: herd-code/herd-tools/herd-downloader/src/test/java/org/finra/herd/tools/downloader/DownloaderControllerTest.java
test_class.identifier: DownloaderControllerTest
test_class.superclass: extends AbstractDownloaderTest
test_case.body: @Test
      public void testLogLocalDirectoryContents() throws Exception
      {
          String appenderName = "TestWriterAppender";
          StringWriter stringWriter = addLoggingWriterAppender(appenderName);
          LogLevel originalLevel = getLogLevel(DownloaderController.class);
          setLogLevel(DownloaderController.class, LogLevel.INFO);
  
          /*
           * Create and inject mock objects
           */
          DownloaderWebClient mockDownloaderWebClient = mock(DownloaderWebClient.class);
          DownloaderWebClient originalDownloaderWebClient = (DownloaderWebClient) ReflectionTestUtils.getField(downloaderController, "downloaderWebClient");
          ReflectionTestUtils.setField(downloaderController, "downloaderWebClient", mockDownloaderWebClient);
  
          DownloaderManifestReader mockDownloaderManifestReader = mock(DownloaderManifestReader.class);
          DownloaderManifestReader originalDownloaderManifestReader =
              (DownloaderManifestReader) ReflectionTestUtils.getField(downloaderController, "manifestReader");
          ReflectionTestUtils.setField(downloaderController, "manifestReader", mockDownloaderManifestReader);
  
          BusinessObjectDataHelper mockBusinessObjectDataHelper = mock(BusinessObjectDataHelper.class);
          BusinessObjectDataHelper originalBusinessObjectDataHelper =
              (BusinessObjectDataHelper) ReflectionTestUtils.getField(downloaderController, "businessObjectDataHelper");
          ReflectionTestUtils.setField(downloaderController, "businessObjectDataHelper", mockBusinessObjectDataHelper);
  
          S3Service mockS3Service = mock(S3Service.class);
          S3Service originalS3Service = (S3Service) ReflectionTestUtils.getField(downloaderController, "s3Service");
          ReflectionTestUtils.setField(downloaderController, "s3Service", mockS3Service);
  
          StorageFileHelper mockStorageFileHelper = mock(StorageFileHelper.class);
          StorageFileHelper originalStorageFileHelper = (StorageFileHelper) ReflectionTestUtils.getField(downloaderController, "storageFileHelper");
          ReflectionTestUtils.setField(downloaderController, "storageFileHelper", mockStorageFileHelper);
  
          StorageHelper mockStorageHelper = mock(StorageHelper.class);
          StorageHelper originalStorageHelper = (StorageHelper) ReflectionTestUtils.getField(downloaderController, "storageHelper");
          ReflectionTestUtils.setField(downloaderController, "storageHelper", mockStorageHelper);
  
          /*
           * Start test
           */
          Path localPath = Files.createTempDirectory(null);
          try
          {
              String s3KeyPrefix = "s3KeyPrefix";
              String storageName = "S3_MANAGED";
              Path targetDirectoryPath = localPath.resolve(s3KeyPrefix);
              Path targetFilePath = targetDirectoryPath.resolve("file");
  
              DownloaderInputManifestDto downloaderInputManifestDto = new DownloaderInputManifestDto();
              BusinessObjectData businessObjectData = new BusinessObjectData();
              StorageUnit storageUnit = new StorageUnit(new Storage(storageName, null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null);
              S3KeyPrefixInformation s3KeyPrefixInformation = new S3KeyPrefixInformation();
              s3KeyPrefixInformation.setS3KeyPrefix(s3KeyPrefix);
  
              /*
               * Mock operations on mocked dependencies
               */
              when(mockDownloaderManifestReader.readJsonManifest(any())).thenReturn(downloaderInputManifestDto);
              when(mockDownloaderWebClient.getBusinessObjectData(any())).thenReturn(businessObjectData);
              when(mockBusinessObjectDataHelper.getStorageUnitByStorageName(any(), any())).thenReturn(storageUnit);
              when(mockDownloaderWebClient.getS3KeyPrefix(any())).thenReturn(s3KeyPrefixInformation);
              when(mockS3Service.downloadDirectory(any())).then(new Answer<S3FileTransferResultsDto>()
              {
                  @Override
                  public S3FileTransferResultsDto answer(InvocationOnMock invocation) throws Throwable
                  {
                      Files.createFile(targetFilePath);
                      return null;
                  }
              });
  
              /*
               * Make the call to the method under test
               */
              RegServerAccessParamsDto regServerAccessParamsDto = null;
              File manifestPath = null;
              S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
              s3FileTransferRequestParamsDto.setLocalPath(localPath.toString());
              s3FileTransferRequestParamsDto.setMaxThreads(1);
  
              downloaderController.performDownload(regServerAccessParamsDto, manifestPath, s3FileTransferRequestParamsDto);
  
              // Assert that the proper delegate method is called with the expected params to retrieve credentials
              verify(mockDownloaderManifestReader).readJsonManifest(manifestPath);
              verify(mockDownloaderWebClient).getBusinessObjectData(downloaderInputManifestDto);
              verify(mockBusinessObjectDataHelper).getStorageUnitByStorageName(businessObjectData, storageName);
              verify(mockDownloaderWebClient).getS3KeyPrefix(businessObjectData);
              verify(mockS3Service).downloadDirectory(s3FileTransferRequestParamsDto);
          }
          finally
          {
              setLogLevel(DownloaderController.class, originalLevel);
              removeLoggingAppender(appenderName);
  
              /*
               * Restore mocked dependencies to their original implementation
               */
              ReflectionTestUtils.setField(downloaderController, "downloaderWebClient", originalDownloaderWebClient);
              ReflectionTestUtils.setField(downloaderController, "manifestReader", originalDownloaderManifestReader);
              ReflectionTestUtils.setField(downloaderController, "businessObjectDataHelper", originalBusinessObjectDataHelper);
              ReflectionTestUtils.setField(downloaderController, "s3Service", originalS3Service);
              ReflectionTestUtils.setField(downloaderController, "storageFileHelper", originalStorageFileHelper);
              ReflectionTestUtils.setField(downloaderController, "storageHelper", originalStorageHelper);
  
              // Clean up any temporary files
              FileUtils.deleteDirectory(localPath.toFile());
          }
      }
test_case.class_method_signature: DownloaderControllerTest.testLogLocalDirectoryContents()
test_case.full_signature: @Test public void testLogLocalDirectoryContents()
test_case.identifier: testLogLocalDirectoryContents
test_case.invocations: addLoggingWriterAppender getLogLevel setLogLevel mock getField setField mock getField setField mock getField setField mock getField setField mock getField setField mock getField setField createTempDirectory resolve resolve setS3KeyPrefix thenReturn when readJsonManifest any thenReturn when getBusinessObjectData any thenReturn when getStorageUnitByStorageName any any thenReturn when getS3KeyPrefix any then when downloadDirectory any createFile setLocalPath toString setMaxThreads performDownload readJsonManifest verify getBusinessObjectData verify getStorageUnitByStorageName verify getS3KeyPrefix verify downloadDirectory verify setLogLevel removeLoggingAppender setField setField setField setField setField setField deleteDirectory toFile
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLogLocalDirectoryContents()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(DownloaderController.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(DownloaderController.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: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.declarator: manifestReader
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private DownloaderManifestReader manifestReader;
focal_class.type: DownloaderManifestReader
focal_class.var_name: manifestReader
focal_class.declarator: manifestWriter
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private DownloaderManifestWriter manifestWriter;
focal_class.type: DownloaderManifestWriter
focal_class.var_name: manifestWriter
focal_class.declarator: downloaderWebClient
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private DownloaderWebClient downloaderWebClient;
focal_class.type: DownloaderWebClient
focal_class.var_name: downloaderWebClient
focal_class.declarator: storageFileHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StorageFileHelper storageFileHelper;
focal_class.type: StorageFileHelper
focal_class.var_name: storageFileHelper
focal_class.declarator: storageHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private StorageHelper storageHelper;
focal_class.type: StorageHelper
focal_class.var_name: storageHelper
focal_class.declarator: OUTPUT_MANIFEST_FILE_NAME = "manifest.json"
focal_class.modifier: private static final
focal_class.original_string: private static final String OUTPUT_MANIFEST_FILE_NAME = "manifest.json";
focal_class.type: String
focal_class.var_name: OUTPUT_MANIFEST_FILE_NAME
focal_class.file: herd-code/herd-tools/herd-downloader/src/main/java/org/finra/herd/tools/downloader/DownloaderController.java
focal_class.identifier: DownloaderController
focal_class.class_method_signature: DownloaderController.performDownload(RegServerAccessParamsDto regServerAccessParamsDto, File manifestPath,
          S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto)
focal_class.full_signature: @SuppressFBWarnings(value = {"BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"}, justification = "manifestReader.readJsonManifest will always return an DownloaderInputManifestDto object. targetLocalDirectory.list().length will not" + " return a NullPointerException.") public void performDownload(RegServerAccessParamsDto regServerAccessParamsDto, File manifestPath,
          S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto)
focal_class.identifier: performDownload
focal_class.modifiers: @SuppressFBWarnings(value = {"BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"}, justification = "manifestReader.readJsonManifest will always return an DownloaderInputManifestDto object. targetLocalDirectory.list().length will not" + " return a NullPointerException.") public
focal_class.parameters: (RegServerAccessParamsDto regServerAccessParamsDto, File manifestPath,
          S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto)
focal_class.return: void
focal_class.signature: void performDownload(RegServerAccessParamsDto regServerAccessParamsDto, File manifestPath,
          S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto)
focal_class.class_method_signature: DownloaderController.logLocalDirectoryContents(File directory)
focal_class.full_signature: private void logLocalDirectoryContents(File directory)
focal_class.identifier: logLocalDirectoryContents
focal_class.modifiers: private
focal_class.parameters: (File directory)
focal_class.return: void
focal_class.signature: void logLocalDirectoryContents(File directory)
focal_class.class_method_signature: DownloaderController.createDownloaderOutputManifestDto(BusinessObjectData businessObjectData, StorageUnit storageUnit, String s3KeyPrefix)
focal_class.full_signature: protected DownloaderOutputManifestDto createDownloaderOutputManifestDto(BusinessObjectData businessObjectData, StorageUnit storageUnit, String s3KeyPrefix)
focal_class.identifier: createDownloaderOutputManifestDto
focal_class.modifiers: protected
focal_class.parameters: (BusinessObjectData businessObjectData, StorageUnit storageUnit, String s3KeyPrefix)
focal_class.return: DownloaderOutputManifestDto
focal_class.signature: DownloaderOutputManifestDto createDownloaderOutputManifestDto(BusinessObjectData businessObjectData, StorageUnit storageUnit, String s3KeyPrefix)
focal_class.superclass: extends DataBridgeController
focal_method.body: private void logLocalDirectoryContents(File directory)
      {
          Collection<File> files = HerdFileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
          LOGGER.info(String.format("Found %d files in \"%s\" target local directory:", files.size(), directory.getPath()));
  
          for (File file : files)
          {
              LOGGER.info(String.format("    %s", file.getPath()));
          }
      }
focal_method.class_method_signature: DownloaderController.logLocalDirectoryContents(File directory)
focal_method.full_signature: private void logLocalDirectoryContents(File directory)
focal_method.identifier: logLocalDirectoryContents
focal_method.invocations: listFiles info format size getPath info format getPath
focal_method.modifiers: private
focal_method.parameters: (File directory)
focal_method.return: void
focal_method.signature: void logLocalDirectoryContents(File directory)