예제 #1
0
 /** Try to view it as a nutritionist that isn't designated */
 @Test
 public void testNonDesignatedNutritionistTotals() {
   action = new ViewFoodEntryAction(factory, 9000000071L);
   try {
     action.getDiaryTotals(1);
     fail("Not his designated nutritionist");
   } catch (ITrustException e) {
     assertEquals("You do not have permission to view the Food Diary!", e.getMessage());
   }
 }
예제 #2
0
 /** Test with evil factory */
 @Test
 public void testEvilFactoryGetDiaryTotals() {
   EvilDAOFactory evil = new EvilDAOFactory();
   action = new ViewFoodEntryAction(evil, 1);
   try {
     action.getDiaryTotals(1);
     fail("Working with evil factory");
   } catch (ITrustException d) {
     assertEquals("Error retrieving Food Diary", d.getMessage());
   }
 }
예제 #3
0
  /**
   * Log in as the HCP Spencer Reid who does have the specialty of nutritionist, so she should be
   * able to view food entries. View the Food Entries for Patient Jennifer Jareau who has some food
   * entries already in her diary.
   */
  @Test
  public void testViewingFoodDiaryWithEntriesAsNutritionist() {
    action = new ViewFoodEntryAction(factory, 9000000071L);
    try {
      List<FoodEntryBean> foodDiary = action.getDiary(334);
      assertEquals(2, foodDiary.size());
      FoodEntryBean entry1 = foodDiary.get(0);
      FoodEntryBean entry2 = foodDiary.get(1);
      // now that we know we have 2 of them, make sure they are the
      // right ones
      assertEquals("09/30/2012", entry1.getDateEatenStr().toString());
      assertEquals("Breakfast", entry1.getMealType().name());
      assertEquals("Hot dog", entry1.getFood());
      assertEquals(4.0, entry1.getServings(), .001);
      assertEquals(80.0, entry1.getCalories(), .001);
      assertEquals(5.0, entry1.getFatGrams(), .001);
      assertEquals(480.0, entry1.getMilligramsSodium(), .001);
      assertEquals(2.0, entry1.getCarbGrams(), .001);
      assertEquals(0.0, entry1.getFiberGrams(), .001);
      assertEquals(0.0, entry1.getSugarGrams(), .001);
      assertEquals(5.0, entry1.getProteinGrams(), .001);
      assertEquals(334, entry1.getPatientID());

      assertEquals("09/30/2012", entry2.getDateEatenStr().toString());
      assertEquals("Lunch", entry2.getMealType().name());
      assertEquals("Mango Passionfruit Juice", entry2.getFood());
      assertEquals(1.2, entry2.getServings(), .001);
      assertEquals(130.0, entry2.getCalories(), .001);
      assertEquals(0.0, entry2.getFatGrams(), .001);
      assertEquals(25.0, entry2.getMilligramsSodium(), .001);
      assertEquals(32.0, entry2.getCarbGrams(), .001);
      assertEquals(0.0, entry2.getFiberGrams(), .001);
      assertEquals(29.0, entry2.getSugarGrams(), .001);
      assertEquals(1.0, entry2.getProteinGrams(), .001);
      assertEquals(334, entry1.getPatientID());

      // now check the totals
      List<FoodEntryBean> totals = action.getDiaryTotals(334);
      assertEquals(1, totals.size());
      FoodEntryBean total = totals.get(0);
      assertEquals(476.0, total.getCalories(), .001);
      assertEquals(20.0, total.getFatGrams(), .001);
      assertEquals(1950.0, total.getMilligramsSodium(), .001);
      assertEquals(46.4, total.getCarbGrams(), .001);
      assertEquals(0.0, total.getFiberGrams(), .001);
      assertEquals(34.8, total.getSugarGrams(), .001);
      assertEquals(21.2, total.getProteinGrams(), .001);

    } catch (ITrustException e) {
      fail(e.getMessage());
    }
  }