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_DirectoryHasMultipleFiles_SomeExpired_SomeNotExpired() throws IOException {
      // given
      Path tempDirectory = Files.createTempDirectory("unit_test", PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx")));
  
      new GtfsCollectorConfiguration().setGtfsBackupFilesStoreTimeInDays("1");
  
      Path expiredBackupFile1 = Files.createFile(Paths.get(tempDirectory + "/prefix1" + LocalDate.now().minusDays(5).toString()),
          PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-")));
  
      Path notExpiredBackupFile1 = Files.createFile(Paths.get(tempDirectory + "/prefix1" + LocalDate.now().toString()),
          PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-")));
  
      Path expiredBackupFile2 = Files.createFile(Paths.get(tempDirectory + "/prefix2" + LocalDate.now().minusDays(5).toString()),
          PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-")));
  
      Path notExpiredBackupFile2 = Files.createFile(Paths.get(tempDirectory + "/prefix2" + LocalDate.now().toString()),
          PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-rw-rw-")));
  
      new GtfsCollectorConfiguration().setGtfsRawFilesBackupDirectory(tempDirectory.toAbsolutePath().toString());
      new GtfsCollectorConfiguration().setBackupFilesPrefixes("[prefix1,prefix2]");
  
      // when
      backupCleanupService.cleanup();
  
      // then
      Assert.assertFalse("expired back up file should be removed", expiredBackupFile1.toFile().exists());
      Assert.assertTrue("not expired back up file shouldn't be removed", notExpiredBackupFile1.toFile().exists());
  
      Assert.assertFalse("expired back up file should be removed", expiredBackupFile2.toFile().exists());
      Assert.assertTrue("not expired back up file shouldn't be removed", notExpiredBackupFile2.toFile().exists());
  
      tempDirectory.toFile().delete();
    }
test_case.class_method_signature: TestBackupCleanupService.testCleanup_DirectoryHasMultipleFiles_SomeExpired_SomeNotExpired()
test_case.full_signature: @Test public void testCleanup_DirectoryHasMultipleFiles_SomeExpired_SomeNotExpired()
test_case.identifier: testCleanup_DirectoryHasMultipleFiles_SomeExpired_SomeNotExpired
test_case.invocations: createTempDirectory asFileAttribute fromString setGtfsBackupFilesStoreTimeInDays createFile get toString minusDays now asFileAttribute fromString createFile get toString now asFileAttribute fromString createFile get toString minusDays now asFileAttribute fromString createFile get toString now asFileAttribute fromString setGtfsRawFilesBackupDirectory toString toAbsolutePath setBackupFilesPrefixes cleanup assertFalse exists toFile assertTrue exists toFile assertFalse exists toFile assertTrue exists toFile delete toFile
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCleanup_DirectoryHasMultipleFiles_SomeExpired_SomeNotExpired()
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()