dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27018
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13395: add test for changed name on person (enrollment-test)
------------------------------------------------------------
revno: 13395
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-23 11:01:36 +0100
message:
add test for changed name on person (enrollment-test)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.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/person/AbstractPersonService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-12-19 08:23:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-12-23 10:01:36 +0000
@@ -28,17 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dxf2.importsummary.ImportConflict;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
@@ -63,6 +52,17 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -345,7 +345,7 @@
}
patient.setName( person.getName() );
-
+
updateSystemIdentifier( person );
removeRelationships( patient );
removeIdentifiers( patient );
=== modified 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 2013-12-16 04:27:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2013-12-23 10:01:36 +0000
@@ -28,16 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
import org.hamcrest.CoreMatchers;
-import org.hisp.dhis.DhisTest;
+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;
@@ -57,11 +49,19 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
public class EnrollmentServiceTest
- extends DhisTest
+ extends DhisSpringTest
{
@Autowired
private PersonService personService;
@@ -97,9 +97,9 @@
manager.save( organisationUnitB );
maleA = createPatient( 'A', organisationUnitA );
- maleB = createPatient( 'B', organisationUnitB );
+ maleB = createPatient( 'B', organisationUnitB );
femaleA = createPatient( 'C', organisationUnitA );
- femaleB = createPatient( 'D', organisationUnitB );
+ femaleB = createPatient( 'D', organisationUnitB );
manager.save( maleA );
manager.save( maleB );
@@ -124,12 +124,6 @@
enrollmentService.setFormat( mockFormat );
}
- @Override
- public boolean emptyDatabaseAfterTest()
- {
- return true;
- }
-
@Test
public void testGetEnrollments()
{
@@ -328,4 +322,27 @@
assertEquals( ImportStatus.ERROR, importSummary.getStatus() );
assertThat( importSummary.getDescription(), CoreMatchers.containsString( "already have an active enrollment in program" ) );
}
+
+ @Test
+ public void testUpdatePersonShouldKeepEnrollments()
+ {
+ Enrollment enrollment = new Enrollment();
+ enrollment.setPerson( maleA.getUid() );
+ enrollment.setProgram( programA.getUid() );
+ enrollment.setDateOfIncident( new Date() );
+ enrollment.setDateOfEnrollment( new Date() );
+
+ ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment );
+ assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
+
+ Person person = personService.getPerson( maleA );
+ person.setName( "Changed Name" );
+ personService.updatePerson( person );
+
+ List<Enrollment> enrollments = enrollmentService.getEnrollments( person ).getEnrollments();
+
+ assertEquals( 1, enrollments.size() );
+ assertEquals( maleA.getUid(), enrollments.get( 0 ).getPerson() );
+ assertEquals( programA.getUid(), enrollments.get( 0 ).getProgram() );
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisSpringTest.java 2013-12-23 10:01:36 +0000
@@ -41,7 +41,6 @@
/**
* @author Trygve Laugstøl
* @author Lars Helge Overland
- * @version $Id: DhisSpringTest.java 6335 2008-11-20 11:11:26Z larshelg $
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath*:/META-INF/dhis/beans.xml","classpath*:/META-INF/dhis/beans-test.xml"})