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

Feature/get build actions #29

Merged
merged 27 commits into from
Jul 26, 2018
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a6b2659
Added actions api to BuildInfo for retrieving build parameters
richabindra Jul 19, 2018
6c87f66
Added Action class to provide parameters and causes api
richabindra Jul 19, 2018
419d91a
Class added to get "causes" values in build info
richabindra Jul 19, 2018
c000735
Class added to get "parameters" values in build info
richabindra Jul 19, 2018
77c31ad
test resource file added - build info with no parameters
richabindra Jul 19, 2018
c2a1468
Mock tests for get build parameters and causes
richabindra Jul 19, 2018
265566c
Nullable annotation added to userName field
richabindra Jul 23, 2018
ef62f58
Added live test for getting build parameters of a job
richabindra Jul 23, 2018
529386b
Added live test for getting build causes of a job
richabindra Jul 23, 2018
f02e443
Added serialized "_class" item to Cause class
richabindra Jul 24, 2018
733dde3
Added serialized "_class" item to Parameter class
richabindra Jul 24, 2018
89f5ae9
Made method parameters final
richabindra Jul 24, 2018
ba324d7
Made method params final
richabindra Jul 24, 2018
ba92bf2
Test resource for build info when empty and null params
richabindra Jul 24, 2018
ac9e189
Added test for get params when empty or null params
richabindra Jul 24, 2018
22c630b
Redo test for get params when empty or null for simpler check
richabindra Jul 24, 2018
af01590
Removed unused import
richabindra Jul 24, 2018
c75a699
Check for potential null value in parameters map and convert to an em…
richabindra Jul 25, 2018
ffd3dbd
Resource build info json returns null string
richabindra Jul 25, 2018
c82f329
Add config xml with no default parameters to test empty and null params
richabindra Jul 25, 2018
f563208
Check for null string
richabindra Jul 25, 2018
5c6adbc
Test for parameters when no build parameters present
richabindra Jul 25, 2018
3295870
Test for empty or null build parameters
richabindra Jul 25, 2018
c2552c4
Move getRunningQueueItem method in a base class
richabindra Jul 26, 2018
a66ba2e
Removed getRunningQueueItem as it is moved to the base class
richabindra Jul 26, 2018
59dd3f3
Ensure queue item is running after build is triggered
richabindra Jul 26, 2018
06f4974
getBuildCauses test made user name independent
richabindra Jul 26, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -577,6 +578,37 @@ public void testGetParamsWhenNoBuildParams() throws Exception {
}
}

public void testGetParamsWhenEmptyorNullParams() throws Exception {
MockWebServer server = mockWebServer();

String body = payloadFromResource("/build-info-empty-and-null-params.json");
server.enqueue(new MockResponse().setBody(body).setResponseCode(200));
JenkinsApi jenkinsApi = api(server.getUrl("/"));
JobsApi api = jenkinsApi.jobsApi();
try {
List<Action> output = api.buildInfo(null,"fish", 10).actions();
List<Parameter> parameters = new ArrayList<>();
for (Action action : output) {
if (!action.parameters().isEmpty()) {
parameters = action.parameters();
}
}
for (Parameter parameter : parameters) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally added the test like this to provide an alternative to get(0) etc for getting params. I can change it if suggested otherwise.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, thanks for the tip, but I don't think it is necessary. In fact it makes the test slightly harder to read.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Makes it harder to read. Lets just use what comes OOTB and iterate over that.

if (parameter.name().equals("bear")) {
assertNull(parameter.value());
}
if (parameter.name().equals("fish")) {
assertTrue(parameter.value().isEmpty());
}
}
assertSent(server, "GET", "/job/fish/10/api/json");

} finally {
jenkinsApi.close();
server.shutdown();
}
}

public void testGetCause() throws Exception {
MockWebServer server = mockWebServer();

Expand Down