Search in sources :

Example 31 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class JobConfigurationObjectBundleHookTest method setUp.

@BeforeEach
public void setUp() {
    analyticsTableJobConfig = new JobConfiguration();
    analyticsTableJobConfig.setJobType(JobType.ANALYTICSTABLE_UPDATE);
    analyticsTableJobConfig.setEnabled(true);
}
Also used : JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class GmlImportServiceTest method setUpTest.

@Override
public void setUpTest() throws IOException {
    inputStream = new ClassPathResource("gml/testGmlPayload.gml").getInputStream();
    /*
         * Create orgunits present in testGmlPayload.gml and set ID properties.
         * Name - FeatureType - ID property Bo - Poly - Name Bonthe - Multi -
         * Code Ole Johan Dahls Hus - Point - Uid Blindern - Point (pos) - Name
         * Forskningsparken - Poly (list) - Name
         *
         * Note: some of these are included to cover different coordinate
         * element schemes such as <posList>, <coordinates> and <pos>.
         */
    userService = _userService;
    boOrgUnit = createOrganisationUnit('A');
    boOrgUnit.setName("Bo");
    organisationUnitService.addOrganisationUnit(boOrgUnit);
    bontheOrgUnit = createOrganisationUnit('B');
    // Match on Code, therefore wrong
    bontheOrgUnit.setName("AA Bonthe");
    // name
    bontheOrgUnit.setCode("CODE_BONTHE");
    organisationUnitService.addOrganisationUnit(bontheOrgUnit);
    ojdOrgUnit = createOrganisationUnit('C');
    ojdOrgUnit.setUid("ImspTQPwCqd");
    // Match on UID,
    ojdOrgUnit.setName("AA Ole Johan Dahls Hus");
    // therefore wrong name
    organisationUnitService.addOrganisationUnit(ojdOrgUnit);
    bliOrgUnit = createOrganisationUnit('D');
    bliOrgUnit.setName("Blindern");
    organisationUnitService.addOrganisationUnit(bliOrgUnit);
    forskOrgUnit = createOrganisationUnit('E');
    forskOrgUnit.setName("Forskningsparken");
    organisationUnitService.addOrganisationUnit(forskOrgUnit);
    user = createAndInjectAdminUser();
    id = new JobConfiguration("gmlImportTest", JobType.METADATA_IMPORT, user.getUid(), true);
    importOptions = new ImportOptions().setImportStrategy(ImportStrategy.UPDATE);
    importOptions.setDryRun(false);
    importOptions.setPreheatCache(true);
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions)

Example 33 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class DefaultMetadataExportServiceTest method getParamsFromMapNotIncludedSecondary.

@Test
void getParamsFromMapNotIncludedSecondary() {
    Mockito.when(schemaService.getSchemaByPluralName(Mockito.eq("jobConfigurations"))).thenReturn(new Schema(JobConfiguration.class, "jobConfiguration", "jobConfigurations"));
    Mockito.when(schemaService.getSchemaByPluralName(Mockito.eq("options"))).thenReturn(new Schema(Option.class, "option", "options"));
    final Map<String, List<String>> params = new HashMap<>();
    params.put("jobConfigurations", Arrays.asList("true", "false"));
    params.put("options", Collections.singletonList("true"));
    MetadataExportParams exportParams = service.getParamsFromMap(params);
    Assertions.assertFalse(exportParams.getClasses().contains(JobConfiguration.class));
    Assertions.assertTrue(exportParams.getClasses().contains(Option.class));
}
Also used : HashMap(java.util.HashMap) Schema(org.hisp.dhis.schema.Schema) Option(org.hisp.dhis.option.Option) List(java.util.List) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Example 34 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class DefaultMetadataExportServiceTest method getParamsFromMapIncludedSecondary.

@Test
void getParamsFromMapIncludedSecondary() {
    Mockito.when(schemaService.getSchemaByPluralName(Mockito.eq("jobConfigurations"))).thenReturn(new Schema(JobConfiguration.class, "jobConfiguration", "jobConfigurations"));
    Mockito.when(schemaService.getSchemaByPluralName(Mockito.eq("options"))).thenReturn(new Schema(Option.class, "option", "options"));
    final Map<String, List<String>> params = new HashMap<>();
    params.put("jobConfigurations", Collections.singletonList("true"));
    params.put("options", Collections.singletonList("true"));
    MetadataExportParams exportParams = service.getParamsFromMap(params);
    Assertions.assertTrue(exportParams.getClasses().contains(JobConfiguration.class));
    Assertions.assertTrue(exportParams.getClasses().contains(Option.class));
}
Also used : HashMap(java.util.HashMap) Schema(org.hisp.dhis.schema.Schema) Option(org.hisp.dhis.option.Option) List(java.util.List) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

Example 35 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class JobConfigurationObjectBundleHookTest method validateDelayForFixedIntervalTypeJobs.

@Test
void validateDelayForFixedIntervalTypeJobs() {
    String jobConfigUid = "o8kG3Qk3nG3";
    JobConfiguration contAnalyticsTableJobConfig = new JobConfiguration();
    contAnalyticsTableJobConfig.setUid(jobConfigUid);
    contAnalyticsTableJobConfig.setJobType(JobType.CONTINUOUS_ANALYTICS_TABLE);
    Mockito.when(jobConfigurationService.getJobConfigurationByUid(Mockito.eq(jobConfigUid))).thenReturn(contAnalyticsTableJobConfig);
    Mockito.when(jobService.getJob(Mockito.eq(JobType.CONTINUOUS_ANALYTICS_TABLE))).thenReturn(job);
    JobConfiguration jobConfiguration = new JobConfiguration();
    jobConfiguration.setUid(jobConfigUid);
    jobConfiguration.setJobType(JobType.CONTINUOUS_ANALYTICS_TABLE);
    jobConfiguration.setJobParameters(new ContinuousAnalyticsJobParameters(1, null, null));
    List<ErrorReport> errorReports = hook.validate(jobConfiguration, null);
    Assertions.assertEquals(1, errorReports.size());
    Assertions.assertEquals(ErrorCode.E7007, errorReports.get(0).getErrorCode());
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) ContinuousAnalyticsJobParameters(org.hisp.dhis.scheduling.parameters.ContinuousAnalyticsJobParameters) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Test(org.junit.jupiter.api.Test)

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