1   package com.atlassian.plugins.codegen.modules.jira;
2   
3   import com.atlassian.plugins.codegen.AbstractModuleCreatorTestCase;
4   
5   import org.junit.Before;
6   import org.junit.Test;
7   
8   import static org.junit.Assert.assertEquals;
9   
10  /**
11   * @since 3.6
12   */
13  public class KeyboardShortcutTest extends AbstractModuleCreatorTestCase<KeyboardShortcutProperties>
14  {
15      public KeyboardShortcutTest()
16      {
17          super("keyboard-shortcut", new KeyboardShortcutModuleCreator());
18      }
19  
20      @Before
21      public void setupProps() throws Exception
22      {
23          setProps(new KeyboardShortcutProperties("My Keyboard Shortcut"));
24          props.setIncludeExamples(false);
25          props.setOperationType("click");
26          props.setOperationValue("do:something");
27          props.setShortcut("m");
28          props.setContext("issueaction");
29      }
30  
31      @Test
32      public void moduleHasShortcut() throws Exception
33      {
34          assertEquals("m", getGeneratedModule().selectSingleNode("shortcut").getText());
35      }
36      
37      @Test
38      public void moduleHasContext() throws Exception
39      {
40          assertEquals("issueaction", getGeneratedModule().selectSingleNode("context").getText());
41      }
42  
43      @Test
44      public void moduleHasOperationType() throws Exception
45      {
46          assertEquals("click", getGeneratedModule().selectSingleNode("operation/@type").getText());
47      }
48  
49      @Test
50      public void moduleHasOperationValue() throws Exception
51      {
52          assertEquals("do:something", getGeneratedModule().selectSingleNode("operation").getText());
53      }
54  
55      @Test
56      public void moduleHasDefaultOrder() throws Exception
57      {
58          assertEquals("10", getGeneratedModule().selectSingleNode("order").getText());
59      }
60  
61      @Test
62      public void moduleHasSpecifiedOrder() throws Exception
63      {
64          props.setOrder(1000);
65          
66          assertEquals("1000", getGeneratedModule().selectSingleNode("order").getText());
67      }
68  }