Skip to content

Commit

Permalink
Add comments in the test class
Browse files Browse the repository at this point in the history
  • Loading branch information
vihaanthora committed Jul 19, 2022
1 parent c358e15 commit 4379ca3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ protected Enumeration<URL> findResources(String name) throws IOException {
List<URL> resources = new ArrayList<>();
if (FAST_LOOKUP) {
for (PluginWrapper p : activePlugins) {
resources
.addAll(Collections.list(ClassLoaderReflectionToolkit._findResources(p.classLoader, name)));
resources.addAll(Collections.list(ClassLoaderReflectionToolkit._findResources(p.classLoader, name)));
}
} else {
for (PluginWrapper p : activePlugins) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import jenkins.model.Jenkins;

/**
* Process and find all the Pipeline steps definied in Jenkins plugins.
* Initializes a HyperLocalPluginManager instance, so that it can be used for testing.
*/
public class HyperLocalPluginManagerInit {
private static final Logger LOG = Logger.getLogger(HyperLocalPluginManagerInit.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,39 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/**
* Uses the git-plugin <code>jpi</code>s to test the <code>HyperLocalPluginManager</code>.
*/
public class HyperLocalPluginManagerTest {
private final static String pluginDir = HyperLocalPluginManagerTest.class.getResource("/git-plugin").getPath();
private static HyperLocalPluginManagerInit starter = new HyperLocalPluginManagerInit();
private static HyperLocalPluginManager pluginManager;
private static List<StepDescriptor> steps;

/**
* Initialize the plugin manager, and query it for the plugin strategy using
* <code>getPluginStrategy</code>.
*
* <code>steps</code> stores the list of components that are of type
* StepDescriptor inside the plugin strategy.
*/
@BeforeAll
public static void init() {
pluginManager = starter.initializeHyperLocalPluginManager(pluginDir);
steps = pluginManager.getPluginStrategy().findComponents(StepDescriptor.class);
}

/**
* Tests if the plugin strategy contains the expected number of components.
*/
@Test
public void TotalStepsShouldBeFortySeven() {
assertEquals(47, steps.size());
}

/**
* Tests if the component list has the git step.
*/
@Test
public void isGitStepPresent() {
boolean containsGit = false;
Expand All @@ -49,6 +65,10 @@ public void isUnarchiveStepAdvanced() {
fail("unarchive step not found");
}

/**
* Tests the plugin name that is assigned to a descriptor using
* <code>getPluginNameForDescriptor</code>.
*/
@Test
public void checkoutShouldBelongToWorkflowSCMStep() {
for (StepDescriptor step : steps) {
Expand All @@ -61,6 +81,10 @@ public void checkoutShouldBelongToWorkflowSCMStep() {
fail("checkout step not found");
}

/**
* Tests if the reactor reaches the last milestone required to initialize the
* plugin manager.
*/
@Test
public void LastMilestoneShouldBeCompletedInitialization() {
assertEquals("Completed initialization", starter.lastMilestone.toString());
Expand Down

0 comments on commit 4379ca3

Please sign in to comment.