Skip to content
Permalink
Browse files

Added test case to expose [JENKINS-39947] [JENKINS-39950].

The test case runs the static analysis plugins for a job that is part of a folder.
  • Loading branch information...
uhafner committed Jan 3, 2017
1 parent a94aef1 commit 02c3799d89681b2447cffaa5380f45f803db9959
@@ -24,7 +24,6 @@
private final String pluginUrl;
private final ContainerPageObject parent;
private final String plugin;
private final String parentName;

/**
* Creates a new instance of a static analysis action.
@@ -33,7 +32,7 @@
* @param plugin plug-in name
*/
public AnalysisAction(final Build parent, final String plugin) {
this(plugin + "Result", plugin, parent, parent.getName());
this(plugin + "Result", plugin, parent);
}

/**
@@ -43,7 +42,7 @@ public AnalysisAction(final Build parent, final String plugin) {
* @param plugin Path to plugin without / at the end
*/
public AnalysisAction(final Job parent, final String plugin) {
this(plugin, plugin, parent, parent.name);
this(plugin, plugin, parent);
}

/**
@@ -55,13 +54,12 @@ protected ContainerPageObject getParent() {
return parent;
}

private AnalysisAction(final String url, final String pluginUrl, final ContainerPageObject parent, final String parentName) {
private AnalysisAction(final String url, final String pluginUrl, final ContainerPageObject parent) {
super(parent, parent.url(url + '/'));

this.pluginUrl = pluginUrl;
this.parent = parent;
plugin = url;
this.parentName = parentName;
}

/**
@@ -85,15 +83,6 @@ private AnalysisAction(final String url, final String pluginUrl, final Container
*/
public abstract Class<? extends AbstractListViewColumn> getViewColumn();

/**
* Returns the human readable name of the parent of this action.
*
* @return the parent name
*/
public String getParentName() {
return parentName;
}

/**
* Returns the human readable name of this action.
*
@@ -0,0 +1,22 @@
package org.jenkinsci.test.acceptance.po;

/**
* A container owns jobs and views. Know container implementations are {@link Jenkins} and {@link Folder}.
*
* @author Ullrich Hafner
*/
public interface Container {
/**
* Returns the jobs in this container.
*
* @return the jobs
*/
JobsMixIn getJobs();

/**
* Returns the views in this container.
*
* @return the views
*/
ViewsMixIn getViews();
}
@@ -29,20 +29,27 @@
import com.google.inject.Injector;

/**
* Top level item representing a folder.
* A container that stores nested items like {@link Job jobs}. A folder may contain a hierarchy of folders.
*/
@Describable("com.cloudbees.hudson.plugins.folder.Folder")
public class FolderItem extends TopLevelItem {
public final JobsMixIn jobs;
public class Folder extends TopLevelItem implements Container {
private final JobsMixIn jobs;
private final ViewsMixIn views;

public FolderItem(Injector injector, URL url, String name) {
public Folder(final Injector injector, final URL url, final String name) {
super(injector, url, name);

jobs = new JobsMixIn(this);
views = new ViewsMixIn(this);
}
public FolderItem(PageObject context, URL url, String name) {
super(context, url, name);
jobs = new JobsMixIn(this);

@Override
public JobsMixIn getJobs() {
return jobs;
}

@Override
public ViewsMixIn getViews() {
return views;
}
}
@@ -1,9 +1,5 @@
package org.jenkinsci.test.acceptance.po;

import static org.hamcrest.Matchers.not;
import static org.jenkinsci.test.acceptance.Matchers.hasContent;
import hudson.util.VersionNumber;

import java.io.IOException;
import java.net.URL;
import java.util.Map;
@@ -12,12 +8,16 @@

import org.hamcrest.MatcherAssert;
import org.jenkinsci.test.acceptance.controller.JenkinsController;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

import com.google.common.base.Predicate;
import com.google.inject.Injector;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import static org.hamcrest.Matchers.*;
import static org.jenkinsci.test.acceptance.Matchers.*;

import hudson.util.VersionNumber;

/**
* Top-level object that acts as an entry point to various systems.
@@ -27,7 +27,7 @@
*
* @author Kohsuke Kawaguchi
*/
public class Jenkins extends Node {
public class Jenkins extends Node implements Container {
private VersionNumber version;

public final JobsMixIn jobs;
@@ -184,4 +184,14 @@ public Plugin getPlugin(String name) {
public String getName() {
return "(master)";
}

@Override
public JobsMixIn getJobs() {
return jobs;
}

@Override
public ViewsMixIn getViews() {
return views;
}
}
@@ -10,8 +10,7 @@

/**
* Super class for top level items.
* Top level items include {@link Job}s and other non-buildable items
* such as {@link FolderItem}s.
* Top level items include {@link Job}s and other non-buildable items such as {@link Folder}s.
* Use {@link Describable} annotation to register an implementation.
*/
public abstract class TopLevelItem extends ContainerPageObject {
@@ -1,20 +1,21 @@
package org.jenkinsci.test.acceptance.po;

import com.google.inject.Injector;
import org.apache.commons.io.IOUtils;
import org.jenkinsci.test.acceptance.plugins.workflow_multibranch.BranchSource;

import java.io.IOException;
import java.net.URL;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.IOUtils;
import org.jenkinsci.test.acceptance.plugins.workflow_multibranch.BranchSource;

import com.google.inject.Injector;

/**
* A pipeline multi-branch job (requires installation of multi-branch-project-plugin).
*
*/
@Describable("org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject")
public class WorkflowMultiBranchJob extends FolderItem {
public class WorkflowMultiBranchJob extends Folder {

public WorkflowMultiBranchJob(Injector injector, URL url, String name) {
super(injector, url, name);
@@ -54,7 +55,7 @@ public Boolean call() {
}

public WorkflowJob getJob(final String name) {
return this.jobs.get(WorkflowJob.class, name);
return this.getJobs().get(WorkflowJob.class, name);
}

}

0 comments on commit 02c3799

Please sign in to comment.
You can’t perform that action at this time.