Search in sources :

Example 11 with JobConfiguration

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());
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) DataSynchronizationJobParameters(org.hisp.dhis.scheduling.parameters.DataSynchronizationJobParameters) Test(org.junit.jupiter.api.Test)

Example 12 with JobConfiguration

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());
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Example 13 with JobConfiguration

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());
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Example 14 with JobConfiguration

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());
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Example 15 with JobConfiguration

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);
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) JmsListener(org.springframework.jms.annotation.JmsListener)

Aggregations

JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)55 Test (org.junit.jupiter.api.Test)23 ErrorReport (org.hisp.dhis.feedback.ErrorReport)10 List (java.util.List)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 ArrayList (java.util.ArrayList)5 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 InputStream (java.io.InputStream)4 IdScheme (org.hisp.dhis.common.IdScheme)4 CachingMap (org.hisp.dhis.commons.collection.CachingMap)4 ImportSummaries (org.hisp.dhis.dxf2.importsummary.ImportSummaries)4 ImportStrategy (org.hisp.dhis.importexport.ImportStrategy)4 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 IdSchemes (org.hisp.dhis.common.IdSchemes)3 IdentifiableObjectManager (org.hisp.dhis.common.IdentifiableObjectManager)3 TrackerTrigramIndexJobParameters (org.hisp.dhis.scheduling.parameters.TrackerTrigramIndexJobParameters)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3