use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class JobConfigurationObjectBundleHookTest method validateInternalNonConfigurableShownValidationErrorE7010Configurable.
@Test
void validateInternalNonConfigurableShownValidationErrorE7010Configurable() {
Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq("jsdhJSJHD"))).thenReturn(analyticsTableJobConfig);
Mockito.when(jobService.getJob(Mockito.eq(JobType.DATA_SYNC))).thenReturn(job);
Mockito.when(job.validate()).thenReturn(new ErrorReport(Class.class, ErrorCode.E7010));
analyticsTableJobConfig.setJobType(JobType.DATA_SYNC);
JobConfiguration jobConfiguration = new JobConfiguration();
jobConfiguration.setUid("jsdhJSJHD");
jobConfiguration.setJobType(JobType.DATA_SYNC);
jobConfiguration.setCronExpression(CRON_HOURLY);
jobConfiguration.setEnabled(true);
DataSynchronizationJobParameters jobParameters = new DataSynchronizationJobParameters();
jobParameters.setPageSize(200);
jobConfiguration.setJobParameters(jobParameters);
List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
Assertions.assertEquals(1, errorReports.size());
Assertions.assertEquals(ErrorCode.E7010, errorReports.get(0).getErrorCode());
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class JobConfigurationObjectBundleHookTest method validateInternalNonConfigurableChangeError.
@Test
void validateInternalNonConfigurableChangeError() {
Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq("jsdhJSJHD"))).thenReturn(analyticsTableJobConfig);
Mockito.when(jobService.getJob(Mockito.eq(JobType.ANALYTICSTABLE_UPDATE))).thenReturn(job);
JobConfiguration jobConfiguration = new JobConfiguration();
jobConfiguration.setUid("jsdhJSJHD");
jobConfiguration.setJobType(JobType.ANALYTICSTABLE_UPDATE);
jobConfiguration.setCronExpression(CRON_HOURLY);
jobConfiguration.setEnabled(false);
List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
Assertions.assertEquals(1, errorReports.size());
Assertions.assertEquals(ErrorCode.E7003, errorReports.get(0).getErrorCode());
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class JobConfigurationObjectBundleHookTest method validateInternalNonConfigurableChange.
@Test
void validateInternalNonConfigurableChange() {
Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq("jsdhJSJHD"))).thenReturn(analyticsTableJobConfig);
Mockito.when(jobService.getJob(Mockito.eq(JobType.ANALYTICSTABLE_UPDATE))).thenReturn(job);
JobConfiguration jobConfiguration = new JobConfiguration();
jobConfiguration.setUid("jsdhJSJHD");
jobConfiguration.setJobType(JobType.ANALYTICSTABLE_UPDATE);
jobConfiguration.setCronExpression(CRON_HOURLY);
jobConfiguration.setEnabled(true);
List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
Assertions.assertEquals(0, errorReports.size());
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class JobConfigurationObjectBundleHookTest method validateInternalNonConfigurableShownValidationErrorE7010NoPrevious.
@Test
void validateInternalNonConfigurableShownValidationErrorE7010NoPrevious() {
Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq("jsdhJSJHD"))).thenReturn(null);
Mockito.when(jobService.getJob(Mockito.eq(JobType.ANALYTICSTABLE_UPDATE))).thenReturn(job);
Mockito.when(job.validate()).thenReturn(new ErrorReport(Class.class, ErrorCode.E7010));
analyticsTableJobConfig.setJobType(JobType.ANALYTICSTABLE_UPDATE);
JobConfiguration jobConfiguration = new JobConfiguration();
jobConfiguration.setUid("jsdhJSJHD");
jobConfiguration.setJobType(JobType.ANALYTICSTABLE_UPDATE);
jobConfiguration.setCronExpression(CRON_HOURLY);
jobConfiguration.setEnabled(true);
List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
Assertions.assertEquals(1, errorReports.size());
Assertions.assertEquals(ErrorCode.E7010, errorReports.get(0).getErrorCode());
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class TrackerMessageManager method consume.
@JmsListener(destination = Topics.TRACKER_IMPORT_JOB_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory")
public void consume(TextMessage message) throws JMSException, JsonProcessingException {
String payload = message.getText();
TrackerMessage trackerMessage = objectMapper.readValue(payload, TrackerMessage.class);
TrackerImportParams trackerImportParams = trackerMessage.getTrackerImportParams();
JobConfiguration jobConfiguration = new JobConfiguration("", JobType.TRACKER_IMPORT_JOB, trackerImportParams.getUserId(), true);
jobConfiguration.setUid(trackerMessage.getUid());
trackerImportParams.setJobConfiguration(jobConfiguration);
TrackerImportThread trackerImportThread = trackerImportThreadFactory.getObject();
trackerImportThread.setTrackerImportParams(trackerImportParams);
SecurityContextHolder.getContext().setAuthentication(AuthenticationSerializer.deserialize(trackerMessage.getAuthentication()));
taskExecutor.executeTask(trackerImportThread);
}
Aggregations