示例#1
0
  @Test
  public void testDrafts() throws CvqException {

    this.createDrafts(2);

    List<Request> drafts = this.getDrafts();
    assertEquals(2, drafts.size());

    requestWorkflowService.delete(drafts.get(0).getId());
    continueWithNewTransaction();

    drafts = getDrafts();
    assertEquals(1, drafts.size());

    Request draft2 = drafts.get(0);
    draft2.setState(RequestState.PENDING);
    requestWorkflowService.modify(draft2);

    continueWithNewTransaction();
    try {
      this.getDraftById(draft2.getId());
      fail();
    } catch (IndexOutOfBoundsException e) {
    }
    requestWorkflowService.delete(draft2.getId());

    continueWithNewTransaction();

    assertEquals(0, getDrafts().size());
  }
示例#2
0
  void createDrafts(int step) throws CvqException {
    continueWithNewTransaction();

    for (int i = 1; i <= step; i++) {
      SecurityContext.setCurrentContext(SecurityContext.FRONT_OFFICE_CONTEXT);
      SecurityContext.setCurrentEcitizen(fake.responsibleId);

      Request request = new SchoolRegistrationRequest();
      request.setRequesterId(SecurityContext.getCurrentEcitizen().getId());
      request.setSubjectId(fake.childId);
      request.setState(RequestState.DRAFT);
      Long id = requestWorkflowService.create(request, null);
      continueWithNewTransaction();

      request = requestSearchService.getById(id, true);
      request.setCreationDate(DateUtils.getShiftedDate(Calendar.DAY_OF_YEAR, i * (-1)));

      SecurityContext.setCurrentContext(SecurityContext.BACK_OFFICE_CONTEXT);
      SecurityContext.setCurrentAgent(agentNameWithManageRoles);
      requestWorkflowService.modify(request);
      continueWithNewTransaction();
    }
  }