Skip to content

Commit

Permalink
Phone number validation for CWC Reg form
Browse files Browse the repository at this point in the history
  • Loading branch information
subhrajitroy committed Jul 1, 2011
1 parent 7b8f676 commit 8e25eaf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public void registerCWCChild(@WebParam(name = "staffId") Integer staffId,
throws ValidationException {

ValidationErrors errors = new ValidationErrors();

validatePhoneNumber(phoneNumber,"PhoneNumber",errors);
User staff = validateStaffId(staffId, errors, "StaffID");
Facility facility = validateFacility(facilityId, errors, "FacilityID");
org.openmrs.Patient patient = validateMotechId(motechId, errors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

public class RegistrarServiceTest{

Expand Down Expand Up @@ -1477,7 +1478,7 @@ public void registerCWCChild() throws ValidationException {
Integer staffId = 1, facilityId = 2, motechId = 3;
String language = "Language", regNumber = "RegNumber";
Boolean enroll = true, consent = true;
String phone = "15555555";
String phone = "0123456789";
Date date = new Date();
ContactNumberType phoneType = ContactNumberType.PERSONAL;
MediaType format = MediaType.VOICE;
Expand Down Expand Up @@ -1517,7 +1518,7 @@ public void registerCWCChildInvalidIds() throws ValidationException {
Integer staffId = 1, facilityId = 2, motechId = 3;
String language = "Language", regNumber = "RegNumber";
Boolean enroll = true, consent = true;
String phone = "15555555";
String phone = "123456789";
Date date = new Date();
ContactNumberType phoneType = ContactNumberType.PERSONAL;
MediaType format = MediaType.VOICE;
Expand Down Expand Up @@ -1550,12 +1551,16 @@ public void registerCWCChildInvalidIds() throws ValidationException {
.getFaultInfo());
List<String> errors = e.getFaultInfo().getErrors();
assertNotNull("Validation Errors is Null", errors);
assertEquals(3, errors.size());
String staffError = errors.get(0);
assertEquals(5, errors.size());
String phoneNumberDoesNotStartWithZeroError = errors.get(0);
assertEquals("PhoneNumber=number should start with zero", phoneNumberDoesNotStartWithZeroError);
String phoneNumberLengthError = errors.get(1);
assertEquals("PhoneNumber=number should be 10 digits long", phoneNumberLengthError);
String staffError = errors.get(2);
assertEquals("StaffID=not found", staffError);
String facilityError = errors.get(1);
String facilityError = errors.get(3);
assertEquals("FacilityID=not found", facilityError);
String patientError = errors.get(2);
String patientError = errors.get(4);
assertEquals("MotechID=not found", patientError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ motechmodule.ws.notfound={0}=not found
motechmodule.ws.inuse={0}=in use
motechmodule.ws.invalid={0}=invalid
motechmodule.ws.missing={0}=missing
motechmodule.ws.duplicate.opdVisitEntry=Duplicate visit entry
motechmodule.ws.duplicate.opdVisitEntry=Duplicate visit entry
motechmodule.ws.numberShouldStartsWithZero={0}=number should start with zero
motechmodule.ws.numberShouldBeTenDigits={0}=number should be 10 digits long
6 changes: 3 additions & 3 deletions motech-server-omod/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@

<!-- Enable this to view the sql statements that hibernate generates-->
<logger name="org.hibernate.SQL">
<level value="INFO"/>
<level value="ERROR"/>
</logger>

<logger name="org.hibernate.tool.hbm2ddl.SchemaExport">
<level value="FATAL"/>
<appender-ref ref="CONSOLE"/>
<!--<appender-ref ref="CONSOLE"/>-->
</logger>

<root>
<level value="ERROR"/>
<appender-ref ref="CONSOLE"/>
<!--<appender-ref ref="CONSOLE"/>-->
</root>

</log4j:configuration>

0 comments on commit 8e25eaf

Please sign in to comment.