test_class.declarator: backupCleanupService
test_class.modifier: private
test_class.original_string: private BackupCleanupService backupCleanupService;
test_class.type: BackupCleanupService
test_class.var_name: backupCleanupService
test_class.file: siri/gtfs_reader/src/test/java/il/org/hasadna/siri_client/gtfs/service/TestBackupCleanupService.java
test_class.identifier: TestBackupCleanupService
test_case.body: @Test
    public void testCleanup_DirectoryHasFile_FileExpired() throws IOException {
      // given
      Path tempDirectory = Files.createTempDirectory("unit_test", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx")));
  
      new GtfsCollectorConfiguration().setGtfsBackupFilesStoreTimeInDays("1");
      Path backupFile = Files.createFile(Paths.get(tempDirectory + "/prefix" + LocalDate.now().minusDays(5).toString()),
          PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-")));
  
      new GtfsCollectorConfiguration().setGtfsRawFilesBackupDirectory(tempDirectory.toAbsolutePath().toString());
      new GtfsCollectorConfiguration().setBackupFilesPrefixes("[prefix]");
  
      // when
      backupCleanupService.cleanup();
  
      // then
      Assert.assertFalse("back up file should be removed", backupFile.toFile().exists());
      tempDirectory.toFile().delete();
    }
test_case.class_method_signature: TestBackupCleanupService.testCleanup_DirectoryHasFile_FileExpired()
test_case.full_signature: @Test public void testCleanup_DirectoryHasFile_FileExpired()
test_case.identifier: testCleanup_DirectoryHasFile_FileExpired
test_case.invocations: createTempDirectory asFileAttribute fromString setGtfsBackupFilesStoreTimeInDays createFile get toString minusDays now asFileAttribute fromString setGtfsRawFilesBackupDirectory toString toAbsolutePath setBackupFilesPrefixes cleanup assertFalse exists toFile delete toFile
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCleanup_DirectoryHasFile_FileExpired()
focal_class.declarator: log = LoggerFactory.getLogger(BackupCleanupService.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger log = LoggerFactory.getLogger(BackupCleanupService.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.file: siri/gtfs_reader/src/main/java/il/org/hasadna/siri_client/gtfs/service/BackupCleanupService.java
focal_class.identifier: BackupCleanupService
focal_class.class_method_signature: BackupCleanupService.cleanup()
focal_class.full_signature: public void cleanup()
focal_class.identifier: cleanup
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void cleanup()
focal_class.class_method_signature: BackupCleanupService.deleteExpiredBackupFiles(String filePrefix)
focal_class.full_signature: private void deleteExpiredBackupFiles(String filePrefix)
focal_class.identifier: deleteExpiredBackupFiles
focal_class.modifiers: private
focal_class.parameters: (String filePrefix)
focal_class.return: void
focal_class.signature: void deleteExpiredBackupFiles(String filePrefix)
focal_class.class_method_signature: BackupCleanupService.isBackupFileExpired(LocalDate fileCreationDate)
focal_class.full_signature: private boolean isBackupFileExpired(LocalDate fileCreationDate)
focal_class.identifier: isBackupFileExpired
focal_class.modifiers: private
focal_class.parameters: (LocalDate fileCreationDate)
focal_class.return: boolean
focal_class.signature: boolean isBackupFileExpired(LocalDate fileCreationDate)
focal_method.body: public void cleanup() {
      try {
        log.info("backup cleanup service started - checking expired backup files");
  
        for (String backupFilePrefix : GtfsCollectorConfiguration.getBackupFilesPrefixes()) {
          deleteExpiredBackupFiles(backupFilePrefix);
        }
  
        log.info("backup cleanup service done.");
  
      } catch (Exception e) {
        log.error("failed performing backup files cleanup", e);
      }
    }
focal_method.class_method_signature: BackupCleanupService.cleanup()
focal_method.full_signature: public void cleanup()
focal_method.identifier: cleanup
focal_method.invocations: info getBackupFilesPrefixes deleteExpiredBackupFiles info error
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void cleanup()