Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix MonitorTest.java for scm-api update and java language level 8 #23

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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