Exemplo n.º 1
0
 /** Try to view it as a nutritionist that isn't designated */
 @Test
 public void testNonDesignatedNutritionistBoundedTotals() {
   action = new ViewFoodEntryAction(factory, 9000000071L);
   try {
     action.getBoundedDiaryTotals("02/02/2014", "02/02/2014", 1);
     fail("Not his designated nutritionist");
   } catch (ITrustException e) {
     assertEquals("You do not have permission to view the Food Diary!", e.getMessage());
   } catch (FormValidationException d) {
     fail(d.getMessage());
   }
 }
 /**
  * testUpdateInformationOctothorpe
  *
  * @throws Exception
  */
 public void testUpdateInformationOctothorpe() throws Exception {
   EditOfficeVisitForm frm = new EditOfficeVisitForm();
   frm.setHcpID("9000000000");
   frm.setPatientID("1");
   frm.setVisitDate("05/02/2001");
   frm.setNotes("semicolon test #");
   try {
     action.updateInformation(frm, false);
   } catch (FormValidationException e) {
     fail(e.getMessage());
   }
 }
Exemplo n.º 3
0
 /** Test with evil factory */
 @Test
 public void testEvilFactoryGetBoundedDiaryTotals() {
   EvilDAOFactory evil = new EvilDAOFactory();
   action = new ViewFoodEntryAction(evil, 1);
   try {
     action.getBoundedDiaryTotals("", "", 1);
     fail("Working with evil factory");
   } catch (ITrustException d) {
     assertEquals("Error retrieving Food Diary", d.getMessage());
   } catch (FormValidationException e) {
     fail(e.getMessage());
   }
 }
Exemplo n.º 4
0
 /** Test bounded diary totals with bad dates */
 @Test
 public void testFoodDiaryBadDatesTotals() {
   action = new ViewFoodEntryAction(factory, 1);
   try {
     action.getBoundedDiaryTotals("", "", 1);
     fail("Bad dates");
   } catch (FormValidationException e) {
     assertEquals(
         "This form has not been validated correctly. "
             + "The following field are not properly "
             + "filled in: [Enter dates in MM/dd/yyyy]",
         e.getMessage());
   } catch (ITrustException d) {
     fail("Wanted bad dates");
   }
 }
Exemplo n.º 5
0
 /** Test start date after end date */
 @Test
 public void testStartAfterEndTotals() {
   action = new ViewFoodEntryAction(factory, 335);
   try {
     action.getBoundedDiaryTotals("12/12/2014", "12/10/2014", 335);
     fail("Start date after end date");
   } catch (ITrustException d) {
     fail("Why the error?");
   } catch (FormValidationException e) {
     assertEquals(
         "This form has not been validated correctly. "
             + "The following field are not properly filled in: "
             + "[Start date must be before end date!]",
         e.getMessage());
   }
 }
 public void testUpdateInformationNewOfficeVisit() throws Exception {
   action = new EditOfficeVisitAction(factory, 9000000001L, "1");
   assertEquals(true, action.isUnsaved());
   assertEquals(-1, action.getOvID());
   EditOfficeVisitForm frm = new EditOfficeVisitForm();
   frm.setHcpID("9000000001");
   frm.setPatientID("1");
   frm.setVisitDate("05/02/2001");
   frm.setNotes("That was a doctor's visit");
   try {
     action.updateInformation(frm);
   } catch (FormValidationException e) {
     fail(e.getMessage());
   }
   assertEquals(false, action.isUnsaved());
   assertFalse(-1 == action.getOvID());
 }
Exemplo n.º 7
0
  /**
   * Creates the patients and adds them to the DB
   *
   * @throws DBException
   * @throws AddPatientFileExceptionTest
   */
  private void createPatients() throws DBException, AddPatientFileException {
    for (int i = 0; i < CSVData.size(); i++) {
      PatientBean temp = new PatientBean();

      temp.setFirstName(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("firstName")]));
      temp.setLastName(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("lastName")]));
      temp.setEmail(
          CSVData.get(i)
              .get(requiredFieldsMapping[Arrays.asList(requiredFields).indexOf("email")]));

      try {
        temp.setStreetAddress1(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("streetAddress1")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setStreetAddress2(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("streetAddress2")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCity(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("city")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setState(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("state")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setZip(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("zip")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setPhone(
            CSVData.get(i).get(validFieldsMapping[Arrays.asList(validFields).indexOf("phone")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setMotherMID(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("motherMID")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setFatherMID(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("fatherMID")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCreditCardType(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("creditCardType")]));
      } catch (NullPointerException e) {
      }
      try {
        temp.setCreditCardNumber(
            CSVData.get(i)
                .get(validFieldsMapping[Arrays.asList(validFields).indexOf("creditCardNumber")]));
      } catch (NullPointerException e) {
      }

      try {
        new AddPatientValidator().validate(temp);
        new PatientValidator().validate(temp);
        if (patientDAO != null) {
          long newMID = patientDAO.addEmptyPatient();
          temp.setMID(newMID);
          String pwd = authDAO.addUser(newMID, Role.PATIENT, RandomPassword.getRandomPassword());
          temp.setPassword(pwd);
          patientDAO.editPatient(temp, loggedInMID);
        }
        patients.add(temp);
      } catch (FormValidationException e) {
        for (int j = 0; j < e.getErrorList().size(); j++) {
          System.out.println(e.getErrorList().get(j));
        }
        errors.addIfNotNull(
            "Input validation failed for patient \""
                + temp.getFirstName()
                + " "
                + temp.getLastName()
                + "\"!");
      }
    }
  }