← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12964: Implement unit tests on ProgramStageSection service methods

 

------------------------------------------------------------
revno: 12964
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-19 13:51:39 +0700
message:
   Implement unit tests on ProgramStageSection service methods
added:
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionServiceTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionStoreTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementServiceTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementStoreTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceStoreTest.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageSectionService.java	2013-11-19 06:51:39 +0000
@@ -104,14 +104,5 @@
      *         there are no ProgramStageSections.
      */
     Collection<ProgramStageSection> getAllProgramStageSections();
-
-    /**
-     * Get all sections by a program stage
-     * 
-     * @param programStage {@link ProgramStage}
-     * 
-     * @return ProgramStageSection list
-     */
-    Collection<ProgramStageSection> getProgramStages( ProgramStage programStage );
-
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageSectionService.java	2013-11-19 06:51:39 +0000
@@ -104,12 +104,6 @@
     }
 
     @Override
-    public Collection<ProgramStageSection> getProgramStages( ProgramStage programStage )
-    {
-        return i18n( i18nService, programStage.getProgramStageSections() );
-    }
-
-    @Override
     public ProgramStageSection getProgramStageSectionByName( String name, ProgramStage programStage )
     {
         return i18n( i18nService, programStageSectionStore.getByNameAndProgramStage( name, programStage ) );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementServiceTest.java	2013-11-19 03:45:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementServiceTest.java	2013-11-19 06:51:39 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.junit.Test;
@@ -66,9 +65,6 @@
     private ProgramService programService;
 
     @Autowired
-    private DataEntryFormService dataEntryFormService;
-
-    @Autowired
     private ProgramStageService programStageService;
 
     private OrganisationUnit organisationUnit;
@@ -190,7 +186,7 @@
     }
 
     @Test
-    public void testGetByStage( )
+    public void testGetByStage()
     {
         programStageDataElementService.addProgramStageDataElement( stageDataElementA );
         programStageDataElementService.addProgramStageDataElement( stageDataElementB );
@@ -205,7 +201,7 @@
     }
 
     @Test
-    public void testGetListDataElementByStage( )
+    public void testGetListDataElementByStage()
     {
         programStageDataElementService.addProgramStageDataElement( stageDataElementA );
         programStageDataElementService.addProgramStageDataElement( stageDataElementB );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementStoreTest.java	2013-11-15 04:35:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageDataElementStoreTest.java	2013-11-19 06:51:39 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.junit.Test;
@@ -66,9 +65,6 @@
     private ProgramService programService;
 
     @Autowired
-    private DataEntryFormService dataEntryFormService;
-
-    @Autowired
     private ProgramStageService programStageService;
 
     private OrganisationUnit organisationUnit;

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java	2013-11-19 03:45:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java	2013-11-19 06:51:39 +0000
@@ -44,7 +44,6 @@
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.message.MessageConversation;
 import org.hisp.dhis.mock.MockI18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -72,7 +71,7 @@
     private ProgramStageInstanceService programStageInstanceService;
 
     @Autowired
-    private ProgramStageDataElementStore programStageDataElementStore;
+    private ProgramStageDataElementService programStageDataElementService;
 
     @Autowired
     private OrganisationUnitService organisationUnitService;
@@ -84,9 +83,6 @@
     private ProgramService programService;
 
     @Autowired
-    private DataEntryFormService dataEntryFormService;
-
-    @Autowired
     private ProgramStageService programStageService;
 
     @Autowired
@@ -221,10 +217,10 @@
         stageDataElementC = new ProgramStageDataElement( stageB, dataElementA, false, 1 );
         stageDataElementD = new ProgramStageDataElement( stageB, dataElementB, false, 2 );
 
-        programStageDataElementStore.save( stageDataElementA );
-        programStageDataElementStore.save( stageDataElementB );
-        programStageDataElementStore.save( stageDataElementC );
-        programStageDataElementStore.save( stageDataElementD );
+        programStageDataElementService.addProgramStageDataElement( stageDataElementA );
+        programStageDataElementService.addProgramStageDataElement( stageDataElementB );
+        programStageDataElementService.addProgramStageDataElement( stageDataElementC );
+        programStageDataElementService.addProgramStageDataElement( stageDataElementD );
 
         /**
          * Program B

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceStoreTest.java	2013-11-19 03:45:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageInstanceStoreTest.java	2013-11-19 06:51:39 +0000
@@ -40,7 +40,6 @@
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.patient.Patient;
@@ -74,9 +73,6 @@
     private ProgramService programService;
 
     @Autowired
-    private DataEntryFormService dataEntryFormService;
-
-    @Autowired
     private ProgramStageService programStageService;
 
     @Autowired

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionServiceTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionServiceTest.java	2013-11-19 06:51:39 +0000
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2004-2013, 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.
+ */
+
+package org.hisp.dhis.program;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $ ProgramStageSectionService.java Nov 14, 2013 4:22:27 PM $
+ */
+public class ProgramStageSectionServiceTest
+    extends DhisSpringTest
+{
+    @Autowired
+    private ProgramStageSectionService programStageSectionService;
+
+    @Autowired
+    private ProgramStageDataElementStore programStageDataElementStore;
+
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+
+    @Autowired
+    private DataElementService dataElementService;
+
+    @Autowired
+    private ProgramService programService;
+
+    @Autowired
+    private ProgramStageService programStageService;
+
+    @Autowired
+    private ProgramStageDataElementService programStageDataElementService;
+
+    private OrganisationUnit organisationUnit;
+
+    private ProgramStage stageA;
+
+    private ProgramStage stageB;
+
+    private ProgramStageSection sectionA;
+
+    private ProgramStageSection sectionB;
+
+    @Override
+    public void setUpTest()
+    {
+        organisationUnit = createOrganisationUnit( 'A' );
+        organisationUnitService.addOrganisationUnit( organisationUnit );
+
+        Program program = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnit );
+        programService.addProgram( program );
+
+        stageA = new ProgramStage( "A", program );
+        programStageService.saveProgramStage( stageA );
+
+        DataElement dataElementA = createDataElement( 'A' );
+        DataElement dataElementB = createDataElement( 'B' );
+
+        dataElementService.addDataElement( dataElementA );
+        dataElementService.addDataElement( dataElementB );
+
+        ProgramStageDataElement stageDeA = new ProgramStageDataElement( stageA, dataElementA, false, 1 );
+        ProgramStageDataElement stageDeB = new ProgramStageDataElement( stageA, dataElementB, false, 2 );
+
+        programStageDataElementService.addProgramStageDataElement( stageDeA );
+        programStageDataElementService.addProgramStageDataElement( stageDeB );
+
+        List<ProgramStageDataElement> psDataElements = new ArrayList<ProgramStageDataElement>();
+        psDataElements.add( stageDeA );
+        psDataElements.add( stageDeB );
+
+        stageB = new ProgramStage( "B", program );
+        programStageService.saveProgramStage( stageB );
+
+        Set<ProgramStage> programStages = new HashSet<ProgramStage>();
+        programStages.add( stageA );
+        programStages.add( stageB );
+        program.setProgramStages( programStages );
+        programService.updateProgram( program );
+
+        sectionA = new ProgramStageSection();
+        sectionA.setName( "A" );
+        sectionA.setProgramStageDataElements( psDataElements );
+        sectionA.setSortOrder( 1 );
+
+        sectionB = new ProgramStageSection();
+        sectionB.setName( "B" );
+        sectionB.setSortOrder( 2 );
+
+        Set<ProgramStageSection> sections = new HashSet<ProgramStageSection>();
+        sections.add( sectionA );
+        sections.add( sectionB );
+        stageA.setProgramStageSections( sections );
+    }
+
+    @Test
+    public void testSaveProgramStageSection()
+    {
+        int idA = programStageSectionService.saveProgramStageSection( sectionA );
+        int idB = programStageSectionService.saveProgramStageSection( sectionB );
+
+        assertNotNull( programStageSectionService.getProgramStageSection( idA ) );
+        assertNotNull( programStageSectionService.getProgramStageSection( idB ) );
+    }
+
+    @Test
+    public void testDeleteProgramStageSection()
+    {
+        int idA = programStageSectionService.saveProgramStageSection( sectionA );
+        int idB = programStageSectionService.saveProgramStageSection( sectionB );
+
+        assertNotNull( programStageSectionService.getProgramStageSection( idA ) );
+        assertNotNull( programStageSectionService.getProgramStageSection( idB ) );
+
+        programStageSectionService.deleteProgramStageSection( sectionA );
+
+        assertNull( programStageSectionService.getProgramStageSection( idA ) );
+        assertNotNull( programStageSectionService.getProgramStageSection( idB ) );
+
+        programStageSectionService.deleteProgramStageSection( sectionB );
+
+        assertNull( programStageSectionService.getProgramStageSection( idA ) );
+        assertNull( programStageSectionService.getProgramStageSection( idB ) );
+    }
+
+    @Test
+    public void testUpdateProgramStageSection()
+    {
+        int idA = programStageSectionService.saveProgramStageSection( sectionA );
+
+        assertNotNull( programStageSectionService.getProgramStageSection( idA ) );
+
+        sectionA.setName( "B" );
+        programStageSectionService.updateProgramStageSection( sectionA );
+
+        assertEquals( "B", programStageSectionService.getProgramStageSection( idA ).getName() );
+    }
+
+    @Test
+    public void testGetProgramStageSectionById()
+    {
+        int idA = programStageSectionService.saveProgramStageSection( sectionA );
+        int idB = programStageSectionService.saveProgramStageSection( sectionB );
+
+        assertEquals( sectionA, programStageSectionService.getProgramStageSection( idA ) );
+        assertEquals( sectionB, programStageSectionService.getProgramStageSection( idB ) );
+    }
+
+    @Test
+    public void testGetProgramStageSectionListByName()
+    {
+        programStageService.updateProgramStage( stageA );
+
+        List<ProgramStageSection> sections = programStageSectionService.getProgramStageSectionByName( "A" );
+        assertEquals( 1, sections.size() );
+        assertTrue( sections.contains( sectionA ) );
+    }
+
+    @Test
+    public void testGetProgramStageSectionByNameStage()
+    {
+        programStageService.updateProgramStage( stageA );
+        assertNotNull( programStageSectionService.getProgramStageSectionByName( "A", stageA ) );
+    }
+
+    @Test
+    public void testGetAllProgramStageSections()
+    {
+        programStageService.updateProgramStage( stageA );
+        Set<ProgramStageSection> sections = stageA.getProgramStageSections();
+
+        assertTrue( equals( sections, sectionA, sectionB ) );
+    }
+
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionStoreTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramStageSectionStoreTest.java	2013-11-19 06:51:39 +0000
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2004-2013, 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.
+ */
+
+package org.hisp.dhis.program;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $ ProgramStageSectionService.java Nov 14, 2013 4:22:27 PM $
+ */
+public class ProgramStageSectionStoreTest
+    extends DhisSpringTest
+{
+    @Autowired
+    private ProgramStageSectionStore programStageSectionStore;
+
+    @Autowired
+    private ProgramStageDataElementStore programStageDataElementStore;
+
+    @Autowired
+    private OrganisationUnitService organisationUnitService;
+
+    @Autowired
+    private DataElementService dataElementService;
+
+    @Autowired
+    private ProgramService programService;
+
+    @Autowired
+    private ProgramStageService programStageService;
+
+    @Autowired
+    private ProgramStageDataElementService programStageDataElementService;
+
+    private OrganisationUnit organisationUnit;
+
+    private ProgramStage stageA;
+
+    private ProgramStage stageB;
+
+    private ProgramStageSection sectionA;
+
+    private ProgramStageSection sectionB;
+
+    @Override
+    public void setUpTest()
+    {
+        organisationUnit = createOrganisationUnit( 'A' );
+        organisationUnitService.addOrganisationUnit( organisationUnit );
+
+        Program program = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnit );
+        programService.addProgram( program );
+
+        stageA = new ProgramStage( "A", program );
+        programStageService.saveProgramStage( stageA );
+
+        DataElement dataElementA = createDataElement( 'A' );
+        DataElement dataElementB = createDataElement( 'B' );
+
+        dataElementService.addDataElement( dataElementA );
+        dataElementService.addDataElement( dataElementB );
+
+        ProgramStageDataElement stageDeA = new ProgramStageDataElement( stageA, dataElementA, false, 1 );
+        ProgramStageDataElement stageDeB = new ProgramStageDataElement( stageA, dataElementB, false, 2 );
+
+        programStageDataElementService.addProgramStageDataElement( stageDeA );
+        programStageDataElementService.addProgramStageDataElement( stageDeB );
+
+        List<ProgramStageDataElement> psDataElements = new ArrayList<ProgramStageDataElement>();
+        psDataElements.add( stageDeA );
+        psDataElements.add( stageDeB );
+
+        stageB = new ProgramStage( "B", program );
+        programStageService.saveProgramStage( stageB );
+
+        Set<ProgramStage> programStages = new HashSet<ProgramStage>();
+        programStages.add( stageA );
+        programStages.add( stageB );
+        program.setProgramStages( programStages );
+        programService.updateProgram( program );
+
+        sectionA = new ProgramStageSection();
+        sectionA.setName( "A" );
+        sectionA.setProgramStageDataElements( psDataElements );
+        sectionA.setSortOrder( 1 );
+
+        sectionB = new ProgramStageSection();
+        sectionB.setName( "B" );
+        sectionB.setSortOrder( 2 );
+
+        Set<ProgramStageSection> sections = new HashSet<ProgramStageSection>();
+        sections.add( sectionA );
+        sections.add( sectionB );
+        stageA.setProgramStageSections( sections );
+    }
+
+    @Test
+    public void testGetProgramStageSectionByNameStage()
+    {
+        programStageService.updateProgramStage( stageA );
+        assertNotNull( programStageSectionStore.getByNameAndProgramStage( "A", stageA ) );
+    }
+
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2013-10-24 08:31:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2013-11-19 06:51:39 +0000
@@ -305,7 +305,7 @@
 
         if ( programStage.getDataEntryType().equals( ProgramStage.TYPE_SECTION ) )
         {
-            sections = new ArrayList<ProgramStageSection>( programStageSectionService.getProgramStages( programStage ) );
+            sections = new ArrayList<ProgramStageSection>( programStage.getProgramStageSections() );
 
             Collections.sort( sections, new ProgramStageSectionSortOrderComparator() );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/GetProgramStageSectionListAction.java	2013-11-19 06:51:39 +0000
@@ -104,7 +104,7 @@
     {
         programStage = programStageService.getProgramStage( id );
 
-        sections = new ArrayList<ProgramStageSection>( programStageSectionService.getProgramStages( programStage ) );
+        sections = new ArrayList<ProgramStageSection>( programStage.getProgramStageSections() );
 
         Collections.sort( sections, new ProgramStageSectionSortOrderComparator() );