@Test
 public void completionOfSymptomReportingTreeOrPreviousDosageReminderTreeShouldCompleteTheTrees() {
   tamaIVRContext.callDirection(CallDirection.Inbound);
   when(treeRegistry.isLeafTree(TAMATreeRegistry.REGIMEN_1_TO_6)).thenReturn(true);
   tamaCallFlowController.treeComplete(TAMATreeRegistry.REGIMEN_1_TO_6, kooKooIVRContext);
   assertEquals(CallState.ALL_TREES_COMPLETED, tamaIVRContext.callState());
 }
 @Test
 public void menuRepeatURLShouldBeReturnedAfterPushOfMessages() {
   tamaIVRContext.callState(CallState.PUSH_MESSAGES_COMPLETE);
   String patientId = "1234";
   tamaIVRContext.patientDocumentId(patientId);
   assertEquals(ControllerURLs.MENU_REPEAT, tamaCallFlowController.urlFor(kooKooIVRContext));
 }
  @Test
  public void shouldTransitionToMenuRepeatWhenCallStateIs_EndOfFlow() {
    tamaIVRContext.callState(CallState.PUSH_MESSAGES_COMPLETE);
    tamaIVRContext.callDirection(CallDirection.Outbound);

    assertEquals(ControllerURLs.MENU_REPEAT, tamaCallFlowController.urlFor(kooKooIVRContext));
  }
  @Test
  public void shouldResetContextWhenRequested() {
    context.callState(CallState.ALL_TREES_COMPLETED);
    CallStateCommand callStateCommand = new CallStateCommand(tamaivrContextFactory);
    callStateCommand.execute(kooKooIVRContext);

    verify(cookies).add(TAMAIVRContext.DO_NOT_PROMPT_FOR_HANG_UP, "true");
    assertEquals(CallState.MAIN_MENU, context.callState());
  }
 @Test
 public void
     whenCurrentDosageIsConfirmedAndWhenPreviousDosageHasBeenCaptured_AllTreesAreCompleted() {
   tamaIVRContext.callDirection(CallDirection.Outbound);
   tamaIVRContext.callState(CallState.AUTHENTICATED);
   when(pillModuleStrategy.previousDosageCaptured(tamaIVRContext)).thenReturn(true);
   tamaCallFlowController.treeComplete(TAMATreeRegistry.CURRENT_DOSAGE_CONFIRM, kooKooIVRContext);
   assertEquals(CallState.ALL_TREES_COMPLETED, tamaIVRContext.callState());
 }
  @Test
  public void shouldReturnSymptomReportingTreeBasedOnCallState() {
    tamaIVRContext.callState(CallState.SYMPTOM_REPORTING_TREE);
    String symptomReportingTreeName = "Regimen1_1";
    tamaIVRContext.symptomReportingTree(symptomReportingTreeName);

    tamaCallFlowController.getTree(TAMATreeRegistry.REGIMEN_1_TO_6, kooKooIVRContext);

    verify(symptomModuleStrategy).getTree("Regimen_1_To_6", tamaIVRContext);
  }
  @Test
  public void shouldTransitionToCurrentDosageReminderTreeForPatientOnDailyPillReminder() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.DailyPillReminder)
                .build());
    tamaIVRContext.callDirection(CallDirection.Outbound);

    assertEquals(
        TAMATreeRegistry.CURRENT_DOSAGE_REMINDER,
        tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldNotRepeatOutboxCallTreeMoreThanOnceDuringOutboxCall() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.DailyPillReminder)
                .build());
    tamaIVRContext.addLastCompletedTreeToListOfCompletedTrees(TAMATreeRegistry.OUTBOX_CALL);
    tamaIVRContext.callDirection(CallDirection.Outbound);

    assertEquals(
        TAMATreeRegistry.MENU_TREE, tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldTransitionToMenuTreeOnceFourDayRecallTreeIsPlayed() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.FourDayRecall)
                .build());
    tamaIVRContext.addLastCompletedTreeToListOfCompletedTrees(TAMATreeRegistry.FOUR_DAY_RECALL);
    tamaIVRContext.callDirection(CallDirection.Outbound);

    assertEquals(
        TAMATreeRegistry.MENU_TREE, tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldNotTransitionToCurrentDosageReminderTreeIsPlayed_AndUserEntersWillTakeLater() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.DailyPillReminder)
                .build());
    tamaIVRContext.addLastCompletedTreeToListOfCompletedTrees(
        TAMATreeRegistry.CURRENT_DOSAGE_REMINDER);
    tamaIVRContext.callDirection(CallDirection.Outbound);

    assertEquals(
        TAMATreeRegistry.MENU_TREE, tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldReturnFourDayRecallIncomingTreeWhenPatientIsSuspendedButOnWeeklyAdherence() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withStatus(Status.Suspended)
                .withCallPreference(CallPreference.FourDayRecall)
                .build());
    tamaIVRContext.callDirection(CallDirection.Inbound);

    assertEquals(
        TAMATreeRegistry.FOUR_DAY_RECALL_INCOMING_CALL,
        tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldReturnMenuTreeWhenPatientIsSuspendedAndIsOnDailyPillReminder() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    when(allPatients.get(null))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.DailyPillReminder)
                .withStatus(Status.Suspended)
                .build());
    tamaIVRContext.callDirection(CallDirection.Inbound);

    assertEquals(
        TAMATreeRegistry.INCOMING_MENU_TREE,
        tamaCallFlowController.decisionTreeName(kooKooIVRContext));
  }
  @Test
  public void shouldReturnPullMessagesTreeWhenCallStateIsPullMessages() {
    tamaIVRContext.callState(CallState.PULL_MESSAGES_TREE);
    tamaIVRContext.callDirection(CallDirection.Inbound);
    tamaIVRContext.lastCompletedTree(TAMATreeRegistry.CURRENT_DOSAGE_CONFIRM);

    when(allPatients.get(anyString()))
        .thenReturn(
            PatientBuilder.startRecording()
                .withDefaults()
                .withCallPreference(CallPreference.DailyPillReminder)
                .build());

    String treeName = tamaCallFlowController.decisionTreeName(kooKooIVRContext);
    assertEquals(TAMATreeRegistry.PULL_MESSAGES_TREE, treeName);
  }
  @Test
  public void shouldReturnDecisionTree() {
    tamaIVRContext.callState(CallState.AUTHENTICATED);
    tamaCallFlowController.getTree(TAMATreeRegistry.CURRENT_DOSAGE_REMINDER, kooKooIVRContext);

    verify(treeRegistry).getTree(TAMATreeRegistry.CURRENT_DOSAGE_REMINDER);
  }
Example #15
0
 @Test
 public void updateIVRContextOnExecute() {
   CallStateCommand callStateCommand =
       new CallStateCommand(CallState.ALL_TREES_COMPLETED, tamaivrContextFactory);
   callStateCommand.execute(kooKooIVRContext);
   assertEquals(CallState.ALL_TREES_COMPLETED, context.callState());
 }
  @Test
  public void outboxURLShouldBeReturnedWhenTheDecisionTreesAreComplete() {
    tamaIVRContext.callState(CallState.ALL_TREES_COMPLETED);
    tamaIVRContext.callDirection(CallDirection.Outbound);
    String patientId = "1234";
    tamaIVRContext.patientDocumentId(patientId);

    Patient patient =
        PatientBuilder.startRecording()
            .withDefaults()
            .withId(patientId)
            .withCallPreference(CallPreference.DailyPillReminder)
            .build();
    when(allPatients.get(patientId)).thenReturn(patient);

    assertEquals(ControllerURLs.PUSH_MESSAGES_URL, tamaCallFlowController.urlFor(kooKooIVRContext));
  }
  @Before
  public void setUp() {
    initMocks(this);

    ivrContext = new TAMAIVRContextForTest().patientDocumentId("patientDocId");

    Patient patient =
        PatientBuilder.startRecording()
            .withDefaults()
            .withId(ivrContext.patientDocumentId())
            .build();

    when(allPatients.get(ivrContext.patientDocumentId())).thenReturn(patient);
    when(clinicMessageBuilder.getInboundMessage(any(Clinic.class), any(IVRLanguage.class)))
        .thenReturn(EXPECTED_WELCOME_MESSAGE);

    incomingWelcomeMessage =
        new IncomingWelcomeMessage(allPatients, allClinics, clinicMessageBuilder);
  }
 @Test
 public void shouldNotPlayClinicGreetingMessageIfAnyTreeWasTraversed() {
   ivrContext.hasTraversedAnyTree(true);
   assertTrue(ArrayUtils.isEmpty(incomingWelcomeMessage.executeCommand(ivrContext)));
 }
 @Test
 public void shouldPlayClinicGreetingMessageIfNoTreeHasBeenTraversed() {
   ivrContext.hasTraversedAnyTree(false);
   assertArrayEquals(
       new String[] {EXPECTED_WELCOME_MESSAGE}, incomingWelcomeMessage.executeCommand(ivrContext));
 }
 @Test
 public void dialPromptsShouldLeadToDialURL() {
   tamaIVRContext.callState(CallState.ALL_TREES_COMPLETED);
   tamaIVRContext.isDialState(true);
   assertEquals(ControllerURLs.DIAL_URL, tamaCallFlowController.urlFor(kooKooIVRContext));
 }
Example #21
0
 private void setupContext() {
   setupKookooContext();
   context = new TAMAIVRContextForTest(kooKooIVRContext);
   context.callState(CallState.AUTHENTICATED);
   when(tamaivrContextFactory.create(kooKooIVRContext)).thenReturn(context);
 }
 @Test
 public void shouldReturnDecisionTreeURLWhenCallStateIsPullMessages() {
   tamaIVRContext.callState(CallState.PULL_MESSAGES_TREE);
   assertEquals(AllIVRURLs.DECISION_TREE_URL, tamaCallFlowController.urlFor(kooKooIVRContext));
 }
 @Test
 public void returnAuthenticationURLWhenTheCallStarts() {
   tamaIVRContext.callState(CallState.STARTED);
   assertEquals(
       ControllerURLs.AUTHENTICATION_URL, tamaCallFlowController.urlFor(kooKooIVRContext));
 }