use of org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay in project BridgeServer2 by Sage-Bionetworks.
the class NextActivityTest method canSerialize.
@Test
public void canSerialize() {
EventStreamDay day = new EventStreamDay();
day.setLabel("label");
day.setSessionGuid("sessionGuid");
day.setSessionName("sessionName");
day.setSessionSymbol("sessionSymbol");
day.setStartDay(1);
day.setStartDate(LocalDate.parse("2015-02-02"));
day.setWeek(2);
day.setStudyBurstId("burst");
day.setStudyBurstNum(3);
NextActivity next = NextActivity.create(day);
JsonNode node = BridgeObjectMapper.get().valueToTree(next);
assertEquals(node.size(), 9);
assertEquals(node.get("label").textValue(), "label");
assertEquals(node.get("sessionGuid").textValue(), "sessionGuid");
assertEquals(node.get("sessionName").textValue(), "sessionName");
assertEquals(node.get("sessionSymbol").textValue(), "sessionSymbol");
assertEquals(node.get("weekInStudy").intValue(), 2);
assertEquals(node.get("studyBurstId").textValue(), "burst");
assertEquals(node.get("studyBurstNum").intValue(), 3);
assertEquals(node.get("startDate").textValue(), "2015-02-02");
assertEquals(node.get("type").textValue(), "NextActivity");
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay in project BridgeServer2 by Sage-Bionetworks.
the class WeeklyAdherenceReportTest method canSerialize.
@Test
public void canSerialize() {
Account account = Account.create();
account.setId(TEST_USER_ID);
NextActivity nextActivity = NextActivity.create(new EventStreamDay());
WeeklyAdherenceReportRow row = new WeeklyAdherenceReportRow();
row.setLabel("rowLabel");
row.setSearchableLabel(":rowLabel:");
row.setSessionGuid("sessionGuid");
row.setSessionSymbol("sessionSymbol");
row.setSessionName("sessionName");
row.setStudyBurstId("studyBurstId");
row.setStudyBurstNum(2);
row.setWeekInStudy(4);
row.setStartEventId("event1");
WeeklyAdherenceReport report = new WeeklyAdherenceReport();
report.setAppId(TEST_APP_ID);
report.setStudyId(TEST_STUDY_ID);
report.setUserId(TEST_USER_ID);
report.setClientTimeZone(TEST_CLIENT_TIME_ZONE);
report.setCreatedOn(MODIFIED_ON);
report.setSearchableLabels(ImmutableSet.of("label1", "label2"));
report.setParticipant(new AccountRef(account, "study1"));
report.setTestAccount(true);
report.setProgression(IN_PROGRESS);
report.setWeeklyAdherencePercent(79);
report.setRows(ImmutableList.of(row));
report.setWeekInStudy(2);
report.setStartDate(LocalDate.parse("2022-02-02"));
report.setByDayEntries(ImmutableMap.of(new Integer(6), ImmutableList.of(new EventStreamDay())));
report.setNextActivity(nextActivity);
// It's there, it works, it's persisted, but it's not part of JSON output
assertTrue(report.isTestAccount());
// These are not in the JSON
assertEquals(report.getAppId(), TEST_APP_ID);
assertEquals(report.getStudyId(), TEST_STUDY_ID);
assertEquals(report.getUserId(), TEST_USER_ID);
assertEquals(report.getSearchableLabels(), ImmutableSet.of("label1", "label2"));
JsonNode node = BridgeObjectMapper.get().valueToTree(report);
assertEquals(node.size(), 12);
assertNull(node.get("appId"));
assertNull(node.get("studyId"));
assertNull(node.get("userId"));
assertEquals(node.get("participant").get("identifier").textValue(), "userId");
assertEquals(node.get("clientTimeZone").textValue(), TEST_CLIENT_TIME_ZONE);
assertEquals(node.get("createdOn").textValue(), MODIFIED_ON.withZone(DateTimeZone.forID(TEST_CLIENT_TIME_ZONE)).toString());
assertEquals(node.get("weeklyAdherencePercent").intValue(), 79);
assertEquals(node.get("participant").get("identifier").textValue(), TEST_USER_ID);
assertTrue(node.get("testAccount").booleanValue());
assertEquals(node.get("progression").textValue(), "in_progress");
assertEquals(node.get("nextActivity").get("type").textValue(), "NextActivity");
assertEquals(node.get("byDayEntries").get("6").get(0).get("type").textValue(), "EventStreamDay");
assertEquals(node.get("weekInStudy").intValue(), 2);
assertEquals(node.get("startDate").textValue(), "2022-02-02");
assertEquals(node.get("type").textValue(), "WeeklyAdherenceReport");
assertEquals(node.get("rows").size(), 1);
JsonNode rowNode = node.get("rows").get(0);
assertEquals(rowNode.get("label").textValue(), "rowLabel");
assertEquals(rowNode.get("searchableLabel").textValue(), ":rowLabel:");
assertEquals(rowNode.get("sessionGuid").textValue(), "sessionGuid");
assertEquals(rowNode.get("sessionSymbol").textValue(), "sessionSymbol");
assertEquals(rowNode.get("sessionName").textValue(), "sessionName");
assertEquals(rowNode.get("studyBurstId").textValue(), "studyBurstId");
assertEquals(rowNode.get("studyBurstNum").intValue(), 2);
assertEquals(rowNode.get("weekInStudy").intValue(), 4);
assertEquals(rowNode.get("startEventId").textValue(), "event1");
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method timestampBeforeSchedule.
@Test
public void timestampBeforeSchedule() throws Exception {
AdherenceState state = createAdherenceState().withNow(DateTime.parse("2020-01-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
for (StudyReportWeek week : report.getWeeks()) {
for (List<EventStreamDay> days : week.getByDayEntries().values()) {
for (EventStreamDay oneDay : days) {
for (EventStreamWindow win : oneDay.getTimeWindows()) {
assertEquals(win.getState(), NOT_YET_AVAILABLE);
}
}
}
}
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method timestampAfterSchedule.
@Test
public void timestampAfterSchedule() throws Exception {
AdherenceState state = createAdherenceState().withNow(DateTime.parse("2022-05-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
for (StudyReportWeek week : report.getWeeks()) {
for (List<EventStreamDay> days : week.getByDayEntries().values()) {
for (EventStreamDay oneDay : days) {
for (EventStreamWindow win : oneDay.getTimeWindows()) {
assertEquals(win.getState(), EXPIRED);
}
}
}
}
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method dayHasNoUnnecessaryFieldsFilledOut.
@Test
public void dayHasNoUnnecessaryFieldsFilledOut() throws Exception {
StudyAdherenceReport report = createReport();
for (StudyReportWeek week : report.getWeeks()) {
for (List<EventStreamDay> days : week.getByDayEntries().values()) {
for (EventStreamDay oneDay : days) {
assertNull(oneDay.getStudyBurstId());
assertNull(oneDay.getStudyBurstNum());
assertNull(oneDay.getSessionName());
assertNull(oneDay.getWeek());
assertNull(oneDay.getStartDay());
for (EventStreamWindow window : oneDay.getTimeWindows()) {
assertNull(window.getEndDay());
}
}
}
}
}
Aggregations