Beispiel #1
0
  @Test
  public void verifyFT144() {

    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    // To check that NMS shall retry the OBD messages which failed as IVR did not attempt OBD for
    // those messages.

    Subscription subscription =
        sh.mksub(SubscriptionOrigin.MCTS_IMPORT, DateTime.now(), SubscriptionPackType.CHILD);
    String contentFileName = sh.getContentMessageFile(subscription, 0);
    CallRetry retry =
        callRetryDataService.create(
            new CallRetry(
                subscription.getSubscriptionId(),
                subscription.getSubscriber().getCallingNumber(),
                DayOfTheWeek.today(),
                CallStage.RETRY_1,
                contentFileName,
                "XXX",
                "XXX",
                "XX",
                SubscriptionOrigin.MCTS_IMPORT));

    Map<Integer, Integer> callStats = new HashMap<>();
    callStats.put(StatusCode.OBD_FAILED_NOATTEMPT.getValue(), 1);
    CallSummaryRecordDto record =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), timestamp),
            subscription.getSubscriber().getCallingNumber(),
            contentFileName,
            "XXX",
            "XXX",
            "XX",
            FinalCallStatus.FAILED,
            callStats,
            0,
            1);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, record);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // There should be one calls to retry since the one above was the last failed with No attempt
    assertEquals(1, callRetryDataService.count());

    List<CallRetry> retries = callRetryDataService.retrieveAll();

    assertEquals(subscription.getSubscriptionId(), retries.get(0).getSubscriptionId());
    assertEquals(CallStage.RETRY_2, retries.get(0).getCallStage());
    assertEquals(DayOfTheWeek.today().nextDay(), retries.get(0).getDayOfTheWeek());
  }
Beispiel #2
0
  /**
   * To check that NMS shall retry OBD message for which second OBD retry fails with single message
   * per week configuration.
   */
  @Test
  public void verifyFT139() {
    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    // Create a record in the CallRetry table marked as "retry_2" and verify it is updated as
    // "retry_last" in
    // CallRetry table

    Subscription subscription =
        sh.mksub(SubscriptionOrigin.MCTS_IMPORT, DateTime.now().minusDays(3));
    String contentFileName = sh.getContentMessageFile(subscription, 0);
    CallRetry retry =
        callRetryDataService.create(
            new CallRetry(
                subscription.getSubscriptionId(),
                subscription.getSubscriber().getCallingNumber(),
                DayOfTheWeek.today(),
                CallStage.RETRY_2,
                contentFileName,
                "XXX",
                "XXX",
                "XX",
                SubscriptionOrigin.MCTS_IMPORT));

    Map<Integer, Integer> callStats = new HashMap<>();
    CallSummaryRecordDto record =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), timestamp),
            subscription.getSubscriber().getCallingNumber(),
            contentFileName,
            "XXX",
            "XXX",
            "XX",
            FinalCallStatus.FAILED,
            callStats,
            0,
            5);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, record);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // There should be one calls to retry since the retry 2 was failed.
    assertEquals(1, callRetryDataService.count());

    List<CallRetry> retries = callRetryDataService.retrieveAll();

    assertEquals(subscription.getSubscriptionId(), retries.get(0).getSubscriptionId());
    assertEquals(CallStage.RETRY_LAST, retries.get(0).getCallStage());
    assertEquals(DayOfTheWeek.today().nextDay(), retries.get(0).getDayOfTheWeek());
  }
Beispiel #3
0
  /**
   * To verify that pregnancyPack beneficiary should not be deactivated if the error “user number
   * does not exist” is not received for all failed delivery attempts during a scheduling period for
   * a message.
   */
  @Test
  public void verifyFT189() {

    Subscription subscription =
        sh.mksub(SubscriptionOrigin.MCTS_IMPORT, DateTime.now(), SubscriptionPackType.PREGNANCY);

    CallSummaryRecordDto csr =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), "11112233445566"),
            subscription.getSubscriber().getCallingNumber(),
            sh.getContentMessageFile(subscription, 0),
            sh.getWeekId(subscription, 0),
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_SWITCHEDOFF, 3),
            0,
            3);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, csr);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // verify that subscription is still Active
    subscription = subscriptionDataService.findBySubscriptionId(subscription.getSubscriptionId());
    assertEquals(SubscriptionStatus.ACTIVE, subscription.getStatus());

    // verify that call is rescheduled for next retry.
    assertEquals(1, callRetryDataService.count());

    List<CallRetry> retries = callRetryDataService.retrieveAll();

    assertEquals(subscription.getSubscriptionId(), retries.get(0).getSubscriptionId());
    assertEquals(CallStage.RETRY_1, retries.get(0).getCallStage());
    assertEquals(DayOfTheWeek.today().nextDay(), retries.get(0).getDayOfTheWeek());

    csr =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), "11112233445566"),
            subscription.getSubscriber().getCallingNumber(),
            sh.getContentMessageFile(subscription, 0),
            sh.getWeekId(subscription, 0),
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_INVALIDNUMBER, 3),
            0,
            3);

    eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, csr);
    motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // verify that subscription is still Active, it is not deactivated because call was not failed
    // due to invalid number for all retries.
    subscription = subscriptionDataService.findBySubscriptionId(subscription.getSubscriptionId());
    assertEquals(SubscriptionStatus.ACTIVE, subscription.getStatus());
  }
Beispiel #4
0
  @Test
  public void verifyFT141() {

    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    // To check that NMS shall retry OBD message for which delivery fails for the first time with
    // two message per
    // week configuration.

    Subscription subscription =
        sh.mksub(SubscriptionOrigin.MCTS_IMPORT, DateTime.now(), SubscriptionPackType.PREGNANCY);
    String contentFileName = sh.getContentMessageFile(subscription, 0);

    csrDataService.create(
        new CallSummaryRecord(
            new RequestId(subscription.getSubscriptionId(), "11112233445566").toString(),
            subscription.getSubscriber().getCallingNumber(),
            "w1_1.wav",
            "w1_1",
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_BUSY, 1),
            0,
            10,
            3));
    Map<Integer, Integer> callStats = new HashMap<>();
    callStats.put(StatusCode.OBD_FAILED_BUSY.getValue(), 1);
    CallSummaryRecordDto record =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), timestamp),
            subscription.getSubscriber().getCallingNumber(),
            contentFileName,
            "XXX",
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            callStats,
            0,
            3);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, record);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    assertEquals(1, callRetryDataService.count());

    List<CallRetry> retries = callRetryDataService.retrieveAll();

    assertEquals(subscription.getSubscriptionId(), retries.get(0).getSubscriptionId());
    assertEquals(CallStage.RETRY_1, retries.get(0).getCallStage());
    assertEquals(DayOfTheWeek.today().nextDay(), retries.get(0).getDayOfTheWeek());
  }
Beispiel #5
0
  // Deactivate if user phone number does not exist
  // https://github.com/motech-implementations/mim/issues/169
  @Test
  public void verifyIssue169() {
    Subscription subscription = sh.mksub(SubscriptionOrigin.IVR, DateTime.now().minusDays(14));
    Subscriber subscriber = subscription.getSubscriber();

    csrDataService.create(
        new CallSummaryRecord(
            new RequestId(subscription.getSubscriptionId(), "11112233445566").toString(),
            subscription.getSubscriber().getCallingNumber(),
            "w1_1.wav",
            "w1_1",
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_INVALIDNUMBER, 10),
            0,
            10,
            3));

    callRetryDataService.create(
        new CallRetry(
            subscription.getSubscriptionId(),
            subscription.getSubscriber().getCallingNumber(),
            DayOfTheWeek.today(),
            CallStage.RETRY_LAST,
            "w1_1.wav",
            "w1_1",
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            SubscriptionOrigin.MCTS_IMPORT));

    CallSummaryRecordDto csr =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), "11112233445566"),
            subscription.getSubscriber().getCallingNumber(),
            "w1_1.wav",
            "w1_1",
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_INVALIDNUMBER, 3),
            0,
            3);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, csr);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    subscription = subscriptionDataService.findBySubscriptionId(subscription.getSubscriptionId());
    assertEquals(SubscriptionStatus.DEACTIVATED, subscription.getStatus());
    assertEquals(DeactivationReason.INVALID_NUMBER, subscription.getDeactivationReason());
  }
Beispiel #6
0
  /**
   * To check that NMS shall not retry OBD message for which all OBD attempts(1 actual+1 retry)
   * fails with two message per week configuration.
   */
  @Test
  public void verifyFT142() {

    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    // Create a record in the CallRetry table marked as "retry 1" and verify it is erased from the
    // CallRetry table

    Subscription subscription =
        sh.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now().minusDays(3),
            SubscriptionPackType.PREGNANCY);
    String contentFileName = sh.getContentMessageFile(subscription, 0);
    CallRetry retry =
        callRetryDataService.create(
            new CallRetry(
                subscription.getSubscriptionId(),
                subscription.getSubscriber().getCallingNumber(),
                DayOfTheWeek.today(),
                CallStage.RETRY_1,
                contentFileName,
                "XXX",
                "XXX",
                "XX",
                SubscriptionOrigin.MCTS_IMPORT));

    Map<Integer, Integer> callStats = new HashMap<>();
    CallSummaryRecordDto record =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), timestamp),
            subscription.getSubscriber().getCallingNumber(),
            contentFileName,
            "XXX",
            "XXX",
            "XX",
            FinalCallStatus.FAILED,
            callStats,
            0,
            5);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, record);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // There should be no calls to retry since the one above was the last try
    assertEquals(0, callRetryDataService.count());
  }
Beispiel #7
0
  /*
   * To verify 48Weeks Pack is marked completed after the Service Pack runs for its scheduled
   * duration including one retry.
   */
  @Test
  public void verifyFT168() {
    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    int days = sh.childPack().getWeeks() * 7;
    Subscription sub =
        sh.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now().minusDays(days),
            SubscriptionPackType.CHILD);

    callRetryDataService.create(
        new CallRetry(
            sub.getSubscriptionId(),
            sub.getSubscriber().getCallingNumber(),
            DayOfTheWeek.today(),
            CallStage.RETRY_1,
            "w48_1.wav",
            "w48_1",
            "XXX",
            "XX",
            SubscriptionOrigin.MCTS_IMPORT));

    int index = sh.getLastMessageIndex(sub);
    CallSummaryRecordDto r =
        new CallSummaryRecordDto(
            new RequestId(sub.getSubscriptionId(), timestamp),
            sub.getSubscriber().getCallingNumber(),
            sh.getContentMessageFile(sub, index),
            sh.getWeekId(sub, index),
            rh.hindiLanguage().getCode(),
            sh.getCircle(sub),
            FinalCallStatus.SUCCESS,
            makeStatsMap(StatusCode.OBD_SUCCESS_CALL_CONNECTED, 1),
            120,
            1);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, r);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);
    sub = subscriptionDataService.findBySubscriptionId(sub.getSubscriptionId());
    assertTrue(SubscriptionStatus.COMPLETED == sub.getStatus());

    // verify call retry entry is also deleted from the database
    CallRetry retry = callRetryDataService.findBySubscriptionId(sub.getSubscriptionId());
    assertNull(retry);
  }
Beispiel #8
0
  /*
   * To verify that childPack Subscription should not be marked completed after just first retry.
   */
  @Test
  public void verifyFT187() {
    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    SubscriptionHelper sh =
        new SubscriptionHelper(
            subscriptionService,
            subscriberDataService,
            subscriptionPackDataService,
            languageDataService,
            circleDataService,
            stateDataService,
            districtDataService,
            districtService);

    int days = sh.childPack().getWeeks() * 7;
    Subscription sub =
        sh.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now().minusDays(days),
            SubscriptionPackType.CHILD);

    callRetryDataService.create(
        new CallRetry(
            sub.getSubscriptionId(),
            sub.getSubscriber().getCallingNumber(),
            DayOfTheWeek.today(),
            CallStage.RETRY_1,
            "w48_1.wav",
            "w48_1",
            "XXX",
            "XX",
            SubscriptionOrigin.MCTS_IMPORT));

    int index = sh.getLastMessageIndex(sub);
    CallSummaryRecordDto r =
        new CallSummaryRecordDto(
            new RequestId(sub.getSubscriptionId(), timestamp),
            sub.getSubscriber().getCallingNumber(),
            sh.getContentMessageFile(sub, index),
            sh.getWeekId(sub, index),
            sh.getLanguageCode(sub),
            sh.getCircle(sub),
            FinalCallStatus.FAILED,
            makeStatsMap(StatusCode.OBD_FAILED_SWITCHEDOFF, 10),
            120,
            1);

    Map<String, Object> eventParams = new HashMap<>();
    eventParams.put(CSR_PARAM_KEY, r);
    MotechEvent motechEvent = new MotechEvent(PROCESS_SUMMARY_RECORD_SUBJECT, eventParams);
    csrService.processCallSummaryRecord(motechEvent);

    // There should be one calls to retry since the retry 2 was failed.
    assertEquals(1, callRetryDataService.count());

    List<CallRetry> retries = callRetryDataService.retrieveAll();

    assertEquals(sub.getSubscriptionId(), retries.get(0).getSubscriptionId());
    assertEquals(CallStage.RETRY_2, retries.get(0).getCallStage());
    assertEquals(DayOfTheWeek.today().nextDay(), retries.get(0).getDayOfTheWeek());

    // verify that subscription is still Active, as last message was not delivered successfully and
    // retries
    // are left
    sub = subscriptionDataService.findBySubscriptionId(sub.getSubscriptionId());
    assertEquals(SubscriptionStatus.ACTIVE, sub.getStatus());
  }