PageRenderTime 31ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/plugin-module-codegen-engine/src/test/java/com/atlassian/plugins/codegen/modules/common/TemplateContextItemTest.java

https://bitbucket.org/mmeinhold/amps
Java | 66 lines | 50 code | 13 blank | 3 comment | 0 complexity | 5dde5d81fd59ca64b3831d24b70272a3 MD5 | raw file
 1package com.atlassian.plugins.codegen.modules.common;
 2
 3import com.atlassian.plugins.codegen.AbstractModuleCreatorTestCase;
 4
 5import org.junit.Before;
 6import org.junit.Test;
 7
 8import static org.junit.Assert.assertEquals;
 9
10/**
11 * @since 3.6
12 */
13public 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}