dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37557
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19184: Test
------------------------------------------------------------
revno: 19184
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-05-26 00:08:54 -0400
message:
Test
modified:
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java 2015-05-26 04:08:54 +0000
@@ -55,26 +55,46 @@
@Test
public void testCreatePeriod()
{
- testDate = new DateTime( 2009, 8, 15, 0 ,0 );
+ testDate = new DateTime( 2009, 8, 15, 0 ,0 );
- startDate = new DateTime( 2009, 4, 1, 0 ,0 );
- endDate = new DateTime( 2009, 9, 30, 0 ,0 );
+ startDate = new DateTime( 2009, 4, 1, 0 ,0 );
+ endDate = new DateTime( 2009, 9, 30, 0 ,0 );
Period period = periodType.createPeriod( testDate.toDate() );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
- testDate = new DateTime( 2009, 12, 15, 0 ,0 );
+ testDate = new DateTime( 2009, 12, 15, 0 ,0 );
- startDate = new DateTime( 2009, 10, 1, 0 ,0 );
- endDate = new DateTime( 2010, 3, 31, 0 ,0 );
+ startDate = new DateTime( 2009, 10, 1, 0 ,0 );
+ endDate = new DateTime( 2010, 3, 31, 0 ,0 );
period = periodType.createPeriod( testDate.toDate() );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
}
+
+ @Test
+ public void testCreatePeriodFromIsoDate()
+ {
+ Period period = periodType.createPeriod( "2015AprilS1" );
+
+ startDate = new DateTime( 2015, 4, 1, 0 ,0 );
+ endDate = new DateTime( 2015, 9, 30, 0 ,0 );
+
+ assertEquals( startDate.toDate(), period.getStartDate() );
+ assertEquals( endDate.toDate(), period.getEndDate() );
+
+ period = periodType.createPeriod( "2015AprilS2" );
+
+ startDate = new DateTime( 2015, 10, 1, 0 ,0 );
+ endDate = new DateTime( 2016, 3, 31, 0 ,0 );
+
+ assertEquals( startDate.toDate(), period.getStartDate() );
+ assertEquals( endDate.toDate(), period.getEndDate() );
+ }
@Test
public void testGetNextPeriod()
@@ -85,8 +105,8 @@
period = periodType.getNextPeriod( period );
- startDate = new DateTime( 2009, 10, 1, 0 ,0 );
- endDate = new DateTime( 2010, 3, 31, 0 ,0 );
+ startDate = new DateTime( 2009, 10, 1, 0 ,0 );
+ endDate = new DateTime( 2010, 3, 31, 0 ,0 );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
@@ -97,8 +117,8 @@
period = periodType.getNextPeriod( period );
- startDate = new DateTime( 2010, 4, 1, 0 ,0 );
- endDate = new DateTime( 2010, 9, 30, 0 ,0 );
+ startDate = new DateTime( 2010, 4, 1, 0 ,0 );
+ endDate = new DateTime( 2010, 9, 30, 0 ,0 );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
@@ -113,8 +133,8 @@
period = periodType.getPreviousPeriod( period );
- startDate = new DateTime( 2008, 10, 1, 0 ,0 );
- endDate = new DateTime( 2009, 3, 31, 0 ,0 );
+ startDate = new DateTime( 2008, 10, 1, 0 ,0 );
+ endDate = new DateTime( 2009, 3, 31, 0 ,0 );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
@@ -125,8 +145,8 @@
period = periodType.getPreviousPeriod( period );
- startDate = new DateTime( 2009, 4, 1, 0 ,0 );
- endDate = new DateTime( 2009, 9, 30, 0 ,0 );
+ startDate = new DateTime( 2009, 4, 1, 0 ,0 );
+ endDate = new DateTime( 2009, 9, 30, 0 ,0 );
assertEquals( startDate.toDate(), period.getStartDate() );
assertEquals( endDate.toDate(), period.getEndDate() );
@@ -140,16 +160,16 @@
List<Period> periods = periodType.generatePeriods( testDate.toDate() );
assertEquals( 2, periods.size() );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
testDate = new DateTime( 2009, 12, 15, 0 ,0 );
periods = periodType.generatePeriods( testDate.toDate() );
assertEquals( 2, periods.size() );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
}
@Test
@@ -160,16 +180,16 @@
List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
assertEquals( 2, periods.size() );
- assertEquals( periodType.createPeriod( new DateTime( 2008, 10, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2008, 10, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
testDate = new DateTime( 2009, 12, 15, 0 ,0 );
periods = periodType.generateRollingPeriods( testDate.toDate() );
assertEquals( 2, periods.size() );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
- assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
}
@Test
@@ -180,7 +200,7 @@
List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
assertEquals( 10, periods.size() );
- assertEquals( periodType.createPeriod( new DateTime( 2005, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
- assertEquals( periodType.createPeriod( new DateTime( 2005, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2005, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+ assertEquals( periodType.createPeriod( new DateTime( 2005, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
}
}