Search in sources :

Example 31 with MonthlyPeriodType

use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.

the class DataElementTest method testGetLatestOpenFuturePeriod.

@Test
public void testGetLatestOpenFuturePeriod() {
    DataElement deA = new DataElement("A");
    assertEquals(0, deA.getOpenFuturePeriods());
    DataSet dsA = new DataSet("A", periodType);
    DataSet dsB = new DataSet("B", periodType);
    dsA.setOpenFuturePeriods(3);
    dsB.setOpenFuturePeriods(3);
    dsA.addDataSetElement(deA);
    dsB.addDataSetElement(deA);
    Period lastOpen = deA.getLatestOpenFuturePeriod();
    assertTrue(lastOpen.isAfter(new MonthlyPeriodType().createPeriod()));
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Period(org.hisp.dhis.period.Period) Test(org.junit.Test)

Example 32 with MonthlyPeriodType

use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.

the class DataSetApprovalFrequencyComparatorTest method testA.

@Test
public void testA() {
    DataSet dsA = new DataSet("DataSetA", new YearlyPeriodType());
    DataSet dsB = new DataSet("DataSetB", new YearlyPeriodType());
    DataSet dsC = new DataSet("DataSetC", new MonthlyPeriodType());
    DataSet dsD = new DataSet("DataSetD", new QuarterlyPeriodType());
    DataApprovalWorkflow workflow = new DataApprovalWorkflow("Workflow A", new QuarterlyPeriodType(), null);
    dsA.setWorkflow(workflow);
    dsD.setWorkflow(workflow);
    List<DataSet> list = Lists.newArrayList(dsA, dsC, dsB, dsD);
    Collections.sort(list, DataSetApprovalFrequencyComparator.INSTANCE);
    assertEquals(dsD, list.get(0));
    assertEquals(dsA, list.get(1));
    assertEquals(dsC, list.get(2));
    assertEquals(dsB, list.get(3));
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) Test(org.junit.Test)

Example 33 with MonthlyPeriodType

use of org.hisp.dhis.period.MonthlyPeriodType in project dhis2-core by dhis2.

the class DataSetFrequencyComparatorTest method testA.

@Test
public void testA() {
    DataSet dsA = new DataSet("DataSetA", new QuarterlyPeriodType());
    DataSet dsB = new DataSet("DataSetB", new YearlyPeriodType());
    DataSet dsC = new DataSet("DataSetC", new MonthlyPeriodType());
    DataSet dsD = new DataSet("DataSetD", new QuarterlyPeriodType());
    List<DataSet> list = Lists.newArrayList(dsA, dsC, dsB, dsD);
    Collections.sort(list, DataSetFrequencyComparator.INSTANCE);
    assertEquals(dsC, list.get(0));
    assertEquals(dsA, list.get(1));
    assertEquals(dsD, list.get(2));
    assertEquals(dsB, list.get(3));
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) YearlyPeriodType(org.hisp.dhis.period.YearlyPeriodType) Test(org.junit.Test)

Aggregations

MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)33 QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)12 Test (org.junit.Test)12 Period (org.hisp.dhis.period.Period)11 PeriodType (org.hisp.dhis.period.PeriodType)11 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)10 DataSet (org.hisp.dhis.dataset.DataSet)8 ArrayList (java.util.ArrayList)7 WeeklyPeriodType (org.hisp.dhis.period.WeeklyPeriodType)6 DateTime (org.joda.time.DateTime)5 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)4 Calendar (java.util.Calendar)3 Date (java.util.Date)3 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 MockCurrentUserService (org.hisp.dhis.mock.MockCurrentUserService)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)2 DataElementCategoryOption (org.hisp.dhis.dataelement.DataElementCategoryOption)2 Indicator (org.hisp.dhis.indicator.Indicator)2