Skip to content

Commit

Permalink
Cleanup - Simplify code using method references
Browse files Browse the repository at this point in the history
  • Loading branch information
darxriggs committed Feb 14, 2019
1 parent 1f9c1cb commit a5d1027
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Expand Up @@ -8,7 +8,6 @@
import hudson.tasks.Builder;
import hudson.Launcher;

import java.util.concurrent.Callable;
import java.io.IOException;

/**
Expand All @@ -22,16 +21,11 @@ public abstract class GroovyHudsonTestCase extends HudsonTestCase {
/**
* Executes the given closure on the server, in the context of an HTTP request.
* This is useful for testing some methods that require {@link StaplerRequest} and {@link StaplerResponse}.
*
* <p>
* The closure will get the request and response as parameters.
*/
public Object executeOnServer(final Closure c) throws Exception {
return executeOnServer(new Callable<Object>() {
public Object call() throws Exception {
return c.call();
}
});
return executeOnServer(c::call);
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/org/jvnet/hudson/test/GroovyJenkinsRule.java
Expand Up @@ -30,7 +30,6 @@
import hudson.model.BuildListener;
import hudson.tasks.Builder;
import java.io.IOException;
import java.util.concurrent.Callable;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

Expand All @@ -43,16 +42,11 @@ public class GroovyJenkinsRule extends JenkinsRule {
/**
* Executes the given closure on the server, in the context of an HTTP request.
* This is useful for testing some methods that require {@link StaplerRequest} and {@link StaplerResponse}.
*
* <p>
* The closure will get the request and response as parameters.
*/
public Object executeOnServer(final Closure c) throws Exception {
return executeOnServer(new Callable<Object>() {
@Override public Object call() throws Exception {
return c.call();
}
});
return executeOnServer(c::call);
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/org/jvnet/hudson/test/MockFolder.java
Expand Up @@ -40,7 +40,6 @@
import hudson.model.View;
import hudson.model.ViewGroupMixIn;
import hudson.model.listeners.ItemListener;
import hudson.util.Function1;
import hudson.views.DefaultViewsTabBar;
import hudson.views.ViewsTabBar;
import java.io.File;
Expand Down Expand Up @@ -83,11 +82,7 @@ protected MockFolder(ItemGroup parent, String name) {

@Override public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
super.onLoad(parent, name);
items = ItemGroupMixIn.loadChildren(this, jobs(), new Function1<String,TopLevelItem>() {
public String call(TopLevelItem item) {
return item.getName();
}
});
items = ItemGroupMixIn.loadChildren(this, jobs(), Item::getName);
}

@Override public Collection<TopLevelItem> getItems() {
Expand Down

0 comments on commit a5d1027

Please sign in to comment.