Search in sources :

Example 1 with ScheduledSession

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());
}
Also used : TimeWindow(org.sagebionetworks.bridge.models.schedules2.TimeWindow) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 2 with ScheduledSession

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");
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) TimeWindow(org.sagebionetworks.bridge.models.schedules2.TimeWindow) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 3 with 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));
}
Also used : TimeWindow(org.sagebionetworks.bridge.models.schedules2.TimeWindow) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 4 with ScheduledSession

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"));
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Example 5 with ScheduledSession

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"));
}
Also used : Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) Session(org.sagebionetworks.bridge.models.schedules2.Session) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)21 Schedule2 (org.sagebionetworks.bridge.models.schedules2.Schedule2)17 Session (org.sagebionetworks.bridge.models.schedules2.Session)13 HashSet (java.util.HashSet)5 TimeWindow (org.sagebionetworks.bridge.models.schedules2.TimeWindow)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 DateRange (org.sagebionetworks.bridge.models.DateRange)2 Schedule2Test (org.sagebionetworks.bridge.models.schedules2.Schedule2Test)2 StudyBurst (org.sagebionetworks.bridge.models.schedules2.StudyBurst)2 ScheduledSession (org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledSession)2 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 LocalTime (org.joda.time.LocalTime)1 Period (org.joda.time.Period)1 AssessmentReference (org.sagebionetworks.bridge.models.schedules2.AssessmentReference)1 SessionTest (org.sagebionetworks.bridge.models.schedules2.SessionTest)1 ParticipantSchedule (org.sagebionetworks.bridge.models.schedules2.participantschedules.ParticipantSchedule)1 ScheduledAssessment (org.sagebionetworks.bridge.models.schedules2.timelines.ScheduledAssessment)1 SessionInfo (org.sagebionetworks.bridge.models.schedules2.timelines.SessionInfo)1