Skip to content

Commit

Permalink
# This is a combination of 3 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Add createActionAndItem method to initialize

- action and item for tests
- typo fix
-Add item.task instance of Job test
  • Loading branch information
yashpal2104 committed Jan 19, 2025
1 parent 53f2ed7 commit 4eafe52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class PriorityStrategy implements ExtensionPoint, Describable<Pr
/**
* Method that checks if strategy can assign a priority to the provided {@link Item}
*
* The caller guaranties that the {@link Item#task} is a {@link Job}
* The caller guarantees that the {@link Item#task} is a {@link Job}
*
* @param item the {@link Item} to check
* @return <code>true</code> if the {@link PriorityStrategy} is applicable else <code>false</code>
Expand All @@ -52,7 +52,7 @@ public abstract class PriorityStrategy implements ExtensionPoint, Describable<Pr
* Method that that return the priority that should be used for this {@link Item}, this method is only called id
* {@link PriorityStrategy#isApplicable(Queue.Item)} returned true
*
* The caller garanties that the {@link Item#task} is a {@link Job}
* The caller guarantees that the {@link Item#task} is a {@link Job}
*
* @param item the {@link Item} to check
* @return the priority to be used by the provided {@link Item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.FreeStyleProject;
import hudson.model.Job;
import hudson.model.Queue;
import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -32,23 +33,22 @@ public class PriorityStrategyTest {
public static void setUp() throws IOException {
project = j.createFreeStyleProject();
strategy = new TestPriorityStrategy();
}

@BeforeClass
public static void createActionAndItem() {
action = new Action() {
/**
*/

@Override
public String getIconFileName() {
return "";
}

/**
*/
@Override
public String getDisplayName() {
return "";
}

/**
*/
@Override
public String getUrlName() {
return "";
Expand Down Expand Up @@ -84,6 +84,16 @@ public void testNumberPrioritiesUpdates() {
public void testAll() {
DescriptorExtensionList<PriorityStrategy, Descriptor<PriorityStrategy>> list = PriorityStrategy.all();
assertNotNull("DescriptorExtensionList should not be null", list);
// The list.size() method returns 7 because the DescriptorExtensionList for PriorityStrategy contains 7
// descriptors. This means there are 7 different implementations of the PriorityStrategy class registered in the
// Jenkins instance.
assertEquals(7, list.size());
}

@Test
public void testItemTaskIsInstanceOfJob() {
item = new Queue.WaitingItem(Calendar.getInstance(), project, new ArrayList<>());
assertTrue(item.task instanceof Job);
}

private static class TestPriorityStrategy extends PriorityStrategy {
Expand Down Expand Up @@ -114,9 +124,6 @@ public int getNewNumberOfPriorities() {
return newNumberOfPriorities;
}

/**
*
*/
@Override
public Descriptor<PriorityStrategy> getDescriptor() {
return null;
Expand Down

0 comments on commit 4eafe52

Please sign in to comment.