@Test public void testSaveCHPSMessageRequest() { System.out.println("saveCHPSMessage"); String messageId = "tsid17"; String workerNumber = "000000000000"; Patient[] patientList = null; List<Language> langList = new ArrayList<Language>(); langList.add(new LanguageImpl()); NameValuePair[] personalInfo = new NameValuePair[0]; MessageStatus expResult = MessageStatus.QUEUED; Date testDate = new Date(); mockRequestDao = createMock(MessageRequestDAO.class); expect( mockCore.createMessageRequest() ).andReturn(new MessageRequestImpl()); expect( mockCore.createNotificationTypeDAO() ).andReturn(mockNoteDao); expect( mockNoteDao.getById(anyLong()) ).andReturn(new NotificationTypeImpl()); expect( mockCore.createLanguageDAO() ).andReturn(mockLangDao); expect( mockLangDao.getByCode((String)anyObject()) ).andReturn(new LanguageImpl()); expect( mockCore.createMessageRequestDAO() ).andReturn(mockRequestDao); expectLastCall(); expect( mockRequestDao.save((MessageRequest) anyObject()) ).andReturn(new MessageRequestImpl()); expectLastCall(); replay(mockCore, mockLangDao, mockRequestDao); MessageStatus result = instance.saveCHPSMessageRequest(messageId, personalInfo, workerNumber, patientList, "lang", MediaType.TEXT, 1L, testDate, testDate); assertEquals(expResult, result); verify(mockCore, mockLangDao, mockRequestDao); }
public MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate) { logger.info("Constructing MessageDetails object..."); if (workerNumber == null || workerNumber.isEmpty()) { return MessageStatus.REJECTED; } MessageRequest messageRequest = coreManager.createMessageRequest(); NotificationType noteType = getNotificationType(notificationType); Language langObject = coreManager.createLanguageDAO().getByCode(langCode); HashSet<NameValuePair> details = new HashSet<NameValuePair>(); if (personalInfo != null) { details.addAll(Arrays.asList(personalInfo)); } if (patientList != null) { for (Patient p : patientList) { if (p.getPreferredName() != null) { details.add(new NameValuePair("PreferredName", p.getPreferredName())); } if (p.getLastName() != null) { details.add(new NameValuePair("LastName", p.getLastName())); } if (p.getCommunity() != null) { details.add(new NameValuePair("Community", p.getCommunity())); } if (p.getFirstName() != null) { details.add(new NameValuePair("FirstName", p.getFirstName())); } if (p.getMotechId() != null) { details.add(new NameValuePair("MotechId", p.getMotechId())); } if (p.getPhoneNumber() != null) { details.add(new NameValuePair("PhoneNumber", p.getPhoneNumber())); } } } messageRequest.setPersInfos(details); messageRequest.setTryNumber(1); messageRequest.setRequestId(messageId); messageRequest.setDateFrom(startDate); messageRequest.setDateTo(endDate); messageRequest.setRecipientNumber(workerNumber); messageRequest.setNotificationType(noteType); messageRequest.setMessageType(MessageType.valueOf(messageType.toString())); messageRequest.setLanguage(langObject); messageRequest.setStatus(MStatus.QUEUED); messageRequest.setDateCreated(new Date()); logger.info("MessageRequest object successfully constructed"); logger.debug(messageRequest); if (messageRequest.getDateFrom() == null && messageRequest.getDateTo() == null) { return sendMessage(messageRequest); } logger.info("Saving MessageRequest..."); MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); msgReqDao.save(messageRequest); return MessageStatus.valueOf(messageRequest.getStatus().toString()); }
OMIServiceImpl implements OMIService { public MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate) { logger.info("Constructing MessageDetails object..."); if (workerNumber == null || workerNumber.isEmpty()) { return MessageStatus.REJECTED; } MessageRequest messageRequest = coreManager.createMessageRequest(); NotificationType noteType = getNotificationType(notificationType); Language langObject = coreManager.createLanguageDAO().getByCode(langCode); HashSet<NameValuePair> details = new HashSet<NameValuePair>(); if (personalInfo != null) { details.addAll(Arrays.asList(personalInfo)); } if (patientList != null) { for (Patient p : patientList) { if (p.getPreferredName() != null) { details.add(new NameValuePair("PreferredName", p.getPreferredName())); } if (p.getLastName() != null) { details.add(new NameValuePair("LastName", p.getLastName())); } if (p.getCommunity() != null) { details.add(new NameValuePair("Community", p.getCommunity())); } if (p.getFirstName() != null) { details.add(new NameValuePair("FirstName", p.getFirstName())); } if (p.getMotechId() != null) { details.add(new NameValuePair("MotechId", p.getMotechId())); } if (p.getPhoneNumber() != null) { details.add(new NameValuePair("PhoneNumber", p.getPhoneNumber())); } } } messageRequest.setPersInfos(details); messageRequest.setTryNumber(1); messageRequest.setRequestId(messageId); messageRequest.setDateFrom(startDate); messageRequest.setDateTo(endDate); messageRequest.setRecipientNumber(workerNumber); messageRequest.setNotificationType(noteType); messageRequest.setMessageType(MessageType.valueOf(messageType.toString())); messageRequest.setLanguage(langObject); messageRequest.setStatus(MStatus.QUEUED); messageRequest.setDateCreated(new Date()); logger.info("MessageRequest object successfully constructed"); logger.debug(messageRequest); if (messageRequest.getDateFrom() == null && messageRequest.getDateTo() == null) { return sendMessage(messageRequest); } logger.info("Saving MessageRequest..."); MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); msgReqDao.save(messageRequest); return MessageStatus.valueOf(messageRequest.getStatus().toString()); } }
OMIServiceImpl implements OMIService { public MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate) { logger.info("Constructing MessageDetails object..."); if (workerNumber == null || workerNumber.isEmpty()) { return MessageStatus.REJECTED; } MessageRequest messageRequest = coreManager.createMessageRequest(); NotificationType noteType = getNotificationType(notificationType); Language langObject = coreManager.createLanguageDAO().getByCode(langCode); HashSet<NameValuePair> details = new HashSet<NameValuePair>(); if (personalInfo != null) { details.addAll(Arrays.asList(personalInfo)); } if (patientList != null) { for (Patient p : patientList) { if (p.getPreferredName() != null) { details.add(new NameValuePair("PreferredName", p.getPreferredName())); } if (p.getLastName() != null) { details.add(new NameValuePair("LastName", p.getLastName())); } if (p.getCommunity() != null) { details.add(new NameValuePair("Community", p.getCommunity())); } if (p.getFirstName() != null) { details.add(new NameValuePair("FirstName", p.getFirstName())); } if (p.getMotechId() != null) { details.add(new NameValuePair("MotechId", p.getMotechId())); } if (p.getPhoneNumber() != null) { details.add(new NameValuePair("PhoneNumber", p.getPhoneNumber())); } } } messageRequest.setPersInfos(details); messageRequest.setTryNumber(1); messageRequest.setRequestId(messageId); messageRequest.setDateFrom(startDate); messageRequest.setDateTo(endDate); messageRequest.setRecipientNumber(workerNumber); messageRequest.setNotificationType(noteType); messageRequest.setMessageType(MessageType.valueOf(messageType.toString())); messageRequest.setLanguage(langObject); messageRequest.setStatus(MStatus.QUEUED); messageRequest.setDateCreated(new Date()); logger.info("MessageRequest object successfully constructed"); logger.debug(messageRequest); if (messageRequest.getDateFrom() == null && messageRequest.getDateTo() == null) { return sendMessage(messageRequest); } logger.info("Saving MessageRequest..."); MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); msgReqDao.save(messageRequest); return MessageStatus.valueOf(messageRequest.getStatus().toString()); } OMIServiceImpl(); }
OMIServiceImpl implements OMIService { public MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate) { logger.info("Constructing MessageDetails object..."); if (workerNumber == null || workerNumber.isEmpty()) { return MessageStatus.REJECTED; } MessageRequest messageRequest = coreManager.createMessageRequest(); NotificationType noteType = getNotificationType(notificationType); Language langObject = coreManager.createLanguageDAO().getByCode(langCode); HashSet<NameValuePair> details = new HashSet<NameValuePair>(); if (personalInfo != null) { details.addAll(Arrays.asList(personalInfo)); } if (patientList != null) { for (Patient p : patientList) { if (p.getPreferredName() != null) { details.add(new NameValuePair("PreferredName", p.getPreferredName())); } if (p.getLastName() != null) { details.add(new NameValuePair("LastName", p.getLastName())); } if (p.getCommunity() != null) { details.add(new NameValuePair("Community", p.getCommunity())); } if (p.getFirstName() != null) { details.add(new NameValuePair("FirstName", p.getFirstName())); } if (p.getMotechId() != null) { details.add(new NameValuePair("MotechId", p.getMotechId())); } if (p.getPhoneNumber() != null) { details.add(new NameValuePair("PhoneNumber", p.getPhoneNumber())); } } } messageRequest.setPersInfos(details); messageRequest.setTryNumber(1); messageRequest.setRequestId(messageId); messageRequest.setDateFrom(startDate); messageRequest.setDateTo(endDate); messageRequest.setRecipientNumber(workerNumber); messageRequest.setNotificationType(noteType); messageRequest.setMessageType(MessageType.valueOf(messageType.toString())); messageRequest.setLanguage(langObject); messageRequest.setStatus(MStatus.QUEUED); messageRequest.setDateCreated(new Date()); logger.info("MessageRequest object successfully constructed"); logger.debug(messageRequest); if (messageRequest.getDateFrom() == null && messageRequest.getDateTo() == null) { return sendMessage(messageRequest); } logger.info("Saving MessageRequest..."); MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); msgReqDao.save(messageRequest); return MessageStatus.valueOf(messageRequest.getStatus().toString()); } 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 { public MessageStatus saveCHPSMessageRequest(String messageId, NameValuePair[] personalInfo, String workerNumber, Patient[] patientList, String langCode, MediaType messageType, Long notificationType, Date startDate, Date endDate) { logger.info("Constructing MessageDetails object..."); if (workerNumber == null || workerNumber.isEmpty()) { return MessageStatus.REJECTED; } MessageRequest messageRequest = coreManager.createMessageRequest(); NotificationType noteType = getNotificationType(notificationType); Language langObject = coreManager.createLanguageDAO().getByCode(langCode); HashSet<NameValuePair> details = new HashSet<NameValuePair>(); if (personalInfo != null) { details.addAll(Arrays.asList(personalInfo)); } if (patientList != null) { for (Patient p : patientList) { if (p.getPreferredName() != null) { details.add(new NameValuePair("PreferredName", p.getPreferredName())); } if (p.getLastName() != null) { details.add(new NameValuePair("LastName", p.getLastName())); } if (p.getCommunity() != null) { details.add(new NameValuePair("Community", p.getCommunity())); } if (p.getFirstName() != null) { details.add(new NameValuePair("FirstName", p.getFirstName())); } if (p.getMotechId() != null) { details.add(new NameValuePair("MotechId", p.getMotechId())); } if (p.getPhoneNumber() != null) { details.add(new NameValuePair("PhoneNumber", p.getPhoneNumber())); } } } messageRequest.setPersInfos(details); messageRequest.setTryNumber(1); messageRequest.setRequestId(messageId); messageRequest.setDateFrom(startDate); messageRequest.setDateTo(endDate); messageRequest.setRecipientNumber(workerNumber); messageRequest.setNotificationType(noteType); messageRequest.setMessageType(MessageType.valueOf(messageType.toString())); messageRequest.setLanguage(langObject); messageRequest.setStatus(MStatus.QUEUED); messageRequest.setDateCreated(new Date()); logger.info("MessageRequest object successfully constructed"); logger.debug(messageRequest); if (messageRequest.getDateFrom() == null && messageRequest.getDateTo() == null) { return sendMessage(messageRequest); } logger.info("Saving MessageRequest..."); MessageRequestDAO msgReqDao = coreManager.createMessageRequestDAO(); msgReqDao.save(messageRequest); return MessageStatus.valueOf(messageRequest.getStatus().toString()); } 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);  }