@Test
  public void shouldNotSendSmsIfPhoneIsNotSet() throws Exception {
    String motechCaseId = "motechCaseId";
    String phuId = "phuId";

    Map<String, String> motherCaseFieldValues = new HashMap<>();
    motherCaseFieldValues.put(Commcare.PHU_ID, phuId);

    MotechEvent event = new MotechEvent();
    event.getParameters().put(EventKeys.MOTHER_CASE_ID, motechCaseId);

    when(commcareCaseService.getCaseByCaseId(motechCaseId)).thenReturn(motherCase);
    when(motherCase.getFieldValues()).thenReturn(motherCaseFieldValues);

    when(fixtureIdMap.getPhoneForFixture(phuId)).thenReturn(null);

    listener.postPartumMissedVisitHandler(event);

    verify(smsService, never()).send(any(OutgoingSms.class));
  }
  @Test
  public void shouldSendSmsWhenTwoAppointmentsAreMissed() throws Exception {
    String motechCaseId = "motechCaseId";
    String phuId = "phuId";
    String phone = "phone";
    String userId = "userId";
    String firstName = "firstName";
    String lastName = "lastName";

    Map<String, String> motherCaseFieldValues = new HashMap<>();
    motherCaseFieldValues.put(Commcare.PHU_ID, phuId);

    MotechEvent event = new MotechEvent();
    event.getParameters().put(EventKeys.MOTHER_CASE_ID, motechCaseId);

    when(commcareCaseService.getCaseByCaseId(motechCaseId)).thenReturn(motherCase);
    when(motherCase.getFieldValues()).thenReturn(motherCaseFieldValues);
    when(motherCase.getUserId()).thenReturn(userId);

    when(fixtureIdMap.getPhoneForFixture(phuId)).thenReturn(phone);

    when(commcareUserService.getCommcareUserById(userId)).thenReturn(commcareUser);
    when(commcareUser.getFirstName()).thenReturn(firstName);
    when(commcareUser.getLastName()).thenReturn(lastName);

    when(settings.getLanguage()).thenReturn(LANGUAGE);
    when(cmsLiteService.getStringContent(LANGUAGE, POST_PARTUM_VISITS_MESSAGE_NAME))
        .thenReturn(new StringContent(LANGUAGE, POST_PARTUM_VISITS_MESSAGE_NAME, "%s"));

    listener.postPartumMissedVisitHandler(event);

    ArgumentCaptor<OutgoingSms> captor = ArgumentCaptor.forClass(OutgoingSms.class);

    verify(smsService).send(captor.capture());

    OutgoingSms value = captor.getValue();

    assertEquals(asList(phone), value.getRecipients());
    assertEquals(firstName + " " + lastName, value.getMessage());
  }