use of org.kohsuke.stapler.StaplerRequest in project blueocean-plugin by jenkinsci.
the class ContainerFilter method filterNames.
private static String[] filterNames() {
StaplerRequest req = Stapler.getCurrentRequest();
if (req == null) {
return new String[0];
}
String itemFilter = req.getParameter("filter");
if (itemFilter == null) {
return new String[0];
}
return itemFilter.split(",");
}
use of org.kohsuke.stapler.StaplerRequest in project blueocean-plugin by jenkinsci.
the class FavoriteContainerImpl method iterator.
@Override
public Iterator<BlueFavorite> iterator() {
StaplerRequest request = Stapler.getCurrentRequest();
int start = 0;
int limit = PagedResponse.DEFAULT_LIMIT;
if (request != null) {
String startParam = request.getParameter("start");
if (StringUtils.isNotBlank(startParam)) {
start = Integer.parseInt(startParam);
}
String limitParam = request.getParameter("limit");
if (StringUtils.isNotBlank(limitParam)) {
limit = Integer.parseInt(limitParam);
}
}
return iterator(start, limit);
}
use of org.kohsuke.stapler.StaplerRequest in project hudson-2.x by hudson.
the class CascadingUtilTest method testBuildExternalProperties.
@Test
@PrepareForTest({ Hudson.class, StaplerRequest.class })
public void testBuildExternalProperties() throws Exception {
Job job = new FreeStyleProjectMock("job");
StaplerRequest req = createMock(StaplerRequest.class);
String javadocArchiverKey = "hudson-tasks-JavadocArchiver";
JSONObject archiver = new JSONObject();
archiver.put("javadoc_dir", "dir");
archiver.put("keep_all", true);
JSONObject json = new JSONObject();
json.put(javadocArchiverKey, archiver);
Hudson hudson = createMock(Hudson.class);
Descriptor<Publisher> javadocDescriptor = new JavadocArchiver.DescriptorImpl();
expect(hudson.getDescriptorOrDie(JavadocArchiver.class)).andReturn(javadocDescriptor);
JavadocArchiver javadocArchiver = new JavadocArchiver("dir", true);
expect(req.bindJSON(JavadocArchiver.class, archiver)).andReturn(javadocArchiver).anyTimes();
List<Descriptor<Publisher>> descriptors = new ArrayList<Descriptor<Publisher>>();
descriptors.add(javadocDescriptor);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replay(Hudson.class, hudson, req);
assertNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
CascadingUtil.buildExternalProperties(req, archiver, descriptors, job);
assertNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
CascadingUtil.buildExternalProperties(req, json, descriptors, job);
assertNotNull(CascadingUtil.getExternalProjectProperty(job, javadocArchiverKey).getValue());
verifyAll();
}
use of org.kohsuke.stapler.StaplerRequest in project support-core-plugin by jenkinsci.
the class ReverseProxyTest method addContents_NoCurrentRequest.
@Test
public void addContents_NoCurrentRequest() {
subject = new ReverseProxy() {
@Override
protected StaplerRequest getCurrentRequest() {
return null;
}
};
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Container container = createContainer(baos);
subject.addContents(container);
for (String header : FORWARDED_HEADERS) {
assertThat(baos.toString(), containsString(expectedMessage(header, ReverseProxy.Trilean.UNKNOWN)));
}
}
Aggregations