Skip to content

Commit

Permalink
Merge branch 'master' into job-inclusion-job-property-test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Dec 29, 2024
2 parents b342fc1 + 003a030 commit d161d4d
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package jenkins.advancedqueue.jobinclusion.strategy;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import hudson.model.FreeStyleProject;
import hudson.model.Run;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class JobInclusionFolderPropertyTest {

@ClassRule
public static JenkinsRule j = new JenkinsRule();

private static FreeStyleProject project;
private static JobInclusionFolderProperty property;

@BeforeClass
public static void createProject() throws Exception {
project = j.createFreeStyleProject();
Run r = project.scheduleBuild2(0).get(); // Schedule a build to ensure the queue item is created
j.assertBuildStatusSuccess(r);
property = new JobInclusionFolderProperty(true, "testGroup");
}

@Test
public void testGetJobGroupName() {
assertEquals("testGroup", property.getJobGroupName());
}

@Test
public void testIsUseJobGroup() {
assertTrue(property.isUseJobGroup());
}

@Test
public void testGetDescriptor() {
assertThat(property.getDescriptor().getId(), is(JobInclusionFolderProperty.class.getName()));
}

@Test
public void testDescriptorImpl() {
JobInclusionFolderProperty.DescriptorImpl descriptor = new JobInclusionFolderProperty.DescriptorImpl();
assertThat(descriptor.getDisplayName(), is("XXX"));
assertThat(descriptor.getJobGroups(), is(empty()));
assertFalse(descriptor.isUsed());
}

@Test
public void testAllJobsJobInclusionStrategy() {
AllJobsJobInclusionStrategy strategy = new AllJobsJobInclusionStrategy();
assertTrue(strategy.contains(null, project));
}
}

0 comments on commit d161d4d

Please sign in to comment.