### Question:
FormCommandAction implements CommandAction, ApplicationContextAware { public IncomingMessageForm initializeForm(IncomingMessage message, String formCode) { IncomingMessageFormDefinition formDefn = ((IncomingMessageFormDefinitionDAO)applicationContext.getBean("incomingMessageFormDefinitionDAO", IncomingMessageFormDefinitionDAO.class)).getByCode(formCode); if (formDefn == null) { return null; } IncomingMessageForm form = (IncomingMessageForm) applicationContext.getBean("incomingMessageForm", IncomingMessageForm.class); form.setIncomingMsgFormDefinition(formDefn); form.setMessageFormStatus(IncMessageFormStatus.NEW); form.setDateCreated(new Date()); form.setIncomingMsgFormParameters(new HashMap<String, IncomingMessageFormParameter>()); form.getIncomingMsgFormParameters().putAll(parser.getParams(message.getContent())); IncomingMessageFormDAO formDao = (IncomingMessageFormDAO) applicationContext.getBean("incomingMessageFormDAO", IncomingMessageFormDAO.class); try { formDao.save(form); } catch (Exception ex) { logger.error("Error initializing form", ex); } return form; }  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);  }### Answer:
@Test public void testInitializeForm() { System.out.println("initializeForm"); IncomingMessage message = new IncomingMessageImpl(); message.setContent("test content"); String formCode = "GENERAL"; mockFormDefDao = createMock(IncomingMessageFormDefinitionDAO.class); mockFormDao = createMock(IncomingMessageFormDAO.class); expect( applicationContext.getBean("incomingMessageFormDefinitionDAO", IncomingMessageFormDefinitionDAO.class) ).andReturn(mockFormDefDao); expect( mockFormDefDao.getByCode((String) anyObject()) ).andReturn(new IncomingMessageFormDefinitionImpl()); expect( applicationContext.getBean("incomingMessageForm", IncomingMessageForm.class) ).andReturn(new IncomingMessageFormImpl()); expect( mockParser.getParams((String)anyObject()) ).andReturn(new HashMap<String,IncomingMessageFormParameter>()); expect( applicationContext.getBean("incomingMessageFormDAO", IncomingMessageFormDAO.class) ).andReturn(mockFormDao); expectLastCall(); expect( mockFormDao.save((IncomingMessageForm) anyObject()) ).andReturn(null); expectLastCall(); replay(applicationContext,mockFormDefDao,mockParser,mockFormDao); IncomingMessageForm result = instance.initializeForm(message, formCode); verify(applicationContext,mockFormDefDao,mockParser,mockFormDao); assertNotNull(result); }