protected List<AppointmentSlotInfo> getAppointmentSlotsForPerson(
      List<MilestoneInfo> milestones, String personId, ContextInfo contextInfo)
      throws MissingParameterException, InvalidParameterException, OperationFailedException,
          PermissionDeniedException {
    List<AppointmentSlotInfo> allAppointmentSlots = new ArrayList<>();
    for (MilestoneInfo milestone : milestones) {
      String milestoneId = milestone.getId();

      // Find the appointment slots for the person/period
      List<AppointmentSlotInfo> appointmentSlots =
          appointmentService.getAppointmentSlotsByPersonAndPeriod(
              personId, milestoneId, contextInfo);

      if (appointmentSlots != null && !appointmentSlots.isEmpty()) {
        allAppointmentSlots.addAll(appointmentSlots);
      }
    }
    return allAppointmentSlots;
  }
  @Before
  public void setUp() throws Exception {

    // create the term resolver
    courseAddDatesTermResolver = new CourseAddDatesTermResolver();

    // set up pre-requisites
    contextInfo = new ContextInfo();
    contextInfo.setCurrentDate(new DateTime(2014, 9, 15, 10, 18).toDate());
    String personId = "MOCK.PERSON";
    String atpId = "MOCK.ATP";
    resolvedPrereqs = new HashMap<>();
    resolvedPrereqs.put(RulesExecutionConstants.CONTEXT_INFO_TERM.getName(), contextInfo);
    resolvedPrereqs.put(RulesExecutionConstants.PERSON_ID_TERM.getName(), personId);
    resolvedPrereqs.put(RulesExecutionConstants.ATP_ID_TERM.getName(), atpId);

    // set up parameters
    parameters = new HashMap<>();

    // set up milestones
    List<MilestoneInfo> earlyRegMilestones = new ArrayList<>();
    String mstoneEarlyRegId = "milestone-early-reg";
    mstoneEarlyReg = new MilestoneInfo();
    mstoneEarlyReg.setId(mstoneEarlyRegId);
    earlyRegMilestones.add(mstoneEarlyReg);

    nonApptMilestones = new ArrayList<>();
    String mstoneNonApptId = "milestone-non-appt";
    MilestoneInfo mstoneNonAppt = new MilestoneInfo();
    mstoneNonAppt.setId(mstoneNonApptId);
    mstoneNonAppt.setStartDate(new DateTime(2014, 9, 16, 0, 1).toDate());
    mstoneNonAppt.setEndDate(new DateTime(2014, 9, 17, 11, 59).toDate());
    nonApptMilestones.add(mstoneNonAppt);

    List<MilestoneInfo> schedAdjMilestones = new ArrayList<>();
    String mstoneSchedAdjId = "milestone-sched-adj";
    MilestoneInfo mstoneSchedAdj = new MilestoneInfo();
    mstoneSchedAdj.setId(mstoneSchedAdjId);
    mstoneSchedAdj.setStartDate(new DateTime(2014, 9, 18, 0, 1).toDate());
    mstoneSchedAdj.setEndDate(new DateTime(2014, 9, 19, 11, 59).toDate());
    schedAdjMilestones.add(mstoneSchedAdj);

    // set up atp service
    AtpService atpService = mock(AtpService.class);
    when(atpService.getMilestonesByTypeForAtp(
            atpId, AtpServiceConstants.MILESTONE_EARLY_REGISTRATION_PERIOD_TYPE_KEY, contextInfo))
        .thenReturn(earlyRegMilestones);
    when(atpService.getMilestonesByTypeForAtp(
            atpId,
            AtpServiceConstants.MILESTONE_EARLY_REGISTRATION_PERIOD_NONAPPT_TYPE_KEY,
            contextInfo))
        .thenReturn(nonApptMilestones);
    when(atpService.getMilestonesByTypeForAtp(
            atpId, AtpServiceConstants.MILESTONE_SCHEDULE_ADJUSTMENT_PERIOD_TYPE_KEY, contextInfo))
        .thenReturn(schedAdjMilestones);

    // set up appointment slots
    appointmentSlots = new ArrayList<>();

    // set up appointment service
    AppointmentService appointmentService = mock(AppointmentService.class);
    when(appointmentService.getAppointmentSlotsByPersonAndPeriod(
            personId, mstoneEarlyRegId, contextInfo))
        .thenReturn(appointmentSlots);

    // add services to the term resolver
    courseAddDatesTermResolver.setAtpService(atpService);
    courseAddDatesTermResolver.setAppointmentService(appointmentService);
  }