dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03117
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1036: Improved report table testing
------------------------------------------------------------
revno: 1036
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-11-16 15:10:08 +0100
message:
Improved report table testing
modified:
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.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-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java 2009-11-16 10:32:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableManagerTest.java 2009-11-16 14:10:08 +0000
@@ -43,6 +43,7 @@
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
@@ -57,7 +58,6 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reporttable.jdbc.ReportTableManager;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -72,7 +72,6 @@
private BatchHandlerFactory batchHandlerFactory;
private List<DataElement> dataElements;
- private List<DataElementCategoryOptionCombo> categoryOptionCombos;
private List<Indicator> indicators;
private List<DataSet> dataSets;
private List<Period> periods;
@@ -84,6 +83,8 @@
private DataElementCategoryOptionCombo categoryOptionComboA;
private DataElementCategoryOptionCombo categoryOptionComboB;
+ private DataElementCategoryCombo categoryComboA;
+
private DataElement dataElementA;
private DataElement dataElementB;
@@ -120,7 +121,6 @@
batchHandlerFactory = (BatchHandlerFactory) getBean( "batchHandlerFactory" );
dataElements = new ArrayList<DataElement>();
- categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
indicators = new ArrayList<Indicator>();
dataSets = new ArrayList<DataSet>();
periods = new ArrayList<Period>();
@@ -132,14 +132,16 @@
indicatorType = createIndicatorType( 'A' );
categoryOptionComboA = createCategoryOptionCombo( 'A', 'A', 'B' );
- categoryOptionComboA = createCategoryOptionCombo( 'B', 'C', 'D' );
+ categoryOptionComboB = createCategoryOptionCombo( 'B', 'C', 'D' );
categoryOptionComboA.setId( 'A' );
- categoryOptionComboA.setId( 'B' );
+ categoryOptionComboB.setId( 'B' );
- categoryOptionCombos.add( categoryOptionComboA );
- categoryOptionCombos.add( categoryOptionComboB );
-
+ categoryComboA = new DataElementCategoryCombo( "CategoryComboA" );
+ categoryComboA.setId( 'A' );
+ categoryComboA.getOptionCombos().add( categoryOptionComboA );
+ categoryComboA.getOptionCombos().add( categoryOptionComboB );
+
dataElementA = createDataElement( 'A' );
dataElementB = createDataElement( 'B' );
@@ -205,6 +207,12 @@
i18nFormat = new MockI18nFormat();
}
+ @Override
+ public boolean emptyDatabaseAfterTest()
+ {
+ return true;
+ }
+
// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------
@@ -344,32 +352,31 @@
}
@Test
- @Ignore //TODO fix
public void testGetAggregatedValueForDataElementWithCategoryOptionCombo()
{
BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class );
batchHandler.init();
- batchHandler.addObject( new AggregatedDataValue( 'A', 'A', 'A', 1, 'A', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'A', 'A', 'A', 1, 'B', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'A', 'B', 'B', 1, 'A', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'A', 'B', 'B', 1, 'B', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'B', 'A', 'A', 1, 'A', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'B', 'A', 'A', 1, 'B', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'B', 'B', 'B', 1, 'A', 2, 10.0 ) );
- batchHandler.addObject( new AggregatedDataValue( 'B', 'B', 'B', 1, 'B', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'A', 'A', 'A', 3, 'A', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'A', 'A', 'A', 3, 'B', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'A', 'B', 'B', 3, 'A', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'A', 'B', 'B', 3, 'B', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'B', 'A', 'A', 3, 'A', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'B', 'A', 'A', 3, 'B', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'B', 'B', 'B', 3, 'A', 2, 10.0 ) );
+ batchHandler.addObject( new AggregatedDataValue( 'B', 'B', 'B', 3, 'B', 2, 10.0 ) );
- batchHandler.flush();
+ batchHandler.flush();
ReportTable reportTable = new ReportTable( "Immunization", ReportTable.MODE_DATAELEMENTS, false,
dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
- null, true, true, true, false, relatives, null, i18nFormat, "january_2000" );
+ categoryComboA, true, true, true, false, relatives, null, i18nFormat, "january_2000" );
reportTable.init();
Map<String, Double> map = reportTableManager.getAggregatedValueMap( reportTable, null, null, null, unitA );
-
+System.out.println( map );
assertNotNull( map );
assertEquals( 4, map.entrySet().size() );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java 2009-11-16 10:32:46 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java 2009-11-16 14:10:08 +0000
@@ -194,7 +194,7 @@
i18nFormat = new MockI18nFormat();
}
-
+
// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------