/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

  1. package com.atlassian.plugins.codegen.modules.common;
  2. import com.atlassian.plugins.codegen.AbstractModuleCreatorTestCase;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. import static org.junit.Assert.assertEquals;
  6. /**
  7. * @since 3.6
  8. */
  9. public class TemplateContextItemTest extends AbstractModuleCreatorTestCase<TemplateContextItemProperties>
  10. {
  11. public TemplateContextItemTest()
  12. {
  13. super("template-context-item", new TemplateContextItemModuleCreator());
  14. }
  15. public static final String MODULE_NAME = "My Template Context Item";
  16. public static final String COMPONENT_REF = "i18nResolver";
  17. public static final String CLASSNAME = "com.atlassian.component.SomeSingleton";
  18. public static final String CONTEXT_KEY = "i18n";
  19. @Before
  20. public void setupProps() throws Exception
  21. {
  22. setProps(new TemplateContextItemProperties(MODULE_NAME, CONTEXT_KEY));
  23. props.setIncludeExamples(false);
  24. props.setComponentRef(COMPONENT_REF);
  25. }
  26. @Test
  27. public void moduleHasContextKey() throws Exception
  28. {
  29. assertEquals(CONTEXT_KEY, getGeneratedModule().attributeValue("context-key"));
  30. }
  31. @Test
  32. public void componentRefModuleHasName() throws Exception
  33. {
  34. assertEquals(COMPONENT_REF, getGeneratedModule().attributeValue("component-ref"));
  35. }
  36. @Test
  37. public void componentRefModuleIsNotGlobal() throws Exception
  38. {
  39. assertEquals("false", getGeneratedModule().attributeValue("global"));
  40. }
  41. @Test
  42. public void globalModuleHasName() throws Exception
  43. {
  44. props.setGlobal(true);
  45. assertEquals(COMPONENT_REF, getGeneratedModule().attributeValue("component-ref"));
  46. }
  47. @Test
  48. public void globalModuleIsGlobal() throws Exception
  49. {
  50. props.setGlobal(true);
  51. assertEquals("true", getGeneratedModule().attributeValue("global"));
  52. }
  53. }