@Test
  public void testUpdateMsisdnNumberAlreadyInUse() throws Exception {
    Long firstMsisdn = subscriptionHelper.makeNumber();
    Long secondMsisdn = subscriptionHelper.makeNumber();

    // create two child subscriptions with different MSISDNs
    Subscription firstSubscription =
        subscriptionHelper.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now(),
            SubscriptionPackType.CHILD,
            firstMsisdn);
    String firstChildId = "0123456789";
    firstSubscription.getSubscriber().setChild(new MctsChild(firstChildId));
    subscriberDataService.update(firstSubscription.getSubscriber());

    Subscription secondSubscription =
        subscriptionHelper.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now(),
            SubscriptionPackType.CHILD,
            secondMsisdn);
    String secondChildId = "9123456789";
    secondSubscription.getSubscriber().setChild(new MctsChild(secondChildId));
    subscriberDataService.update(secondSubscription.getSubscriber());

    // try to set the second child's MSISDN to the same number as the first child's MSISDN
    Reader reader =
        createUpdateReaderWithHeaders("1," + secondChildId + ",,,,,,,,,,,,," + firstMsisdn);
    mctsBeneficiaryUpdateService.updateBeneficiaryData(reader);

    List<SubscriptionError> errors = subscriptionErrorDataService.findByContactNumber(firstMsisdn);
    assertEquals(1, errors.size());
  }
예제 #2
0
  /*
   *To verify 72Weeks Pack is marked completed after the Service Pack runs for its scheduled duration.
   */
  @Test
  public void verifyFT165() {
    String timestamp = DateTime.now().toString(TIME_FORMATTER);

    int days = sh.pregnancyPack().getWeeks() * 7;
    Subscription sub =
        sh.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now().minusDays(days),
            SubscriptionPackType.PREGNANCY);
    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());
  }
예제 #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());
  }
  @Test
  public void testUpdateDOB() throws Exception {
    createLocationData();

    Long msisdn = subscriptionHelper.makeNumber();
    String childId = "0123456789";
    DateTime originalDOB = DateTime.now();
    DateTime updatedDOB = originalDOB.minusDays(100);

    subscriptionHelper.mksub(
        SubscriptionOrigin.MCTS_IMPORT, originalDOB, SubscriptionPackType.CHILD, msisdn);
    Subscriber subscriber = subscriberDataService.findByCallingNumber(msisdn);
    subscriber.setDateOfBirth(originalDOB);
    MctsChild child = new MctsChild(childId);
    child.setState(stateDataService.findByCode(21L));
    child.setDistrict(districtService.findByStateAndCode(child.getState(), 3L));
    subscriber.setChild(child);
    subscriberDataService.update(subscriber);

    // this updates the db with the new data (DOB)
    Reader reader =
        createUpdateReaderWithHeaders(
            "1," + childId + ",," + getDateString(updatedDOB) + ",,,,,,,,,,,");
    mctsBeneficiaryUpdateService.updateBeneficiaryData(reader);

    // This query should return the updated subscriber information (but it doesn't...causing the
    // assert to fail)
    Subscriber updatedSubscriber = subscriberDataService.findByCallingNumber(msisdn);
    assertEquals(getDateString(updatedDOB), getDateString(updatedSubscriber.getDateOfBirth()));
    Subscription updatedSubscription =
        updatedSubscriber.getActiveAndPendingSubscriptions().iterator().next();
    assertEquals(getDateString(updatedDOB), getDateString(updatedSubscription.getStartDate()));
    assertEquals(SubscriptionStatus.ACTIVE, updatedSubscription.getStatus());
  }
예제 #5
0
  /**
   * To verify that beneficiary(via mcts import) will be deactivated if he/she has MSISDN number
   * added to the DND database.
   */
  @Test
  public void verifyFT177() {

    Subscription subscription =
        sh.mksub(SubscriptionOrigin.MCTS_IMPORT, DateTime.now().minusDays(14));

    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.REJECTED,
            makeStatsMap(StatusCode.OBD_DNIS_IN_DND, 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 created via MCTS-import is still Deactivated with reason "do not
    // disturb"
    subscription = subscriptionDataService.findBySubscriptionId(subscription.getSubscriptionId());
    assertEquals(SubscriptionStatus.DEACTIVATED, subscription.getStatus());
    assertEquals(DeactivationReason.DO_NOT_DISTURB, subscription.getDeactivationReason());
  }
예제 #6
0
  /*
   * NMS_FT_163
   * To verify pregnancyPack Pack created via IVR, shouldn't get deactivated due to reason DND.
   */
  @Test
  public void verifyFT163() {

    Subscription subscription2 = sh.mksub(SubscriptionOrigin.IVR, DateTime.now().minusDays(14));

    CallSummaryRecordDto csr =
        new CallSummaryRecordDto(
            new RequestId(subscription2.getSubscriptionId(), "11112233445566"),
            subscription2.getSubscriber().getCallingNumber(),
            sh.getContentMessageFile(subscription2, 0),
            sh.getWeekId(subscription2, 0),
            rh.hindiLanguage().getCode(),
            rh.delhiCircle().getName(),
            FinalCallStatus.REJECTED,
            makeStatsMap(StatusCode.OBD_DNIS_IN_DND, 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 created via IVR is still Active
    subscription2 = subscriptionDataService.findBySubscriptionId(subscription2.getSubscriptionId());
    assertEquals(SubscriptionStatus.ACTIVE, subscription2.getStatus());
  }
  @Test
  public void testUpdateLMP() throws Exception {
    createLocationData();

    Long msisdn = subscriptionHelper.makeNumber();
    String motherId = "0123456789";
    DateTime originalLMP = DateTime.now().minusDays(100);
    DateTime updatedLMP = originalLMP.minusDays(200);

    subscriptionHelper.mksub(
        SubscriptionOrigin.MCTS_IMPORT, originalLMP, SubscriptionPackType.PREGNANCY, msisdn);
    Subscriber subscriber = subscriberDataService.findByCallingNumber(msisdn);
    subscriber.setLastMenstrualPeriod(originalLMP);
    MctsMother mother = new MctsMother(motherId);
    mother.setState(stateDataService.findByCode(21L));
    mother.setDistrict(districtService.findByStateAndCode(mother.getState(), 3L));
    subscriber.setMother(mother);
    subscriberDataService.update(subscriber);

    Reader reader =
        createUpdateReaderWithHeaders(
            "1," + motherId + ",,," + getDateString(updatedLMP) + ",,,,,,,,,,");
    mctsBeneficiaryUpdateService.updateBeneficiaryData(reader);

    Subscriber updatedSubscriber = subscriberDataService.findByCallingNumber(msisdn);
    assertEquals(
        getDateString(updatedLMP), getDateString(updatedSubscriber.getLastMenstrualPeriod()));
    Subscription updatedSubscription =
        updatedSubscriber.getActiveAndPendingSubscriptions().iterator().next();
    assertEquals(
        getDateString(updatedLMP.plusDays(90)), getDateString(updatedSubscription.getStartDate()));
    assertEquals(SubscriptionStatus.ACTIVE, updatedSubscription.getStatus());
  }
  @Test
  public void testUpdateMsisdnForSubscriberWithBothPacks() throws Exception {
    Long oldMsisdn = subscriptionHelper.makeNumber();
    Long newMsisdn = subscriptionHelper.makeNumber();

    Subscription childSubscription =
        subscriptionHelper.mksub(
            SubscriptionOrigin.MCTS_IMPORT, DateTime.now(), SubscriptionPackType.CHILD, oldMsisdn);
    String childId = "0123456789";
    childSubscription.getSubscriber().setChild(new MctsChild(childId));
    subscriberDataService.update(childSubscription.getSubscriber());

    Subscription pregnancySubscription =
        subscriptionHelper.mksub(
            SubscriptionOrigin.MCTS_IMPORT,
            DateTime.now().minusDays(150),
            SubscriptionPackType.PREGNANCY,
            oldMsisdn);
    String motherId = "9876543210";
    pregnancySubscription.getSubscriber().setMother(new MctsMother(motherId));
    subscriberDataService.update(pregnancySubscription.getSubscriber());

    assertEquals(
        2,
        subscriberDataService
            .findByCallingNumber(oldMsisdn)
            .getActiveAndPendingSubscriptions()
            .size());

    Reader reader = createUpdateReaderWithHeaders("1," + motherId + ",,,,,,,,,,,,," + newMsisdn);
    mctsBeneficiaryUpdateService.updateBeneficiaryData(reader);

    Subscriber pregnancySubscriber = subscriberDataService.findByCallingNumber(newMsisdn);
    Subscriber childSubscriber = subscriberDataService.findByCallingNumber(oldMsisdn);

    assertNotNull(pregnancySubscriber);
    assertNotNull(childSubscriber);
    assertNotEquals(childSubscriber, pregnancySubscriber);
    assertEquals(newMsisdn, pregnancySubscriber.getCallingNumber());
    assertEquals(oldMsisdn, childSubscriber.getCallingNumber());
    assertNull(pregnancySubscriber.getChild());
    assertNull(childSubscriber.getMother());
    assertEquals(1, pregnancySubscriber.getActiveAndPendingSubscriptions().size());
    assertEquals(1, childSubscriber.getActiveAndPendingSubscriptions().size());
  }
예제 #9
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());
  }
예제 #10
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());
  }
예제 #11
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());
  }
예제 #12
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());
  }
 private void makeMctsSubscription(
     MctsBeneficiary beneficiary, DateTime startDate, SubscriptionPackType packType, Long number) {
   subscriptionHelper.mksub(SubscriptionOrigin.MCTS_IMPORT, startDate, packType, number);
   Subscriber subscriber = subscriberDataService.findByCallingNumber(number);
   if (packType == SubscriptionPackType.CHILD) {
     subscriber.setChild((MctsChild) beneficiary);
     subscriber.setDateOfBirth(startDate);
   } else {
     subscriber.setMother((MctsMother) beneficiary);
     subscriber.setLastMenstrualPeriod(startDate.minusDays(90));
   }
   subscriberDataService.update(subscriber);
 }
예제 #14
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());
  }
예제 #15
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);
  }
예제 #16
0
  @Test
  public void verifyServiceFunctional() {
    Subscription subscription = sh.mksub(SubscriptionOrigin.IVR, DateTime.now().minusDays(14));

    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);
  }
예제 #17
0
  @Test
  public void verifyFT149() {

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

    // To check that NMS shall not retry the OBD messages which failed due to user number in dnd.

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

    Map<Integer, Integer> callStats = new HashMap<>();
    callStats.put(StatusCode.OBD_DNIS_IN_DND.getValue(), 1);
    CallSummaryRecordDto record =
        new CallSummaryRecordDto(
            new RequestId(subscription.getSubscriptionId(), timestamp),
            subscription.getSubscriber().getCallingNumber(),
            contentFileName,
            "XXX",
            "XXX",
            "XX",
            FinalCallStatus.REJECTED,
            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 no calls to retry since the one above was the last rejected with DND reason
    assertEquals(0, callRetryDataService.count());
    subscription = subscriptionService.getSubscription(subscription.getSubscriptionId());
    assertTrue(SubscriptionStatus.DEACTIVATED == subscription.getStatus());
  }
  @Test
  public void testUpdateMsisdn() throws Exception {
    Long oldMsisdn = subscriptionHelper.makeNumber();
    Long newMsisdn = subscriptionHelper.makeNumber();

    Subscription subscription =
        subscriptionHelper.mksub(
            SubscriptionOrigin.MCTS_IMPORT, DateTime.now(), SubscriptionPackType.CHILD, oldMsisdn);
    String mctsId = "0123456789";

    subscription.getSubscriber().setChild(new MctsChild(mctsId));
    subscriberDataService.update(subscription.getSubscriber());

    Reader reader = createUpdateReaderWithHeaders("1," + mctsId + ",,,,,,,,,,,,," + newMsisdn);
    mctsBeneficiaryUpdateService.updateBeneficiaryData(reader);

    Subscriber oldSubscriber = subscriberDataService.findByCallingNumber(oldMsisdn);
    assertNull(oldSubscriber.getChild());
    assertEquals(0, oldSubscriber.getActiveAndPendingSubscriptions().size());

    Subscriber subscriber = subscriberDataService.findByCallingNumber(newMsisdn);
    assertNotNull(subscriber);
    assertEquals(mctsId, subscriber.getChild().getBeneficiaryId());
  }
예제 #19
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());
  }