Class BackdoorControl<T extends BackdoorControl<T>>
- java.lang.Object
-
- com.atlassian.bamboo.testutils.backdoor.BackdoorControl<T>
-
- Direct Known Subclasses:
AdministrationControl,AgentsControl,AnalyticsControl,ApplicationLinksControl,ArtifactsControl,AuthenticationAnalyticsControl,BuildResultsControl,CacheControl,CapabilitiesControl,CaptchaControl,DarkFeatureControl,DatabaseControl,DeploymentsControl,EnvironmentsControl,EventsControl,GlobalPermissionControl,GroupControl,IndexControl,LogControl,LogSettingsControl,PermissionsControl,PlansControl,PluginSettingsControl,PreferencesControl,ProjectsControl,PropertyControl,QueueControl,QuickFiltersControl,RepositoryControl,RollbackControl,SchedulerControl,SecretControl,ServerCapabilitiesControl,ServerControl,SharedCredentialsControl,StatsControl,SystemControl,TestsControl,TroubleshootingControl,UserControl
public class BackdoorControl<T extends BackdoorControl<T>> extends Object
Copied from jira-testkit-client
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBackdoorControl.AddXsrfNoCheckTokenFilterprotected static classBackdoorControl.JsonMediaTypeFilterSets theContent-Typeheader to ""application/json"" if not already set.
-
Field Summary
Fields Modifier and Type Field Description static StringADMIN_REST_PATHstatic StringAPI_REST_PATHstatic StringDEFAULT_REST_PATHThe default REST path for the TestKit resources.protected StringrootPathBase URL.
-
Constructor Summary
Constructors Constructor Description BackdoorControl(@NotNull BambooEnvironmentData environmentData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.sun.jersey.api.client.Clientclient()Returns the Jersey client to use.protected com.sun.jersey.api.client.WebResourcecreateResource()Creates the resource that corresponds to the root of the TestKit REST API, using the values returned bygetRestModulePath().protected com.sun.jersey.api.client.WebResourcecreateResourceForPath(String restModulePath)Creates the resource that corresponds to the root of a REST API.protected Stringget(com.sun.jersey.api.client.WebResource webResource)Convenience method that simply callsWebResource.get(String.class)on the passed-in WebResource.protected BambooEnvironmentDatagetEnvironmentData()protected StringgetRestModulePath()Returns the REST path used in this plugin'satlassian-plugin.xml(e.g.protected static StringpercentEncode(String queryParam)Percent-encode the % when stuffing it into a query param.PingResponseping()protected static <T> Tpost(com.sun.jersey.api.client.UniformInterface entity, Class<T> clazz)protected com.sun.jersey.api.client.WebResourceresourceRoot(String url)Creates a WebResource with authentication parameters set for the default user.voidtearDown()Cleanup resources
-
-
-
Field Detail
-
DEFAULT_REST_PATH
public static final String DEFAULT_REST_PATH
The default REST path for the TestKit resources.- See Also:
- Constant Field Values
-
API_REST_PATH
public static final String API_REST_PATH
- See Also:
- Constant Field Values
-
ADMIN_REST_PATH
public static final String ADMIN_REST_PATH
- See Also:
- Constant Field Values
-
rootPath
protected final String rootPath
Base URL.
-
-
Constructor Detail
-
BackdoorControl
public BackdoorControl(@NotNull @NotNull BambooEnvironmentData environmentData)
-
-
Method Detail
-
ping
public PingResponse ping()
-
tearDown
public void tearDown()
Cleanup resources
-
client
protected com.sun.jersey.api.client.Client client()
Returns the Jersey client to use.- Returns:
- a Client
-
resourceRoot
protected com.sun.jersey.api.client.WebResource resourceRoot(String url)
Creates a WebResource with authentication parameters set for the default user.
-
createResource
protected com.sun.jersey.api.client.WebResource createResource()
Creates the resource that corresponds to the root of the TestKit REST API, using the values returned bygetRestModulePath(). Note that the createdWebResourcehas the following properties:- it logs all GET/POST/etc requests made through it
- it sets the
Content-Type: application/jsonby default (override withWebResource.type(javax.ws.rs.core.MediaType))
createResourceForPath(java.lang.String)- Returns:
- a WebResource for the TestKit REST API root
- See Also:
createResource(),getRestModulePath()
-
createResourceForPath
protected final com.sun.jersey.api.client.WebResource createResourceForPath(String restModulePath)
Creates the resource that corresponds to the root of a REST API. Note that the createdWebResourcehas the following properties:- it logs all GET/POST/etc requests made through it
- it sets the
Content-Type: application/jsonby default (override withWebResource.type(javax.ws.rs.core.MediaType))
- Parameters:
restModulePath- a String containing the REST path- Returns:
- a WebResource for the the API root at the specified path
- See Also:
getRestModulePath()
-
getRestModulePath
protected String getRestModulePath()
Returns the REST path used in this plugin'satlassian-plugin.xml(e.g.<rest path="...">). The default value is ""backdoor"".- Returns:
- the REST path used in this plugin's
atlassian-plugin.xml(e.g.<rest path="...">).
-
get
protected final String get(com.sun.jersey.api.client.WebResource webResource)
Convenience method that simply callsWebResource.get(String.class)on the passed-in WebResource.This method is often used for mutative operations which should really be using a POST instead, but doing a GET is much more convenient since you can do it right from your browser when testing a backdoor and this is only testing code so it's OK.
- Parameters:
webResource- the WebResource to perform the GET on
-
percentEncode
protected static String percentEncode(String queryParam)
Percent-encode the % when stuffing it into a query param. Otherwise it may not get escaped properly, as per this EAC blog.- Parameters:
queryParam- the query param value- Returns:
- a String with % replaced by %25
-
getEnvironmentData
protected BambooEnvironmentData getEnvironmentData()
-
post
protected static <T> T post(com.sun.jersey.api.client.UniformInterface entity, Class<T> clazz)
-
-