@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()); }
// 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()); }