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 junit.framework.Assert.assertEquals;
9   
10  /**
11   * @since 3.6
12   */
13  public class WorkflowValidatorTest extends AbstractModuleCreatorTestCase<WorkflowElementProperties>
14  {
15      public WorkflowValidatorTest()
16      {
17          super("workflow-validator", new WorkflowValidatorModuleCreator());
18      }
19  
20      @Before
21      public void setupProps() throws Exception
22      {
23          setProps(new WorkflowElementProperties(PACKAGE_NAME + ".MyWorkflowValidator"));
24          props.setIncludeExamples(false);
25      }
26  
27      @Test
28      public void classFileIsGenerated() throws Exception
29      {
30          getSourceFile(PACKAGE_NAME, "MyWorkflowValidator");
31      }
32  
33      @Test
34      public void factoryClassFileIsGenerated() throws Exception
35      {
36          getSourceFile(PACKAGE_NAME, "MyWorkflowValidatorFactory");
37      }
38      
39      @Test
40      public void unitTestFileIsGenerated() throws Exception
41      {
42          getTestSourceFile(TEST_PACKAGE_NAME, "MyWorkflowValidatorTest");
43      }
44     
45      @Test
46      public void moduleHasDefaultKey() throws Exception
47      {
48          assertEquals("my-workflow-validator",
49                       getGeneratedModule().attributeValue("key"));
50      }
51      
52      @Test
53      public void moduleHasClass() throws Exception
54      {
55          assertEquals(PACKAGE_NAME + ".MyWorkflowValidatorFactory",
56                       getGeneratedModule().attributeValue("class"));
57      }
58      
59      @Test
60      public void moduleHasValidatorClass() throws Exception
61      {
62          assertEquals(PACKAGE_NAME + ".MyWorkflowValidator", getGeneratedModule().selectSingleNode("validator-class").getText());
63      }
64  }