1 2 package inklings.jgatms.command; 3 4 import java.util.List; 5 import java.util.Iterator; 6 7 import org.apache.commons.chain.Command; 8 import org.apache.commons.chain.Context; 9 import org.apache.commons.chain.impl.ContextBase; 10 11 import inklings.jgatms.context.JgatmsContext; 12 import inklings.jgatms.CommandKeys; 13 import inklings.jgatms.ContextKeys; 14 import inklings.jgatms.bean.Question; 15 import inklings.jgatms.bean.Response; 16 17 /*** 18 * Tests the <code>AddResponseToQuestion</code> JGATMS command. 19 */ 20 public class AddResponseToQuestionTest extends BaseTestCase { 21 22 /*** 23 * Verifies that a response can be added to a question 24 */ 25 public void testAddResponseToQuestion() throws Exception { 26 27 JgatmsContext context = new JgatmsContext(); 28 Command command = catalog.getCommand(CommandKeys.GET_QUESTION); 29 assertNotNull(CommandKeys.GET_QUESTION + " not found", command); 30 31 Long questionId = new Long(0); 32 context.put(ContextKeys.QUESTION_ID_KEY, questionId); 33 command.execute(context); 34 String dispatch = context.getDispatch(); 35 assertTrue("Unsuccessful command execution.", 36 dispatch.equals(ContextKeys.SUCCESS_DISPATCH)); 37 38 Question question = (Question) context.get(ContextKeys.QUESTION_KEY); 39 assertNotNull(ContextKeys.QUESTION_KEY + " not found.", question); 40 41 command = catalog.getCommand(CommandKeys.ADD_RESPONSE_TO_QUESTION); 42 assertNotNull(CommandKeys.ADD_RESPONSE_TO_QUESTION + " not found", 43 command); 44 45 Response response = new Response(); 46 response.setResponse("fittica"); 47 context.put(ContextKeys.RESPONSE_KEY, response); 48 context.put(ContextKeys.QUESTION_KEY, question); 49 command.execute(context); 50 dispatch = context.getDispatch(); 51 assertTrue("Unsuccessful command execution.", 52 dispatch.equals(ContextKeys.SUCCESS_DISPATCH)); 53 } 54 }

This page was automatically generated by Maven