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.ContextKeys;
13 import inklings.jgatms.CommandKeys;
14 import inklings.jgatms.bean.Skill;
15 import inklings.jgatms.bean.Question;
16 import inklings.jgatms.bean.Response;
17
18 /***
19 * Tests the <code>GetSkillsList</code> JGATMS command.
20 */
21 public class GetSkillsListTest extends BaseTestCase {
22
23 /***
24 * Verifies that all skills can be retrieved.
25 */
26 public void testGetSkillsList() throws Exception {
27 JgatmsContext context = new JgatmsContext();
28 Command command = catalog.getCommand(CommandKeys.GET_SKILLS_LIST);
29 assertNotNull(CommandKeys.GET_SKILLS_LIST + " 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 List skills = (List) context.get(ContextKeys.SKILL_LIST_KEY);
37 assertNotNull(ContextKeys.SKILL_LIST_KEY + " not found.", skills);
38
39 Iterator i = skills.iterator();
40 while (i.hasNext()) {
41 Skill skill = (Skill) i.next();
42
43 System.out.println("======================================");
44 System.out.println("Skill: " + skill.getName());
45 System.out.println("Skill id: " + skill.getSkillId());
46
47 System.out.println("Skill questions...");
48 List questions = skill.getQuestions();
49 if (questions != null) {
50 Iterator j = questions.iterator();
51 while (j.hasNext()) {
52 Question question = (Question) j.next();
53
54 System.out.println("Question: " + question.getQuestion());
55 System.out.println("Question id: " +
56 question.getQuestionId());
57
58 System.out.println("Possible responses ...");
59 List possibleResponses =
60 question.getPossibleResponses();
61 Iterator k = possibleResponses.iterator();
62 while (k.hasNext()) {
63 Response response = (Response) k.next();
64
65 System.out.println("Response: " +
66 response.getResponse());
67 System.out.println("Response id: " +
68 response.getResponseId());
69 }
70 }
71 }
72 }
73
74 }
75 }
This page was automatically generated by Maven