1   package com.atlassian.plugins.codegen.modules.common.licensing;
2   
3   import com.atlassian.plugins.codegen.AbstractCodegenTestCase;
4   import com.atlassian.plugins.codegen.ClassId;
5   
6   import org.junit.Before;
7   import org.junit.Test;
8   
9   import static com.atlassian.plugins.codegen.ClassId.fullyQualified;
10  import static org.junit.Assert.assertEquals;
11  
12  /**
13   * @since 3.8
14   */
15  public class LicensingUpm2Test extends AbstractCodegenTestCase<LicensingProperties>
16  {
17      private static final ClassId LICENSE_CHECKER_CLASS = ClassId.packageAndClass(PACKAGE_NAME, "MyLicenseChecker");
18      
19      @Before
20      public void setupProps()
21      {
22          setCreator(new LicensingUpm2ModuleCreator());
23          setProps(new LicensingProperties(LICENSE_CHECKER_CLASS.getFullName()));
24      }
25  
26      @Test
27      public void licensingPluginParamIsAdded() throws Exception
28      {
29          assertEquals("true", getChangesetForModule().getPluginParameters().get("atlassian-licensing-enabled"));
30      }
31      
32      @Test
33      public void licenseCheckerComponentIsAdded() throws Exception
34      {
35          getComponentOfClass(LICENSE_CHECKER_CLASS);
36      }
37      
38      @Test
39      public void licenseCheckerClassIsCreated() throws Exception
40      {
41          getSourceFile(PACKAGE_NAME, LICENSE_CHECKER_CLASS.getName());
42      }
43      
44      @Test
45      public void pluginLicenseManagerImportIsAdded() throws Exception
46      {
47          getComponentImportOfInterface(fullyQualified("com.atlassian.upm.api.license.PluginLicenseManager"));
48      }
49      
50      @Test
51      public void pluginLicenseEventRegistryImportIsAdded() throws Exception
52      {
53          getComponentImportOfInterface(fullyQualified("com.atlassian.upm.api.license.PluginLicenseEventRegistry"));
54      }
55      
56      @Test
57      public void pluginControllerImportIsAdded() throws Exception
58      {
59          getComponentImportOfInterface(fullyQualified("com.atlassian.plugin.PluginController"));
60      }
61      
62      @Test
63      public void upmApiDependencyIsAdded() throws Exception
64      {
65          getDependency("com.atlassian.upm", "upm-api");
66      }
67      
68      @Test
69      public void licensingApiDependencyIsAdded() throws Exception
70      {
71          getDependency("com.atlassian.upm", "licensing-api");
72      }
73      
74      @Test
75      public void pluginsDependencyIsAdded() throws Exception
76      {
77          getDependency("com.atlassian.plugins", "atlassian-plugins-core");
78      }
79      
80      @Test
81      public void salDependencyIsAdded() throws Exception
82      {
83          getDependency("com.atlassian.sal", "sal-api");
84      }
85  }