← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11415: add test for dhis-service-mobile

 

------------------------------------------------------------
revno: 11415
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Wed 2013-07-17 16:52:18 +0700
message:
  add test for dhis-service-mobile
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.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-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-07-16 11:57:30 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java	2013-07-17 09:52:18 +0000
@@ -1,7 +1,16 @@
 package org.hisp.dhis.mobile.service;
 
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.api.mobile.ActivityReportingService;
+import org.hisp.dhis.api.mobile.NotAllowedException;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
+import org.hisp.dhis.api.mobile.model.PatientIdentifier;
+import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -12,8 +21,37 @@
     private ActivityReportingService activityReportingService;
 
     @Test
-    public void test()
-    {
-        //TODO
+    public void testSavePatient()
+    {
+        Patient patientA = this.createLWUITPatient( 'A' );
+        Patient patientB = this.createLWUITPatient( 'B' );
+        try
+        {
+            assertNotNull( activityReportingService.savePatient( patientA, 779 ) );
+            assertNotNull( activityReportingService.savePatient( patientB, 779 ) );
+        }
+        catch ( NotAllowedException e )
+        {
+            e.printStackTrace();
+        }
+
+    }
+
+
+    private Patient createLWUITPatient( char uniqueCharacter )
+    {
+        Patient patient = new Patient();
+        patient.setAge( 1 );
+        patient.setBirthDate( new Date() );
+        patient.setFirstName( "Firstname" + uniqueCharacter );
+        patient.setMiddleName( "Middlename" + uniqueCharacter );
+        patient.setLastName( "LastName" + uniqueCharacter );
+        patient.setGender( "male" );
+        patient.setOrganisationUnitName( "OrgUnitName" );
+        patient.setPhoneNumber( "095678943" );
+        patient.setRegistrationDate( new Date() );
+        patient.setIdentifiers( new ArrayList<PatientIdentifier>() );
+        patient.setPatientAttValues( new ArrayList<PatientAttribute>() );
+        return patient;
     }
 }