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);
}
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);
}
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));
}
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));
}
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());
}
Aggregations