dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33482
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17091: Made SqlViewServiceTest a DhisSpringTest. Removed data browser tests
------------------------------------------------------------
revno: 17091
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-13 20:14:45 +0200
message:
Made SqlViewServiceTest a DhisSpringTest. Removed data browser tests
removed:
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserStoreTest.java
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java
modified:
dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.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
=== removed directory 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser'
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserServiceTest.java 1970-01-01 00:00:00 +0000
@@ -1,478 +0,0 @@
-package org.hisp.dhis.databrowser;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.hisp.dhis.common.Grid;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author joakibj, briane, eivinhb
- * @author Dang Duy Hieu
- * @version $Id$
- * @since 2010-04-15
- */
-public class DataBrowserServiceTest
- extends DataBrowserTest
-{
- @Autowired
- private DataBrowserGridService dataBrowserService;
-
- private boolean isZeroAdded;
-
- @Override
- public void setUpTest()
- throws Exception
- {
- super.setUpDataBrowserTest();
- }
-
- @Override
- public boolean emptyDatabaseAfterTest()
- {
- return true;
- }
-
- /**
- * DataBrowserTable getDataSetsInPeriod( String startDate, String endDate,
- * PeriodType periodType );
- */
- @Test
- public void testGetDataSetsInPeriod()
- {
- // Get all DataSets from earliest to latest registered on daily basis
- // (this should be period A and B data values)
- Grid grid = dataBrowserService.getDataSetsInPeriod( null, null, periodA.getPeriodType(), mockFormat,
- isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_set", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "Metarows", 1, grid.getRows().size() );
- //assertEquals( dataSetB.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- //assertEquals( dataSetB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataSetA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataSetA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- //assertEquals( dataSetC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- //assertEquals( dataSetC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- //assertEquals( "DataValues in dataSetB", "18", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataSetA", "12", grid.getRow( 0 ).get( 1 ).toString() );
- //assertEquals( "DataValues in dataSetC", "3", grid.getRow( 2 ).get( 1 ).toString() );
-
- // Get all DataSets from 2005-05-01 to 2005-05-31 registered on weekly
- // basis (this should be only period D data values)
- grid = dataBrowserService.getDataSetsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType(), mockFormat,
- isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_set", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataSetC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataSetC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataSetC", "6", grid.getRow( 0 ).get( 1 ).toString() );
- }
-
- /**
- * DataBrowserTable getDataElementGroupsInPeriod( String startDate, String
- * endDate, PeriodType periodType );
- */
- @Test
- public void testGetDataElementGroupsInPeriod()
- {
- // Get all DataElementGroups from earliest to latest registered on daily
- // basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getDataElementGroupsInPeriod( null, null, periodA.getPeriodType(), mockFormat,
- isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementGroupB", "18", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupA", "12", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupC", "3", grid.getRow( 2 ).get( 1 ).toString() );
-
- // Get all DataElementGroups from 2005-05-01 to 2005-05-31 registered on
- // weekly basis (this should be only period D data values)
- grid = dataBrowserService.getDataElementGroupsInPeriod( "2005-05-01", "2005-05-31", periodD.getPeriodType(),
- mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementGroupC", "6", grid.getRow( 0 ).get( 1 ).toString() );
- }
-
- /**
- * DataBrowserTable getOrgUnitGroupsInPeriod( String startDate, String
- * endDate, PeriodType periodType );
- */
- @Test
- public void testGetOrgUnitGroupsInPeriod()
- {
- // Get all OrganisationUnitGroups from earliest to latest registered on
- // daily
- // basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getOrgUnitGroupsInPeriod( null, null, periodA.getPeriodType(), mockFormat,
- isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_orgunit_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 2, grid.getRows().size() );
- assertEquals( unitGroupB.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( unitGroupB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( unitGroupA.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( unitGroupA.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
-
- // unitD has 6 datavalues, unitE has 6 datavalues and unitF has 5
- // datavalues for periods A and B
- assertEquals( "DataValues in unitGroupB", "17", grid.getRow( 0 ).get( 1 ).toString() );
- // unitB has 0 datavalues and unitC has 6 datavalues for periods A and B
- assertEquals( "DataValues in unitGroupA", "6", grid.getRow( 1 ).get( 1 ).toString() );
- }
-
- /**
- * DataBrowserTable getOrgUnitsInPeriod( Integer orgUnitParent, String
- * startDate, String endDate, PeriodType periodType );
- */
- @Ignore
- public void testGetOrgUnitsInPeriod()
- {
- // Get all children of unit B from 2005-03-01 to 2005-04-30 registered
- // on daily basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getOrgUnitsInPeriod( unitB.getId(), "2005-03-01", "2005-04-30", periodA
- .getPeriodType(), 4, mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_organisation_unit", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
- assertEquals( "Period column header", "2005-04-01", grid.getVisibleHeaders().get( 2 ).getName() );
-
- // unitB has three children - sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( unitD.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( unitD.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( unitE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( unitE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( unitF.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( unitF.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in unitD for periodA", "4", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in unitD for periodB", "2", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in unitE for periodA", "4", grid.getRow( 2 ).get( 1 ).toString() );
- assertEquals( "DataValues in unitE for periodB", "2", grid.getRow( 3 ).get( 1 ).toString() );
- assertEquals( "DataValues in unitF for periodA", "2", grid.getRow( 4 ).get( 1 ).toString() );
- assertEquals( "DataValues in unitF for periodB", "3", grid.getRow( 5 ).get( 1 ).toString() );
-
- // Retrieve children of unitG - zero children
- grid = dataBrowserService.getOrgUnitsInPeriod( unitG.getId(), null, null, periodA.getPeriodType(), 4,
- mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_organisation_unit", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
- // Service layer adds "zero-column"
- assertEquals( "No.Row entries", 0, grid.getRows().size() );
- }
-
- /**
- * DataBrowserTable getCountDataElementsForDataSetInPeriod( Integer
- * dataSetId, String startDate, String endDate, PeriodType periodType );
- */
- @Test
- public void testGetCountDataElementsForDataSetInPeriod()
- {
- // Get count for dataSetA from 2005-03-01 to 2005-04-30 registered on
- // daily basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getCountDataElementsForDataSetInPeriod( dataSetA.getId(), "2005-03-01",
- "2005-04-30", periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
- assertEquals( "Period column header", "2005-04-01", grid.getVisibleHeaders().get( 2 ).getName() );
-
- // dataSetA has one dataElement - sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementA", "6", grid.getRow( 0 ).get( 1 ).toString() );
-
- // Get count for dataSetC from 2005-05-01 to 2005-05-31 registered on
- // weekly basis (this should be only period D data values)
- grid = dataBrowserService.getCountDataElementsForDataSetInPeriod( dataSetC.getId(), "2005-05-01", "2005-05-31",
- periodD.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-05-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // dataSetC has three dataElements - sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementF.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementF.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementC", "3", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementE", "3", grid.getRow( 1 ).get( 1 ).toString() );
- }
-
- /**
- * DataBrowserTable getCountDataElementsForDataElementGroupInPeriod( Integer
- * dataElementGroupId, String startDate, String endDate, PeriodType
- * periodType );
- */
- @Test
- public void testGetCountDataElementsForDataElementGroupInPeriod()
- {
- // Get count for dataElementGroupA from 2005-03-01 to 2005-04-30
- // registered on daily basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getCountDataElementsForDataElementGroupInPeriod( dataElementGroupA.getId(),
- "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
- assertEquals( "Period column header", "2005-04-01", grid.getVisibleHeaders().get( 2 ).getName() );
-
- // dataElementGroupA has one dataElement - sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementA", "6", grid.getRow( 0 ).get( 1 ).toString() );
-
- // Get count for dataElementGroupC from 2005-05-01 to 2005-05-31
- // registered on weekly basis (this should be only period D data values)
- grid = dataBrowserService.getCountDataElementsForDataElementGroupInPeriod( dataElementGroupC.getId(),
- "2005-05-01", "2005-05-31", periodD.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-05-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // dataElementGroupC has two dataElements - sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementC", "3", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementE", "3", grid.getRow( 1 ).get( 1 ).toString() );
- }
-
- /**
- * DataBrowserTable getCountDataElementGroupsForOrgUnitGroupInPeriod(
- * Integer orgUnitGroupId, String startDate, String endDate, PeriodType
- * periodType, I18nFormat format, boolean zeroShowed );
- */
- @Test
- public void testGetCountDataElementGroupsForOrgUnitGroupInPeriod()
- {
- isZeroAdded = true;
-
- // Get count for unitGroupA from 2005-03-01 to 2005-04-30 registered on
- // daily
- // basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getCountDataElementGroupsForOrgUnitGroupInPeriod( unitGroupA.getId(),
- "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- // unitGroupA has data values for dataElementGroup A, B and C in the two
- // periods
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
- assertEquals( "Period column header", "2005-04-01", grid.getVisibleHeaders().get( 2 ).getName() );
-
- // unitGroupA has data values for dataElementGroup A, B and C - sorted
- // by name
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementGroupA for periodA", "1", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupA for PeriodB", "1", grid.getRow( 0 ).get( 2 ).toString() );
- assertEquals( "DataValues in dataElementGroupB for PeriodA", "2", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupB for PeriodB", "1", grid.getRow( 1 ).get( 2 ).toString() );
- assertEquals( "DataValues in dataElementGroupC for PeriodA", "1", grid.getRow( 2 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupC for PeriodB", "0", grid.getRow( 2 ).get( 2 ).toString() );
- }
-
- /**
- * DataBrowserTable getCountDataElementsForOrgUnitInPeriod( Integer
- * organizationUnitId, String startDate, String endDate, PeriodType
- * periodType );
- */
- @Ignore
- public void testGetRawDataElementsForOrgUnitInPeriod()
- {
- // Get count for unitB from 2005-03-01 to 2005-04-30 registered on daily
- // basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getRawDataElementsForOrgUnitInPeriod( unitB.getId(), "2005-03-01", "2005-04-30",
- periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- // unitB has no data values
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- // Service layer adds "zero-column"
- assertEquals( "Period column header", "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 )
- .getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 0, grid.getRows().size() );
-
- // Get count for unitF from 2005-03-01 to 2005-04-30 registered on daily
- // basis (this should be period A and B data values)
- grid = dataBrowserService.getRawDataElementsForOrgUnitInPeriod( unitF.getId(), "2005-03-01", "2005-04-30",
- periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- // unitF has data values for dataElements A, B, D and E in two periods
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
- assertEquals( "Period column header", "2005-04-01", grid.getVisibleHeaders().get( 2 ).getName() );
-
- // unitF has data values for data elements A, B, and D - sorted by name
- // Consists:
- // two data values for A count
- // two data values for B count
- // one data value for D count
-
- assertEquals( "No.Row entries", 4, grid.getRows().size() );
-
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementD.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementD.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementA for periodA", "1", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementA for PeriodB", "1", grid.getRow( 0 ).get( 2 ).toString() );
- assertEquals( "DataValues in dataElementB for PeriodA", "1", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementB for PeriodB", "1", grid.getRow( 1 ).get( 2 ).toString() );
- assertEquals( "DataValues in dataElementD for PeriodA", "0", grid.getRow( 2 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementD for PeriodB", "1", grid.getRow( 2 ).get( 2 ).toString() );
- }
-
- /**
- * String convertDate( PeriodType periodType, String dateString, I18nFormat
- * format );
- */
- @Test
- public void testConvertDate()
- {
- // Get count for unitGroupA from 2005-03-01 to 2005-04-30 registered on
- // daily
- // basis (this should be period A and B data values)
- Grid grid = dataBrowserService.getCountDataElementGroupsForOrgUnitGroupInPeriod( unitGroupA.getId(),
- "2005-03-01", "2005-04-30", periodA.getPeriodType(), mockFormat, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- // unitGroupA has data values for dataElementGroup A, B and C in the two
- // periods
- assertEquals( "Header Size", 3, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
-
- assertEquals( "drilldown_data_element_group", dataBrowserService.convertDate( periodA.getPeriodType(), grid
- .getVisibleHeaders().get( 0 ).getName(), mockI18n, mockFormat ) );
- assertTrue( "Period column header 2005-03-01", dataBrowserService.convertDate( periodA.getPeriodType(),
- grid.getVisibleHeaders().get( 1 ).getName(), mockI18n, mockFormat ).startsWith( "Period_2005-03-01" ) );
- assertTrue( "Period column header 2005-04-01", dataBrowserService.convertDate( periodA.getPeriodType(),
- grid.getVisibleHeaders().get( 2 ).getName(), mockI18n, mockFormat ).startsWith( "Period_2005-04-01" ) );
-
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserStoreTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserStoreTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserStoreTest.java 1970-01-01 00:00:00 +0000
@@ -1,562 +0,0 @@
-package org.hisp.dhis.databrowser;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.system.grid.ListGrid;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import static org.junit.Assert.*;
-
-/**
- * @author joakibj, briane, eivinhb
- * @version $Id$
- */
-public class DataBrowserStoreTest
- extends DataBrowserTest
-{
- @Autowired
- private DataBrowserGridStore dataBrowserStore;
-
- private boolean isZeroAdded;
-
- @Override
- public void setUpTest()
- throws Exception
- {
- super.setUpDataBrowserTest();
- }
-
- @Override
- public boolean emptyDatabaseAfterTest()
- {
- return true;
- }
-
- /**
- * Grid getDataSetsBetweenPeriods( List<Integer> betweenPeriodIds );
- */
- @Test
- public void testGetDataSetsBetweenPeriods()
- {
- List<Integer> betweenPeriodIds = new ArrayList<>();
- betweenPeriodIds.add( periodA.getId() );
- betweenPeriodIds.add( periodB.getId() );
- betweenPeriodIds.add( periodC.getId() );
- betweenPeriodIds.add( periodD.getId() );
-
- Grid grid = dataBrowserStore.getDataSetsBetweenPeriods( betweenPeriodIds, periodA.getPeriodType(), isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_set", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- // assertEquals( dataSetB.getName(), ((MetaValue) grid.getRow( 0 ).get(
- // 0 )).getName() );
- // assertEquals( dataSetB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0
- // )).getId().intValue() );
- assertEquals( dataSetA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataSetA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- // assertEquals( dataSetC.getName(), ((MetaValue) grid.getRow( 2 ).get(
- // 0 )).getName() );
- // assertEquals( dataSetC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0
- // )).getId().intValue() );
-
- // assertEquals( "DataValues in dataSetB", "24", grid.getRow( 0 ).get( 1
- // ).toString() );
- assertEquals( "DataValues in dataSetA", "18", grid.getRow( 0 ).get( 1 ).toString() );
- // assertEquals( "DataValues in dataSetC", "12", grid.getRow( 2 ).get( 1
- // ).toString() );
- }
-
- /**
- * Grid getDataElementGroupsBetweenPeriods( List<Integer> betweenPeriodIds );
- */
- @Test
- public void testGetDataElementGroupsBetweenPeriods()
- {
- List<Integer> betweenPeriodIds = new ArrayList<>();
- betweenPeriodIds.add( periodA.getId() );
- betweenPeriodIds.add( periodB.getId() );
- betweenPeriodIds.add( periodC.getId() );
- betweenPeriodIds.add( periodD.getId() );
-
- Grid grid = dataBrowserStore.getDataElementGroupsBetweenPeriods( betweenPeriodIds, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementGroupB", "24", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupA", "18", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupC", "12", grid.getRow( 2 ).get( 1 ).toString() );
- }
-
- /**
- * Grid getOrgUnitGroupsBetweenPeriods( List<Integer> betweenPeriodIds );
- */
- @Test
- public void testGetOrgUnitGroupsBetweenPeriods()
- {
- List<Integer> betweenPeriodIds = new ArrayList<>();
-
- betweenPeriodIds.add( periodA.getId() );
- betweenPeriodIds.add( periodB.getId() );
- betweenPeriodIds.add( periodC.getId() );
- betweenPeriodIds.add( periodD.getId() );
-
- Grid grid = dataBrowserStore.getOrgUnitGroupsBetweenPeriods( betweenPeriodIds, isZeroAdded );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_orgunit_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "counts_of_aggregated_values", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by count
- assertEquals( "No.Row entries", 2, grid.getRows().size() );
- assertEquals( unitGroupB.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( unitGroupB.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( unitGroupA.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( unitGroupA.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
-
- // unitD has 10 DataValues, unitE has 10 DataValues and unitF has 8
- // DataValues
- assertEquals( "DataValues in unitGroupB", "28", grid.getRow( 0 ).get( 1 ).toString() );
- // unitB has 0 DataValues and unitC has 10 DataValues
- assertEquals( "DataValues in unitGroupA", "10", grid.getRow( 1 ).get( 1 ).toString() );
- }
-
- /**
- * void setDataElementStructureForDataSetBetweenPeriods( DataBrowserTable
- * table, Integer dataSetId, List<Integer> betweenPeriods );
- */
- @Test
- public void testSetDataElementStructureForDataSetBetweenPeriods()
- {
- List<Integer> metaList = new ArrayList<>();
-
- // Retrieve dataElements of DataSetA - one dataElement
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementStructureForDataSet( grid, dataSetA.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- // Retrieve dataElements of DataSetC - three dataElements
- grid = new ListGrid();
- metaList.clear();
-
- dataBrowserStore.setDataElementStructureForDataSet( grid, dataSetC.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementF.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementF.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
- }
-
- /**
- * void setDataElementStructureForDataElementGroup( Grid grid, Integer
- * dataElementGroupId, List<Integer> betweenPeriods );
- */
- @Test
- public void testSetDataElementStructureForDataElementGroup()
- {
- List<Integer> metaList = new ArrayList<>();
-
- // Retrieve dataElements of DataElementGroupA - one dataElement
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementStructureForDataElementGroup( grid, dataElementGroupA.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- // Retrieve dataElements of DataElementGroupC - three dataElements
- grid = new ListGrid();
- metaList.clear();
-
- dataBrowserStore.setDataElementStructureForDataElementGroup( grid, dataElementGroupC.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementF.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementF.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
- }
-
- /**
- * void setDataElementGroupStructureForOrgUnitGroup( Grid grid, Integer
- * orgUnitGroupId, List<Integer> betweenPeriods );
- */
- @Test
- public void testSetDataElementGroupStructureForOrgUnitGroup()
- {
- List<Integer> metaList = new ArrayList<>();
-
- // Retrieve orgUnitGroupA - three dataElementGroups
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementGroupStructureForOrgUnitGroup( grid, unitGroupA.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- // Retrieve dataElements of orgUnitGroupB - three dataElementGroups
- grid = new ListGrid();
- metaList.clear();
-
- dataBrowserStore.setDataElementGroupStructureForOrgUnitGroup( grid, unitGroupB.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
- }
-
- /**
- * void setStructureForOrgUnit( Grid grid, Integer orgUnitParent, List<Integer>
- * betweenPeriods );
- */
- @Test
- public void testSetStructureForOrgUnit()
- {
- List<Integer> metaList = new ArrayList<>();
-
- // Retrieve children of unitB - three children
- Grid grid = new ListGrid();
- dataBrowserStore.setStructureForOrgUnit( grid, unitB.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_orgunit", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( unitD.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( unitD.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( unitE.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( unitE.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( unitF.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( unitF.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- // Retrieve children of unitG - zero children
- grid = new ListGrid();
- metaList.clear();
-
- dataBrowserStore.setStructureForOrgUnit( grid, unitG.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_orgunit", grid.getVisibleHeaders().get( 0 ).getName() );
-
- assertEquals( "No.Row entries", 0, grid.getRows().size() );
- }
-
- /**
- * void setDataElementStructureForOrgUnit( DataBrowserTable grid, String
- * orgUnitId, List<Integer> betweenPeriodIds );
- *
- * Notes: This test would be failure if active because of
- * _CATEGORYOPTIONCOMBONAME is missing/not found by H2 database
- */
- @Ignore
- public void testSetDataElementStructureForOrgUnit()
- {
- List<Integer> metaList = new ArrayList<>();
-
- // Retrieve structure for dataElements in periodA for unitC - six
- // dataElements
- Grid grid = new ListGrid();
-
- dataBrowserStore.setDataElementStructureForOrgUnit( grid, unitC.getId(), metaList );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 1, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 6, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementD.getName(), ((MetaValue) grid.getRow( 3 ).get( 0 )).getName() );
- assertEquals( dataElementD.getId(), ((MetaValue) grid.getRow( 3 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 4 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 4 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementF.getName(), ((MetaValue) grid.getRow( 5 ).get( 0 )).getName() );
- assertEquals( dataElementF.getId(), ((MetaValue) grid.getRow( 5 ).get( 0 )).getId().intValue() );
- }
-
- /**
- * Integer setCountDataElementsForDataSetBetweenPeriods( DataBrowserTable
- * grid, Integer dataSetId, List<Integer> betweenPeriodIds, List<Integer>
- * metaIds, boolean zeroShowed );
- */
- @Test
- public void testSetCountDataElementsForDataSet()
- {
- List<Integer> metaIds = new ArrayList<>();
- List<Integer> pList = new ArrayList<>();
- pList.add( periodA.getId() );
-
- // Retrieve structure for dataElements in periodA for dataSetA - one
- // dataElement
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementStructureForDataSet( grid, dataSetA.getId(), metaIds );
-
- // Retrieve actual count for dataElements in periodA for dataSetA
- int results = dataBrowserStore.setCountDataElementsForDataSetBetweenPeriods( grid, dataSetA.getId(), periodA
- .getPeriodType(), pList, metaIds, isZeroAdded );
- assertEquals( "DataValue results", 1, results );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementA for periodA", "6", grid.getRow( 0 ).get( 1 ).toString() );
- }
-
- /**
- * Integer setDataElementStructureForDataElementGroup( Grid grid, Integer
- * dataElementGroupId, List<Integer> betweenPeriodIds, List<Integer>
- * metaIds, boolean zeroShowed );
- */
- @Test
- public void testSetCountDataElementsForDataElementGroupBetweenPeriods()
- {
- List<Integer> metaIds = new ArrayList<>();
- List<Integer> pList = new ArrayList<>();
- pList.add( periodA.getId() );
-
- // Retrieve structure for dataElements in periodA for dataElementGroupA
- // - one dataElement
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementStructureForDataElementGroup( grid, dataElementGroupA.getId(), metaIds );
-
- // Retrieve actual count for dataElements in periodA for
- // dataElementGroupA
- int results = dataBrowserStore.setCountDataElementsForDataElementGroupBetweenPeriods( grid, dataElementGroupA
- .getId(), pList, metaIds, isZeroAdded );
- assertEquals( "DataValue results", 1, results );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 1, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementA for periodA", "6", grid.getRow( 0 ).get( 1 ).toString() );
- }
-
- /**
- * Integer setCountDataElementGroupsForOrgUnitGroupBetweenPeriods( Grid
- * grid, Integer orgUnitGroupId, List<Integer> betweenPeriodIds, List<Integer>
- * metaIds, boolean zeroShowed );
- */
- @Test
- public void testSetCountDataElementGroupsForOrgUnitGroupBetweenPeriods()
- {
- List<Integer> metaIds = new ArrayList<>();
- List<Integer> pList = new ArrayList<>();
- pList.add( periodA.getId() );
-
- // Retrieve structure for dataElementGroups in periodA for unitGroupA -
- // three dataElementGroups
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementGroupStructureForOrgUnitGroup( grid, unitGroupA.getId(), metaIds );
-
- // Retrieve actual count for dataElementGroups in periodA for unitGroupA
- int results = dataBrowserStore.setCountDataElementGroupsForOrgUnitGroupBetweenPeriods( grid,
- unitGroupA.getId(), pList, metaIds, isZeroAdded );
- assertEquals( "DataValue results", 3, results );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element_group", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 3, grid.getRows().size() );
- assertEquals( dataElementGroupA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementGroupA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementGroupB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementGroupC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementGroupC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
-
- assertEquals( "DataValues in dataElementGroupA for periodA", "1", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupB for periodA", "2", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementGroupC for periodA", "1", grid.getRow( 2 ).get( 1 ).toString() );
- }
-
- /**
- * Integer setRawDataElementsForOrgUnitBetweenPeriods( DataBrowserTable
- * grid, String orgUnitId, List<Integer> betweenPeriodIds, List<Integer>
- * metaIds, boolean zeroShowed );
- *
- * Notes: This test would be failure if active because of
- * _CATEGORYOPTIONCOMBONAME is missing/not found by H2 database
- */
- @Ignore
- public void testSetRawDataElementsForOrgUnitBetweenPeriods()
- {
- List<Integer> metaIds = new ArrayList<>();
- List<Integer> pList = new ArrayList<>();
- pList.add( periodA.getId() );
-
- // Retrieve structure for dataElements in periodA for unitC - six
- // dataElements
- Grid grid = new ListGrid();
- dataBrowserStore.setDataElementStructureForOrgUnit( grid, unitC.getId(), metaIds );
-
- // Retrieve actual count for dataElements in periodA for unitC
- int results = dataBrowserStore.setRawDataElementsForOrgUnitBetweenPeriods( grid, unitC.getId(), pList, metaIds,
- isZeroAdded );
- assertEquals( "DataValue results", 4, results );
-
- assertNotNull( "Grid not supposed to be null", grid );
-
- assertEquals( "Header Size", 2, grid.getVisibleHeaders().size() );
- assertEquals( "drilldown_data_element", grid.getVisibleHeaders().get( 0 ).getName() );
- assertEquals( "Period column header", "2005-03-01", grid.getVisibleHeaders().get( 1 ).getName() );
-
- // Sorted by name
- assertEquals( "No.Row entries", 6, grid.getRows().size() );
- assertEquals( dataElementA.getName(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getName() );
- assertEquals( dataElementA.getId(), ((MetaValue) grid.getRow( 0 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementB.getName(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getName() );
- assertEquals( dataElementB.getId(), ((MetaValue) grid.getRow( 1 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementC.getName(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getName() );
- assertEquals( dataElementC.getId(), ((MetaValue) grid.getRow( 2 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementD.getName(), ((MetaValue) grid.getRow( 3 ).get( 0 )).getName() );
- assertEquals( dataElementD.getId(), ((MetaValue) grid.getRow( 3 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementE.getName(), ((MetaValue) grid.getRow( 4 ).get( 0 )).getName() );
- assertEquals( dataElementE.getId(), ((MetaValue) grid.getRow( 4 ).get( 0 )).getId().intValue() );
- assertEquals( dataElementF.getName(), ((MetaValue) grid.getRow( 5 ).get( 0 )).getName() );
- assertEquals( dataElementF.getId(), ((MetaValue) grid.getRow( 5 ).get( 0 )).getId().intValue() );
-
- // unitC has all six dataElements but only dataValues in periodA for
- // four of them. The other two (C and E) are zero
- assertEquals( "DataValues in dataElementA for periodA", "1", grid.getRow( 0 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementB for periodA", "1", grid.getRow( 1 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementC for periodA", "0", grid.getRow( 2 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementD for periodA", "1", grid.getRow( 3 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementE for periodA", "0", grid.getRow( 4 ).get( 1 ).toString() );
- assertEquals( "DataValues in dataElementF for periodA", "1", grid.getRow( 5 ).get( 1 ).toString() );
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/databrowser/DataBrowserTest.java 1970-01-01 00:00:00 +0000
@@ -1,379 +0,0 @@
-package org.hisp.dhis.databrowser;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.hisp.dhis.DhisTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.mock.MockI18n;
-import org.hisp.dhis.mock.MockI18nFormat;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author joakibj, briane, eivinhb
- * @version $Id$
- */
-public abstract class DataBrowserTest
- extends DhisTest
-{
- protected final String T = "true";
- protected final String F = "false";
-
- protected DataElementCategoryCombo categoryCombo;
- protected DataElementCategoryOptionCombo categoryOptionCombo;
-
- protected Collection<Integer> dataElementIds;
- protected Set<Integer> dataElementGroupIds;
-
- protected Collection<Integer> periodIds;
-
- protected Collection<Integer> organisationUnitIds;
- protected Collection<Integer> organisationUnitGroupIds;
-
- protected DataSet dataSetA;
- protected DataSet dataSetB;
- protected DataSet dataSetC;
-
- protected DataElementGroup dataElementGroupA;
- protected DataElementGroup dataElementGroupB;
- protected DataElementGroup dataElementGroupC;
-
- protected DataElement dataElementA;
- protected DataElement dataElementB;
- protected DataElement dataElementC;
- protected DataElement dataElementD;
- protected DataElement dataElementE;
- protected DataElement dataElementF;
-
- protected Period periodA;
- protected Period periodB;
- protected Period periodC;
- protected Period periodD;
-
- protected OrganisationUnit unitA;
- protected OrganisationUnit unitB;
- protected OrganisationUnit unitC;
- protected OrganisationUnit unitD;
- protected OrganisationUnit unitE;
- protected OrganisationUnit unitF;
- protected OrganisationUnit unitG;
- protected OrganisationUnit unitH;
- protected OrganisationUnit unitI;
-
- protected OrganisationUnitGroup unitGroupA;
- protected OrganisationUnitGroup unitGroupB;
-
- protected MockI18n mockI18n;
-
- protected MockI18nFormat mockFormat;
-
- @Autowired
- private DataElementService dataElementService;
-
- @Autowired
- private DataValueService dataValueService;
-
- @Autowired
- private IndicatorService indicatorService;
-
- @Autowired
- private PeriodService periodService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Autowired
- private OrganisationUnitGroupService organisationUnitGroupService;
-
- @Autowired
- private DataElementCategoryService categoryService;
-
- @Autowired
- private DataSetService dataSetService;
-
- public void setUpDataBrowserTest()
- throws Exception
- {
- mockI18n = new MockI18n();
-
- mockFormat = new MockI18nFormat();
-
- categoryCombo = categoryService.getDataElementCategoryComboByName( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME );
-
- categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-
-
- // ---------------------------------------------------------------------
- // Setup identifier Collections
- // ---------------------------------------------------------------------
-
- dataElementIds = new HashSet<>();
- dataElementGroupIds = new HashSet<>();
- periodIds = new HashSet<>();
- organisationUnitIds = new HashSet<>();
- organisationUnitGroupIds = new HashSet<>();
-
- // ---------------------------------------------------------------------
- // Setup DataElements
- // ---------------------------------------------------------------------
-
- dataElementA = createDataElement( 'A', DataElement.VALUE_TYPE_INT, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
- dataElementB = createDataElement( 'B', DataElement.VALUE_TYPE_BOOL, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
- dataElementC = createDataElement( 'C', DataElement.VALUE_TYPE_STRING, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
- dataElementD = createDataElement( 'D', DataElement.VALUE_TYPE_INT, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
- dataElementE = createDataElement( 'E', DataElement.VALUE_TYPE_BOOL, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
- dataElementF = createDataElement( 'F', DataElement.VALUE_TYPE_STRING, DataElement.AGGREGATION_OPERATOR_SUM,
- categoryCombo );
-
- dataElementIds.add( dataElementService.addDataElement( dataElementA ) );
- dataElementIds.add( dataElementService.addDataElement( dataElementB ) );
- dataElementIds.add( dataElementService.addDataElement( dataElementC ) );
- dataElementIds.add( dataElementService.addDataElement( dataElementD ) );
- dataElementIds.add( dataElementService.addDataElement( dataElementE ) );
- dataElementIds.add( dataElementService.addDataElement( dataElementF ) );
-
- Set<DataElement> dataElementsA = new HashSet<>();
- Set<DataElement> dataElementsB = new HashSet<>();
- Set<DataElement> dataElementsC = new HashSet<>();
-
- // One dataElement
- dataElementsA.add( dataElementA );
-
- // Two dataElements
- dataElementsB.add( dataElementB );
- dataElementsB.add( dataElementD );
-
- // Three dataElements
- dataElementsC.add( dataElementC );
- dataElementsC.add( dataElementE );
- dataElementsC.add( dataElementF );
-
- // ---------------------------------------------------------------------
- // Setup Periods
- // ---------------------------------------------------------------------
-
- Iterator<PeriodType> periodTypeIt = periodService.getAllPeriodTypes().iterator();
- PeriodType periodTypeA = periodTypeIt.next(); // Daily
- PeriodType periodTypeB = periodTypeIt.next(); // Weekly
-
- Date mar01 = getDate( 2005, 3, 1 );
- Date mar31 = getDate( 2005, 3, 31 );
- Date apr01 = getDate( 2005, 4, 1 );
- Date apr30 = getDate( 2005, 4, 30 );
- Date may01 = getDate( 2005, 5, 1 );
- Date may31 = getDate( 2005, 5, 31 );
-
- periodA = createPeriod( periodTypeA, mar01, mar31 );
- periodB = createPeriod( periodTypeA, apr01, apr30 );
- periodC = createPeriod( periodTypeB, mar01, may31 );
- periodD = createPeriod( periodTypeB, may01, may31 );
-
- periodIds.add( periodService.addPeriod( periodA ) );
- periodIds.add( periodService.addPeriod( periodB ) );
- periodIds.add( periodService.addPeriod( periodC ) );
- periodIds.add( periodService.addPeriod( periodD ) );
-
- // ---------------------------------------------------------------------
- // Setup DataSets
- // ---------------------------------------------------------------------
-
- dataSetA = createDataSet( 'A', periodTypeA );
- dataSetB = createDataSet( 'B', periodTypeB );
- dataSetC = createDataSet( 'C', periodTypeB );
-
- dataSetA.setDataElements( dataElementsA );
- dataSetB.setDataElements( dataElementsB );
- dataSetC.setDataElements( dataElementsC );
-
- dataSetService.addDataSet( dataSetA );
- dataSetService.addDataSet( dataSetB );
- dataSetService.addDataSet( dataSetC );
-
- // ---------------------------------------------------------------------
- // Setup DataElementGroups
- // ---------------------------------------------------------------------
-
- dataElementGroupA = createDataElementGroup( 'A' );
- dataElementGroupB = createDataElementGroup( 'B' );
- dataElementGroupC = createDataElementGroup( 'C' );
-
- dataElementGroupA.setMembers( dataElementsA );
- dataElementGroupB.setMembers( dataElementsB );
- dataElementGroupC.setMembers( dataElementsC );
-
- dataElementGroupIds.add( dataElementService.addDataElementGroup( dataElementGroupA ) );
- dataElementGroupIds.add( dataElementService.addDataElementGroup( dataElementGroupB ) );
- dataElementGroupIds.add( dataElementService.addDataElementGroup( dataElementGroupC ) );
-
- // ---------------------------------------------------------------------
- // Setup OrganisationUnits
- // ---------------------------------------------------------------------
-
- unitA = createOrganisationUnit( 'A' );
- unitB = createOrganisationUnit( 'B', unitA );
- unitC = createOrganisationUnit( 'C', unitA );
- unitD = createOrganisationUnit( 'D', unitB );
- unitE = createOrganisationUnit( 'E', unitB );
- unitF = createOrganisationUnit( 'F', unitB );
- unitG = createOrganisationUnit( 'G', unitF );
- unitH = createOrganisationUnit( 'H', unitF );
- unitI = createOrganisationUnit( 'I' );
-
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitA ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitB ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitC ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitD ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitE ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitF ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitG ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitH ) );
- organisationUnitIds.add( organisationUnitService.addOrganisationUnit( unitI ) );
-
- // ---------------------------------------------------------------------
- // Setup OrganisationUnitGroups
- // ---------------------------------------------------------------------
-
- Collection<OrganisationUnit> orgUnitsA = new HashSet<>();
- Collection<OrganisationUnit> orgUnitsB = new HashSet<>();
-
- // Two orgUnits
- orgUnitsA.add( unitB );
- orgUnitsA.add( unitC );
-
- // Three orgUnits
- orgUnitsB.add( unitD );
- orgUnitsB.add( unitE );
- orgUnitsB.add( unitF );
-
- unitGroupA = createOrganisationUnitGroup( 'A' );
- unitGroupB = createOrganisationUnitGroup( 'B' );
-
- unitGroupA.setMembers( (Set<OrganisationUnit>) orgUnitsA );
- unitGroupB.setMembers( (Set<OrganisationUnit>) orgUnitsB );
-
- organisationUnitGroupIds.add( organisationUnitGroupService.addOrganisationUnitGroup( unitGroupA ) );
- organisationUnitGroupIds.add( organisationUnitGroupService.addOrganisationUnitGroup( unitGroupB ) );
-
- // ---------------------------------------------------------------------
- // Setup DataValues
- // ---------------------------------------------------------------------
-
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitC, "90", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitD, "10", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitE, "35", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitF, "25", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitG, "20", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodA, unitH, "60", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitC, "70", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitD, "40", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitE, "65", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitF, "55", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitG, "20", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodB, unitH, "15", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitC, "95", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitD, "40", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitE, "45", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitF, "30", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitG, "50", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementA, periodC, unitH, "70", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitC, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitD, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitE, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitF, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitG, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodA, unitH, T, categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitC, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitD, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitE, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitF, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitG, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodB, unitH, T, categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitC, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitD, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitE, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitF, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitG, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementB, periodC, unitH, T, categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementC, periodD, unitC, "String1", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementC, periodD, unitD, "String2", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementC, periodD, unitE, "String3", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementD, periodA, unitC, "10", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementD, periodA, unitD, "20", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementD, periodA, unitE, "30", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementD, periodB, unitF, "40", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementD, periodB, unitG, "50", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementD, periodB, unitH, "60", categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementE, periodC, unitC, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementE, periodC, unitD, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementE, periodC, unitE, T, categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementE, periodD, unitF, T, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementE, periodD, unitG, F, categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementE, periodD, unitH, T, categoryOptionCombo ) );
-
- dataValueService.addDataValue( createDataValue( dataElementF, periodA, unitC, "String4", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementF, periodA, unitD, "String5", categoryOptionCombo ) );
- dataValueService.addDataValue( createDataValue( dataElementF, periodA, unitE, "String6", categoryOptionCombo ) );
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java 2014-10-07 13:46:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java 2014-10-13 18:14:45 +0000
@@ -32,20 +32,16 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
-import org.hisp.dhis.DhisTest;
+
+import org.hisp.dhis.DhisSpringTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author Dang Duy Hieu
- * @version $Id$
*/
public class SqlViewServiceTest
- extends DhisTest
+ extends DhisSpringTest
{
@Autowired
private SqlViewService sqlViewService;
@@ -94,9 +90,6 @@
assertEquals( idB, sqlViewB.getId() );
assertEq( 'B', sqlViewB, SQL2 );
-
- sqlViewService.deleteSqlView( sqlViewA );
- sqlViewService.deleteSqlView( sqlViewB );
}
@Test
@@ -113,16 +106,10 @@
sqlView.setName( "SqlViewC" );
sqlViewService.updateSqlView( sqlView );
-
- sqlView = sqlViewService.getSqlView( id );
-
- assertEquals( sqlView.getName(), "SqlViewC" );
-
- sqlViewService.deleteSqlView( sqlView );
}
@Test
- public void testDeleteAndGetSqlView()
+ public void testGetAndDeleteSqlView()
{
SqlView sqlViewA = createSqlView( 'A', SQL3 );
SqlView sqlViewB = createSqlView( 'B', SQL4 );
@@ -157,34 +144,6 @@
assertEquals( sqlViewService.getSqlView( "SqlViewA" ).getId(), idA );
assertEquals( sqlViewService.getSqlView( "SqlViewB" ).getId(), idB );
assertNull( sqlViewService.getSqlView( "SqlViewC" ) );
-
- sqlViewService.deleteSqlView( sqlViewA );
- sqlViewService.deleteSqlView( sqlViewB );
- }
-
- @Test
- public void testGetAllSqlViews()
- {
- SqlView sqlViewA = createSqlView( 'A', SQL1 );
- SqlView sqlViewB = createSqlView( 'B', SQL2 );
- SqlView sqlViewC = createSqlView( 'C', SQL3 );
- SqlView sqlViewD = createSqlView( 'D', SQL4 );
-
- sqlViewService.saveSqlView( sqlViewA );
- sqlViewService.saveSqlView( sqlViewB );
- sqlViewService.saveSqlView( sqlViewC );
-
- Collection<SqlView> sqlViews = sqlViewService.getAllSqlViews();
-
- assertEquals( sqlViews.size(), 3 );
- assertTrue( sqlViews.contains( sqlViewA ) );
- assertTrue( sqlViews.contains( sqlViewB ) );
- assertTrue( sqlViews.contains( sqlViewC ) );
- assertTrue( !sqlViews.contains( sqlViewD ) );
-
- sqlViewService.deleteSqlView( sqlViewA );
- sqlViewService.deleteSqlView( sqlViewB );
- sqlViewService.deleteSqlView( sqlViewC );
}
@Test
@@ -201,8 +160,6 @@
SqlView sqlViewB = sqlViewService.getSqlView( idA );
assertEq( 'A', sqlViewB, "SELECT * FROM _categorystructure;" );
-
- sqlViewService.deleteSqlView( sqlViewService.getSqlView( idA ) );
}
@Test
@@ -213,18 +170,5 @@
assertEquals( "_view_sqlviewc", sqlViewC.getViewName() );
assertNotSame( "_view_sqlviewc", sqlViewD.getViewName() );
-
- }
-
- @Test
- public void testTestSqlGrammar()
- {
- String sql = "select de.name, de.name from dataelement de";
-
- assertNotSame( sqlViewService.testSqlGrammar( sql ), "" );
-
- sql += " xyz";
-
- assertNotSame( sqlViewService.testSqlGrammar( sql ), "" );
}
}