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>GetQuestion</code> JGATMS command. 19 */ 20 public class GetQuestionTest extends BaseTestCase { 21 22 /*** 23 * Verifies that all questions can be retrieved. 24 */ 25 public void testGetQuestion() throws Exception { 26 JgatmsContext context = new JgatmsContext(); 27 context.put(ContextKeys.QUESTION_ID_KEY, new Long(0)); 28 Command command = catalog.getCommand(CommandKeys.GET_QUESTION); 29 assertNotNull(CommandKeys.GET_QUESTION + " not found.", command); 30 31 command.execute(context); 32 String dispatch = context.getDispatch(); 33 assertTrue("Unsuccessful command execution.", 34 dispatch.equals(ContextKeys.SUCCESS_DISPATCH)); 35 36 Question question = (Question) context.get(ContextKeys.QUESTION_KEY); 37 assertNotNull(ContextKeys.QUESTION_KEY + " not found.", question); 38 39 System.out.println("======================================"); 40 System.out.println("Question: " + question.getQuestion()); 41 System.out.println("question id: " + question.getQuestionId()); 42 43 System.out.println("Possible responses..."); 44 List possibleResponses = question.getPossibleResponses(); 45 if (possibleResponses != null) { 46 Iterator j = possibleResponses.iterator(); 47 while (j.hasNext()) { 48 Response response = (Response) j.next(); 49 50 System.out.println("Response: " + response.getResponse()); 51 System.out.println("Response id: " + response.getResponseId()); 52 } 53 } 54 55 } 56 }

This page was automatically generated by Maven