public void testGetCurrentTime() throws ParseException {
   Calendar calendar = Calendar.getInstance();
   SimpleDateFormat sdf = new SimpleDateFormat("h:m a");
   calendar.setTime(sdf.parse("1:12 PM"));
   Time t = Time.getCurrentTime(calendar);
   assertEquals("Hour should be set by current time", 13, t.getHour());
   assertEquals("Minute should be set by current time", 12, t.getMinute());
 }
  public void testAMConstructor() {
    Time t = new Time("12:10 AM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Route should be set", "Route T", t.getRoute());
    assertEquals("TimeOfWeek should be set", Time.TimeOfWeek.Weekday, t.getTimeOfWeek());
    assertEquals("Hour should be set", 0, t.getHour());
    assertEquals("Minute should be set", 10, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());

    t = new Time("1:46 AM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 1, t.getHour());
    assertEquals("Minute should be set", 46, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());
  }
  public void testAltConstructor() {
    Time t = new Time(0, 0);
    assertEquals("Hour should be set", 0, t.getHour());
    assertEquals("Minute should be set", 0, t.getMinute());
    assertTrue("AM/PM should be set", t.isAM());

    t = new Time(12, 0);
    assertEquals("Hour should be set", 12, t.getHour());
    assertEquals("Minute should be set", 0, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());
  }
  public void testPMConstructor() {
    Time t = new Time("12:01 PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 12, t.getHour());
    assertEquals("Minute should be set", 1, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());

    t = new Time("6:21 PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Hour should be set", 18, t.getHour());
    assertEquals("Minute should be set", 21, t.getMinute());
    assertFalse("AM/PM should be set", t.isAM());
  }
 public void testGetTimeOfWeekAsString() {
   Time t1 = new Time("12:01 AM", Time.TimeOfWeek.Weekday, "Route T");
   Time t2 = new Time("1:00 AM", Time.TimeOfWeek.Friday, "Route T");
   Time t3 = new Time("1:00 PM", Time.TimeOfWeek.Weekend, "Route T");
   assertEquals("Should return the time of week", "Weekday", t1.getTimeOfWeekAsString());
   assertEquals("Should return the time of week", "Friday", t2.getTimeOfWeekAsString());
   assertEquals("Should return the time of week", "Weekend", t3.getTimeOfWeekAsString());
 }
  public void testBadConstructorArgs() {
    Time t = new Time("12:01PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 12, t.getHour());
    assertEquals("Bad format: Minute should be set", 1, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("6:21       PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("06:21       PM", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time("6:21       pm   ", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());

    t = new Time(" 6 : 21       Pm   ", Time.TimeOfWeek.Weekday, "Route T");
    assertEquals("Bad format: Hour should be set", 18, t.getHour());
    assertEquals("Bad format: Minute should be set", 21, t.getMinute());
    assertFalse("Bad format: AM/PM should be set", t.isAM());
  }