Esempio n. 1
0
  private void ensureValidAlertedOnPersonStateOrFail(Person person)
      throws ObjectNotFoundException, ValidationException {

    if (person.getObjectStatus() != ObjectStatus.ACTIVE) {
      person.setObjectStatus(ObjectStatus.ACTIVE);
    }

    final ProgramStatus programStatus = programStatusService.getActiveStatus();
    if (programStatus == null) {
      throw new ObjectNotFoundException(
          "Unable to find a ProgramStatus representing \"activeness\".", "ProgramStatus");
    }

    Set<PersonProgramStatus> programStatuses = person.getProgramStatuses();
    if (programStatuses == null || programStatuses.isEmpty()) {
      PersonProgramStatus personProgramStatus = new PersonProgramStatus();
      personProgramStatus.setEffectiveDate(new Date());
      personProgramStatus.setProgramStatus(programStatus);
      personProgramStatus.setPerson(person);
      programStatuses.add(personProgramStatus);
      person.setProgramStatuses(programStatuses);
      // save should cascade, but make sure custom create logic fires
      personProgramStatusService.create(personProgramStatus);
    }

    if (person.getStudentType() == null) {
      StudentType studentType = studentTypeService.get(StudentType.EAL_ID);
      if (studentType == null) {
        throw new ObjectNotFoundException(
            "Unable to find a StudentType representing an early " + "alert-assigned type.",
            "StudentType");
      }
      person.setStudentType(studentType);
    }
  }
  @Test
  public void testGetCurrent() throws ObjectNotFoundException, ValidationException {

    final PersonProgramStatus status = personProgramStatusService.getCurrent(PERSON_ID);

    final Date yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
    status.setExpirationDate(yesterday);

    // arrange, act
    final PersonProgramStatusTO programStatus = controller.getCurrent(PERSON_ID);

    // assert
    assertNull(
        "No PersonProgramStatus should have been returned as they are all currently expired.",
        programStatus);
  }