@Test public void testProcessMessageRetries(){ System.out.println("processMessageRetries"); List<MessageRequest> messageList = new ArrayList<MessageRequest>(); MessageRequest msgReq1 = new MessageRequestImpl(); msgReq1.setDateFrom(new Date()); msgReq1.setDateTo(new Date()); msgReq1.setId(19000000003l); msgReq1.setTryNumber(1); msgReq1.setMessageType(MessageType.TEXT); msgReq1.setRecipientName("Tester"); msgReq1.setRecipientNumber("000000000000"); msgReq1.setStatus(MStatus.QUEUED); messageList.add(msgReq1); GatewayRequestDetails details = new GatewayRequestDetailsImpl(); details.setId(19000000004l); details.setMessage("Some message"); details.setMessageType(MessageType.TEXT); details.setNumberOfPages(1); details.setGatewayRequests(new HashSet()); msgReq1.setGatewayRequestDetails(details); expect( mockCore.createMessageRequestDAO() ).andReturn(mockRequestDao); expect( mockRequestDao.getMsgRequestByStatusAndTryNumber((MStatus) anyObject(), anyInt()) ).andReturn(messageList); replay(mockCore, mockRequestDao); instance.processMessageRetries(); verify(mockCore, mockRequestDao); }
@Transactional(readOnly = true) public void processMessageRetries() { MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); List<MessageRequest> messages = msgReqDao.getMsgRequestByStatusAndTryNumber(MStatus.RETRY, maxTries); if (messages == null || messages.isEmpty()) { logger.info("No message request to retry"); return; } logger.info("Fetched " + messages.size() + " message requests for retry"); logger.info("Processing messages..."); for (MessageRequest message : messages) { try { processMessageRetry(message); } catch (Exception e) { logger.error("Error while retrying message requests: ", e); } } logger.info("Messages processed successfully"); }
OMIServiceImpl implements OMIService { @Transactional(readOnly = true) public void processMessageRetries() { MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); List<MessageRequest> messages = msgReqDao.getMsgRequestByStatusAndTryNumber(MStatus.RETRY, maxTries); if (messages == null || messages.isEmpty()) { logger.info("No message request to retry"); return; } logger.info("Fetched " + messages.size() + " message requests for retry"); logger.info("Processing messages..."); for (MessageRequest message : messages) { try { processMessageRetry(message); } catch (Exception e) { logger.error("Error while retrying message requests: ", e); } } logger.info("Messages processed successfully"); } }
OMIServiceImpl implements OMIService { @Transactional(readOnly = true) public void processMessageRetries() { MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); List<MessageRequest> messages = msgReqDao.getMsgRequestByStatusAndTryNumber(MStatus.RETRY, maxTries); if (messages == null || messages.isEmpty()) { logger.info("No message request to retry"); return; } logger.info("Fetched " + messages.size() + " message requests for retry"); logger.info("Processing messages..."); for (MessageRequest message : messages) { try { processMessageRetry(message); } catch (Exception e) { logger.error("Error while retrying message requests: ", e); } } logger.info("Messages processed successfully"); } OMIServiceImpl(); }
OMIServiceImpl implements OMIService { @Transactional(readOnly = true) public void processMessageRetries() { MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); List<MessageRequest> messages = msgReqDao.getMsgRequestByStatusAndTryNumber(MStatus.RETRY, maxTries); if (messages == null || messages.isEmpty()) { logger.info("No message request to retry"); return; } logger.info("Fetched " + messages.size() + " message requests for retry"); logger.info("Processing messages..."); for (MessageRequest message : messages) { try { processMessageRetry(message); } catch (Exception e) { logger.error("Error while retrying message requests: ", e); } } logger.info("Messages processed successfully"); } OMIServiceImpl(); MessageStatus savePatientMessageRequest(String messageId,
                                                   NameValuePair[] personalInfo,
                                                   String patientNumber,
                                                   ContactNumberType patientNumberType,
                                                   String langCode,
                                                   MediaType mediaType,
                                                   Long notificationType,
                                                   Date startDate,
                                                   Date endDate,
                                                   String recipientId); MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate); MessageStatus sendMessage(MessageRequest message); MessageStatus sendMessage(MessageRequest message, String content); MessageStatus sendMessage(String content, String recipient); MessageStatus scheduleMessage(String content, String recipient); MessageStatus scheduleMessage(MessageRequest message, String content); MessageStatus sendDefaulterMessage(String messageId, String workerNumber, Care[] cares,
                                              CareMessageGroupingStrategy groupingStrategy,
                                              MediaType messageType, Date startDate, Date endDate); MessageStatus sendDeliveriesMessage(String messageId, String workerNumber, Patient[] patients, String deliveryStatus, MediaType messageType, Date startDate, Date endDate); MessageStatus sendUpcomingCaresMessage(String messageId, String workerNumber, Patient patient, MediaType messageType, Date startDate, Date endDate); MessageStatus sendBulkCaresMessage(String messageId, String workerNumber, Care[] cares,
                                              CareMessageGroupingStrategy groupingStrategy,
                                              MediaType messageType, Date startDate, Date endDate); @Transactional(readOnly = true) void processMessageRequests(); void processMessageRequest(MessageRequest message, Language defaultLanguage); @Transactional(readOnly = true) void processMessageRetries(); void processMessageRetry(MessageRequest message); @Transactional(readOnly = true) void processMessageResponses(); void processMessageResponse(GatewayResponse response); MessageStoreManager getStoreManager(); void setStoreManager(MessageStoreManager storeManager); OMPManager getOmpManager(); void setOmpManager(OMPManager ompManager); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); StatusHandler getStatHandler(); void setStatHandler(StatusHandler statHandler); String getDefaultLang(); void setDefaultLang(String defaultLang); int getMaxTries(); void setMaxTries(int maxRetries); void setOmiManager(OMIManager omiManager); OMIServiceWorker getWorker(); void setWorker(OMIServiceWorker worker); }
OMIServiceImpl implements OMIService { @Transactional(readOnly = true) public void processMessageRetries() { MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); List<MessageRequest> messages = msgReqDao.getMsgRequestByStatusAndTryNumber(MStatus.RETRY, maxTries); if (messages == null || messages.isEmpty()) { logger.info("No message request to retry"); return; } logger.info("Fetched " + messages.size() + " message requests for retry"); logger.info("Processing messages..."); for (MessageRequest message : messages) { try { processMessageRetry(message); } catch (Exception e) { logger.error("Error while retrying message requests: ", e); } } logger.info("Messages processed successfully"); } OMIServiceImpl(); MessageStatus savePatientMessageRequest(String messageId,
                                                   NameValuePair[] personalInfo,
                                                   String patientNumber,
                                                   ContactNumberType patientNumberType,
                                                   String langCode,
                                                   MediaType mediaType,
                                                   Long notificationType,
                                                   Date startDate,
                                                   Date endDate,
                                                   String recipientId); MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate); MessageStatus sendMessage(MessageRequest message); MessageStatus sendMessage(MessageRequest message, String content); MessageStatus sendMessage(String content, String recipient); MessageStatus scheduleMessage(String content, String recipient); MessageStatus scheduleMessage(MessageRequest message, String content); MessageStatus sendDefaulterMessage(String messageId, String workerNumber, Care[] cares,
                                              CareMessageGroupingStrategy groupingStrategy,
                                              MediaType messageType, Date startDate, Date endDate); MessageStatus sendDeliveriesMessage(String messageId, String workerNumber, Patient[] patients, String deliveryStatus, MediaType messageType, Date startDate, Date endDate); MessageStatus sendUpcomingCaresMessage(String messageId, String workerNumber, Patient patient, MediaType messageType, Date startDate, Date endDate); MessageStatus sendBulkCaresMessage(String messageId, String workerNumber, Care[] cares,
                                              CareMessageGroupingStrategy groupingStrategy,
                                              MediaType messageType, Date startDate, Date endDate); @Transactional(readOnly = true) void processMessageRequests(); void processMessageRequest(MessageRequest message, Language defaultLanguage); @Transactional(readOnly = true) void processMessageRetries(); void processMessageRetry(MessageRequest message); @Transactional(readOnly = true) void processMessageResponses(); void processMessageResponse(GatewayResponse response); MessageStoreManager getStoreManager(); void setStoreManager(MessageStoreManager storeManager); OMPManager getOmpManager(); void setOmpManager(OMPManager ompManager); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); StatusHandler getStatHandler(); void setStatHandler(StatusHandler statHandler); String getDefaultLang(); void setDefaultLang(String defaultLang); int getMaxTries(); void setMaxTries(int maxRetries); void setOmiManager(OMIManager omiManager); OMIServiceWorker getWorker(); void setWorker(OMIServiceWorker worker);  }