diff --git a/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java b/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java index 89996e9208cd288e76bf7c55eebc38dd5e5f51d0..a79dac380ee030d55e6796d6235cda86e401685c 100644 --- a/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java +++ b/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java @@ -117,7 +117,7 @@ public class PreRegisterPatientTest extends iTrustSeleniumTest { assertTrue(driver.findElement(By.xpath("//body")).getText().contains("This form has not been validated correctly")); } - public void testInvalidEmail() { + public void testInvalidEmailFormException() { goToPreRegister(); driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname"); @@ -166,4 +166,29 @@ public class PreRegisterPatientTest extends iTrustSeleniumTest { assertEquals("iTrust - Pre-Registered Patient Home", driver.getTitle()); } + + public void testDuplicateEmailITrustException() { + // Add a user with name@email.com + goToPreRegister(); + driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname"); + driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname"); + driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com"); + driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123"); + driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123"); + driver.findElement(By.id("submit_preregister")).click(); + + goToPreRegister(); + + // Fill the form + driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("otherfname"); + driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("otherlname"); + driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com"); + driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123"); + driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123"); + + // Submit + driver.findElement(By.id("submit_preregister")).click(); + + assertTrue(driver.findElement(By.xpath("//body")).getText().contains("This email is already in use. Please use another email address.")); + } } \ No newline at end of file diff --git a/iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java b/iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java index fadb9cd4d0a80c9e95af00c775f6613527546834..fcbc49831043ad3e148873dc2695a04a62a00a31 100644 --- a/iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java +++ b/iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java @@ -108,7 +108,6 @@ public class AddPreRegisterPatientActionTest extends TestCase { p.setEmail("1234"); p.setPassword("password"); - // maybe not needed try { action.addPatient(p, defaultHRF); fail("Invalid email"); @@ -117,6 +116,40 @@ public class AddPreRegisterPatientActionTest extends TestCase { } } + /** + * Ensure that invalid heights and weights are not allowed + */ + public void testPreRegisterPatientInvalidHeightWeight() throws Exception { + PatientBean p = new PatientBean(); + p.setFirstName("Jiminy"); + p.setLastName("Cricket"); + p.setEmail("email@email.com"); + p.setPassword("password"); + + HealthRecordForm h = new HealthRecordForm(); + h = new HealthRecordForm(); + h.setIsSmoker("0"); + h.setHeight("abc"); + h.setWeight("100"); + + try { + action.addPatient(p, h); + fail("Expected exception"); + } catch (FormValidationException e) { + + } + + h.setHeight("100"); + h.setWeight("abc"); + + try { + action.addPatient(p, h); + fail("Expected exception"); + } catch (FormValidationException e) { + + } + } + /** * Ensure that duplicate emails are not allowed */