dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09240
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2398: added missing test and fixed public modifier
------------------------------------------------------------
revno: 2398
committer: Bob Joliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-12-20 12:52:12 +0000
message:
added missing test and fixed public modifier
added:
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.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/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2010-12-20 12:43:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2010-12-20 12:52:12 +0000
@@ -179,7 +179,7 @@
*
* @return the period string
*/
- String getIsoDate() {
+ public String getIsoDate() {
return periodType.getIsoDate(this);
}
/**
=== added file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/StringFormatTest.java 2010-12-20 12:52:12 +0000
@@ -0,0 +1,52 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.hisp.dhis.period;
+
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.junit.Test;
+import static junit.framework.Assert.assertEquals;
+
+/**
+ *
+ * @author bobj
+ */
+public class StringFormatTest {
+
+ private static Date getDate( int year, int month, int day )
+ {
+ final Calendar calendar = Calendar.getInstance();
+
+ calendar.clear();
+ calendar.set( year, month - 1, day );
+
+ return calendar.getTime();
+ }
+
+ @Test
+ public void testStringFormat()
+ {
+ Period day1 = new Period(new DailyPeriodType(),getDate(2010,1,1), getDate(2010,1,1));
+ Period week52 = new Period(new WeeklyPeriodType(),getDate(2009,12,21), getDate(2009,12,27));
+ Period week53 = new Period(new WeeklyPeriodType(),getDate(2009,12,28), getDate(2010,1,3));
+ Period week1 = new Period(new WeeklyPeriodType(),getDate(2010,1,4), getDate(2010,1,11));
+ Period month1 = new Period(new MonthlyPeriodType(),getDate(2010,1,1), getDate(2010,1,1));
+ Period year1 = new Period(new YearlyPeriodType(),getDate(2010,1,1), getDate(2010,1,1));
+ Period quarter1 = new Period(new QuarterlyPeriodType(),getDate(2010,1,1), getDate(2010,1,1));
+ Period semester1 = new Period(new SixMonthlyPeriodType(),getDate(2010,1,1), getDate(2010,1,1));
+
+ assertEquals("Day format", "20100101", day1.getIsoDate());
+ assertEquals("Week format", "2009W52", week52.getIsoDate());
+ assertEquals("Week format", "2009W53", week53.getIsoDate());
+ assertEquals("Week format", "2010W1", week1.getIsoDate());
+ assertEquals("Month format", "201001", month1.getIsoDate());
+ assertEquals("Year format", "2010", year1.getIsoDate());
+ assertEquals("Quarter format", "2010Q1", quarter1.getIsoDate());
+ assertEquals("Semester format", "2010S1", semester1.getIsoDate());
+ }
+}