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 com.atlassian.fugue.Option.some;
9   import static com.atlassian.plugins.codegen.ClassId.fullyQualified;
10  import static org.junit.Assert.assertEquals;
11  import static org.junit.Assert.assertFalse;
12  
13  /**
14   * @since 3.8
15   */
16  public abstract class AbstractRPCTest extends AbstractModuleCreatorTestCase<RPCProperties>
17  {
18      protected boolean isSoap;
19      
20      public AbstractRPCTest(String type, boolean isSoap)
21      {
22          super(type, new RPCModuleCreator());
23          this.isSoap = isSoap;
24      }
25  
26      @Before
27      public void setupProps()
28      {
29          setProps(new RPCProperties(PACKAGE_NAME + ".MyEndpoint"));
30          props.setSoap(isSoap);
31      }
32  
33      @Test
34      public void interfaceFileIsGenerated() throws Exception
35      {
36          getSourceFile(PACKAGE_NAME, "MyEndpoint");
37      }
38  
39      @Test
40      public void classFileIsGenerated() throws Exception
41      {
42          getSourceFile(PACKAGE_NAME, "MyEndpointImpl");
43      }
44  
45      @Test
46      public void unitTestFileIsGenerated() throws Exception
47      {
48          getTestSourceFile(PACKAGE_NAME, "MyEndpointImplTest");
49      }
50  
51      @Test
52      public void moduleHasClass() throws Exception
53      {
54          assertEquals(PACKAGE_NAME + ".MyEndpointImpl", getGeneratedModule().attributeValue("class"));
55      }
56  
57      @Test
58      public void moduleHasServicePath() throws Exception
59      {
60          assertEquals("myendpoint-v1", getGeneratedModule().selectSingleNode("service-path").getText());
61      }
62      
63      @Test
64      public void componentAdded() throws Exception
65      {
66          assertFalse(getChangesetForModule().getComponentDeclarations().isEmpty());
67      }
68      
69      @Test
70      public void componentHasClass() throws Exception
71      {
72          assertEquals(fullyQualified(PACKAGE_NAME + ".MyEndpointImpl"), getChangesetForModule().getComponentDeclarations().get(0).getClassId());
73      }
74  
75      @Test
76      public void componentHasInterface() throws Exception
77      {
78          assertEquals(some(fullyQualified(PACKAGE_NAME + ".MyEndpoint")), getChangesetForModule().getComponentDeclarations().get(0).getInterfaceId());
79      }
80  }