Skip to content

Commit 5cc0f3f

Browse files
committed
Added a test case
1 parent 1eb939f commit 5cc0f3f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.jenkins.plugins.launchable;
2+
3+
import com.cloudbees.hudson.plugins.folder.Folder;
4+
import hudson.model.FreeStyleBuild;
5+
import hudson.model.FreeStyleProject;
6+
import net.sf.json.JSONObject;
7+
import org.hamcrest.MatcherAssert;
8+
import org.junit.Rule;
9+
import org.junit.Test;
10+
import org.jvnet.hudson.test.JenkinsRule;
11+
12+
import java.io.IOException;
13+
14+
import static org.hamcrest.CoreMatchers.*;
15+
import static org.junit.Assert.*;
16+
17+
public class PropBuilderTest {
18+
@Rule
19+
public JenkinsRule j = new JenkinsRule();
20+
21+
@Test
22+
public void basics() throws Exception {
23+
Folder folder1 = j.jenkins.createProject(Folder.class,"foo");
24+
FreeStyleProject project = folder1.createProject(FreeStyleProject.class,"bar");
25+
FreeStyleBuild build = project.scheduleBuild2(0).get();
26+
27+
JSONObject props = new PropsBuilder<>(build).build();
28+
MatcherAssert.assertThat(props, is(new JSONObject()
29+
.accumulate("job", new JSONObject()
30+
.accumulate("fullName", "foo/bar")
31+
.accumulate("type", FreeStyleProject.class.getName())
32+
.accumulate("components", new JSONObject[] {
33+
new JSONObject()
34+
.accumulate("name", "foo")
35+
.accumulate("type", Folder.class.getName()),
36+
new JSONObject()
37+
.accumulate("name", "bar")
38+
.accumulate("type", FreeStyleProject.class.getName())
39+
}))
40+
.accumulate("build", new JSONObject()
41+
.accumulate("number", 1)
42+
.accumulate("displayName", "#1")
43+
)
44+
));
45+
}
46+
}

0 commit comments

Comments
 (0)