예제 #1
0
 private CallEvent getMissedCallEvent() {
   CallEvent callEvent = new CallEvent("Missed");
   CallEventCustomData callEventCustomData = new CallEventCustomData();
   callEventCustomData.add(IVRService.CALL_TYPE, "Pill Reminder");
   callEvent.setData(callEventCustomData);
   return callEvent;
 }
 private CallEvent messagesEvent() {
   CallEvent event = new CallEvent(CallState.PULL_MESSAGES.name());
   CallEventCustomData data = new CallEventCustomData();
   data.add(
       CallEventConstants.CUSTOM_DATA_LIST,
       "<response><playaudio>http://localhost/response1.wav</playaudio><playaudio>http://localhost/response2.wav</playaudio></response>");
   data.add(CallEventConstants.CALL_STATE, CallState.PULL_MESSAGES.name());
   event.setTimeStamp(DateUtil.now());
   event.setData(data);
   return event;
 }
  private void setUpCallLog(CallDirection callDirection) {
    String patientDocId = "patientDocId";
    String clinicId = "clinicId";
    callLog = new CallLog(patientDocId);
    callLog.patientId("patientId");
    initiatedTime = DateUtil.newDateTime(2011, 10, 10, 10, 9, 10);
    startTime = DateUtil.newDateTime(2011, 10, 10, 10, 10, 10);
    callLog.setStartTime(initiatedTime);
    callLog.setEndTime(DateUtil.now());
    callLog.setCallDirection(callDirection);
    callLog.clinicId(clinicId);
    callLog.setPhoneNumber("1234567890");
    callLog.callLanguage("en");

    final CallEvent callEvent = mock(CallEvent.class);
    when(callEvent.getTimeStamp()).thenReturn(startTime);
    CallEventCustomData customData = new CallEventCustomData();
    customData.add(TAMAIVRContext.MESSAGE_CATEGORY_NAME, "All Messages");
    when(callEvent.getData()).thenReturn(customData);
    callLog.setCallEvents(
        new ArrayList<CallEvent>() {
          {
            add(callEvent);
          }
        });
    Clinic clinic = new Clinic(clinicId);
    Patient patient =
        PatientBuilder.startRecording()
            .withId(patientDocId)
            .withPatientId("patientId")
            .withGender(Gender.newGender("Male"))
            .withClinic(clinic)
            .withTravelTimeToClinicInDays(1)
            .withTravelTimeToClinicInHours(1)
            .withTravelTimeToClinicInMinutes(1)
            .withDateOfBirth(DateUtil.today().minusYears(40))
            .build();
    CallLogView callLogView = mock(CallLogView.class);
    clinic.setName("clinicName");

    when(allIVRLanguages.getByCode("en")).thenReturn(IVRLanguage.newIVRLanguage("English", "en"));
    when(allPatients.getAll()).thenReturn(asList(patient));
    when(callLogViewMapper.toCallLogView(asList(callLog))).thenReturn(asList(callLogView));

    callLogSummaryBuilder =
        new CallLogSummaryBuilder(allPatients, new Patients(allPatients.getAll()), allIVRLanguages);
  }
  @Test
  public void shouldHaveUniqueMessageCategoriesAccessedInCall() {
    setUpCallLog(CallDirection.Outbound);

    CallEventCustomData customData = new CallEventCustomData();
    customData.add(TAMAIVRContext.MESSAGE_CATEGORY_NAME, TAMAMessageType.ALL_MESSAGES.name());

    CallEvent event = mock(CallEvent.class);
    when(event.getData()).thenReturn(customData);
    when(event.getTimeStamp()).thenReturn(startTime);

    callLog.setCallEvents(asList(event, event));

    CallLogSummary callLogSummary = callLogSummaryBuilder.build(callLog);
    assertEquals(
        TAMAMessageType.ALL_MESSAGES.getDisplayName(), callLogSummary.getMessageCategories());
  }