Search in sources :

Example 11 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class EventStreamAdherenceReportGeneratorTest method progression_done.

@Test
public void progression_done() {
    AdherenceRecord adherenceRecord = createRecord(STARTED_ON, FINISHED_ON, "sessionInstanceGuid", false);
    StudyActivityEvent event = createEvent("sessionStartEventId", NOW.minusDays(14));
    AdherenceState state = createState(NOW, META1, event, adherenceRecord, true);
    EventStreamAdherenceReport report = INSTANCE.generate(state);
    assertEquals(report.getProgression(), ParticipantStudyProgress.DONE);
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) Test(org.testng.annotations.Test)

Example 12 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class EventStreamAdherenceReportGeneratorTest method groupsUnderEventId.

@Test
public void groupsUnderEventId() throws Exception {
    AdherenceRecord adherenceRecord = createRecord(STARTED_ON, FINISHED_ON, "gnescr0HRz5T2JEjc0Ad6Q", false);
    StudyActivityEvent event = createEvent("study_burst:Main Sequence:01", NOW.minusDays(3));
    AdherenceState state = createState(NOW, META2_A, META2_B, event, adherenceRecord, false);
    EventStreamAdherenceReport report = INSTANCE.generate(state);
    assertNotNull(report.getStreams().get(0).getByDayEntries().get(2));
    assertNotNull(report.getStreams().get(0).getByDayEntries().get(4));
    assertEquals(getReportStates(report), ImmutableList.of(COMPLETED, NOT_YET_AVAILABLE));
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) Test(org.testng.annotations.Test)

Example 13 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class EventStreamAdherenceReportGeneratorTest method handleNulls.

@Test
public void handleNulls() {
    AdherenceState state = new AdherenceState.Builder().withNow(NOW).build();
    EventStreamAdherenceReport report = INSTANCE.generate(state);
    assertEquals(100, report.getAdherencePercent());
    // no time zone adjustment
    assertEquals(report.getTimestamp(), NOW);
    assertTrue(report.getStreams().isEmpty());
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) Test(org.testng.annotations.Test)

Example 14 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class EventStreamAdherenceReportGeneratorTest method stateCalculation_futureChangesState.

@Test
public void stateCalculation_futureChangesState() throws Exception {
    AdherenceRecord adherenceRecord = createRecord(null, null, "sessionInstanceGuid", false);
    StudyActivityEvent event = createEvent("sessionStartEventId", NOW);
    AdherenceState state = createState(NOW.plusDays(28), META1, event, adherenceRecord);
    EventStreamAdherenceReport report = INSTANCE.generate(state);
    assertEquals(getReportStates(report), ImmutableList.of(EXPIRED));
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) Test(org.testng.annotations.Test)

Example 15 with AdherenceState

use of org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState in project BridgeServer2 by Sage-Bionetworks.

the class EventStreamAdherenceReportGeneratorTest method persistentSessionWindowsAreIgnored.

@Test
public void persistentSessionWindowsAreIgnored() {
    AdherenceRecord adherenceRecord = createRecord(STARTED_ON, FINISHED_ON, "JOQg4yz0lrif7V3HYYzACw", false);
    StudyActivityEvent event = createEvent("created_on", NOW);
    AdherenceState state = createState(NOW, META_PERSISTENT, event, adherenceRecord);
    assertTrue(INSTANCE.generate(state).getStreams().isEmpty());
}
Also used : AdherenceState(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState) AdherenceRecord(org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) Test(org.testng.annotations.Test)

Aggregations

AdherenceState (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceState)42 Test (org.testng.annotations.Test)40 StudyActivityEvent (org.sagebionetworks.bridge.models.activities.StudyActivityEvent)25 AdherenceRecord (org.sagebionetworks.bridge.models.schedules2.adherence.AdherenceRecord)20 EventStreamDay (org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamDay)5 Schedule2 (org.sagebionetworks.bridge.models.schedules2.Schedule2)4 Timeline (org.sagebionetworks.bridge.models.schedules2.timelines.Timeline)4 DateTime (org.joda.time.DateTime)3 LocalDate (org.joda.time.LocalDate)3 DateRange (org.sagebionetworks.bridge.models.DateRange)3 EventStreamWindow (org.sagebionetworks.bridge.models.schedules2.adherence.eventstream.EventStreamWindow)3 ParticipantSchedule (org.sagebionetworks.bridge.models.schedules2.participantschedules.ParticipantSchedule)3 HashMap (java.util.HashMap)2 Schedule2Test (org.sagebionetworks.bridge.models.schedules2.Schedule2Test)2 TimelineMetadata (org.sagebionetworks.bridge.models.schedules2.timelines.TimelineMetadata)2 Study (org.sagebionetworks.bridge.models.studies.Study)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1