PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-engine/src/test/java/com/atlassian/plugins/codegen/modules/jira/AbstractRPCTest.java

https://bitbucket.org/mmeinhold/amps
Java | 81 lines | 64 code | 14 blank | 3 comment | 0 complexity | da2dca0799b13fa64b6b4ddd852e0d49 MD5 | raw file
 1package com.atlassian.plugins.codegen.modules.jira;
 2
 3import com.atlassian.plugins.codegen.AbstractModuleCreatorTestCase;
 4import com.atlassian.plugins.codegen.ComponentDeclaration;
 5
 6import org.junit.Before;
 7import org.junit.Test;
 8
 9import static com.atlassian.fugue.Option.some;
10import static com.atlassian.plugins.codegen.ClassId.fullyQualified;
11import static org.junit.Assert.assertEquals;
12import static org.junit.Assert.assertFalse;
13
14/**
15 * @since 3.8
16 */
17public 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}