@Test public void testSendMessage() { GatewayRequest gatewayRequest = getGatewayRequestTemplate(); List<IVRCallSession> daoResponse = new ArrayList<IVRCallSession>(); IVRDAO mockIvrDao = createMock(IVRDAO.class); intellivrBean.setIvrDao(mockIvrDao); Integer[] expectedStates = {IVRCallSession.OPEN}; expect(mockIvrDao.loadIVRCallSessions(EasyMock.eq(gatewayRequest.getMessageRequest().getRecipientId()), EasyMock.eq(gatewayRequest.getMessageRequest().getRecipientNumber()), EasyMock.eq(gatewayRequest.getMessageRequest().getLanguage().getName()), EasyMock.aryEq(expectedStates), EasyMock.eq(0), EasyMock.eq(0), EasyMock.eq(IVRCallSession.OUTBOUND))) .andReturn(daoResponse); expect(mockIvrDao.saveIVRCallSession((IVRCallSession)EasyMock.anyObject())) .andReturn(1L); replay(mockIvrDao); Set<GatewayResponse> actualGatewayResponseSet = intellivrBean.sendMessage(gatewayRequest); assertEquals(1, actualGatewayResponseSet.size()); for ( GatewayResponse response : actualGatewayResponseSet ) assertEquals(StatusType.OK.value(), response.getResponseText()); verify(mockIvrDao); }
@Transactional public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { Set<GatewayResponse> responses = null; try { log.debug("Received GatewayRequest:" + gatewayRequest); String recipientID = gatewayRequest.getMessageRequest().getRecipientId(); String phone = gatewayRequest.getRecipientsNumber(); String status = StatusType.OK.value(); boolean isErrorCondition = recipientID == null || phone == null || gatewayRequest.getMessageRequest().getMessageType() == MessageType.TEXT; if (isErrorCondition) { status = StatusType.ERROR.value(); } else { String phoneType = gatewayRequest.getMessageRequest().getPhoneNumberType(); if (phoneType.equalsIgnoreCase("PERSONAL") || phoneType.equalsIgnoreCase("HOUSEHOLD")) { Language language = gatewayRequest.getMessageRequest().getLanguage(); Integer[] openState = {IVRCallSession.OPEN}; List<IVRCallSession> existingSessions = ivrDao.loadIVRCallSessions(recipientID, phone, language.getName(), openState, 0, 0, IVRCallSession.OUTBOUND); if (existingSessions.size() == 0) { Date callTime = gatewayRequest.getDateFrom(); Date bundlingExpiration = addToDate(callTime, GregorianCalendar.MILLISECOND, (int) bundlingDelay); IVRCallSession session = new IVRCallSession(recipientID, phone, language.getName(), IVRCallSession.OUTBOUND, 0, 0, IVRCallSession.OPEN, callTime, bundlingExpiration); session.getMessageRequests().add(gatewayRequest.getMessageRequest()); ivrDao.saveIVRCallSession(session); log.debug("Created session " + session); } else { existingSessions.get(0).getMessageRequests().add(gatewayRequest.getMessageRequest()); log.debug("Using session " + existingSessions.get(0)); } } else { log.debug("GatewayRequest " + gatewayRequest.getId() + " has phone type " + gatewayRequest.getMessageRequest().getPhoneNumberType() + ". Call will not be made and message will remain pending."); } } responses = messageHandler.parseMessageResponse(gatewayRequest, status); for (GatewayResponse response : responses) statusStore.updateStatus(response.getGatewayMessageId(), response.getResponseText()); } catch (Exception e) { log.error("Error scheduling intellIVR call", e); } return responses; }
IntellIVRBean implements GatewayManager, GetIVRConfigRequestHandler, IVRCallRequester, IVRCallSessionProcessor, IVRCallStatsProvider, ReportHandler { @Transactional public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { Set<GatewayResponse> responses = null; try { log.debug("Received GatewayRequest:" + gatewayRequest); String recipientID = gatewayRequest.getMessageRequest().getRecipientId(); String phone = gatewayRequest.getRecipientsNumber(); String status = StatusType.OK.value(); boolean isErrorCondition = recipientID == null || phone == null || gatewayRequest.getMessageRequest().getMessageType() == MessageType.TEXT; if (isErrorCondition) { status = StatusType.ERROR.value(); } else { String phoneType = gatewayRequest.getMessageRequest().getPhoneNumberType(); if (phoneType.equalsIgnoreCase("PERSONAL") || phoneType.equalsIgnoreCase("HOUSEHOLD")) { Language language = gatewayRequest.getMessageRequest().getLanguage(); Integer[] openState = {IVRCallSession.OPEN}; List<IVRCallSession> existingSessions = ivrDao.loadIVRCallSessions(recipientID, phone, language.getName(), openState, 0, 0, IVRCallSession.OUTBOUND); if (existingSessions.size() == 0) { Date callTime = gatewayRequest.getDateFrom(); Date bundlingExpiration = addToDate(callTime, GregorianCalendar.MILLISECOND, (int) bundlingDelay); IVRCallSession session = new IVRCallSession(recipientID, phone, language.getName(), IVRCallSession.OUTBOUND, 0, 0, IVRCallSession.OPEN, callTime, bundlingExpiration); session.getMessageRequests().add(gatewayRequest.getMessageRequest()); ivrDao.saveIVRCallSession(session); log.debug("Created session " + session); } else { existingSessions.get(0).getMessageRequests().add(gatewayRequest.getMessageRequest()); log.debug("Using session " + existingSessions.get(0)); } } else { log.debug("GatewayRequest " + gatewayRequest.getId() + " has phone type " + gatewayRequest.getMessageRequest().getPhoneNumberType() + ". Call will not be made and message will remain pending."); } } responses = messageHandler.parseMessageResponse(gatewayRequest, status); for (GatewayResponse response : responses) statusStore.updateStatus(response.getGatewayMessageId(), response.getResponseText()); } catch (Exception e) { log.error("Error scheduling intellIVR call", e); } return responses; } }
IntellIVRBean implements GatewayManager, GetIVRConfigRequestHandler, IVRCallRequester, IVRCallSessionProcessor, IVRCallStatsProvider, ReportHandler { @Transactional public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { Set<GatewayResponse> responses = null; try { log.debug("Received GatewayRequest:" + gatewayRequest); String recipientID = gatewayRequest.getMessageRequest().getRecipientId(); String phone = gatewayRequest.getRecipientsNumber(); String status = StatusType.OK.value(); boolean isErrorCondition = recipientID == null || phone == null || gatewayRequest.getMessageRequest().getMessageType() == MessageType.TEXT; if (isErrorCondition) { status = StatusType.ERROR.value(); } else { String phoneType = gatewayRequest.getMessageRequest().getPhoneNumberType(); if (phoneType.equalsIgnoreCase("PERSONAL") || phoneType.equalsIgnoreCase("HOUSEHOLD")) { Language language = gatewayRequest.getMessageRequest().getLanguage(); Integer[] openState = {IVRCallSession.OPEN}; List<IVRCallSession> existingSessions = ivrDao.loadIVRCallSessions(recipientID, phone, language.getName(), openState, 0, 0, IVRCallSession.OUTBOUND); if (existingSessions.size() == 0) { Date callTime = gatewayRequest.getDateFrom(); Date bundlingExpiration = addToDate(callTime, GregorianCalendar.MILLISECOND, (int) bundlingDelay); IVRCallSession session = new IVRCallSession(recipientID, phone, language.getName(), IVRCallSession.OUTBOUND, 0, 0, IVRCallSession.OPEN, callTime, bundlingExpiration); session.getMessageRequests().add(gatewayRequest.getMessageRequest()); ivrDao.saveIVRCallSession(session); log.debug("Created session " + session); } else { existingSessions.get(0).getMessageRequests().add(gatewayRequest.getMessageRequest()); log.debug("Using session " + existingSessions.get(0)); } } else { log.debug("GatewayRequest " + gatewayRequest.getId() + " has phone type " + gatewayRequest.getMessageRequest().getPhoneNumberType() + ". Call will not be made and message will remain pending."); } } responses = messageHandler.parseMessageResponse(gatewayRequest, status); for (GatewayResponse response : responses) statusStore.updateStatus(response.getGatewayMessageId(), response.getResponseText()); } catch (Exception e) { log.error("Error scheduling intellIVR call", e); } return responses; }  }
IntellIVRBean implements GatewayManager, GetIVRConfigRequestHandler, IVRCallRequester, IVRCallSessionProcessor, IVRCallStatsProvider, ReportHandler { @Transactional public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { Set<GatewayResponse> responses = null; try { log.debug("Received GatewayRequest:" + gatewayRequest); String recipientID = gatewayRequest.getMessageRequest().getRecipientId(); String phone = gatewayRequest.getRecipientsNumber(); String status = StatusType.OK.value(); boolean isErrorCondition = recipientID == null || phone == null || gatewayRequest.getMessageRequest().getMessageType() == MessageType.TEXT; if (isErrorCondition) { status = StatusType.ERROR.value(); } else { String phoneType = gatewayRequest.getMessageRequest().getPhoneNumberType(); if (phoneType.equalsIgnoreCase("PERSONAL") || phoneType.equalsIgnoreCase("HOUSEHOLD")) { Language language = gatewayRequest.getMessageRequest().getLanguage(); Integer[] openState = {IVRCallSession.OPEN}; List<IVRCallSession> existingSessions = ivrDao.loadIVRCallSessions(recipientID, phone, language.getName(), openState, 0, 0, IVRCallSession.OUTBOUND); if (existingSessions.size() == 0) { Date callTime = gatewayRequest.getDateFrom(); Date bundlingExpiration = addToDate(callTime, GregorianCalendar.MILLISECOND, (int) bundlingDelay); IVRCallSession session = new IVRCallSession(recipientID, phone, language.getName(), IVRCallSession.OUTBOUND, 0, 0, IVRCallSession.OPEN, callTime, bundlingExpiration); session.getMessageRequests().add(gatewayRequest.getMessageRequest()); ivrDao.saveIVRCallSession(session); log.debug("Created session " + session); } else { existingSessions.get(0).getMessageRequests().add(gatewayRequest.getMessageRequest()); log.debug("Using session " + existingSessions.get(0)); } } else { log.debug("GatewayRequest " + gatewayRequest.getId() + " has phone type " + gatewayRequest.getMessageRequest().getPhoneNumberType() + ". Call will not be made and message will remain pending."); } } responses = messageHandler.parseMessageResponse(gatewayRequest, status); for (GatewayResponse response : responses) statusStore.updateStatus(response.getGatewayMessageId(), response.getResponseText()); } catch (Exception e) { log.error("Error scheduling intellIVR call", e); } return responses; }  @Transactional void init(); void cleanUp(); String getMessageStatus(GatewayResponse response); MStatus mapMessageStatus(GatewayResponse response); @Transactional Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest); @Transactional void processOpenSessions(); @Transactional void processWaitingSessions(); @Transactional void requestCall(IVRCallSession session, String externalId); RequestType createIVRRequest(IVRCallSession session, String externalId); @Transactional ResponseType handleRequest(GetIVRConfigRequest request); @SuppressWarnings("unchecked") @Transactional ResponseType handleRequest(GetIVRConfigRequest request, String externalId); @Transactional ResponseType handleReport(ReportType report); @Transactional int getCountIVRCallSessions(); @Transactional int getCountIVRSessionsInLastMinutes(int minutes); @Transactional int getCountIVRCallSessionsInLastHours(int hours); @Transactional int getCountIVRCallSessionsInLastDays(int days); @Transactional int getCountIVRCalls(); @Transactional int getCountIVRCallsInLastMinutes(int minutes); @Transactional int getCountIVRCallsInLastHours(int hours); @Transactional int getCountIVRCallsInLastDays(int days); @Transactional int getCountIVRCallsWithStatus(IVRCallStatus status); @Transactional int getCountIVRCallsInLastMinutesWithStatus(int minutes, IVRCallStatus status); @Transactional int getCountIVRCallsInLastHoursWithStatus(int hours, IVRCallStatus status); @Transactional int getCountIVRCallsInLastDaysWithStatus(int days, IVRCallStatus status); @Transactional List<IVRRecordingStat> getIVRRecordingStats(); @Transactional List<IVRCallStatusStat> getIVRCallStatusStats(); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastMinutes(int minutes); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastHours(int hours); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastDays(int days); @Transactional List<IVRCallSession> getIVRCallSessions(); @Transactional List<IVRCallSession> getIVRCallSessionsInLastMinutes(int minutes); @Transactional List<IVRCallSession> getIVRCallSessionsInLastHours(int hours); @Transactional List<IVRCallSession> getIVRCallSessionsInLastDays(int days); @Transactional List<IVRCallSession> getIVRCallSessionsForUser(String user); @Transactional List<IVRCallSession> getIVRCallSessionsForPhone(String phone); void setMessageHandler(GatewayMessageHandler messageHandler); GatewayMessageHandler getMessageHandler(); String getReportURL(); void setReportURL(String reportURL); String getApiID(); void setApiID(String apiID); IntellIVRServer getIvrServer(); void setIvrServer(IntellIVRServer ivrServer); String getMethod(); void setMethod(String method); String getDefaultLanguage(); void setDefaultLanguage(String defaultLanguage); String getDefaultTree(); void setDefaultTree(String defaultTree); String getDefaultReminder(); void setDefaultReminder(String defaultReminder); MessageStatusStore getStatusStore(); void setStatusStore(MessageStatusStore statusStore); long getBundlingDelay(); void setBundlingDelay(long bundlingDelay); int getRetryDelay(); void setRetryDelay(int retryDelay); int getMaxAttempts(); void setMaxAttempts(int maxAttempts); int getMaxDays(); void setMaxDays(int maxDays); int getAvailableDays(); void setAvailableDays(int availableDays); int getCallCompletedThreshold(); void setCallCompletedThreshold(int callCompletedThreshold); int getPreReminderDelay(); void setPreReminderDelay(int preReminderDelay); boolean isAccelerateRetries(); void setAccelerateRetries(boolean accelerateRetries); String getNoPendingMessagesRecordingName(); void setNoPendingMessagesRecordingName(
            String noPendingMessagesRecordingName); String getWelcomeMessageRecordingName(); void setWelcomeMessageRecordingName(String welcomeMessageRecordingName); Resource getMappingResource(); void setMappingResource(Resource mappingsFile); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); RegistrarService getRegistrarService(); void setRegistrarService(RegistrarService registrarService); IVRDAO getIvrDao(); void setIvrDao(IVRDAO ivrDao); IVRCallRequester getIvrCallRequester(); void setIvrCallRequester(IVRCallRequester ivrCallRequester); }
IntellIVRBean implements GatewayManager, GetIVRConfigRequestHandler, IVRCallRequester, IVRCallSessionProcessor, IVRCallStatsProvider, ReportHandler { @Transactional public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { Set<GatewayResponse> responses = null; try { log.debug("Received GatewayRequest:" + gatewayRequest); String recipientID = gatewayRequest.getMessageRequest().getRecipientId(); String phone = gatewayRequest.getRecipientsNumber(); String status = StatusType.OK.value(); boolean isErrorCondition = recipientID == null || phone == null || gatewayRequest.getMessageRequest().getMessageType() == MessageType.TEXT; if (isErrorCondition) { status = StatusType.ERROR.value(); } else { String phoneType = gatewayRequest.getMessageRequest().getPhoneNumberType(); if (phoneType.equalsIgnoreCase("PERSONAL") || phoneType.equalsIgnoreCase("HOUSEHOLD")) { Language language = gatewayRequest.getMessageRequest().getLanguage(); Integer[] openState = {IVRCallSession.OPEN}; List<IVRCallSession> existingSessions = ivrDao.loadIVRCallSessions(recipientID, phone, language.getName(), openState, 0, 0, IVRCallSession.OUTBOUND); if (existingSessions.size() == 0) { Date callTime = gatewayRequest.getDateFrom(); Date bundlingExpiration = addToDate(callTime, GregorianCalendar.MILLISECOND, (int) bundlingDelay); IVRCallSession session = new IVRCallSession(recipientID, phone, language.getName(), IVRCallSession.OUTBOUND, 0, 0, IVRCallSession.OPEN, callTime, bundlingExpiration); session.getMessageRequests().add(gatewayRequest.getMessageRequest()); ivrDao.saveIVRCallSession(session); log.debug("Created session " + session); } else { existingSessions.get(0).getMessageRequests().add(gatewayRequest.getMessageRequest()); log.debug("Using session " + existingSessions.get(0)); } } else { log.debug("GatewayRequest " + gatewayRequest.getId() + " has phone type " + gatewayRequest.getMessageRequest().getPhoneNumberType() + ". Call will not be made and message will remain pending."); } } responses = messageHandler.parseMessageResponse(gatewayRequest, status); for (GatewayResponse response : responses) statusStore.updateStatus(response.getGatewayMessageId(), response.getResponseText()); } catch (Exception e) { log.error("Error scheduling intellIVR call", e); } return responses; }  @Transactional void init(); void cleanUp(); String getMessageStatus(GatewayResponse response); MStatus mapMessageStatus(GatewayResponse response); @Transactional Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest); @Transactional void processOpenSessions(); @Transactional void processWaitingSessions(); @Transactional void requestCall(IVRCallSession session, String externalId); RequestType createIVRRequest(IVRCallSession session, String externalId); @Transactional ResponseType handleRequest(GetIVRConfigRequest request); @SuppressWarnings("unchecked") @Transactional ResponseType handleRequest(GetIVRConfigRequest request, String externalId); @Transactional ResponseType handleReport(ReportType report); @Transactional int getCountIVRCallSessions(); @Transactional int getCountIVRSessionsInLastMinutes(int minutes); @Transactional int getCountIVRCallSessionsInLastHours(int hours); @Transactional int getCountIVRCallSessionsInLastDays(int days); @Transactional int getCountIVRCalls(); @Transactional int getCountIVRCallsInLastMinutes(int minutes); @Transactional int getCountIVRCallsInLastHours(int hours); @Transactional int getCountIVRCallsInLastDays(int days); @Transactional int getCountIVRCallsWithStatus(IVRCallStatus status); @Transactional int getCountIVRCallsInLastMinutesWithStatus(int minutes, IVRCallStatus status); @Transactional int getCountIVRCallsInLastHoursWithStatus(int hours, IVRCallStatus status); @Transactional int getCountIVRCallsInLastDaysWithStatus(int days, IVRCallStatus status); @Transactional List<IVRRecordingStat> getIVRRecordingStats(); @Transactional List<IVRCallStatusStat> getIVRCallStatusStats(); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastMinutes(int minutes); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastHours(int hours); @Transactional List<IVRCallStatusStat> getIVRCallStatusStatsFromLastDays(int days); @Transactional List<IVRCallSession> getIVRCallSessions(); @Transactional List<IVRCallSession> getIVRCallSessionsInLastMinutes(int minutes); @Transactional List<IVRCallSession> getIVRCallSessionsInLastHours(int hours); @Transactional List<IVRCallSession> getIVRCallSessionsInLastDays(int days); @Transactional List<IVRCallSession> getIVRCallSessionsForUser(String user); @Transactional List<IVRCallSession> getIVRCallSessionsForPhone(String phone); void setMessageHandler(GatewayMessageHandler messageHandler); GatewayMessageHandler getMessageHandler(); String getReportURL(); void setReportURL(String reportURL); String getApiID(); void setApiID(String apiID); IntellIVRServer getIvrServer(); void setIvrServer(IntellIVRServer ivrServer); String getMethod(); void setMethod(String method); String getDefaultLanguage(); void setDefaultLanguage(String defaultLanguage); String getDefaultTree(); void setDefaultTree(String defaultTree); String getDefaultReminder(); void setDefaultReminder(String defaultReminder); MessageStatusStore getStatusStore(); void setStatusStore(MessageStatusStore statusStore); long getBundlingDelay(); void setBundlingDelay(long bundlingDelay); int getRetryDelay(); void setRetryDelay(int retryDelay); int getMaxAttempts(); void setMaxAttempts(int maxAttempts); int getMaxDays(); void setMaxDays(int maxDays); int getAvailableDays(); void setAvailableDays(int availableDays); int getCallCompletedThreshold(); void setCallCompletedThreshold(int callCompletedThreshold); int getPreReminderDelay(); void setPreReminderDelay(int preReminderDelay); boolean isAccelerateRetries(); void setAccelerateRetries(boolean accelerateRetries); String getNoPendingMessagesRecordingName(); void setNoPendingMessagesRecordingName(
            String noPendingMessagesRecordingName); String getWelcomeMessageRecordingName(); void setWelcomeMessageRecordingName(String welcomeMessageRecordingName); Resource getMappingResource(); void setMappingResource(Resource mappingsFile); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); RegistrarService getRegistrarService(); void setRegistrarService(RegistrarService registrarService); IVRDAO getIvrDao(); void setIvrDao(IVRDAO ivrDao); IVRCallRequester getIvrCallRequester(); void setIvrCallRequester(IVRCallRequester ivrCallRequester);  }