use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method participantStudyProgress_noSchedule.
@Test
public void participantStudyProgress_noSchedule() throws Exception {
AdherenceState state = createAdherenceState().withMetadata(null).build();
StudyAdherenceReport report = INSTANCE.generate(state);
assertEquals(report.getProgression(), ParticipantStudyProgress.NO_SCHEDULE);
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method adherenceNotCalculatedForFutureWeeks.
@Test
public void adherenceNotCalculatedForFutureWeeks() throws Exception {
AdherenceState state = new AdherenceState.Builder().withStudyStartEventId("timeline_retrieved").withMetadata(createTimelineMetadata()).withEvents(createEvents()).withNow(DateTime.parse("2022-03-7T01:00:00.000-08:00")).build();
StudyAdherenceReport report = StudyAdherenceReportGenerator.INSTANCE.generate(state);
List<StudyReportWeek> weeks = ImmutableList.copyOf(report.getWeeks());
assertEquals(weeks.get(0).getAdherencePercent(), Integer.valueOf(0));
assertNull(weeks.get(1).getAdherencePercent());
assertNull(weeks.get(2).getAdherencePercent());
assertNull(weeks.get(3).getAdherencePercent());
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method eventStreamsWithNoEventsTransferredToUnused.
@Test
public void eventStreamsWithNoEventsTransferredToUnused() throws Exception {
AdherenceState state = createAdherenceState().withEvents(null).build();
StudyAdherenceReport report = INSTANCE.generate(state);
assertTrue(report.getWeeks().isEmpty());
assertTrue(report.getEventTimestamps().isEmpty());
assertEquals(report.getUnsetEventIds(), ImmutableSet.of("study_burst:Study Burst:02", "study_burst:Study Burst:01", "study_burst:Study Burst:03", "custom:event1", "timeline_retrieved"));
assertEquals(report.getUnscheduledSessions(), ImmutableSet.of("Supplemental Survey", "Initial Survey", "Baseline Tapping Test", "Study Burst Tapping Test", "Final Survey"));
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method todaySet.
@Test
public void todaySet() throws Exception {
AdherenceState state = createAdherenceState().build();
StudyAdherenceReport report = INSTANCE.generate(state);
for (StudyReportWeek week : report.getWeeks()) {
for (List<EventStreamDay> days : week.getByDayEntries().values()) {
for (EventStreamDay oneDay : days) {
if (oneDay.isToday()) {
assertEquals(oneDay.getStartDate().toString(), "2022-03-15");
} else if (oneDay.getStartDate() != null) {
assertNotEquals(oneDay.getStartDate().toString(), "2022-03-15");
}
}
}
}
}
use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.
the class StudyAdherenceReportGeneratorTest method emptyEventStreamReportGeneratesEmptyStudyAdherenceReport.
@Test
public void emptyEventStreamReportGeneratesEmptyStudyAdherenceReport() throws Exception {
AdherenceState state = new AdherenceState.Builder().withNow(DateTime.parse("2022-03-01T00:00:00.000-08:00")).build();
StudyAdherenceReport report = INSTANCE.generate(state);
// these fields are not set in the generator, they are set in the service.
// participant, testAccount, createdOn, timestamp, clientTimeZone
assertEquals(report.getProgression(), ParticipantStudyProgress.NO_SCHEDULE);
assertEquals(report.getUnsetEventIds(), ImmutableSet.of());
assertEquals(report.getUnscheduledSessions(), ImmutableSet.of());
assertTrue(report.getWeeks().isEmpty());
assertNull(report.getCurrentWeek());
assertNull(report.getNextActivity());
assertTrue(report.getEventTimestamps().isEmpty());
}
Aggregations