org.jvnet.hudson.test
Class MockFolder

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.Actionable
          extended by hudson.model.AbstractItem
              extended by org.jvnet.hudson.test.MockFolder
All Implemented Interfaces:
ExtensionPoint, Describable<TopLevelItem>, DescriptorByNameOwner, Item, ItemGroup<TopLevelItem>, ModelObject, ModifiableItemGroup<TopLevelItem>, PersistenceRoot, Saveable, TopLevelItem, ViewGroup, SearchableModelObject, SearchItem, AccessControlled, ModelObjectWithContextMenu, ModifiableTopLevelItemGroup, org.kohsuke.stapler.HttpDeletable, org.kohsuke.stapler.StaplerFallback

public class MockFolder
extends AbstractItem
implements ModifiableTopLevelItemGroup, TopLevelItem, ViewGroup, org.kohsuke.stapler.StaplerFallback

Minimal implementation of a modifiable item group akin to the CloudBees Folders plugin. No UI, just enough implementation to test functionality of code which should deal with item full names, etc.

Since:
1.494

Nested Class Summary
static class MockFolder.DescriptorImpl
           
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.MenuItem
 
Field Summary
 
Fields inherited from class hudson.model.AbstractItem
description, displayName, name, PRONOUN
 
Fields inherited from interface hudson.model.Saveable
NOOP
 
Fields inherited from interface hudson.model.Item
BUILD, CANCEL, CONFIGURE, CREATE, DELETE, DISCOVER, EXTENDED_READ, PERMISSIONS, READ, WIPEOUT, WORKSPACE
 
Method Summary
 void addView(View view)
           
 boolean canDelete(View view)
          Determine whether a view may be deleted.
<T extends TopLevelItem>
T
copy(T src, String name)
          Copys a job.
<T extends TopLevelItem>
T
createProject(Class<T> type, String name)
          Convenience method to create a FreeStyleProject or similar.
 TopLevelItem createProject(TopLevelItemDescriptor type, String name, boolean notify)
          Creates a new job.
 TopLevelItem createProjectFromXML(String name, InputStream xml)
          /** Creates a new job from its configuration XML.
 void deleteView(View view)
          Deletes a view in this group.
 TopLevelItem doCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          The request format follows that of &lt;n:form xmlns:n="/lib/form">.
 Collection<? extends Job> getAllJobs()
          Gets all the jobs that this Item contains as descendants.
 TopLevelItemDescriptor getDescriptor()
          Gets the descriptor for this instance.
 TopLevelItem getItem(String name)
          Gets the Item inside this group that has a given name.
 ItemGroup<? extends TopLevelItem> getItemGroup()
          Returns the ItemGroup from which the views in this group should render items.
 Collection<TopLevelItem> getItems()
          Gets all the items in this collection in a read-only view.
 TopLevelItem getJob(String name)
          Same as getItem(java.lang.String) but named this way as a WebMethod.
 View getPrimaryView()
          If the view group renders one view in its own URL (like Jenkins top page does), then that view is called the primary view.
 File getRootDirFor(TopLevelItem child)
          Assigns the root directory for children.
 Object getStaplerFallback()
           
 String getUrlChildPrefix()
          Gets the URL token that prefixes the URLs for child Items.
 View getView(String name)
          Gets a view of the given name.
 List<Action> getViewActions()
          Returns actions that should be displayed in views.
 Collection<View> getViews()
          Gets all the views in this group.
 ViewsTabBar getViewsTabBar()
          Gets the TabBar for the views.
 void onDeleted(TopLevelItem item)
          Internal method.
 void onLoad(ItemGroup<? extends Item> parent, String name)
          Called right after when a Item is loaded from disk.
 void onRenamed(TopLevelItem item, String oldName, String newName)
          Internal method.
 void onViewRenamed(View view, String oldName, String newName)
          View calls this method when it's renamed.
 
Methods inherited from class hudson.model.AbstractItem
checkPermission, delete, delete, doConfigDotXml, doDoDelete, doSetName, doSubmitDescription, getAbsoluteUrl, getACL, getApi, getConfigFile, getDescription, getDescriptorByName, getDisplayName, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getPronoun, getRelativeNameFrom, getRelativeNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getUrl, hasPermission, onCopiedFrom, onCreatedFromScratch, performDelete, renameTo, resolveForCLI, save, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml
 
Methods inherited from class hudson.model.Actionable
addAction, doContextMenu, getAction, getAction, getActions, getActions, getDynamic
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hudson.model.ItemGroup
getFullDisplayName, getFullName, getUrl
 
Methods inherited from interface hudson.model.PersistenceRoot
getRootDir
 
Methods inherited from interface hudson.model.Saveable
save
 
Methods inherited from interface hudson.model.Item
delete, getAbsoluteUrl, getDisplayName, getFullDisplayName, getFullName, getName, getParent, getRelativeNameFrom, getRelativeNameFrom, getShortUrl, getUrl, onCopiedFrom, onCreatedFromScratch, save
 
Methods inherited from interface hudson.search.SearchableModelObject
getSearch
 
Methods inherited from interface hudson.search.SearchItem
getSearchIndex, getSearchName, getSearchUrl
 
Methods inherited from interface hudson.security.AccessControlled
checkPermission, getACL, hasPermission
 
Methods inherited from interface hudson.model.ViewGroup
getUrl
 

Method Detail

onLoad

public void onLoad(ItemGroup<? extends Item> parent,
                   String name)
            throws IOException
Description copied from class: AbstractItem
Called right after when a Item is loaded from disk. This is an opporunity to do a post load processing.

Specified by:
onLoad in interface Item
Overrides:
onLoad in class AbstractItem
name - Name of the directory (not a path --- just the name portion) from which the configuration was loaded. This usually becomes the name of this item.
Throws:
IOException

getItems

public Collection<TopLevelItem> getItems()
Description copied from interface: ItemGroup
Gets all the items in this collection in a read-only view.

Specified by:
getItems in interface ItemGroup<TopLevelItem>

getItem

public TopLevelItem getItem(String name)
Description copied from interface: ItemGroup
Gets the Item inside this group that has a given name.

Specified by:
getItem in interface ItemGroup<TopLevelItem>

getAllJobs

public Collection<? extends Job> getAllJobs()
Description copied from class: AbstractItem
Gets all the jobs that this Item contains as descendants.

Specified by:
getAllJobs in interface Item
Specified by:
getAllJobs in class AbstractItem

copy

public <T extends TopLevelItem> T copy(T src,
                                       String name)
                            throws IOException
Description copied from interface: ModifiableTopLevelItemGroup
Copys a job.

Specified by:
copy in interface ModifiableTopLevelItemGroup
Parameters:
src - A TopLevelItem to be copied.
name - Name of the newly created project.
Returns:
Newly created TopLevelItem.
Throws:
IOException

createProjectFromXML

public TopLevelItem createProjectFromXML(String name,
                                         InputStream xml)
                                  throws IOException
Description copied from interface: ModifiableTopLevelItemGroup
/** Creates a new job from its configuration XML. The type of the job created will be determined by what's in this XML.

Specified by:
createProjectFromXML in interface ModifiableTopLevelItemGroup
Parameters:
name - Name of the newly created project.
xml - Item configuration as xml
Returns:
Newly created TopLevelItem.
Throws:
IOException

createProject

public TopLevelItem createProject(TopLevelItemDescriptor type,
                                  String name,
                                  boolean notify)
                           throws IOException
Description copied from interface: ModifiableTopLevelItemGroup
Creates a new job.

Specified by:
createProject in interface ModifiableTopLevelItemGroup
Parameters:
type - Descriptor for job type
name - Name for job
notify - Whether to fire onCreated method for all ItemListeners
Throws:
IOException

createProject

public <T extends TopLevelItem> T createProject(Class<T> type,
                                                String name)
                                     throws IOException
Convenience method to create a FreeStyleProject or similar.

Throws:
IOException

doCreateItem

public TopLevelItem doCreateItem(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp)
                          throws IOException,
                                 javax.servlet.ServletException
Description copied from interface: ModifiableItemGroup
The request format follows that of &lt;n:form xmlns:n="/lib/form">.

Specified by:
doCreateItem in interface ModifiableItemGroup<TopLevelItem>
Throws:
IOException
javax.servlet.ServletException

getUrlChildPrefix

public String getUrlChildPrefix()
Description copied from interface: ItemGroup
Gets the URL token that prefixes the URLs for child Items. Like "job", "item", etc.

Specified by:
getUrlChildPrefix in interface ItemGroup<TopLevelItem>

getRootDirFor

public File getRootDirFor(TopLevelItem child)
Description copied from interface: ItemGroup
Assigns the root directory for children.

Specified by:
getRootDirFor in interface ItemGroup<TopLevelItem>

onRenamed

public void onRenamed(TopLevelItem item,
                      String oldName,
                      String newName)
               throws IOException
Description copied from interface: ItemGroup
Internal method. Called by Items when they are renamed by users.

Specified by:
onRenamed in interface ItemGroup<TopLevelItem>
Throws:
IOException

onDeleted

public void onDeleted(TopLevelItem item)
               throws IOException
Description copied from interface: ItemGroup
Internal method. Called by Items when they are deleted by users.

Specified by:
onDeleted in interface ItemGroup<TopLevelItem>
Throws:
IOException

getDescriptor

public TopLevelItemDescriptor getDescriptor()
Description copied from interface: Describable
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<TopLevelItem>
Specified by:
getDescriptor in interface TopLevelItem
See Also:
Describable.getDescriptor()

addView

public void addView(View view)
             throws IOException
Throws:
IOException

canDelete

public boolean canDelete(View view)
Description copied from interface: ViewGroup
Determine whether a view may be deleted.

Specified by:
canDelete in interface ViewGroup

deleteView

public void deleteView(View view)
                throws IOException
Description copied from interface: ViewGroup
Deletes a view in this group.

Specified by:
deleteView in interface ViewGroup
Throws:
IOException

getViews

public Collection<View> getViews()
Description copied from interface: ViewGroup
Gets all the views in this group.

Specified by:
getViews in interface ViewGroup
Returns:
can be empty but never null.

getView

public View getView(String name)
Description copied from interface: ViewGroup
Gets a view of the given name. This also creates the URL binding for views (in the form of ".../view/FOOBAR/...")

Specified by:
getView in interface ViewGroup

getPrimaryView

public View getPrimaryView()
Description copied from interface: ViewGroup
If the view group renders one view in its own URL (like Jenkins top page does), then that view is called the primary view. In this case, the hyperlink to the primary view points to the view group itself.

If the view group doesn't do such rendering, this method can always return null.

This method was added later to ViewGroup, so old plugins might not be implementing this. To work around this, Views can use View.getOwnerPrimaryView().

Specified by:
getPrimaryView in interface ViewGroup

onViewRenamed

public void onViewRenamed(View view,
                          String oldName,
                          String newName)
Description copied from interface: ViewGroup
View calls this method when it's renamed. This method is intended to work as a notification to the ViewGroup (so that it can adjust its internal data structure, for example.)

It is the caller's responsibility to ensure that the new name is a legal view name.

Specified by:
onViewRenamed in interface ViewGroup

getViewsTabBar

public ViewsTabBar getViewsTabBar()
Description copied from interface: ViewGroup
Gets the TabBar for the views. TabBar for views can be provided by extension. Only one TabBar can be active at a given time (Selectable by user in the global Configuration page). Default TabBar is provided by Hudson Platform.

Specified by:
getViewsTabBar in interface ViewGroup

getItemGroup

public ItemGroup<? extends TopLevelItem> getItemGroup()
Description copied from interface: ViewGroup
Returns the ItemGroup from which the views in this group should render items.

Generally speaking, Views render a subset of TopLevelItems that belong to this item group. This method was added later to ViewGroup, so old plugins might not be implementing this. To work around this, Views can use View.getOwnerItemGroup().

Specified by:
getItemGroup in interface ViewGroup
Returns:
Never null. Sometimes this is ModifiableItemGroup (if the container allows arbitrary addition)

getViewActions

public List<Action> getViewActions()
Description copied from interface: ViewGroup
Returns actions that should be displayed in views.

In this interface, the return value is used read-only. This doesn't prevent subtypes from returning modifiable actions, however.

This method was added later to ViewGroup, so old plugins might not be implementing this. To work around this, Views can use View.getOwnerViewActions().

Specified by:
getViewActions in interface ViewGroup
Returns:
may be empty but never null.
See Also:
Actionable.getActions()

getStaplerFallback

public Object getStaplerFallback()
Specified by:
getStaplerFallback in interface org.kohsuke.stapler.StaplerFallback

getJob

public TopLevelItem getJob(String name)
Same as getItem(java.lang.String) but named this way as a WebMethod.

See Also:
Hudson.getJob(java.lang.String)


Copyright © 2004-2013. All Rights Reserved.