/** * Get and validates configuration value for the delay in days to complete the business object data destroy operation. * * @return the delay in days to complete the business object data destroy operation */ int getAndValidateFinalDestroyInDays() { // Get the configured delay (in days) for business object data finalize destroy. int finalDestroyInDays = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS); // Validate the finalize delay configuration value. if (finalDestroyInDays <= 0) { throw new IllegalStateException( String.format("Configuration \"%s\" must be a positive integer.", ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS.getKey())); } return finalDestroyInDays; }
/** * Get and validates configuration value for the delay in days to complete the business object data destroy operation. * * @return the delay in days to complete the business object data destroy operation */ int getAndValidateFinalDestroyInDays() { // Get the configured delay (in days) for business object data finalize destroy. int finalDestroyInDays = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS); // Validate the finalize delay configuration value. if (finalDestroyInDays <= 0) { throw new IllegalStateException( String.format("Configuration \"%s\" must be a positive integer.", ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS.getKey())); } return finalDestroyInDays; }
/** * Gets a list of historic process instances by the given process definition keys, job status, start time, and/or end time. If the given list of process * definition keys is empty or null, the result will not be filtered by the process definition keys. If the given job status is null, the result will not be * filtered by the job status. When job status is RUNNING or SUSPENDED, then all "unfinished" process instances are returned. * * @param processDefinitionKeys Optional. The set of process definition keys * @param jobStatus an optional job status * @param startTime an optional job start time * @param endTime an optional job end time * * @return A list of historic process instances */ private List<HistoricProcessInstance> getHistoricProcessInstances(Collection<String> processDefinitionKeys, JobStatusEnum jobStatus, DateTime startTime, DateTime endTime) { /* * Validates the result count before actually retrieving the result set, so that it would fail-fast and minimize the impact of the query. */ long processInstanceCount = activitiService.getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime); int jobsMaxQueryResults = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.JOBS_QUERY_MAX_RESULTS); Assert.isTrue(processInstanceCount <= jobsMaxQueryResults, "Too many jobs found for the specified filter parameters. The maximum number of results allowed is " + jobsMaxQueryResults + " and the number of results returned was " + processInstanceCount + "."); return activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime); }
/** * Gets a list of historic process instances by the given process definition keys, job status, start time, and/or end time. If the given list of process * definition keys is empty or null, the result will not be filtered by the process definition keys. If the given job status is null, the result will not be * filtered by the job status. When job status is RUNNING or SUSPENDED, then all "unfinished" process instances are returned. * * @param processDefinitionKeys Optional. The set of process definition keys * @param jobStatus an optional job status * @param startTime an optional job start time * @param endTime an optional job end time * * @return A list of historic process instances */ private List<HistoricProcessInstance> getHistoricProcessInstances(Collection<String> processDefinitionKeys, JobStatusEnum jobStatus, DateTime startTime, DateTime endTime) { /* * Validates the result count before actually retrieving the result set, so that it would fail-fast and minimize the impact of the query. */ long processInstanceCount = activitiService.getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime); int jobsMaxQueryResults = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.JOBS_QUERY_MAX_RESULTS); Assert.isTrue(processInstanceCount <= jobsMaxQueryResults, "Too many jobs found for the specified filter parameters. The maximum number of results allowed is " + jobsMaxQueryResults + " and the number of results returned was " + processInstanceCount + "."); return activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime); }
@Before public void before() { initMocks(this); when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.JOBS_QUERY_MAX_RESULTS)).thenReturn(1); when(jobDefinitionHelper.getJobDefinitionKey(eq("a.b"), any())).thenReturn(new JobDefinitionAlternateKeyDto("a", "b")); }
@Test public void testGetAndValidateFinalDestroyInDaysNonPositiveValue() { // Mock the external calls. when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS)).thenReturn(0); // Try to call the method under test. try { businessObjectDataInitiateDestroyHelperServiceImpl.getAndValidateFinalDestroyInDays(); fail(); } catch (IllegalStateException e) { assertEquals(String.format("Configuration \"%s\" must be a positive integer.", ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS.getKey()), e.getMessage()); } // Verify the external calls. verify(herdStringHelper).getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS); verifyNoMoreInteractionsHelper(); }
herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_PROCESSOR_BDATA_UPDATED_ON_THRESHOLD_DAYS); int maxAllowedTransitionAttempts = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_TRANSITION_MAX_ALLOWED_ATTEMPTS);
herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_PROCESSOR_BDATA_UPDATED_ON_THRESHOLD_DAYS); int maxAllowedTransitionAttempts = herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_TRANSITION_MAX_ALLOWED_ATTEMPTS);
when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_PROCESSOR_BDATA_UPDATED_ON_THRESHOLD_DAYS)) .thenReturn(updatedOnThresholdInDays); when(businessObjectDataDao.getBusinessObjectDataEntitiesMatchingStoragePolicies(StoragePolicySelectorServiceImpl.STORAGE_POLICY_PRIORITY_LEVELS.get(0), StoragePolicySelectorServiceImpl.SUPPORTED_BUSINESS_OBJECT_DATA_STATUSES, storagePolicyTransitionMaxAllowedAttempts, 0, maxResults)) .thenReturn(noMatchingBusinessObjectDataEntities); when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_TRANSITION_MAX_ALLOWED_ATTEMPTS)) .thenReturn(storagePolicyTransitionMaxAllowedAttempts); verify(herdStringHelper).getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_PROCESSOR_BDATA_UPDATED_ON_THRESHOLD_DAYS); verify(herdStringHelper).getConfigurationValueAsInteger(ConfigurationValue.STORAGE_POLICY_TRANSITION_MAX_ALLOWED_ATTEMPTS); verify(businessObjectDataDao) .getBusinessObjectDataEntitiesMatchingStoragePolicies(StoragePolicySelectorServiceImpl.STORAGE_POLICY_PRIORITY_LEVELS.get(0),
when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN)).thenReturn(S3_OBJECT_TAGGER_ROLE_ARN); when(configurationHelper.getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME)).thenReturn(S3_OBJECT_TAGGER_ROLE_SESSION_NAME); when(herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS)) .thenReturn(BDATA_FINAL_DESTROY_DELAY_IN_DAYS); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_ARN); verify(configurationHelper).getRequiredProperty(ConfigurationValue.S3_OBJECT_DELETE_ROLE_SESSION_NAME); verify(herdStringHelper).getConfigurationValueAsInteger(ConfigurationValue.BDATA_FINAL_DESTROY_DELAY_IN_DAYS); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(businessObjectDataHelper).getDateFromString(PARTITION_VALUE);
herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_RESTORE_EXPIRATION_IN_DAYS_DEFAULT);
herdStringHelper.getConfigurationValueAsInteger(ConfigurationValue.BDATA_RESTORE_EXPIRATION_IN_DAYS_DEFAULT);