dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16494
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6284: Improved test coverage for reporting rates
------------------------------------------------------------
revno: 6284
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-16 19:28:34 +0100
message:
Improved test coverage for reporting rates
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/error.html
--
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/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2012-03-16 12:05:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2012-03-16 18:28:34 +0000
@@ -57,7 +57,7 @@
*/
public static final String NAME = "Monthly";
- public static final int FREQUENCY_ORDER = 31;
+ public static final int FREQUENCY_ORDER = 30;
// -------------------------------------------------------------------------
// PeriodType functionality
=== 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 2012-03-16 12:05:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java 2012-03-16 18:28:34 +0000
@@ -219,7 +219,7 @@
{
double no = (double) this.periodType.getFrequencyOrder() / type.getFrequencyOrder();
- return (int) Math.round( no );
+ return (int) Math.floor( no );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2012-02-13 11:41:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2012-03-16 18:28:34 +0000
@@ -55,7 +55,7 @@
*/
public static final String NAME = "Quarterly";
- public static final int FREQUENCY_ORDER = 92;
+ public static final int FREQUENCY_ORDER = 91;
// -------------------------------------------------------------------------
// PeriodType functionality
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2012-03-16 12:05:01 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2012-03-16 18:28:34 +0000
@@ -130,7 +130,7 @@
assertEquals( 1, periodType.createPeriod().getPeriodSpan( periodType ) );
assertEquals( 4, new MonthlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
- assertEquals( 9, new BiMonthlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
+ assertEquals( 8, new BiMonthlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
assertEquals( 13, new QuarterlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
assertEquals( 26, new SixMonthlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
assertEquals( 52, new YearlyPeriodType().createPeriod().getPeriodSpan( periodType ) );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java 2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/completeness/jdbc/JDBCDataSetCompletenessStore.java 2012-03-16 18:28:34 +0000
@@ -102,11 +102,11 @@
final String sql =
"SELECT COUNT(*) " +
"FROM completedatasetregistration cr " +
- "JOIN period p ON (cr.periodid = p.periodid) " +
+ "JOIN period pe ON (cr.periodid = pe.periodid) " +
"WHERE cr.datasetid = " + dataSet.getId() + " " +
"AND cr.periodid IN ( " + getCommaDelimitedString( periods ) + " ) " +
"AND cr.sourceid IN ( " + getCommaDelimitedString( relevantSources ) + " ) " +
- "AND cr.date <= " + statementBuilder.getAddDate( "p.enddate", completenessOffset );
+ "AND cr.date <= " + statementBuilder.getAddDate( "pe.enddate", completenessOffset );
return statementManager.getHolder().queryForInteger( sql );
}
@@ -117,13 +117,14 @@
public Integer getCompulsoryDataElementRegistrations( DataSet dataSet, Collection<Integer> children, Collection<Integer> periods )
{
- return getCompulsoryDataElementRegistrations( dataSet, children, periods, 0 );
+ return getCompulsoryDataElementRegistrations( dataSet, children, periods, -1 );
}
public Integer getCompulsoryDataElementRegistrations( DataSet dataSet, Collection<Integer> children, Collection<Integer> periods, int completenessOffset )
{
final int compulsoryElements = dataSet.getCompulsoryDataElementOperands().size();
- final String deadlineCriteria = ""; //FIXME //deadline != null ? "AND lastupdated < '" + DateUtils.getMediumDateString( deadline ) + "' " : "";
+
+ final String deadlineCriteria = completenessOffset >= 0 ? "AND lastupdated <= " + statementBuilder.getAddDate( "pe.enddate", completenessOffset ) : "";
final String sql =
"SELECT COUNT(completed) FROM ( " +
@@ -133,7 +134,9 @@
"ON dv.dataelementid=deo.dataelementid AND dv.categoryoptioncomboid=deo.categoryoptioncomboid " +
"JOIN datasetoperands dso " +
"ON deo.dataelementoperandid=dso.dataelementoperandid " +
- "WHERE periodid IN ( " + getCommaDelimitedString( periods ) + " ) " + deadlineCriteria +
+ "JOIN period pe " +
+ "ON dv.periodid=pe.periodid " +
+ "WHERE dv.periodid IN ( " + getCommaDelimitedString( periods ) + " ) " + deadlineCriteria +
"AND sourceid IN ( " + getCommaDelimitedString( children ) + " ) " +
"AND datasetid = " + dataSet.getId() + " GROUP BY sourceid) AS completed " +
"WHERE completed.sources = " + compulsoryElements;
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java 2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/completeness/DataSetCompletenessServiceTest.java 2012-03-16 18:28:34 +0000
@@ -163,6 +163,7 @@
organisationUnitService.addOrganisationUnit( unitH );
unitIdsA = new HashSet<Integer>();
+ unitIdsA.add( unitIdA );
unitIdsA.add( unitIdB );
unitIdsA.add( unitIdC );
@@ -266,28 +267,32 @@
dataSetService.addDataSet( dataSetC );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitA, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitA, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitD, tooLateA, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodA, unitA, tooLateA, "" ) );
- registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodA, unitB, tooLateA, "" ) );
- registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodA, unitC, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodA, unitB, onTimeA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodA, unitC, onTimeA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetB, periodB, unitC, tooLateB, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitA, tooLateA, "" ) );
- registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitB, tooLateA, "" ) );
-
- registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitA, tooLateB, "" ) );
- registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitD, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetC, periodA, unitB, onTimeA, "" ) );
Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdA );
- DataSetCompletenessResult resultA = new DataSetCompletenessResult( dataSetA.getName(), 3, 1, 0 );
- DataSetCompletenessResult resultB = new DataSetCompletenessResult( dataSetB.getName(), 2, 2, 0 );
- DataSetCompletenessResult resultC = new DataSetCompletenessResult( dataSetC.getName(), 2, 1, 0 );
-
- assertNotNull( results );
- assertEquals( 3, results.size() );
- assertTrue( results.contains( resultA ) );
- assertTrue( results.contains( resultB ) );
- assertTrue( results.contains( resultC ) );
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetA.getName(), 3, 1, 0 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetB.getName(), 2, 2, 2 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetC.getName(), 2, 1, 1 ) ) );
+
+ results = completenessService.getDataSetCompleteness( periodIdC, unitIdA );
+
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetA.getName(), 9, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetB.getName(), 6, 3, 2 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetC.getName(), 6, 1, 1 ) ) );
}
@Test
@@ -309,13 +314,21 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitF, tooLateA, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitG, onTimeA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitE, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitF, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, tooLateB, "" ) );
+
Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdA );
- DataSetCompletenessResult resultA = new DataSetCompletenessResult( dataSetA.getName(), 7, 5, 3 );
+ assertNotNull( results );
+ assertEquals( 1, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetA.getName(), 7, 5, 3 ) ) );
+
+ results = completenessService.getDataSetCompleteness( periodIdC, unitIdA );
assertNotNull( results );
assertEquals( 1, results.size() );
- assertTrue( results.contains( resultA ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( dataSetA.getName(), 21, 8, 5 ) ) );
}
@Test
@@ -332,15 +345,25 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitF, tooLateA, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitG, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitE, onTimeA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitF, onTimeA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeA, "" ) );
+
Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
- DataSetCompletenessResult resultA = new DataSetCompletenessResult( unitB.getName(), 2, 2, 0 );
- DataSetCompletenessResult resultB = new DataSetCompletenessResult( unitC.getName(), 2, 1, 0 );
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 2, 2, 0 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 2, 1, 0 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 4, 3, 0 ) ) );
+ results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+
assertNotNull( results );
- assertEquals( 2, results.size() );
- assertTrue( results.contains( resultA ) );
- assertTrue( results.contains( resultB ) );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 6, 4, 2 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 6, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 12, 6, 3 ) ) );
}
@Test
@@ -356,15 +379,25 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitG, tooLateA, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitH, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitE, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitH, onTimeB, "" ) );
+
Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
- DataSetCompletenessResult resultA = new DataSetCompletenessResult( unitB.getName(), 2, 1, 0 );
- DataSetCompletenessResult resultB = new DataSetCompletenessResult( unitC.getName(), 1, 1, 0 );
-
- assertNotNull( results );
- assertEquals( 2, results.size() );
- assertTrue( results.contains( resultA ) );
- assertTrue( results.contains( resultB ) );
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 2, 1, 0 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 1, 1, 0 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 3, 2, 0 ) ) );
+
+ results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 6, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 3, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 9, 4, 2 ) ) );
}
@Test
@@ -382,14 +415,25 @@
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitG, onTimeA, "" ) );
registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodA, unitH, tooLateA, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitE, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitF, tooLateB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitG, onTimeB, "" ) );
+ registrationService.saveCompleteDataSetRegistration( new CompleteDataSetRegistration( dataSetA, periodB, unitH, tooLateB, "" ) );
+
Collection<DataSetCompletenessResult> results = completenessService.getDataSetCompleteness( periodIdA, unitIdsA, dataSetIdA );
- DataSetCompletenessResult resultA = new DataSetCompletenessResult( unitB.getName(), 2, 2, 1 );
- DataSetCompletenessResult resultB = new DataSetCompletenessResult( unitC.getName(), 2, 2, 1 );
-
- assertNotNull( results );
- assertEquals( 2, results.size() );
- assertTrue( results.contains( resultA ) );
- assertTrue( results.contains( resultB ) );
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 2, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 2, 2, 1 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 4, 4, 2 ) ) );
+
+ results = completenessService.getDataSetCompleteness( periodIdC, unitIdsA, dataSetIdA );
+
+ assertNotNull( results );
+ assertEquals( 3, results.size() );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitB.getName(), 6, 4, 2 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitC.getName(), 6, 4, 2 ) ) );
+ assertTrue( results.contains( new DataSetCompletenessResult( unitA.getName(), 12, 8, 4 ) ) );
}
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2012-03-16 16:49:58 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2012-03-16 18:28:34 +0000
@@ -103,7 +103,6 @@
+ "SELECT * FROM datavalue AS d2 " + "WHERE d2.dataelementid=" + destDataElementId + " "
+ "AND d2.categoryoptioncomboid=" + destCategoryOptionComboId + " " + "AND d1.periodid=d2.periodid "
+ "AND d1.sourceid=d2.sourceid );";
-
}
@Override
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/error.html'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/error.html 2012-02-13 17:18:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/error.html 2012-03-16 18:28:34 +0000
@@ -27,7 +27,7 @@
#content
{
- font-family: Arial, sans-serif;
+ font-family: sans-serif;
background-color: transparent;
}