Search in sources :

Example 1 with MockI18nFormat

use of org.hisp.dhis.mock.MockI18nFormat in project dhis2-core by dhis2.

the class ProgramStageInstanceServiceTest method setUpTest.

@Override
public void setUpTest() {
    mockFormat = new MockI18nFormat();
    organisationUnitA = createOrganisationUnit('A');
    organisationUnitService.addOrganisationUnit(organisationUnitA);
    organisationUnitB = createOrganisationUnit('B');
    organisationUnitService.addOrganisationUnit(organisationUnitB);
    entityInstanceA = createTrackedEntityInstance('A', organisationUnitA);
    entityInstanceService.addTrackedEntityInstance(entityInstanceA);
    entityInstanceB = createTrackedEntityInstance('B', organisationUnitB);
    entityInstanceService.addTrackedEntityInstance(entityInstanceB);
    TrackedEntityAttribute attribute = createTrackedEntityAttribute('A');
    attribute.setValueType(ValueType.PHONE_NUMBER);
    attributeService.addTrackedEntityAttribute(attribute);
    TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue('A', entityInstanceA, attribute);
    attributeValue.setValue("123456789");
    attributeValueService.addTrackedEntityAttributeValue(attributeValue);
    entityInstanceA.getTrackedEntityAttributeValues().add(attributeValue);
    entityInstanceService.updateTrackedEntityInstance(entityInstanceA);
    /**
         * Program A
         */
    programA = createProgram('A', new HashSet<>(), organisationUnitA);
    programService.addProgram(programA);
    stageA = createProgramStage('A', 0);
    stageA.setProgram(programA);
    stageA.setSortOrder(1);
    programStageService.saveProgramStage(stageA);
    stageB = new ProgramStage("B", programA);
    stageB.setSortOrder(2);
    programStageService.saveProgramStage(stageB);
    Set<ProgramStage> programStages = new HashSet<>();
    programStages.add(stageA);
    programStages.add(stageB);
    programA.setProgramStages(programStages);
    programService.updateProgram(programA);
    dataElementA = createDataElement('A');
    dataElementB = createDataElement('B');
    dataElementService.addDataElement(dataElementA);
    dataElementService.addDataElement(dataElementB);
    stageDataElementA = new ProgramStageDataElement(stageA, dataElementA, false, 1);
    stageDataElementB = new ProgramStageDataElement(stageA, dataElementB, false, 2);
    stageDataElementC = new ProgramStageDataElement(stageB, dataElementA, false, 1);
    stageDataElementD = new ProgramStageDataElement(stageB, dataElementB, false, 2);
    programStageDataElementService.addProgramStageDataElement(stageDataElementA);
    programStageDataElementService.addProgramStageDataElement(stageDataElementB);
    programStageDataElementService.addProgramStageDataElement(stageDataElementC);
    programStageDataElementService.addProgramStageDataElement(stageDataElementD);
    /**
         * Program B
         */
    Program programB = createProgram('B', new HashSet<>(), organisationUnitB);
    programService.addProgram(programB);
    stageC = new ProgramStage("C", programB);
    stageC.setSortOrder(1);
    programStageService.saveProgramStage(stageC);
    stageD = new ProgramStage("D", programB);
    stageB.setSortOrder(2);
    stageC.setRepeatable(true);
    programStageService.saveProgramStage(stageD);
    programStages = new HashSet<>();
    programStages.add(stageC);
    programStages.add(stageD);
    programB.setProgramStages(programStages);
    programService.updateProgram(programB);
    /**
         * Program Instance and Program Stage Instance
         */
    DateTime testDate1 = DateTime.now();
    testDate1.withTimeAtStartOfDay();
    testDate1 = testDate1.minusDays(70);
    incidenDate = testDate1.toDate();
    DateTime testDate2 = DateTime.now();
    testDate2.withTimeAtStartOfDay();
    enrollmentDate = testDate2.toDate();
    programInstanceA = new ProgramInstance(enrollmentDate, incidenDate, entityInstanceA, programA);
    programInstanceA.setUid("UID-PIA");
    programInstanceService.addProgramInstance(programInstanceA);
    programInstanceB = new ProgramInstance(enrollmentDate, incidenDate, entityInstanceB, programB);
    programInstanceService.addProgramInstance(programInstanceB);
    programStageInstanceA = new ProgramStageInstance(programInstanceA, stageA);
    programStageInstanceA.setDueDate(enrollmentDate);
    programStageInstanceA.setUid("UID-A");
    programStageInstanceB = new ProgramStageInstance(programInstanceA, stageB);
    programStageInstanceB.setDueDate(enrollmentDate);
    programStageInstanceB.setUid("UID-B");
    programStageInstanceC = new ProgramStageInstance(programInstanceB, stageC);
    programStageInstanceC.setDueDate(enrollmentDate);
    programStageInstanceC.setUid("UID-C");
    programStageInstanceD1 = new ProgramStageInstance(programInstanceB, stageD);
    programStageInstanceD1.setDueDate(enrollmentDate);
    programStageInstanceD1.setUid("UID-D1");
    programStageInstanceD2 = new ProgramStageInstance(programInstanceB, stageD);
    programStageInstanceD2.setDueDate(enrollmentDate);
    programStageInstanceD2.setUid("UID-D2");
}
Also used : MockI18nFormat(org.hisp.dhis.mock.MockI18nFormat) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) DateTime(org.joda.time.DateTime) HashSet(java.util.HashSet)

Example 2 with MockI18nFormat

use of org.hisp.dhis.mock.MockI18nFormat in project dhis2-core by dhis2.

the class ReportTableTest method setUpTest.

// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    dataElements = new ArrayList<>();
    categoryOptionCombos = new ArrayList<>();
    indicators = new ArrayList<>();
    reportingRates = new ArrayList<>();
    periods = new ArrayList<>();
    units = new ArrayList<>();
    relativeUnits = new ArrayList<>();
    groups = new ArrayList<>();
    montlyPeriodType = PeriodType.getPeriodTypeByName(MonthlyPeriodType.NAME);
    dataElementA = createDataElement('A');
    dataElementB = createDataElement('B');
    dataElementA.setId('A');
    dataElementB.setId('B');
    dataElements.add(dataElementA);
    dataElements.add(dataElementB);
    deGroupSetA = createDataElementGroupSet('A');
    deGroupA = createDataElementGroup('A');
    deGroupB = createDataElementGroup('B');
    deGroupA.getGroupSets().add(deGroupSetA);
    deGroupB.getGroupSets().add(deGroupSetA);
    deGroupSetA.getMembers().add(deGroupA);
    deGroupSetA.getMembers().add(deGroupB);
    categoryOptionComboA = createCategoryOptionCombo('A', 'A', 'B');
    categoryOptionComboB = createCategoryOptionCombo('B', 'C', 'D');
    categoryOptionComboA.setId('A');
    categoryOptionComboB.setId('B');
    categoryOptionCombos.add(categoryOptionComboA);
    categoryOptionCombos.add(categoryOptionComboB);
    categoryCombo = new DataElementCategoryCombo("CategoryComboA", DataDimensionType.DISAGGREGATION);
    categoryCombo.setId('A');
    categoryCombo.setOptionCombos(new HashSet<>(categoryOptionCombos));
    indicatorType = createIndicatorType('A');
    indicatorA = createIndicator('A', indicatorType);
    indicatorB = createIndicator('B', indicatorType);
    indicatorA.setId('A');
    indicatorB.setId('B');
    indicators.add(indicatorA);
    indicators.add(indicatorB);
    DataSet dataSetA = createDataSet('A', montlyPeriodType);
    DataSet dataSetB = createDataSet('B', montlyPeriodType);
    dataSetA.setId('A');
    dataSetB.setId('B');
    reportingRateA = new ReportingRate(dataSetA);
    reportingRateB = new ReportingRate(dataSetB);
    reportingRates.add(reportingRateA);
    reportingRates.add(reportingRateB);
    periodA = createPeriod(montlyPeriodType, getDate(2008, 1, 1), getDate(2008, 1, 31));
    periodB = createPeriod(montlyPeriodType, getDate(2008, 2, 1), getDate(2008, 2, 28));
    periodA.setId('A');
    periodB.setId('B');
    periods.add(periodA);
    periods.add(periodB);
    relatives = new RelativePeriods();
    relatives.setLastMonth(true);
    relatives.setThisYear(true);
    List<Period> rp = relatives.getRelativePeriods();
    periodC = rp.get(0);
    periodD = rp.get(1);
    unitA = createOrganisationUnit('A');
    unitB = createOrganisationUnit('B', unitA);
    unitC = createOrganisationUnit('C', unitA);
    unitA.setId('A');
    unitB.setId('B');
    unitC.setId('C');
    unitA.getChildren().add(unitB);
    unitA.getChildren().add(unitC);
    units.add(unitA);
    units.add(unitB);
    relativeUnits.add(unitA);
    ouGroupSetA = createOrganisationUnitGroupSet('A');
    ouGroupA = createOrganisationUnitGroup('A');
    ouGroupB = createOrganisationUnitGroup('B');
    ouGroupA.getGroupSets().add(ouGroupSetA);
    ouGroupB.getGroupSets().add(ouGroupSetA);
    ouGroupA.setId('A');
    ouGroupB.setId('B');
    ouGroupSetA.getOrganisationUnitGroups().add(ouGroupA);
    ouGroupSetA.getOrganisationUnitGroups().add(ouGroupB);
    groups.add(ouGroupA);
    groups.add(ouGroupB);
    i18nFormat = new MockI18nFormat();
}
Also used : MockI18nFormat(org.hisp.dhis.mock.MockI18nFormat) DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) RelativePeriods(org.hisp.dhis.period.RelativePeriods) DataSet(org.hisp.dhis.dataset.DataSet) ReportingRate(org.hisp.dhis.common.ReportingRate) Period(org.hisp.dhis.period.Period)

Example 3 with MockI18nFormat

use of org.hisp.dhis.mock.MockI18nFormat in project dhis2-core by dhis2.

the class ChartServiceTest method testGetBarChart.

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------
@Test
public void testGetBarChart() {
    int id = chartService.addChart(chartA);
    JFreeChart jFreeChart = chartService.getJFreeChart(id, new MockI18nFormat());
    assertNotNull(jFreeChart);
}
Also used : MockI18nFormat(org.hisp.dhis.mock.MockI18nFormat) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

MockI18nFormat (org.hisp.dhis.mock.MockI18nFormat)3 HashSet (java.util.HashSet)1 DhisSpringTest (org.hisp.dhis.DhisSpringTest)1 ReportingRate (org.hisp.dhis.common.ReportingRate)1 DataElementCategoryCombo (org.hisp.dhis.dataelement.DataElementCategoryCombo)1 DataSet (org.hisp.dhis.dataset.DataSet)1 Period (org.hisp.dhis.period.Period)1 RelativePeriods (org.hisp.dhis.period.RelativePeriods)1 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)1 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)1 JFreeChart (org.jfree.chart.JFreeChart)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1