@Test public void testInitializeSession() { System.out.println("initializeSession"); IncomingMessage message = new IncomingMessageImpl(); String requesterPhone = "000000000000"; mockSessDao = createMock(IncomingMessageSessionDAO.class); expect( applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class) ).andReturn(new IncomingMessageSessionImpl()); expect( mockParser.getFormCode((String) anyObject()) ).andReturn("GENERAL"); expect( applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class) ).andReturn(mockSessDao); expectLastCall(); expect( mockSessDao.save((IncomingMessageSession) anyObject()) ).andReturn(null); expectLastCall(); replay(applicationContext,mockParser,mockSessDao); IncomingMessageSession result = instance.initializeSession(message, requesterPhone); verify(applicationContext,mockParser,mockSessDao); assertNotNull(result); }
public IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone) { String formCode = parser.getFormCode(message.getContent()); IncomingMessageSession imSession = (IncomingMessageSession) applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class); imSession.setFormCode(formCode); imSession.setRequesterPhone(requesterPhone); imSession.setMessageSessionStatus(IncMessageSessionStatus.STARTED); imSession.setDateStarted(new Date()); imSession.setLastActivity(new Date()); imSession.addIncomingMessage(message); IncomingMessageSessionDAO sessionDao = (IncomingMessageSessionDAO) applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class); try { sessionDao.save(imSession); } catch (Exception ex) { logger.error("Error initializing incoming message session", ex); } return imSession; }
FormCommandAction implements CommandAction, ApplicationContextAware { public IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone) { String formCode = parser.getFormCode(message.getContent()); IncomingMessageSession imSession = (IncomingMessageSession) applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class); imSession.setFormCode(formCode); imSession.setRequesterPhone(requesterPhone); imSession.setMessageSessionStatus(IncMessageSessionStatus.STARTED); imSession.setDateStarted(new Date()); imSession.setLastActivity(new Date()); imSession.addIncomingMessage(message); IncomingMessageSessionDAO sessionDao = (IncomingMessageSessionDAO) applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class); try { sessionDao.save(imSession); } catch (Exception ex) { logger.error("Error initializing incoming message session", ex); } return imSession; } }
FormCommandAction implements CommandAction, ApplicationContextAware { public IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone) { String formCode = parser.getFormCode(message.getContent()); IncomingMessageSession imSession = (IncomingMessageSession) applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class); imSession.setFormCode(formCode); imSession.setRequesterPhone(requesterPhone); imSession.setMessageSessionStatus(IncMessageSessionStatus.STARTED); imSession.setDateStarted(new Date()); imSession.setLastActivity(new Date()); imSession.addIncomingMessage(message); IncomingMessageSessionDAO sessionDao = (IncomingMessageSessionDAO) applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class); try { sessionDao.save(imSession); } catch (Exception ex) { logger.error("Error initializing incoming message session", ex); } return imSession; }  }
FormCommandAction implements CommandAction, ApplicationContextAware { public IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone) { String formCode = parser.getFormCode(message.getContent()); IncomingMessageSession imSession = (IncomingMessageSession) applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class); imSession.setFormCode(formCode); imSession.setRequesterPhone(requesterPhone); imSession.setMessageSessionStatus(IncMessageSessionStatus.STARTED); imSession.setDateStarted(new Date()); imSession.setLastActivity(new Date()); imSession.addIncomingMessage(message); IncomingMessageSessionDAO sessionDao = (IncomingMessageSessionDAO) applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class); try { sessionDao.save(imSession); } catch (Exception ex) { logger.error("Error initializing incoming message session", ex); } return imSession; }  IncomingMessageResponse execute(IncomingMessage message, String requesterPhone); IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone); IncomingMessageForm initializeForm(IncomingMessage message, String formCode); IncomingMessageResponse prepareResponse(IncomingMessage message, String wsResponse); IncomingMessageParser getParser(); void setParser(IncomingMessageParser parser); IncomingMessageFormValidator getFormValidator(); void setFormValidator(IncomingMessageFormValidator formValidator); void setFormProcessor(FormProcessor formProcessor); String getSenderFieldName(); void setSenderFieldName(String senderFieldName); void setApplicationContext(ApplicationContext applicationContext); }
FormCommandAction implements CommandAction, ApplicationContextAware { public IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone) { String formCode = parser.getFormCode(message.getContent()); IncomingMessageSession imSession = (IncomingMessageSession) applicationContext.getBean("incomingMessageSession", IncomingMessageSession.class); imSession.setFormCode(formCode); imSession.setRequesterPhone(requesterPhone); imSession.setMessageSessionStatus(IncMessageSessionStatus.STARTED); imSession.setDateStarted(new Date()); imSession.setLastActivity(new Date()); imSession.addIncomingMessage(message); IncomingMessageSessionDAO sessionDao = (IncomingMessageSessionDAO) applicationContext.getBean("incomingMessageSessionDAO", IncomingMessageSessionDAO.class); try { sessionDao.save(imSession); } catch (Exception ex) { logger.error("Error initializing incoming message session", ex); } return imSession; }  IncomingMessageResponse execute(IncomingMessage message, String requesterPhone); IncomingMessageSession initializeSession(IncomingMessage message, String requesterPhone); IncomingMessageForm initializeForm(IncomingMessage message, String formCode); IncomingMessageResponse prepareResponse(IncomingMessage message, String wsResponse); IncomingMessageParser getParser(); void setParser(IncomingMessageParser parser); IncomingMessageFormValidator getFormValidator(); void setFormValidator(IncomingMessageFormValidator formValidator); void setFormProcessor(FormProcessor formProcessor); String getSenderFieldName(); void setSenderFieldName(String senderFieldName); void setApplicationContext(ApplicationContext applicationContext);  }