-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for FolderPropertyLoader class
- Loading branch information
1 parent
7a9621e
commit 5066d89
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/test/java/jenkins/advancedqueue/jobinclusion/strategy/FolderPropertyLoaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package jenkins.advancedqueue.jobinclusion.strategy; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import com.cloudbees.hudson.plugins.folder.Folder; | ||
import hudson.model.FreeStyleProject; | ||
import jenkins.advancedqueue.DecisionLogger; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
public class FolderPropertyLoaderTest { | ||
|
||
@Rule | ||
public JenkinsRule jenkinsRule = new JenkinsRule(); | ||
|
||
private Folder folder; | ||
private FreeStyleProject project; | ||
private DecisionLogger decisionLogger; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
folder = jenkinsRule.createProject(com.cloudbees.hudson.plugins.folder.Folder.class, "testFolder"); | ||
project = folder.createProject(FreeStyleProject.class, "testProject"); | ||
decisionLogger = new DecisionLogger() { | ||
@Override | ||
public DecisionLogger addDecisionLog(int indent, String log) { | ||
return null; | ||
} | ||
}; | ||
} | ||
|
||
@Test | ||
public void getJobGroupName_returnsGroupName_whenJobGroupIsEnabled() throws Exception { | ||
JobInclusionFolderProperty property = new JobInclusionFolderProperty(true, "TestGroup"); | ||
folder.getProperties().add(property); | ||
|
||
String result = FolderPropertyLoader.getJobGroupName(decisionLogger, project); | ||
|
||
assertEquals("TestGroup", result); | ||
} | ||
|
||
@Test | ||
public void getJobGroupName_returnsNull_whenNoJobGroupProperty() throws Exception { | ||
String result = FolderPropertyLoader.getJobGroupName(decisionLogger, project); | ||
|
||
assertNull(result); | ||
} | ||
|
||
@Test | ||
public void getJobGroupName_returnsNull_whenJobGroupIsDisabled() throws Exception { | ||
JobInclusionFolderProperty property = new JobInclusionFolderProperty(false, "TestGroup"); | ||
folder.getProperties().add(property); | ||
|
||
String result = FolderPropertyLoader.getJobGroupName(decisionLogger, project); | ||
|
||
assertNull(result); | ||
} | ||
|
||
@Test | ||
public void getJobGroupName_returnsNull_whenParentIsNotFolder() throws Exception { | ||
FreeStyleProject standaloneProject = jenkinsRule.createFreeStyleProject("standaloneProject"); | ||
|
||
String result = FolderPropertyLoader.getJobGroupName(decisionLogger, standaloneProject); | ||
|
||
assertNull(result); | ||
} | ||
} |