@Test
  public void test() {
    Contact Pete = new ContactImpl("Pete Jones", "Marketing manager");
    Contact Tom = new ContactImpl("Tom Hanks", "Actor");
    Contact Mary = new ContactImpl("Mary", "Director");

    Calendar focDate; // id = 3
    PastMeeting foc;
    Set<Contact> focContacts = new HashSet<Contact>();
    focContacts.add(Tom);
    focContacts.add(new ContactImpl("Mark", "examiner"));
    focDate = Calendar.getInstance();
    focDate.set(2014, 4, 22, 11, 30);
    foc = new PastMeetingImpl(focContacts, focDate, "FoC exam");

    String output = foc.getNotes();
    String expected = "FoC exam.";
    assertEquals(output, expected);
  }
  public List<PastMeeting> getPastMeetingList(Contact contact) {
    /** @throws IllegalArgumentException if the contact does not exist */
    if (!contactSet.contains(contact)) {
      throw new IllegalArgumentException(
          "Contact \"" + contact.getName() + "\" does not exist! Please try again");
    } else {
      /**
       * @param list a list to store any matching PastMeetings; will be returned empty if no matches
       */
      List<PastMeeting> list = new ArrayList<PastMeeting>();

      for (PastMeeting pm : pastMeetings) {
        if (pm.getContacts().contains(contact)) {
          list.add(pm);
        }
      }
      /**
       * @see MeetingImpl#MeetingComparator - calls custom comparator in MeetingImpl to
       *     chronologically sort
       */
      Collections.sort(list, MeetingImpl.MeetingComparator);
      return list;
    }
  }
  /**
   * This method is used EITHER: when a future meeting happens, and is then converted to a past
   * meeting (with notes), OR: to add notes to a past meeting at a date after its creation.
   */
  public void addMeetingNotes(int id, String text) {
    Meeting meeting = getMeeting(id); // find meeting by id - will be null if doesn't exist

    if (meeting == null) {
      throw new IllegalArgumentException("Specified meeting does not exist!");
    } else if (text == null) {
      throw new NullPointerException("Cannot add null string of notes");
    } else if (((MeetingImpl) meeting).inFuture() == true) {
      throw new IllegalStateException(
          "Meeting set for date in the future - not eligible for conversion!");
    } else if (meeting instanceof FutureMeeting) // we know it's a future meeting needing conversion
    {
      /**
       * @param convertedMeeting name to indicate the original FutureMeeting type is now a
       *     PastMeeting the 0 id field (an impossible id) is a flag to let us know whether or not
       *     it goes through the for loop if statement
       */
      Set<Contact> set =
          new HashSet<
              Contact>(); // to use for our empty convertedMeeting, to avoid a NullPointerException
      PastMeeting convertedMeeting = new PastMeetingImpl(0, set, null);
      for (FutureMeeting fm : futureMeetings) {
        if (fm.getId() == id) {
          /**
           * convertedMeeting is now re-constructed with proper values, which shows that we have an
           * id match
           */
          convertedMeeting = new PastMeetingImpl(fm.getId(), fm.getContacts(), fm.getDate());
        }
      }
      if (convertedMeeting.getId()
          == 0) // i.e. we haven't had an id match (got into the for loop if statement)
      {
        throw new IllegalArgumentException("Couldn't find meeting in list of meetings!");
      } else // we know that convertedMeeting has been through the for loop if statement, so can add
      // it to our sets/lists
      {
        meetingSet.remove(meeting); // remove the old FutureMeeting from main meeting set
        futureMeetings.remove(meeting); // remove the old FutureMeeting from list of future meetings
        pastMeetings.add(convertedMeeting); // add the new PastMeeting to list of past meetings
        meetingSet.add(convertedMeeting); // add the new PastMeeting to main meeting set
        /**
         * here we call this method again to add the notes to our new PastMeeting object, knowing it
         * will drop through to the else if below (as it is now an instanceof PastMeeting)
         */
        addMeetingNotes(convertedMeeting.getId(), text);
      }
    } else if (meeting
        instanceof
        PastMeeting) // this will catch cases where we just want to add notes to a PastMeeting
    // (including the convertedMeeting)
    {
      for (PastMeeting pm : pastMeetings) {
        if (pm.getId() == id) {
          meetingSet.remove(
              meeting); // remove the old PastMeeting (without new note) from list of past meetings
          pastMeetings.remove(
              pm); // add the new PastMeeting (without new note) from list of past meetings
          /**
           * @see PastMeetingImpl#addNotes(String) use this method to actually add notes to avoid
           *     unnecessary code duplication
           */
          ((PastMeetingImpl) pm).addNotes(text);
          pastMeetings.add(pm); // add the new PastMeeting (with new note) to list of past meetings
          meetingSet.add(pm); // add the new PastMeeting (with new note) to main meeting set
        } else {
          throw new IllegalArgumentException("Couldn't find meeting in list of meetings!");
        }
      }
    }
  }
 @Test
 public void testNewPastMeeting() {
   PastMeeting pastMeeting = new PastMeetingImpl(id, calendar, contacts, notes);
   assertEquals(pastMeeting.getNotes(), notes);
 }