@Test
  public void shouldBuildCallSummaryWithEmptyCallFlowDetailsWhenCallLogDoesNotHaveAnyFlows() {
    DateTime callStartTime = DateUtil.now();
    CallLog callLog = new CallLog();
    callLog.setStartTime(callStartTime);
    callLog.setEndTime(callStartTime.plusMinutes(1));

    CallLogSummary logSummary =
        new CallLogSummaryBuilder(allPatients, new Patients(allPatients.getAll()), allIVRLanguages)
            .build(callLog);
    assertNotNull(logSummary.getFlowDetailsMap());
  }
  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());
  }
 @Test
 public void shouldMapCallDate() {
   assertEquals(callLog.getStartTime().toDate(), messagesRequest.getCallDate());
 }
 @Test
 public void shouldMapPatientDocumentId() {
   assertEquals(callLog.getPatientDocumentId(), messagesRequest.getPatientDocumentId());
 }
 private void setupCallLog() {
   callLog = new CallLog("patientDocumentId");
   callLog.setStartTime(DateUtil.now());
   callLog.setCallDirection(CallDirection.Inbound);
   callLog.setCallEvents(asList(messagesEvent(), endOfCallEvent()));
 }