コード例 #1
0
 @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()));
 }
コード例 #2
0
 @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();
 }
コード例 #3
0
  protected MilitaryCensusRequest fillMeARequest() {
    MilitaryCensusRequest request = new MilitaryCensusRequest();

    request.setFatherBirthDepartment(InseeDepartementCodeType.NONE);

    request.setChildProfession("ChildProfession");

    request.setChildStatus(FamilyStatusType.MARRIED);

    request.setAliveChildren(BigInteger.valueOf(1));

    request.setAffectionOrDisease(Boolean.valueOf(true));

    request.setStatePupil(Boolean.valueOf(true));

    request.setChildTitle(TitleType.MISTER);

    request.setChildMail("ChildMail");

    request.setChildDiploma(ChildDiplomaType.B_A_C);

    request.setMotherBirthCountry(CountryType.UNKNOWN);

    request.setFatherBirthCity("FatherBirthCity");

    request.setFatherBirthDate(new Date());

    if ("FatherFirstName".length() > 38)
      request.setFatherFirstName("FatherFirstName".substring(0, 38));
    else request.setFatherFirstName("FatherFirstName");

    request.setMotherBirthCity("MotherBirthCity");

    request.setFatherNationality(FullNationalityType.NONE);

    request.setMotherBirthDate(new Date());

    if ("MotherFirstName".length() > 38)
      request.setMotherFirstName("MotherFirstName".substring(0, 38));
    else request.setMotherFirstName("MotherFirstName");

    request.setChildBirthCountry(CountryType.UNKNOWN);

    request.setMotherNationality(FullNationalityType.NONE);

    request.setHighlyInfirm(Boolean.valueOf(true));

    request.setChildSpeciality("ChildSpeciality");

    request.setChildOtherCountry(FullNationalityType.NONE);

    request.setChildrenInCharge(BigInteger.valueOf(1));

    request.setJapdExemption(Boolean.valueOf(true));

    request.setChildSituation(ChildSituationType.COLLEGE);

    if ("MaidenName".length() > 38) request.setMaidenName("MaidenName".substring(0, 38));
    else request.setMaidenName("MaidenName");

    if ("ChildPhone".length() > 10) request.setChildPhone("ChildPhone".substring(0, 10));
    else request.setChildPhone("ChildPhone");

    if ("MotherLastName".length() > 38)
      request.setMotherLastName("MotherLastName".substring(0, 38));
    else request.setMotherLastName("MotherLastName");

    if ("FatherLastName".length() > 38)
      request.setFatherLastName("FatherLastName".substring(0, 38));
    else request.setFatherLastName("FatherLastName");

    request.setPrefectPupilDepartment(InseeDepartementCodeType.NONE);

    request.setMotherBirthDepartment(InseeDepartementCodeType.NONE);

    request.setChildResidenceCountry(CountryType.UNKNOWN);

    request.setOtherSituation("OtherSituation");

    request.setPrefectPupil(Boolean.valueOf(true));

    request.setChildCountry(FullNationalityType.NONE);

    if ("ChildConvention".length() > 255)
      request.setChildConvention("ChildConvention".substring(0, 255));
    else request.setChildConvention("ChildConvention");

    request.setFatherBirthCountry(CountryType.UNKNOWN);

    // Means Of Contact
    MeansOfContact meansOfContact =
        meansOfContactService.getMeansOfContactByType(MeansOfContactEnum.EMAIL);
    request.setMeansOfContact(meansOfContact);
    MilitaryCensusRequestFeeder.feed(request);
    return request;
  }
コード例 #4
0
 protected void completeValidateAndDelete(MilitaryCensusRequest request)
     throws CvqException, IOException {
   // add a document to the request
   ///////////////////////////////
   Document doc = new Document();
   doc.setEcitizenNote("Ma carte d'identité !");
   doc.setDepositOrigin(DepositOrigin.ECITIZEN);
   doc.setDepositType(DepositType.PC);
   doc.setHomeFolderId(request.getHomeFolderId());
   doc.setIndividualId(request.getRequesterId());
   doc.setDocumentType(
       documentTypeService.getDocumentTypeByType(IDocumentTypeService.IDENTITY_RECEIPT_TYPE));
   Long documentId = documentService.create(doc);
   requestDocumentService.addDocument(request.getId(), documentId);
   Set<RequestDocument> documentsSet =
       requestDocumentService.getAssociatedDocuments(request.getId());
   assertEquals(documentsSet.size(), 1);
   // FIXME : test list of pending / in-progress registrations
   Critere testCrit = new Critere();
   testCrit.setAttribut(Request.SEARCH_BY_HOME_FOLDER_ID);
   testCrit.setComparatif(Critere.EQUALS);
   testCrit.setValue(request.getHomeFolderId());
   Set<Critere> testCritSet = new HashSet<Critere>();
   testCritSet.add(testCrit);
   List<Request> allRequests = requestSearchService.get(testCritSet, null, null, -1, 0, false);
   assertNotNull(allRequests);
   // close current session and re-open a new one
   continueWithNewTransaction();
   SecurityContext.setCurrentSite(localAuthorityName, SecurityContext.BACK_OFFICE_CONTEXT);
   SecurityContext.setCurrentAgent(agentNameWithCategoriesRoles);
   requestWorkflowService.updateRequestState(request.getId(), RequestState.COMPLETE, null);
   requestWorkflowService.updateRequestState(request.getId(), RequestState.VALIDATED, null);
   // close current session and re-open a new one
   continueWithNewTransaction();
   byte[] generatedCertificate =
       requestSearchService.getCertificate(request.getId(), RequestState.PENDING);
   if (generatedCertificate == null) fail("No certificate found");
   //     Write tele-service xml data file
   File xmlFile = File.createTempFile("tmp" + request.getId(), ".xml");
   FileOutputStream xmlFos = new FileOutputStream(xmlFile);
   xmlFos.write(requestSearchService.getById(request.getId(), true).modelToXmlString().getBytes());
   File file = File.createTempFile("tmp" + request.getId(), ".pdf");
   FileOutputStream fos = new FileOutputStream(file);
   fos.write(generatedCertificate);
   // close current session and re-open a new one
   continueWithNewTransaction();
   // delete request
   requestWorkflowService.delete(request.getId());
 }