Exemplo n.º 1
0
  @Test
  public void testAutoFill() throws Exception {
    // Does not throw error if patient is null
    new Appointment(entityManager).autoFill();

    Patient patient = new Patient(entityManager);
    Appointment app = new Appointment(entityManager).setPatient(patient).autoFill();
    assertNull(app.getNurseId());
    assertNull(app.getStart());
    assertNull(app.getEnd());

    Appointment last =
        new Appointment(entityManager)
            .setNurseId(42)
            .setStart(DateTime.parse("2014-12-23T07:43:00"))
            .setEnd(DateTime.parse("2014-12-23T08:30:00"));
    patient.addAppointment(last);
    app.autoFill();
    assertEquals(42, app.getNurseId().intValue());
    assertEquals("" + last.getStartTime(), "" + app.getStartTime());
    assertEquals("" + last.getEndTime(), "" + app.getEndTime());

    app = new Appointment(entityManager).setPatient(patient).setStart(DateTime.parse("2014-12-29"));
    app.autoFill();
    assertEquals(42, app.getNurseId().intValue());
    assertEquals(12, app.getStart().getMonthOfYear());
    assertEquals(29, app.getStart().getDayOfMonth());
    assertEquals(2014, app.getStart().getYear());
    assertEquals("" + last.getStartTime(), "" + app.getStartTime());
    assertEquals("" + last.getEndTime(), "" + app.getEndTime());
  }
Exemplo n.º 2
0
  @Test
  public void testDateTimeMethods() throws ParseException, Exception {
    Appointment app = new Appointment(null);
    assertNull(app.getStart());
    assertNull(app.getEnd());
    app.setStartDate(FormatText.USER_DATE.parse("02/18/2013"));
    assertEquals(2, app.getStart().getMonthOfYear());
    assertEquals(18, app.getStart().getDayOfMonth());
    assertEquals(2013, app.getStart().getYear());
    assertEquals(0, app.getStart().getMillisOfDay());
    app.setStartTime(new Time(FormatText.TIME.parse("08:48:48").getTime()));
    assertEquals(2, app.getStart().getMonthOfYear());
    assertEquals(18, app.getStart().getDayOfMonth());
    assertEquals(2013, app.getStart().getYear());
    assertEquals(8, app.getStart().getHourOfDay());
    assertEquals(48, app.getStart().getMinuteOfHour());
    assertEquals(48, app.getStart().getSecondOfMinute());

    app.setPropertyValue("END_TIME", "10:48:48");
    assertEquals(2, app.getEnd().getMonthOfYear());
    assertEquals(18, app.getEnd().getDayOfMonth());
    assertEquals(2013, app.getEnd().getYear());
    assertEquals(10, app.getEnd().getHourOfDay());
    assertEquals(48, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    // End time set before start time. End date +1.
    app.setPropertyValue("END_TIME", "07:12");
    assertEquals(2, app.getEnd().getMonthOfYear());
    assertEquals(19, app.getEnd().getDayOfMonth());
    assertEquals(2013, app.getEnd().getYear());
    assertEquals(7, app.getEnd().getHourOfDay());
    assertEquals(12, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    // End time adjusted to after start time. End date -1.
    app.setPropertyValue("END_TIME", "12:12");
    assertEquals(2, app.getEnd().getMonthOfYear());
    assertEquals(18, app.getEnd().getDayOfMonth());
    assertEquals(2013, app.getEnd().getYear());
    assertEquals(12, app.getEnd().getHourOfDay());
    assertEquals(12, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    // Start time jumps past end time. End date +1.
    app.setPropertyValue("START_TIME", "13:13");
    assertEquals(2, app.getEnd().getMonthOfYear());
    assertEquals(19, app.getEnd().getDayOfMonth());
    assertEquals(2013, app.getEnd().getYear());
    assertEquals(12, app.getEnd().getHourOfDay());
    assertEquals(12, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    // End time set while start still null.
    app = new Appointment(null);
    assertNull(app.getStart());
    assertNull(app.getEnd());
    app.setPropertyValue("END_TIME", "12:12");
    assertEquals(1, app.getEnd().getMonthOfYear());
    assertEquals(1, app.getEnd().getDayOfMonth());
    assertEquals(1970, app.getEnd().getYear());
    assertEquals(12, app.getEnd().getHourOfDay());
    assertEquals(12, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    // Start Date set. End should follow.
    app.setStartDate(FormatText.USER_DATE.parse("02/18/2013"));
    assertEquals(2, app.getEnd().getMonthOfYear());
    assertEquals(18, app.getEnd().getDayOfMonth());
    assertEquals(2013, app.getEnd().getYear());
    assertEquals(12, app.getEnd().getHourOfDay());
    assertEquals(12, app.getEnd().getMinuteOfHour());
    assertEquals(0, app.getEnd().getSecondOfMinute());

    app.setPropertyValue("TIME_IN", "10:52");
    assertEquals(10, app.getTimeIn().getHourOfDay());
    assertEquals(52, app.getTimeIn().getMinuteOfHour());
  }