@Test
 public void testWithoutHomeFolder()
     throws CvqException, CvqObjectNotFoundException, FileNotFoundException, IOException {
   if (!requestService.supportUnregisteredCreation()) return;
   startTransaction();
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.FRONT_OFFICE_CONTEXT);
   TicketBookingRequest request = fillMeARequest();
   Address address = BusinessObjectsFactory.gimmeAdress("12", "Rue d'Aligre", "Paris", "75012");
   Adult requester =
       BusinessObjectsFactory.gimmeAdult(
           TitleType.MISTER, "LASTNAME", "requester", address, FamilyStatusType.MARRIED);
   requester.setPassword("requester");
   requester.setAdress(address);
   homeFolderService.addHomeFolderRole(requester, RoleType.HOME_FOLDER_RESPONSIBLE);
   TicketBookingRequestFeeder.setSubject(
       request, requestService.getSubjectPolicy(), requester, null);
   Long requestId = requestWorkflowService.create(request, requester);
   // close current session and re-open a new one
   continueWithNewTransaction();
   // start testing request creation
   /////////////////////////////////
   TicketBookingRequest requestFromDb =
       (TicketBookingRequest) requestSearchService.getById(requestId, true);
   assertEquals(requestId, requestFromDb.getId());
   assertNotNull(requestFromDb.getRequesterId());
   assertNotNull(requestFromDb.getRequesterLastName());
   if (requestFromDb.getSubjectId() != null) assertNotNull(requestFromDb.getSubjectLastName());
   Long homeFolderId = requestFromDb.getHomeFolderId();
   Long requesterId = requestFromDb.getRequesterId();
   // close current session and re-open a new one
   continueWithNewTransaction();
   completeValidateAndDelete(requestFromDb);
   // close current session and re-open a new one
   continueWithNewTransaction();
   try {
     homeFolderService.getById(homeFolderId);
     fail("should not have found home folder");
   } catch (CvqObjectNotFoundException confe) {
     // great, that was expected
   }
   try {
     individualService.getById(requesterId);
     fail("should not have found requester");
   } catch (CvqObjectNotFoundException confe) {
     // great, that was expected
   }
   SecurityContext.resetCurrentSite();
   commitTransaction();
 }
  @Override
  public List<Adult> matchAdults(Long externalHomeFolderId) throws CvqException {
    ExternalHomeFolder ehf =
        (ExternalHomeFolder) genericDAO.findById(ExternalHomeFolder.class, externalHomeFolderId);
    ExternalIndividual ehfr = ehf.getResponsible();

    if (ehfr == null) return new ArrayList<Adult>();

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("firstName", ehfr.getFirstName());
    parameters.put("lastName", ehfr.getLastName());
    parameters.put("email", ehfr.getEmail());
    parameters.put("homePhone", ehfr.getHomePhone());
    parameters.put("address", ehf.getAddress());
    List<Adult> adults = adultDAO.matchAdults(parameters);
    List<Adult> responsibles = new ArrayList<Adult>();
    for (Adult adult : adults) {
      for (IndividualRole ir : adult.getIndividualRoles())
        if (ir.getRole().equals(RoleType.HOME_FOLDER_RESPONSIBLE)) responsibles.add(adult);
    }
    return responsibles;
  }