@Test
 public void testWithHomeFolderPojo()
     throws CvqException, CvqObjectNotFoundException, FileNotFoundException, IOException {
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.FRONT_OFFICE_CONTEXT);
   // create a vo card request (to create home folder and associates)
   CreationBean cb = gimmeAnHomeFolderWithRequest();
   SecurityContext.setCurrentEcitizen(cb.getLogin());
   // get the home folder id
   HomeFolder homeFolder = homeFolderService.getById(cb.getHomeFolderId());
   assertNotNull(homeFolder);
   Long homeFolderId = homeFolder.getId();
   assertNotNull(homeFolderId);
   // fill and create the request
   //////////////////////////////
   MilitaryCensusRequest request = fillMeARequest();
   request.setRequesterId(SecurityContext.getCurrentUserId());
   request.setHomeFolderId(homeFolderId);
   MilitaryCensusRequestFeeder.setSubject(
       request, requestService.getSubjectPolicy(), null, homeFolder);
   Long requestId = requestWorkflowService.create(request, null);
   MilitaryCensusRequest requestFromDb =
       (MilitaryCensusRequest) requestSearchService.getById(requestId, true);
   assertEquals(requestId, requestFromDb.getId());
   assertNotNull(requestFromDb.getRequesterId());
   assertNotNull(requestFromDb.getRequesterLastName());
   if (requestFromDb.getSubjectId() != null) assertNotNull(requestFromDb.getSubjectLastName());
   completeValidateAndDelete(requestFromDb);
   HomeFolder homeFolderAfterDelete = homeFolderService.getById(homeFolderId);
   assertNotNull(homeFolderAfterDelete);
   assertNotNull(homeFolderService.getHomeFolderResponsible(homeFolderAfterDelete.getId()));
 }
 @Test
 public void testWithoutHomeFolder()
     throws CvqException, CvqObjectNotFoundException, FileNotFoundException, IOException {
   if (!requestService.supportUnregisteredCreation()) return;
   startTransaction();
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.FRONT_OFFICE_CONTEXT);
   MilitaryCensusRequest 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);
   MilitaryCensusRequestFeeder.setSubject(
       request, requestService.getSubjectPolicy(), requester, null);
   Long requestId = requestWorkflowService.create(request, requester, null);
   // close current session and re-open a new one
   continueWithNewTransaction();
   // start testing request creation
   /////////////////////////////////
   MilitaryCensusRequest requestFromDb =
       (MilitaryCensusRequest) 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();
 }