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