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");
}
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);
}
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);
}
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"));
}
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"));
}
Aggregations