Esempio n. 1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    pscUserService = registerMockFor(PscUserService.class);
    ssaXmlSerializer = registerNiceMockFor(StudySubjectAssignmentXmlSerializer.class);

    Site nu = createSite("NU", "IL036");
    Study a = createBasicTemplate("A");
    StudySite a_nu = createStudySite(a, nu);
    a_nu.approveAmendment(a.getAmendment(), new Date());
    a_nu_1 = createAssignment(a_nu, createSubject("First", "One"));

    StudySegment ae0s1 = a.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(0);
    ScheduledStudySegment scheduledStudySegment = createScheduledStudySegment(ae0s1);
    a_nu_1.getScheduledCalendar().addStudySegment(scheduledStudySegment);

    jo =
        new PscUserBuilder("jo")
            .add(PscRole.STUDY_SUBJECT_CALENDAR_MANAGER)
            .forAllSites()
            .forAllStudies()
            .toUser();
    alice =
        new PscUserBuilder("alice")
            .add(PscRole.STUDY_SUBJECT_CALENDAR_MANAGER)
            .forAllSites()
            .forAllStudies()
            .toUser();

    setCurrentUser(alice);
    UriTemplateParameters.USERNAME.putIn(request, "jo");
    expect(pscUserService.getAuthorizableUser("jo")).andStubReturn(jo);
    expect(pscUserService.getManagedAssignments(jo, alice))
        .andStubReturn(createExpectedUssars(jo, a_nu_1));
  }
 @Override
 public Element createElement(StudySubjectAssignment assignment, boolean inCollection) {
   Element elt = SUBJECT_ASSIGNMENT.create();
   ASSIGNMENT_STUDY_NAME.addTo(elt, assignment.getStudySite().getStudy().getName());
   ASSIGNMENT_SITE_NAME.addTo(elt, assignment.getStudySite().getSite().getName());
   ASSIGNMENT_START_DATE.addTo(elt, assignment.getStartDate());
   ASSIGNMENT_END_DATE.addTo(elt, assignment.getEndDate());
   ASSIGNMENT_SUBJECT_COORD.addTo(elt, assignment.getStudySubjectCalendarManager().getName());
   ASSIGNMENT_CURRENT_AMENDMENT.addTo(elt, assignment.getCurrentAmendment().getNaturalKey());
   ASSIGNMENT_ID.addTo(elt, assignment.getGridId());
   if (!subjectCentric) {
     elt.add(subjectXmlSerializer.createElement(assignment.getSubject()));
   }
   if (subjectCentric || includeScheduledCalendar) {
     elt.add(scheduledCalendarXmlSerializer.createElement(assignment.getScheduledCalendar()));
   }
   return elt;
 }