@Override
  public List<StudentCourseRecordInfo> resolve(
      Map<String, Object> resolvedPrereqs, Map<String, String> parameters)
      throws TermResolutionException {

    DateTime startTime = new DateTime();

    ContextInfo context =
        (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM.getName());
    String personId =
        (String) resolvedPrereqs.get(RulesExecutionConstants.PERSON_ID_TERM.getName());
    String versionIndId =
        (String) resolvedPrereqs.get(RulesExecutionConstants.CLU_VERSION_IND_ID_TERM.getName());

    List<StudentCourseRecordInfo> records = null;
    try {
      records =
          getAcademicRecordService()
              .getStudentCourseRecordsForCourse(personId, versionIndId, context);
    } catch (Exception e) {
      KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
    }

    DateTime endTime = new DateTime();
    RegEnginePerformanceUtil.putStatistics(
        RegEnginePerformanceUtil.TERMS, getOutput(), startTime, endTime);

    return records;
  }
  @Override
  public Boolean resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters)
      throws TermResolutionException {
    ContextInfo context =
        (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM.getName());
    String personId =
        (String) resolvedPrereqs.get(RulesExecutionConstants.PERSON_ID_TERM.getName());

    boolean coursesWithGrade = true;

    try {
      // Retrieve the list of cluIds from the cluset.
      String cluSetId =
          parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_COURSE_CLUSET_KEY);
      String gradeType = parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_GRADE_TYPE_KEY);
      String grade = parameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_GRADE_KEY);

      List<String> versionIndIds = this.getCluIdsForCluSet(cluSetId, parameters, context);
      if (versionIndIds != null && !versionIndIds.isEmpty()) {
        for (String versionIndId : versionIndIds) {
          if (!this.checkCourseWithGrade(
              personId, versionIndId, grade, gradeType, parameters, context)) {
            coursesWithGrade = false;
          }
        }
      } else {
        coursesWithGrade = false;
      }
    } catch (Exception e) {
      KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
    }

    return coursesWithGrade;
  }
 @Override
 public Set<String> getPrerequisites() {
   Set<String> prereqs = new HashSet<>(3);
   prereqs.add(RulesExecutionConstants.PERSON_ID_TERM.getName());
   prereqs.add(RulesExecutionConstants.CONTEXT_INFO_TERM.getName());
   prereqs.add(RulesExecutionConstants.CLU_VERSION_IND_ID_TERM.getName());
   return Collections.unmodifiableSet(prereqs);
 }
  @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);
  }