Search in sources :

Example 1 with Schedule2

use of org.sagebionetworks.bridge.models.schedules2.Schedule2 in project BridgeServer2 by Sage-Bionetworks.

the class StudyValidatorTest method customEvents_missingEventIdInExistingSchedule.

@Test
public void customEvents_missingEventIdInExistingSchedule() {
    study = createStudy();
    study.setScheduleGuid(SCHEDULE_GUID);
    Schedule2 schedule = new Schedule2();
    schedule.setOwnerId(TEST_ORG_ID);
    when(mockScheduleService.getScheduleForStudy(TEST_APP_ID, study)).thenReturn(Optional.of(schedule));
    validator = new StudyValidator(Sets.newHashSet("aaa", "ccc"), mockScheduleService, TEST_ORG_ID);
    StudyCustomEvent studyCustomEvent = new StudyCustomEvent();
    studyCustomEvent.setEventId("aaa");
    study.setCustomEvents(ImmutableList.of(studyCustomEvent));
    assertValidatorMessage(validator, study, CUSTOM_EVENTS_FIELD, "cannot remove custom events currently used in a schedule: ccc");
}
Also used : StudyCustomEvent(org.sagebionetworks.bridge.models.studies.StudyCustomEvent) Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) StudyValidator(org.sagebionetworks.bridge.validators.StudyValidator) Test(org.testng.annotations.Test)

Example 2 with Schedule2

use of org.sagebionetworks.bridge.models.schedules2.Schedule2 in project BridgeServer2 by Sage-Bionetworks.

the class StudyValidatorTest method customEvents_emptySetOk.

@Test
public void customEvents_emptySetOk() {
    study = createStudy();
    study.setScheduleGuid(SCHEDULE_GUID);
    Schedule2 schedule = new Schedule2();
    schedule.setOwnerId(TEST_ORG_ID);
    when(mockScheduleService.getScheduleForStudy(TEST_APP_ID, study)).thenReturn(Optional.of(schedule));
    validator = new StudyValidator(Sets.newHashSet(), mockScheduleService, TEST_ORG_ID);
    StudyCustomEvent studyCustomEvent = new StudyCustomEvent();
    studyCustomEvent.setEventId("aaa");
    studyCustomEvent.setUpdateType(MUTABLE);
    study.setCustomEvents(ImmutableList.of(studyCustomEvent));
    Validate.entityThrowingException(validator, study);
}
Also used : StudyCustomEvent(org.sagebionetworks.bridge.models.studies.StudyCustomEvent) Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) StudyValidator(org.sagebionetworks.bridge.validators.StudyValidator) Test(org.testng.annotations.Test)

Example 3 with Schedule2

use of org.sagebionetworks.bridge.models.schedules2.Schedule2 in project BridgeServer2 by Sage-Bionetworks.

the class SchedulerTest method twoOneTimeSessions.

@Test
public void twoOneTimeSessions() {
    Schedule2 schedule = createSchedule("P2W");
    Session session1 = createOneTimeSession(null);
    Session session2 = createOneTimeSession("P2D");
    session2.setGuid(SESSION_GUID_4);
    schedule.setSessions(ImmutableList.of(session1, session2));
    Timeline timeline = INSTANCE.calculateTimeline(schedule);
    assertEquals(timeline.getSchedule().size(), 2);
    assertEquals(timeline.getAssessments().size(), 1);
    assertEquals(timeline.getSessions().size(), 2);
    assertDayRange(timeline, 0, 0, 0);
    assertDayRange(timeline, 1, 2, 2);
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 4 with Schedule2

use of org.sagebionetworks.bridge.models.schedules2.Schedule2 in project BridgeServer2 by Sage-Bionetworks.

the class SchedulerTest method timeWindowStartExpiresAfterDayUsingDays.

@Test
public void timeWindowStartExpiresAfterDayUsingDays() {
    Schedule2 schedule = createSchedule("P5D");
    Session session = createOneTimeSession(null);
    session.getTimeWindows().get(0).setExpiration(Period.parse("P4D"));
    schedule.setSessions(ImmutableList.of(session));
    Timeline timeline = INSTANCE.calculateTimeline(schedule);
    assertEquals(timeline.getSchedule().size(), 1);
    ScheduledSession schSession = timeline.getSchedule().get(0);
    assertEquals(schSession.getStartDay(), Integer.valueOf(0));
    assertEquals(schSession.getEndDay(), Integer.valueOf(4));
    assertEquals(schSession.getStartTime(), LocalTime.parse("08:00"));
    assertEquals(schSession.getExpiration(), Period.parse("P4D"));
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 5 with Schedule2

use of org.sagebionetworks.bridge.models.schedules2.Schedule2 in project BridgeServer2 by Sage-Bionetworks.

the class SchedulerTest method timeWindowStartExpiresWithinDay.

@Test
public void timeWindowStartExpiresWithinDay() {
    Schedule2 schedule = createSchedule("P2D");
    // This is the default configuration of the test time window as we expect it to be typical
    Session session = createOneTimeSession(null);
    schedule.setSessions(ImmutableList.of(session));
    Timeline timeline = INSTANCE.calculateTimeline(schedule);
    assertEquals(timeline.getSchedule().size(), 1);
    ScheduledSession schSession = timeline.getSchedule().get(0);
    assertEquals(schSession.getStartDay(), Integer.valueOf(0));
    assertEquals(schSession.getEndDay(), Integer.valueOf(0));
    assertEquals(schSession.getStartTime(), LocalTime.parse("08:00"));
    assertEquals(schSession.getExpiration(), Period.parse("PT8H"));
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Aggregations

Schedule2 (org.sagebionetworks.bridge.models.schedules2.Schedule2)196 Test (org.testng.annotations.Test)174 SessionTest (org.sagebionetworks.bridge.models.schedules2.SessionTest)89 Study (org.sagebionetworks.bridge.models.studies.Study)64 Schedule2Test (org.sagebionetworks.bridge.models.schedules2.Schedule2Test)59 Session (org.sagebionetworks.bridge.models.schedules2.Session)42 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)22 RequestContext (org.sagebionetworks.bridge.RequestContext)21 StudyBurst (org.sagebionetworks.bridge.models.schedules2.StudyBurst)20 Timeline (org.sagebionetworks.bridge.models.schedules2.timelines.Timeline)19 HashSet (java.util.HashSet)12 AssessmentReference (org.sagebionetworks.bridge.models.schedules2.AssessmentReference)10 App (org.sagebionetworks.bridge.models.apps.App)9 TimeWindow (org.sagebionetworks.bridge.models.schedules2.TimeWindow)9 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)8 ParticipantSchedule (org.sagebionetworks.bridge.models.schedules2.participantschedules.ParticipantSchedule)7 StudyCustomEvent (org.sagebionetworks.bridge.models.studies.StudyCustomEvent)7 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)6 DateTime (org.joda.time.DateTime)5 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)5