From 20d972067f1ae21630bc6de05c65d75e0cca998c Mon Sep 17 00:00:00 2001 From: simonsymhoven Date: Wed, 5 May 2021 12:15:42 +0200 Subject: [PATCH] fix MonitorTest.java for scm-api update and java language level 8 --- .../plugins/monitoring/MonitorTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/jenkins/plugins/monitoring/MonitorTest.java b/src/test/java/io/jenkins/plugins/monitoring/MonitorTest.java index f59d1653..48253d94 100644 --- a/src/test/java/io/jenkins/plugins/monitoring/MonitorTest.java +++ b/src/test/java/io/jenkins/plugins/monitoring/MonitorTest.java @@ -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; @@ -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; @@ -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; }