use of org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledSession in project BridgeServer2 by Sage-Bionetworks.
the class ScheduledSessionTest method copyWithoutAssessments.
@Test
public void copyWithoutAssessments() {
Session session = new Session();
session.setGuid(SESSION_GUID_1);
session.setStartEventIds(ImmutableList.of("enrollment"));
TimeWindow window = new TimeWindow();
window.setGuid(SESSION_WINDOW_GUID_1);
ScheduledAssessment asmt = new ScheduledAssessment.Builder().withRefKey("ref").withInstanceGuid("instanceGuid").build();
ScheduledSession.Builder builder = new ScheduledSession.Builder().withSession(session).withTimeWindow(window).withStartEventId("timeline_retrieved").withInstanceGuid("instanceGuid").withStartDay(10).withEndDay(13).withDelayTime(Period.parse("PT3H")).withStartTime(LocalTime.parse("17:00")).withExpiration(Period.parse("PT30M")).withPersistent(true).withScheduledAssessment(asmt);
ScheduledSession.Builder copy = builder.build().toBuilder();
ScheduledSession schSession = copy.build();
assertEquals(schSession.getRefGuid(), SESSION_GUID_1);
assertEquals(schSession.getInstanceGuid(), "instanceGuid");
assertEquals(schSession.getStartEventId(), "timeline_retrieved");
assertEquals(schSession.getStartDay(), Integer.valueOf(10));
assertEquals(schSession.getEndDay(), Integer.valueOf(13));
assertEquals(schSession.getStartTime(), LocalTime.parse("17:00"));
assertEquals(schSession.getDelayTime(), Period.parse("PT3H"));
assertEquals(schSession.getExpiration(), Period.parse("PT30M"));
assertEquals(schSession.getTimeWindow(), window);
assertTrue(schSession.isPersistent());
assertTrue(schSession.getAssessments().isEmpty());
assertNull(schSession.getStudyBurstId());
assertNull(schSession.getStudyBurstNum());
}
use of org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledSession in project BridgeServer2 by Sage-Bionetworks.
the class ScheduledSessionTest method serializationHandlesNulls.
@Test
public void serializationHandlesNulls() {
ScheduledSession schSession = new ScheduledSession.Builder().withSession(new Session()).withTimeWindow(new TimeWindow()).build();
JsonNode node = BridgeObjectMapper.get().valueToTree(schSession);
assertEquals(node.size(), 2);
assertNull(node.get("startDay"));
assertNull(node.get("endDay"));
assertEquals(node.get("assessments").size(), 0);
assertEquals(node.get("type").textValue(), "ScheduledSession");
}
use of org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledSession in project BridgeServer2 by Sage-Bionetworks.
the class ScheduledSessionTest method reportsStudyBurstInformation.
@Test
public void reportsStudyBurstInformation() {
Session session = new Session();
session.setGuid(SESSION_GUID_1);
TimeWindow window = new TimeWindow();
window.setGuid(SESSION_WINDOW_GUID_1);
ScheduledSession schSession = new ScheduledSession.Builder().withSession(session).withTimeWindow(window).withStartEventId("study_burst:foo:01").build();
assertEquals(schSession.getStudyBurstId(), "foo");
assertEquals(schSession.getStudyBurstNum(), Integer.valueOf(1));
}
use of org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledSession 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.timelines.ScheduledSession 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