← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19567: remove unused tests, simplified EnrollmentService

 

------------------------------------------------------------
revno: 19567
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 10:04:42 +0700
message:
  remove unused tests, simplified EnrollmentService
removed:
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-07-07 06:11:54 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-07-08 03:04:42 +0000
@@ -49,10 +49,11 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceQueryParams;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStatus;
 import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
-import org.hisp.dhis.program.ProgramType;
 import org.hisp.dhis.system.callable.IdentifiableObjectSearchCallable;
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.MathUtils;
@@ -68,7 +69,6 @@
 import org.springframework.util.Assert;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
@@ -125,73 +125,15 @@
     // -------------------------------------------------------------------------
 
     @Override
-    public Enrollments getEnrollments()
-    {
-        List<Program> programs = getProgramsWithRegistration();
-
-        List<ProgramInstance> programInstances = new ArrayList<>(
-            programInstanceService.getProgramInstances( programs ) );
-
-        return getEnrollments( programInstances );
-    }
-
-    @Override
-    public Enrollments getEnrollments( EnrollmentStatus status )
-    {
-        List<Program> programs = getProgramsWithRegistration();
-
-        List<ProgramInstance> programInstances = new ArrayList<>(
-            programInstanceService.getProgramInstances( programs, status.getValue() ) );
-
-        return getEnrollments( programInstances );
-    }
-
-    @Override
-    public Enrollments getEnrollments( TrackedEntityInstance trackedEntityInstance )
-    {
-        org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( trackedEntityInstance
-            .getTrackedEntityInstance() );
-
-        return getEnrollments( entityInstance );
-    }
-
-    @Override
-    public Enrollments getEnrollments( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
-    {
-        List<ProgramInstance> programInstances = new ArrayList<>( entityInstance.getProgramInstances() );
-
-        return getEnrollments( programInstances );
-    }
-
-    @Override
-    public Enrollments getEnrollments( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance,
-        EnrollmentStatus status )
-    {
-        List<ProgramInstance> programInstances = new ArrayList<>(
-            programInstanceService.getProgramInstances( entityInstance, status.getValue() ) );
-
-        return getEnrollments( programInstances );
-    }
-
-    @Override
-    public Enrollments getEnrollments( Program program, TrackedEntityInstance trackedEntityInstance,
-        EnrollmentStatus status )
-    {
-        org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( trackedEntityInstance
-            .getTrackedEntityInstance() );
-        return getEnrollments( programInstanceService.getProgramInstances( entityInstance, program, status.getValue() ) );
-    }
-
-    @Override
-    public Enrollments getEnrollments( Collection<ProgramInstance> programInstances )
-    {
-        Enrollments enrollments = new Enrollments();
+    public List<Enrollment> getEnrollments( Iterable<ProgramInstance> programInstances )
+    {
+        List<Enrollment> enrollments = new ArrayList<>();
 
         for ( ProgramInstance programInstance : programInstances )
         {
             if ( programInstance != null && programInstance.getEntityInstance() != null )
             {
-                enrollments.getEnrollments().add( getEnrollment( programInstance ) );
+                enrollments.add( getEnrollment( programInstance ) );
             }
         }
 
@@ -287,9 +229,15 @@
 
         Program program = getProgram( enrollment.getProgram() );
 
-        Enrollments enrollments = getEnrollments( program, trackedEntityInstance, EnrollmentStatus.ACTIVE );
-
-        if ( !enrollments.getEnrollments().isEmpty() )
+        ProgramInstanceQueryParams params = new ProgramInstanceQueryParams();
+        params.setSkipPaging( true );
+        params.setProgram( program );
+        params.setTrackedEntityInstance( entityInstance );
+        params.setProgramStatus( ProgramStatus.ACTIVE );
+
+        List<Enrollment> enrollments = getEnrollments( programInstanceService.getProgramInstances( params ) );
+
+        if ( !enrollments.isEmpty() )
         {
             importSummary.setStatus( ImportStatus.ERROR );
             importSummary.setDescription( "TrackedEntityInstance " + trackedEntityInstance.getTrackedEntityInstance()
@@ -301,9 +249,14 @@
 
         if ( program.getOnlyEnrollOnce() )
         {
-            enrollments = getEnrollments( program, trackedEntityInstance, EnrollmentStatus.COMPLETED );
-
-            if ( !enrollments.getEnrollments().isEmpty() )
+            params.setSkipPaging( true );
+            params.setProgram( program );
+            params.setTrackedEntityInstance( entityInstance );
+            params.setProgramStatus( ProgramStatus.COMPLETED );
+
+            enrollments = getEnrollments( programInstanceService.getProgramInstances( params ) );
+
+            if ( !enrollments.isEmpty() )
             {
                 importSummary.setStatus( ImportStatus.ERROR );
                 importSummary.setDescription( "TrackedEntityInstance " + trackedEntityInstance.getTrackedEntityInstance()
@@ -640,13 +593,6 @@
         }
     }
 
-    private List<Program> getProgramsWithRegistration()
-    {
-        List<Program> programs = programService.getPrograms( ProgramType.WITH_REGISTRATION );
-
-        return programs;
-    }
-
     private org.hisp.dhis.trackedentity.TrackedEntityInstance getTrackedEntityInstance( String trackedEntityInstance )
     {
         org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = teiService

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java	2015-07-07 06:11:54 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java	2015-07-08 03:04:42 +0000
@@ -28,18 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
 import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
 import org.hisp.dhis.importexport.ImportStrategy;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collection;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -53,24 +48,12 @@
     // READ
     // -------------------------------------------------------------------------
 
-    Enrollments getEnrollments();
-
-    Enrollments getEnrollments( EnrollmentStatus status );
-
-    Enrollments getEnrollments( TrackedEntityInstance trackedEntityInstance );
-
-    Enrollments getEnrollments( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance );
-
-    Enrollments getEnrollments( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance, EnrollmentStatus status );
-
-    Enrollments getEnrollments( Program program, TrackedEntityInstance trackedEntityInstance, EnrollmentStatus status );
-
-    Enrollments getEnrollments( Collection<ProgramInstance> programInstances );
-
     Enrollment getEnrollment( String id );
 
     Enrollment getEnrollment( ProgramInstance programInstance );
 
+    List<Enrollment> getEnrollments( Iterable<ProgramInstance> programInstances );
+
     // -------------------------------------------------------------------------
     // CREATE
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java	2015-06-08 03:29:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/JacksonEnrollmentService.java	2015-07-08 03:04:42 +0000
@@ -140,12 +140,12 @@
     {
         ImportSummaries importSummaries = new ImportSummaries();
 
-        Enrollments create = new Enrollments();
-        Enrollments update = new Enrollments();
+        List<Enrollment> create = new ArrayList<>();
+        List<Enrollment> update = new ArrayList<>();
 
         if ( strategy.isCreate() )
         {
-            create.getEnrollments().addAll( enrollments );
+            create.addAll( enrollments );
         }
         else if ( strategy.isCreateAndUpdate() )
         {
@@ -153,24 +153,24 @@
             {
                 if ( StringUtils.isEmpty( enrollment.getEnrollment() ) )
                 {
-                    create.getEnrollments().add( enrollment );
+                    create.add( enrollment );
                 }
                 else
                 {
                     if ( programInstanceService.getProgramInstance( enrollment.getEnrollment() ) == null )
                     {
-                        create.getEnrollments().add( enrollment );
+                        create.add( enrollment );
                     }
                     else
                     {
-                        update.getEnrollments().add( enrollment );
+                        update.add( enrollment );
                     }
                 }
             }
         }
 
-        importSummaries.addImportSummaries( addEnrollments( create.getEnrollments() ) );
-        importSummaries.addImportSummaries( updateEnrollments( update.getEnrollments() ) );
+        importSummaries.addImportSummaries( addEnrollments( create ) );
+        importSummaries.addImportSummaries( updateEnrollments( update ) );
 
         return importSummaries;
     }

=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java	2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java	1970-01-01 00:00:00 +0000
@@ -1,367 +0,0 @@
-package org.hisp.dhis.dxf2.events;
-
-/*
- * Copyright (c) 2004-2015, 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.assertThat;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
-import org.hamcrest.CoreMatchers;
-import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
-import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
-import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
-import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
-import org.hisp.dhis.dxf2.importsummary.ImportStatus;
-import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramType;
-import org.hisp.dhis.trackedentity.TrackedEntity;
-import org.hisp.dhis.trackedentity.TrackedEntityService;
-import org.joda.time.DateTime;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class EnrollmentServiceTest
-    extends DhisSpringTest
-{
-    @Autowired
-    private TrackedEntityService trackedEntityService;
-
-    @Autowired
-    private TrackedEntityInstanceService trackedEntityInstanceService;
-
-    @Autowired
-    private EnrollmentService enrollmentService;
-
-    @Autowired
-    private IdentifiableObjectManager manager;
-
-    @Autowired
-    private ProgramInstanceService programInstanceService;
-
-    private org.hisp.dhis.trackedentity.TrackedEntityInstance maleA;
-    private org.hisp.dhis.trackedentity.TrackedEntityInstance maleB;
-    private org.hisp.dhis.trackedentity.TrackedEntityInstance femaleA;
-    private org.hisp.dhis.trackedentity.TrackedEntityInstance femaleB;
-
-    private OrganisationUnit organisationUnitA;
-    private OrganisationUnit organisationUnitB;
-
-    private Program programA;
-    private ProgramStage programStage;
-
-    @Override
-    protected void setUpTest() 
-        throws Exception
-    {
-        organisationUnitA = createOrganisationUnit( 'A' );
-        organisationUnitB = createOrganisationUnit( 'B' );
-        organisationUnitB.setParent( organisationUnitA );
-
-        manager.save( organisationUnitA );
-        manager.save( organisationUnitB );
-
-        TrackedEntity trackedEntity = createTrackedEntity( 'A' );
-        trackedEntityService.addTrackedEntity( trackedEntity );
-
-        maleA = createTrackedEntityInstance( 'A', organisationUnitA );
-        maleB = createTrackedEntityInstance( 'B', organisationUnitB );
-        femaleA = createTrackedEntityInstance( 'C', organisationUnitA );
-        femaleB = createTrackedEntityInstance( 'D', organisationUnitB );
-
-        maleA.setTrackedEntity( trackedEntity );
-        maleB.setTrackedEntity( trackedEntity );
-        femaleA.setTrackedEntity( trackedEntity );
-        femaleB.setTrackedEntity( trackedEntity );
-
-        manager.save( maleA );
-        manager.save( maleB );
-        manager.save( femaleA );
-        manager.save( femaleB );
-
-        programStage = createProgramStage( 'A', 0 );
-        programStage.setGeneratedByEnrollmentDate( true );
-        manager.save( programStage );
-
-        programA = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnitA );
-        programA.setProgramType( ProgramType.WITH_REGISTRATION );
-        manager.save( programA );
-
-        programA.getProgramStages().add( programStage );
-        programStage.setProgram( programA );
-
-        manager.save( programA );
-    }
-
-    @Test
-    public void testGetEnrollments()
-    {
-        programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
-        programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
-
-        assertEquals( 2, enrollmentService.getEnrollments().getEnrollments().size() );
-    }
-
-    @Test
-    public void testGetEnrollmentsByPatient()
-    {
-        programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
-        programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
-
-        assertEquals( 1, enrollmentService.getEnrollments( maleA ).getEnrollments().size() );
-        assertEquals( 1, enrollmentService.getEnrollments( femaleA ).getEnrollments().size() );
-    }
-
-    @Test
-    public void testGetEnrollmentsByPerson()
-    {
-
-        programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
-        programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
-
-        TrackedEntityInstance male = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
-        TrackedEntityInstance female = trackedEntityInstanceService.getTrackedEntityInstance( femaleA );
-
-        assertEquals( 1, enrollmentService.getEnrollments( male ).getEnrollments().size() );
-        assertEquals( 1, enrollmentService.getEnrollments( female ).getEnrollments().size() );
-    }
-
-    @Test
-    public void testGetEnrollmentsByStatus()
-    {
-        ProgramInstance piMale = programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
-        ProgramInstance piFemale = programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
-
-        assertEquals( 2, enrollmentService.getEnrollments( EnrollmentStatus.ACTIVE ).getEnrollments().size() );
-        assertEquals( 0, enrollmentService.getEnrollments( EnrollmentStatus.CANCELLED ).getEnrollments().size() );
-        assertEquals( 0, enrollmentService.getEnrollments( EnrollmentStatus.COMPLETED ).getEnrollments().size() );
-
-        programInstanceService.cancelProgramInstanceStatus( piMale );
-
-        assertEquals( 1, enrollmentService.getEnrollments( EnrollmentStatus.ACTIVE ).getEnrollments().size() );
-        assertEquals( 1, enrollmentService.getEnrollments( EnrollmentStatus.CANCELLED ).getEnrollments().size() );
-        assertEquals( 0, enrollmentService.getEnrollments( EnrollmentStatus.COMPLETED ).getEnrollments().size() );
-
-        programInstanceService.completeProgramInstanceStatus( piFemale );
-
-        assertEquals( 0, enrollmentService.getEnrollments( EnrollmentStatus.ACTIVE ).getEnrollments().size() );
-        assertEquals( 1, enrollmentService.getEnrollments( EnrollmentStatus.CANCELLED ).getEnrollments().size() );
-        assertEquals( 1, enrollmentService.getEnrollments( EnrollmentStatus.COMPLETED ).getEnrollments().size() );
-    }
-
-    @Test
-    public void testSaveEnrollment()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        assertEquals( maleA.getUid(), enrollments.get( 0 ).getTrackedEntityInstance() );
-        assertEquals( programA.getUid(), enrollments.get( 0 ).getProgram() );
-    }
-
-    @Test
-    public void testUpdateEnrollment()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        enrollment = enrollments.get( 0 );
-
-        assertEquals( maleA.getUid(), enrollment.getTrackedEntityInstance() );
-        assertEquals( programA.getUid(), enrollment.getProgram() );
-
-        Date MARCH_20_81 = new DateTime( 81, 2, 20, 0, 0 ).toDate();
-
-        enrollment.setDateOfEnrollment( MARCH_20_81 );
-        enrollmentService.updateEnrollment( enrollment );
-
-        enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-        assertEquals( 1, enrollments.size() );
-        assertEquals( MARCH_20_81, enrollments.get( 0 ).getDateOfEnrollment() );
-    }
-
-    @Test
-    public void testUpdateCompleted()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-        assertEquals( 0, enrollments.size() );
-        
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        enrollment = enrollments.get( 0 );
-        enrollment.setStatus( EnrollmentStatus.COMPLETED );
-
-        enrollmentService.updateEnrollment( enrollment );
-        enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-        assertEquals( 1, enrollments.size() );
-        assertEquals( EnrollmentStatus.COMPLETED, enrollments.get( 0 ).getStatus() );
-    }
-
-    @Test
-    public void testUpdateCancelled()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        enrollment = enrollments.get( 0 );
-        enrollment.setStatus( EnrollmentStatus.CANCELLED );
-
-        enrollmentService.updateEnrollment( enrollment );
-        enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-        assertEquals( 1, enrollments.size() );
-        assertEquals( EnrollmentStatus.CANCELLED, enrollments.get( 0 ).getStatus() );
-    }
-
-    @Test
-    public void testUpdateReEnrollmentShouldFail()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        enrollment = enrollments.get( 0 );
-        enrollment.setStatus( EnrollmentStatus.CANCELLED );
-
-        importSummary = enrollmentService.updateEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        enrollments = enrollmentService.getEnrollments( maleA ).getEnrollments();
-        assertEquals( 1, enrollments.size() );
-        assertEquals( EnrollmentStatus.CANCELLED, enrollments.get( 0 ).getStatus() );
-
-        enrollment.setStatus( EnrollmentStatus.ACTIVE );
-        importSummary = enrollmentService.updateEnrollment( enrollment );
-        assertEquals( ImportStatus.ERROR, importSummary.getStatus() );
-    }
-
-    @Test
-    public void testMultipleEnrollmentsShouldFail()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-        importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.ERROR, importSummary.getStatus() );
-        assertThat( importSummary.getDescription(), CoreMatchers.containsString( "already have an active enrollment in program" ) );
-    }
-
-    @Test
-    @Ignore
-    public void testUpdatePersonShouldKeepEnrollments()
-    {
-        Enrollment enrollment = new Enrollment();
-        enrollment.setOrgUnit( organisationUnitA.getUid() );
-        enrollment.setTrackedEntityInstance( maleA.getUid() );
-        enrollment.setProgram( programA.getUid() );
-        enrollment.setDateOfIncident( new Date() );
-        enrollment.setDateOfEnrollment( new Date() );
-
-        ImportSummary importSummary = enrollmentService.addEnrollment( enrollment );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
-        trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance );
-
-        List<Enrollment> enrollments = enrollmentService.getEnrollments( trackedEntityInstance ).getEnrollments();
-
-        assertEquals( 1, enrollments.size() );
-        assertEquals( maleA.getUid(), enrollments.get( 0 ).getTrackedEntityInstance() );
-        assertEquals( programA.getUid(), enrollments.get( 0 ).getProgram() );
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-07-08 03:04:42 +0000
@@ -211,32 +211,6 @@
         assertEquals( 1, eventService.getEvents( params ).getEvents().size() );
     }
 
-    @Test
-    public void testMultipleEnrollmentsWithEventShouldGiveDifferentUIDs()
-    {
-        Enrollment enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        enrollmentService.addEnrollment( enrollment );
-
-        Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        event.setStatus( EventStatus.COMPLETED );
-        ImportSummary importSummary1 = eventService.addEvent( event );
-        assertEquals( ImportStatus.SUCCESS, importSummary1.getStatus() );
-        enrollment = enrollmentService.getEnrollments( trackedEntityInstanceMaleA ).getEnrollments().get( 0 );
-        enrollmentService.completeEnrollment( enrollment );
-
-        enrollment = createEnrollment( programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        enrollmentService.addEnrollment( enrollment );
-
-        event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance() );
-        event.setStatus( EventStatus.COMPLETED );
-        ImportSummary importSummary2 = eventService.addEvent( event );
-        assertEquals( ImportStatus.SUCCESS, importSummary2.getStatus() );
-        enrollment = enrollmentService.getEnrollments( trackedEntityInstanceMaleA ).getEnrollments().get( 0 );
-        enrollmentService.completeEnrollment( enrollment );
-
-        assertNotEquals( importSummary1.getReference(), importSummary2.getReference() );
-    }
-
     private Enrollment createEnrollment( String program, String person )
     {
         Enrollment enrollment = new Enrollment();

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java	2015-07-07 06:11:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EnrollmentController.java	2015-07-08 03:04:42 +0000
@@ -124,7 +124,7 @@
             programEndDate, trackedEntity, trackedEntityInstance, followUp, page, pageSize, totalPages, skipPaging );
 
         List<Enrollment> enrollments = new ArrayList<>( enrollmentService.getEnrollments(
-            programInstanceService.getProgramInstances( params ) ).getEnrollments() );
+            programInstanceService.getProgramInstances( params ) ) );
 
         RootNode rootNode = NodeUtils.createMetadata();
         rootNode.addChild( fieldFilterService.filter( Enrollment.class, enrollments, fields ) );