@Test public void deletingFromArchiveTablesContinuesAsLongAsOldWorkflowsAreFound() { doReturn(oldWorkdlowIds, oldWorkdlowIds, oldWorkdlowIds, emptyList).when(dao).getOldWorkflowIds(ARCHIVE, limit, BATCH_SIZE, emptySet()); when(dao.deleteWorkflows(ARCHIVE, oldWorkdlowIds)).thenReturn(oldWorkdlowIds.size()); MaintenanceResults results = service.cleanupWorkflows(deleteArchiveConfig); assertEquals(oldWorkdlowIds.size() * 3, results.deletedArchivedWorkflows); assertValidArchiveTablesAreChecked(); verify(dao, times(4)).getOldWorkflowIds(ARCHIVE, limit, BATCH_SIZE, emptySet()); verify(dao, times(3)).deleteWorkflows(ARCHIVE, oldWorkdlowIds); verifyNoMoreInteractions(dao, tableMetadataChecker); }
@SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") public MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration) { validateConfiguration(configuration); if (configuration.archiveWorkflows != null || configuration.deleteArchivedWorkflows != null) { ARCHIVABLE_TABLES.forEach(table -> tableMetadataChecker.ensureCopyingPossible(MAIN.nameOf(table), ARCHIVE.nameOf(table))); } Builder builder = new MaintenanceResults.Builder(); if (configuration.deleteArchivedWorkflows != null) { builder.setDeletedArchivedWorkflows(doAction("Deleting archived workflows", configuration.deleteArchivedWorkflows, ARCHIVE, idList -> maintenanceDao.deleteWorkflows(ARCHIVE, idList))); } if (configuration.archiveWorkflows != null) { builder.setArchivedWorkflows( doAction("Archiving workflows", configuration.archiveWorkflows, MAIN, maintenanceDao::archiveWorkflows)); } if (configuration.deleteWorkflows != null) { builder.setDeletedWorkflows(doAction("Deleting workflows", configuration.deleteWorkflows, MAIN, idList -> maintenanceDao.deleteWorkflows(MAIN, idList))); } return builder.build(); }
MaintenanceService { @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") public MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration) { validateConfiguration(configuration); if (configuration.archiveWorkflows != null || configuration.deleteArchivedWorkflows != null) { ARCHIVABLE_TABLES.forEach(table -> tableMetadataChecker.ensureCopyingPossible(MAIN.nameOf(table), ARCHIVE.nameOf(table))); } Builder builder = new MaintenanceResults.Builder(); if (configuration.deleteArchivedWorkflows != null) { builder.setDeletedArchivedWorkflows(doAction("Deleting archived workflows", configuration.deleteArchivedWorkflows, ARCHIVE, idList -> maintenanceDao.deleteWorkflows(ARCHIVE, idList))); } if (configuration.archiveWorkflows != null) { builder.setArchivedWorkflows( doAction("Archiving workflows", configuration.archiveWorkflows, MAIN, maintenanceDao::archiveWorkflows)); } if (configuration.deleteWorkflows != null) { builder.setDeletedWorkflows(doAction("Deleting workflows", configuration.deleteWorkflows, MAIN, idList -> maintenanceDao.deleteWorkflows(MAIN, idList))); } return builder.build(); } }
MaintenanceService { @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") public MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration) { validateConfiguration(configuration); if (configuration.archiveWorkflows != null || configuration.deleteArchivedWorkflows != null) { ARCHIVABLE_TABLES.forEach(table -> tableMetadataChecker.ensureCopyingPossible(MAIN.nameOf(table), ARCHIVE.nameOf(table))); } Builder builder = new MaintenanceResults.Builder(); if (configuration.deleteArchivedWorkflows != null) { builder.setDeletedArchivedWorkflows(doAction("Deleting archived workflows", configuration.deleteArchivedWorkflows, ARCHIVE, idList -> maintenanceDao.deleteWorkflows(ARCHIVE, idList))); } if (configuration.archiveWorkflows != null) { builder.setArchivedWorkflows( doAction("Archiving workflows", configuration.archiveWorkflows, MAIN, maintenanceDao::archiveWorkflows)); } if (configuration.deleteWorkflows != null) { builder.setDeletedWorkflows(doAction("Deleting workflows", configuration.deleteWorkflows, MAIN, idList -> maintenanceDao.deleteWorkflows(MAIN, idList))); } return builder.build(); } @Inject  MaintenanceService(MaintenanceDao maintenanceDao, TableMetadataChecker tableMetadataChecker,
      WorkflowDefinitionService workflowDefinitionService); }
MaintenanceService { @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") public MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration) { validateConfiguration(configuration); if (configuration.archiveWorkflows != null || configuration.deleteArchivedWorkflows != null) { ARCHIVABLE_TABLES.forEach(table -> tableMetadataChecker.ensureCopyingPossible(MAIN.nameOf(table), ARCHIVE.nameOf(table))); } Builder builder = new MaintenanceResults.Builder(); if (configuration.deleteArchivedWorkflows != null) { builder.setDeletedArchivedWorkflows(doAction("Deleting archived workflows", configuration.deleteArchivedWorkflows, ARCHIVE, idList -> maintenanceDao.deleteWorkflows(ARCHIVE, idList))); } if (configuration.archiveWorkflows != null) { builder.setArchivedWorkflows( doAction("Archiving workflows", configuration.archiveWorkflows, MAIN, maintenanceDao::archiveWorkflows)); } if (configuration.deleteWorkflows != null) { builder.setDeletedWorkflows(doAction("Deleting workflows", configuration.deleteWorkflows, MAIN, idList -> maintenanceDao.deleteWorkflows(MAIN, idList))); } return builder.build(); } @Inject  MaintenanceService(MaintenanceDao maintenanceDao, TableMetadataChecker tableMetadataChecker,
      WorkflowDefinitionService workflowDefinitionService); @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration); }
MaintenanceService { @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") public MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration) { validateConfiguration(configuration); if (configuration.archiveWorkflows != null || configuration.deleteArchivedWorkflows != null) { ARCHIVABLE_TABLES.forEach(table -> tableMetadataChecker.ensureCopyingPossible(MAIN.nameOf(table), ARCHIVE.nameOf(table))); } Builder builder = new MaintenanceResults.Builder(); if (configuration.deleteArchivedWorkflows != null) { builder.setDeletedArchivedWorkflows(doAction("Deleting archived workflows", configuration.deleteArchivedWorkflows, ARCHIVE, idList -> maintenanceDao.deleteWorkflows(ARCHIVE, idList))); } if (configuration.archiveWorkflows != null) { builder.setArchivedWorkflows( doAction("Archiving workflows", configuration.archiveWorkflows, MAIN, maintenanceDao::archiveWorkflows)); } if (configuration.deleteWorkflows != null) { builder.setDeletedWorkflows(doAction("Deleting workflows", configuration.deleteWorkflows, MAIN, idList -> maintenanceDao.deleteWorkflows(MAIN, idList))); } return builder.build(); } @Inject  MaintenanceService(MaintenanceDao maintenanceDao, TableMetadataChecker tableMetadataChecker,
      WorkflowDefinitionService workflowDefinitionService); @SuppressFBWarnings(value = "BAS_BLOATED_ASSIGNMENT_SCOPE", justification = "periodicLogger is defined in correct scope") MaintenanceResults cleanupWorkflows(MaintenanceConfiguration configuration);  }