← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12885: Implement unit tests on patient attribute service methods.

 

------------------------------------------------------------
revno: 12885
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-05 16:31:47 +0700
message:
   Implement unit tests on patient attribute service methods.
added:
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeServiceTest.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeStoreTest.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.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/patient/PatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java	2013-11-05 09:31:47 +0000
@@ -121,9 +121,9 @@
     /**
      * Get patient attributes by groupBy option
      * 
-     * @param groupBy True/False value
+     * @return PatientAttribute with groupby as true
      */
-    PatientAttribute getPatientAttributeByGroupBy( boolean groupBy );
+    PatientAttribute getPatientAttributeByGroupBy();
 
     /**
      * Get patient attributes without groups

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java	2013-11-05 09:31:47 +0000
@@ -75,11 +75,9 @@
     /**
      * Get patient attributes by groupBy option
      * 
-     * @param groupBy True/False value
-     * 
-     * @return List of patient attributes
+     * @return PatientAttribute with groupby as true
      */
-    PatientAttribute getByGroupBy( boolean groupBy );
+    PatientAttribute getByGroupBy();
 
     /**
      * Get patient attributes which are displayed in visit schedule

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-11-01 09:56:52 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-11-05 09:31:47 +0000
@@ -330,7 +330,7 @@
             }
         }
 
-        this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( true ) );
+        this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( ) );
 
         if ( items.isEmpty() )
         {
@@ -358,7 +358,7 @@
             }
         }
 
-        this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( true ) );
+        this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy(  ) );
 
         if ( items.isEmpty() )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java	2013-11-05 09:31:47 +0000
@@ -100,9 +100,9 @@
         return i18n( i18nService, patientAttributeStore.getByName( name ) );
     }
 
-    public PatientAttribute getPatientAttributeByGroupBy( boolean groupBy )
+    public PatientAttribute getPatientAttributeByGroupBy( )
     {
-        return i18n( i18nService, patientAttributeStore.getByGroupBy( groupBy ) );
+        return i18n( i18nService, patientAttributeStore.getByGroupBy( ) );
     }
 
     public Collection<PatientAttribute> getOptionalPatientAttributesWithoutGroup()

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java	2013-09-27 10:43:38 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java	2013-11-05 09:31:47 +0000
@@ -65,9 +65,9 @@
             .add( Restrictions.eq( "mandatory", false ) ).list();
     }
 
-    public PatientAttribute getByGroupBy( boolean groupBy )
+    public PatientAttribute getByGroupBy( )
     {
-        return (PatientAttribute) getCriteria( Restrictions.eq( "groupBy", groupBy ) ).uniqueResult();
+        return (PatientAttribute) getCriteria( Restrictions.eq( "groupBy", true ) ).uniqueResult();
     }
 
     @SuppressWarnings("unchecked")

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeServiceTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeServiceTest.java	2013-11-05 09:31:47 +0000
@@ -0,0 +1,160 @@
+/*
+ * 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.patient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $ PatientAttributeServiceTest.java Nov 5, 2013 3:42:42 PM $
+ */
+public class PatientAttributeServiceTest
+    extends DhisSpringTest
+{
+    @Autowired
+    private PatientAttributeStore attributeStore;
+
+    @Autowired
+    private PatientAttributeGroupService attributeGroupService;
+
+    private PatientAttribute attributeA;
+
+    private PatientAttribute attributeB;
+
+    private PatientAttribute attributeC;
+
+    private PatientAttributeGroup attributeGroup;
+
+    @Override
+    public void setUpTest()
+    {
+        attributeA = createPatientAttribute( 'A' );
+        attributeB = createPatientAttribute( 'B' );
+        attributeC = createPatientAttribute( 'C', PatientAttribute.TYPE_INT );
+
+        List<PatientAttribute> attributesA = new ArrayList<PatientAttribute>();
+        attributesA.add( attributeA );
+        attributesA.add( attributeB );
+        attributeGroup = createPatientAttributeGroup( 'A', attributesA );
+    }
+
+    @Test
+    public void testGetPatientAttributesByValueType()
+    {
+        attributeStore.save( attributeA );
+        attributeStore.save( attributeB );
+        attributeStore.save( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeStore.getByValueType( PatientAttribute.TYPE_STRING );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+
+        attributes = attributeStore.getByValueType( PatientAttribute.TYPE_INT );
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+
+    }
+
+    @Test
+    public void testGetPatientAttributesByMandatory()
+    {
+        attributeA.setMandatory( true );
+        attributeB.setMandatory( true );
+        attributeC.setMandatory( false );
+
+        attributeStore.save( attributeA );
+        attributeStore.save( attributeB );
+        attributeStore.save( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeStore.getByMandatory( true );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+    }
+
+    @Test
+    public void testGetPatientAttributeByGroupBy()
+    {
+        attributeA.setGroupBy( true );
+        attributeB.setGroupBy( false );
+        attributeC.setGroupBy( false );
+
+        attributeStore.save( attributeA );
+        attributeStore.save( attributeB );
+        attributeStore.save( attributeC );
+
+        assertEquals( attributeA, attributeStore.getByGroupBy() );
+    }
+
+    @Test
+    public void testGetPatientAttributesWithoutGroup()
+    {
+        attributeStore.save( attributeA );
+        attributeStore.save( attributeB );
+        attributeStore.save( attributeC );
+
+        attributeGroupService.savePatientAttributeGroup( attributeGroup );
+
+        Collection<PatientAttribute> attributes = attributeStore.getOptionalPatientAttributesWithoutGroup();
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+    }
+
+    @Test
+    public void testGetPatientAttributesByDisplayOnVisitSchedule()
+    {
+        attributeA.setDisplayOnVisitSchedule( true );
+        attributeB.setDisplayOnVisitSchedule( true );
+        attributeC.setDisplayOnVisitSchedule( false );
+
+        attributeStore.save( attributeA );
+        attributeStore.save( attributeB );
+        attributeStore.save( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeStore.getByDisplayOnVisitSchedule( true );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+
+        attributes = attributeStore.getByDisplayOnVisitSchedule( false );
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+    }
+
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeStoreTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeStoreTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientAttributeStoreTest.java	2013-11-05 09:31:47 +0000
@@ -0,0 +1,243 @@
+/*
+ * 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.patient;
+
+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.Collection;
+import java.util.List;
+
+import org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $ PatientAttributeStoreTest.java Nov 5, 2013 04:21:02 PM $
+ */
+public class PatientAttributeStoreTest
+    extends DhisSpringTest
+{
+    @Autowired
+    private PatientAttributeService attributeService;
+
+    @Autowired
+    private PatientAttributeGroupService attributeGroupService;
+
+    private PatientAttribute attributeA;
+
+    private PatientAttribute attributeB;
+
+    private PatientAttribute attributeC;
+
+    private PatientAttributeGroup attributeGroup;
+
+    @Override
+    public void setUpTest()
+    {
+        attributeA = createPatientAttribute( 'A' );
+        attributeB = createPatientAttribute( 'B' );
+        attributeC = createPatientAttribute( 'C', PatientAttribute.TYPE_INT );
+
+        List<PatientAttribute> attributesA = new ArrayList<PatientAttribute>();
+        attributesA.add( attributeA );
+        attributesA.add( attributeB );
+        attributeGroup = createPatientAttributeGroup( 'A', attributesA );
+    }
+
+    @Test
+    public void testSavePatientAttribute()
+    {
+        int idA = attributeService.savePatientAttribute( attributeA );
+        int idB = attributeService.savePatientAttribute( attributeB );
+
+        assertNotNull( attributeService.getPatientAttribute( idA ) );
+        assertNotNull( attributeService.getPatientAttribute( idB ) );
+    }
+
+    @Test
+    public void testDeletePatientAttribute()
+    {
+        int idA = attributeService.savePatientAttribute( attributeA );
+        int idB = attributeService.savePatientAttribute( attributeB );
+
+        assertNotNull( attributeService.getPatientAttribute( idA ) );
+        assertNotNull( attributeService.getPatientAttribute( idB ) );
+
+        attributeService.deletePatientAttribute( attributeA );
+
+        assertNull( attributeService.getPatientAttribute( idA ) );
+        assertNotNull( attributeService.getPatientAttribute( idB ) );
+
+        attributeService.deletePatientAttribute( attributeB );
+
+        assertNull( attributeService.getPatientAttribute( idA ) );
+        assertNull( attributeService.getPatientAttribute( idB ) );
+    }
+
+    @Test
+    public void testUpdatePatientAttribute()
+    {
+        int idA = attributeService.savePatientAttribute( attributeA );
+
+        assertNotNull( attributeService.getPatientAttribute( idA ) );
+
+        attributeA.setName( "B" );
+        attributeService.updatePatientAttribute( attributeA );
+
+        assertEquals( "B", attributeService.getPatientAttribute( idA ).getName() );
+    }
+
+    @Test
+    public void testGetPatientAttributeById()
+    {
+        int idA = attributeService.savePatientAttribute( attributeA );
+        int idB = attributeService.savePatientAttribute( attributeB );
+
+        assertEquals( attributeA, attributeService.getPatientAttribute( idA ) );
+        assertEquals( attributeB, attributeService.getPatientAttribute( idB ) );
+    }
+
+    @Test
+    public void testGetPatientAttributeByUid()
+    {
+        attributeA.setUid( "uid" );
+        attributeService.savePatientAttribute( attributeA );
+
+        assertEquals( attributeA, attributeService.getPatientAttribute( "uid" ) );
+    }
+
+    @Test
+    public void testGetPatientAttributeByName()
+    {
+        int idA = attributeService.savePatientAttribute( attributeA );
+
+        assertNotNull( attributeService.getPatientAttribute( idA ) );
+        assertEquals( attributeA.getName(), attributeService.getPatientAttributeByName( "AttributeA" ).getName() );
+    }
+
+    @Test
+    public void testGetAllPatientAttributes()
+    {
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+
+        assertTrue( equals( attributeService.getAllPatientAttributes(), attributeA, attributeB ) );
+    }
+
+    @Test
+    public void testGetPatientAttributesByValueType()
+    {
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+        attributeService.savePatientAttribute( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeService
+            .getPatientAttributesByValueType( PatientAttribute.TYPE_STRING );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+
+        attributes = attributeService.getPatientAttributesByValueType( PatientAttribute.TYPE_INT );
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+
+    }
+
+    @Test
+    public void testGetPatientAttributesByMandatory()
+    {
+        attributeA.setMandatory( true );
+        attributeB.setMandatory( true );
+        attributeC.setMandatory( false );
+
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+        attributeService.savePatientAttribute( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeService.getPatientAttributesByMandatory( true );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+    }
+
+    @Test
+    public void testGetPatientAttributeByGroupBy()
+    {
+        attributeA.setGroupBy( true );
+        attributeB.setGroupBy( false );
+        attributeC.setGroupBy( false );
+
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+        attributeService.savePatientAttribute( attributeC );
+
+        assertEquals( attributeA, attributeService.getPatientAttributeByGroupBy() );
+    }
+
+    @Test
+    public void testGetPatientAttributesWithoutGroup()
+    {
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+        attributeService.savePatientAttribute( attributeC );
+
+        attributeGroupService.savePatientAttributeGroup( attributeGroup );
+
+        Collection<PatientAttribute> attributes = attributeService.getOptionalPatientAttributesWithoutGroup();
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+    }
+
+    @Test
+    public void testGetPatientAttributesByDisplayOnVisitSchedule()
+    {
+        attributeA.setDisplayOnVisitSchedule( true );
+        attributeB.setDisplayOnVisitSchedule( true );
+        attributeC.setDisplayOnVisitSchedule( false );
+
+        attributeService.savePatientAttribute( attributeA );
+        attributeService.savePatientAttribute( attributeB );
+        attributeService.savePatientAttribute( attributeC );
+
+        Collection<PatientAttribute> attributes = attributeService.getPatientAttributesByDisplayOnVisitSchedule( true );
+        assertEquals( 2, attributes.size() );
+        assertTrue( attributes.contains( attributeA ) );
+        assertTrue( attributes.contains( attributeB ) );
+
+        attributes = attributeService.getPatientAttributesByDisplayOnVisitSchedule( false );
+        assertEquals( 1, attributes.size() );
+        assertTrue( attributes.contains( attributeC ) );
+    }
+
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-11-05 08:49:50 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2013-11-05 09:31:47 +0000
@@ -95,6 +95,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttribute;
 import org.hisp.dhis.patient.PatientAttributeGroup;
+import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patient.PatientIdentifier;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
@@ -1076,6 +1077,21 @@
 
         return patientAttribute;
     }
+    
+    /**
+     * @param uniqueCharacter A unique character to identify the object.
+     * @return PatientAttribute
+     */
+    public static PatientAttribute createPatientAttribute( char uniqueChar, String type )
+    {
+        PatientAttribute patientAttribute = new PatientAttribute();
+
+        patientAttribute.setName( "Attribute" + uniqueChar );
+        patientAttribute.setDescription( "Attribute" + uniqueChar );
+        patientAttribute.setValueType( type );
+
+        return patientAttribute;
+    }
 
     /**
      * @param uniqueCharacter A unique character to identify the object.