dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24783
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12202: re-enabled enrollment tests, working correctly now
------------------------------------------------------------
revno: 12202
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-23 10:43:52 +0200
message:
re-enabled enrollment tests, working correctly now
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.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/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-09-20 15:12:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2013-09-23 08:43:52 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hamcrest.CoreMatchers;
import org.hisp.dhis.DhisTest;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
@@ -44,7 +45,6 @@
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramStage;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +52,7 @@
import java.util.List;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
/**
@@ -108,9 +109,8 @@
manager.save( programStage );
programA = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnitA );
- programA.setUseBirthDateAsEnrollmentDate( true );
- programA.setUseBirthDateAsIncidentDate( true );
- programA.setIgnoreOverdueEvents( false );
+ programA.setType( Program.SINGLE_EVENT_WITH_REGISTRATION );
+ manager.save( programA );
programA.getProgramStages().add( programStage );
programStage.setProgram( programA );
@@ -129,7 +129,6 @@
}
@Test
- @Ignore
public void testGetEnrollments()
{
programInstanceService.enrollPatient( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
@@ -139,7 +138,6 @@
}
@Test
- @Ignore
public void testGetEnrollmentsByPatient()
{
programInstanceService.enrollPatient( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
@@ -150,7 +148,6 @@
}
@Test
- @Ignore
public void testGetEnrollmentsByPerson()
{
programInstanceService.enrollPatient( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
@@ -164,10 +161,8 @@
}
@Test
- @Ignore
public void testGetEnrollmentsByStatus()
{
-
ProgramInstance piMale = programInstanceService.enrollPatient( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
ProgramInstance piFemale = programInstanceService.enrollPatient( femaleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
@@ -189,7 +184,6 @@
}
@Test
- @Ignore
public void testSaveEnrollment()
{
Enrollment enrollment = new Enrollment();
@@ -205,4 +199,18 @@
assertEquals( maleA.getUid(), enrollments.get( 0 ).getPerson() );
assertEquals( programA.getUid(), enrollments.get( 0 ).getProgram() );
}
+
+ @Test
+ public void testMultipleEnrollmentsShouldFail()
+ {
+ Enrollment enrollment = new Enrollment();
+ enrollment.setPerson( maleA.getUid() );
+ enrollment.setProgram( programA.getUid() );
+
+ ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment );
+ assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
+ importSummary = enrollmentService.saveEnrollment( enrollment );
+ assertEquals( ImportStatus.ERROR, importSummary.getStatus() );
+ assertThat( importSummary.getDescription(), CoreMatchers.containsString( "already have an active enrollment in program" ) );
+ }
}