1   package com.atlassian.plugins.codegen.modules.common;
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 TemplateContextItemTest extends AbstractModuleCreatorTestCase<TemplateContextItemProperties>
14  {
15      public TemplateContextItemTest()
16      {
17          super("template-context-item", new TemplateContextItemModuleCreator());
18      }
19      
20      public static final String MODULE_NAME = "My Template Context Item";
21      public static final String COMPONENT_REF = "i18nResolver";
22      public static final String CLASSNAME = "com.atlassian.component.SomeSingleton";
23      public static final String CONTEXT_KEY = "i18n";
24  
25      @Before
26      public void setupProps() throws Exception
27      {
28          setProps(new TemplateContextItemProperties(MODULE_NAME, CONTEXT_KEY));
29          props.setIncludeExamples(false);
30          props.setComponentRef(COMPONENT_REF);
31      }
32  
33      @Test
34      public void moduleHasContextKey() throws Exception
35      {
36          assertEquals(CONTEXT_KEY, getGeneratedModule().attributeValue("context-key"));
37      }
38      
39      @Test
40      public void componentRefModuleHasName() throws Exception
41      {
42          assertEquals(COMPONENT_REF, getGeneratedModule().attributeValue("component-ref"));
43      }
44      
45      @Test
46      public void componentRefModuleIsNotGlobal() throws Exception
47      {
48          assertEquals("false", getGeneratedModule().attributeValue("global"));
49      }
50  
51      @Test
52      public void globalModuleHasName() throws Exception
53      {
54          props.setGlobal(true);
55  
56          assertEquals(COMPONENT_REF, getGeneratedModule().attributeValue("component-ref"));
57      }
58      
59      @Test
60      public void globalModuleIsGlobal() throws Exception
61      {
62          props.setGlobal(true);
63  
64          assertEquals("true", getGeneratedModule().attributeValue("global"));
65      }
66  }