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