use of com.google.cloud.asset.v1.TimeWindow in project BridgeServer2 by Sage-Bionetworks.
the class SessionValidatorTest method makeWindows.
private Session makeWindows(String time1, String exp1, String time2, String exp2, String time3, String exp3) {
Session session = createValidSession();
TimeWindow win1 = new TimeWindow();
win1.setGuid(SESSION_GUID_1);
win1.setStartTime(LocalTime.parse(time1));
win1.setExpiration(Period.parse(exp1));
TimeWindow win2 = new TimeWindow();
win2.setGuid(SESSION_GUID_2);
win2.setStartTime(LocalTime.parse(time2));
win2.setExpiration(Period.parse(exp2));
TimeWindow win3 = new TimeWindow();
win3.setGuid(SESSION_GUID_3);
win3.setStartTime(LocalTime.parse(time3));
win3.setExpiration(Period.parse(exp3));
session.setTimeWindows(ImmutableList.of(win1, win2, win3));
return session;
}
use of com.google.cloud.asset.v1.TimeWindow in project BridgeServer2 by Sage-Bionetworks.
the class SessionValidatorTest method timeWindows_nullScheduleDurationPasses.
@Test
public void timeWindows_nullScheduleDurationPasses() {
Session session = createValidSession();
TimeWindow timeWindow = new TimeWindow();
timeWindow.setGuid(SESSION_GUID_1);
timeWindow.setStartTime(LocalTime.parse("08:00"));
timeWindow.setExpiration(Period.parse("P4W"));
session.setTimeWindows(ImmutableList.of(timeWindow));
session.setInterval(Period.parse("P4W"));
session.setDelay(Period.parse("P4WT1H"));
SessionValidator validator = new SessionValidator(null, ImmutableSet.of("burst1"));
Validate.entityThrowingException(validator, session);
}
use of com.google.cloud.asset.v1.TimeWindow 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 com.google.cloud.asset.v1.TimeWindow 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 com.google.cloud.asset.v1.TimeWindow 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));
}
Aggregations