Skip to content

Commit

Permalink
fix MonitorTest.java for scm-api update and java language level 8
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsymhoven committed May 5, 2021
1 parent abb046c commit 20d9720
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/test/java/io/jenkins/plugins/monitoring/MonitorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import hudson.model.Result;
import jenkins.branch.BranchSource;
import jenkins.scm.impl.mock.MockSCMController;
import jenkins.scm.impl.mock.MockSCMDiscoverBranches;
import jenkins.scm.impl.mock.MockSCMDiscoverChangeRequests;
import jenkins.scm.impl.mock.MockSCMSource;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand Down Expand Up @@ -83,12 +85,14 @@ private WorkflowMultiBranchProject createRepositoryWithPr(String jenkinsfile) th
final int num = controller.openChangeRequest("scm-repo", "master");
final String crNum = "change-request/" + num;
InputStream st = getClass().getResourceAsStream(String.format("/io/jenkins/plugins/monitoring/%s", jenkinsfile));
byte[] targetArray = new byte[st.available()];
st.read(targetArray);
controller.addFile("scm-repo", crNum, "Jenkinsfile", "Jenkinsfile",
st.readAllBytes());
targetArray);

WorkflowMultiBranchProject project = jenkinsRule.createProject(WorkflowMultiBranchProject.class);
project.getSourcesList().add(new BranchSource(new MockSCMSource("1", controller, "scm-repo",
false, false, true)));
project.getSourcesList().add(new BranchSource(new MockSCMSource(controller, "scm-repo",
new MockSCMDiscoverChangeRequests())));


return project;
Expand All @@ -99,12 +103,14 @@ private WorkflowMultiBranchProject createRepositoryWithoutPr(String jenkinsfile)
controller.createRepository("scm-repo");
controller.createBranch("scm-repo", "master");
InputStream st = getClass().getResourceAsStream(String.format("/io/jenkins/plugins/monitoring/%s", jenkinsfile));
byte[] targetArray = new byte[st.available()];
st.read(targetArray);
controller.addFile("scm-repo", "master", "Jenkinsfile", "Jenkinsfile",
st.readAllBytes());
targetArray);

WorkflowMultiBranchProject project = jenkinsRule.createProject(WorkflowMultiBranchProject.class);
project.getSourcesList().add(new BranchSource(new MockSCMSource("1", controller, "scm-repo",
true, false, false)));
project.getSourcesList().add(new BranchSource(new MockSCMSource(controller, "scm-repo",
new MockSCMDiscoverBranches())));

return project;
}
Expand Down

0 comments on commit 20d9720

Please sign in to comment.