Пример #1
0
  @Before
  public void doTheNeedful() {

    testingService.clearDatabase();

    rh =
        new RegionHelper(
            languageDataService,
            circleDataService,
            stateDataService,
            districtDataService,
            districtService);

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

    sh.childPack();
    sh.pregnancyPack();
    csrService.buildMessageDurationCache();
  }
Пример #2
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);
  }
  @Before
  public void setUp() {
    testingService.clearDatabase();

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

    subscriptionHelper.pregnancyPack();
    subscriptionHelper.childPack();
  }
Пример #4
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());
  }