/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

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