Package com.inflectra.spiratest.plugins
Class SpiraImportExport
java.lang.Object
com.inflectra.spiratest.plugins.SpiraImportExport
This defines the 'SpiraImportExport' class that provides the Java facade for
calling the REST web service exposed by SpiraTest
- Version:
- 4.0.2
- Author:
- Inflectra Corporation
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncleanApiText(String text) Escapes strings for safe inclusion in JSON valuesRemoves any invalid XML control characters from a stringstatic StringconvertDatetoUtc(Date date) createArtifactUrl(String prefix, int artifactId) Returns the full spira artifact URL for an artifactintgetUrl()static StringPerforms an HTTP GET request to the specified URL with authentication via headers.static StringPerforms an HTTP POST request to the specified URL with authentication via headers.static intPerforms an HTTP PUT request to the specified URL with authentication via headers.intrecordBuild(String releaseVersionNumber, Date creationDate, int buildStatusId, String name, String description, List<String> revisions, List<Integer> incidents) Creates a new build entry in SpiraTestvoidsetPassword(Secret password) voidsetProjectId(int projectId) voidvoidsetUserName(String userName) booleanTests the SpiraTeam connectionverifyRelease(String releaseVersionNumber) Verifies that the release exists in the project
-
Constructor Details
-
SpiraImportExport
public SpiraImportExport() -
SpiraImportExport
-
-
Method Details
-
httpPost
public static String httpPost(String input, String body, String username, String apiKey) throws IOException Performs an HTTP POST request to the specified URL with authentication via headers.- Parameters:
input- The URL to perform the query onbody- The request body to be sentusername- The Spira username for authenticationapiKey- The Spira API key for authentication- Returns:
- A string containing the JSON returned from the POST request
- Throws:
IOException
-
httpPut
public static int httpPut(String input, String body, String username, String apiKey) throws IOException Performs an HTTP PUT request to the specified URL with authentication via headers.- Parameters:
input- The URL to perform the query onbody- The request body to be sentusername- The Spira username for authenticationapiKey- The Spira API key for authentication- Returns:
- The HTTP response code returned from the PUT request
- Throws:
IOException
-
httpGet
Performs an HTTP GET request to the specified URL with authentication via headers.- Parameters:
input- The URL to perform the query onusername- The Spira username for authenticationapiKey- The Spira API key for authentication- Returns:
- A string containing the JSON returned from the GET request
- Throws:
IOException
-
testConnection
Tests the SpiraTeam connection- Returns:
- true or false, depending on the result
- Throws:
Exception
-
verifyRelease
Verifies that the release exists in the project- Parameters:
releaseVersionNumber-- Returns:
- The id of the release or null
- Throws:
Exception
-
createArtifactUrl
Returns the full spira artifact URL for an artifact- Parameters:
prefix- The artifact prefixartifactId- The artifact id- Returns:
- The full URL to the artifact
- Throws:
Exception
-
recordBuild
public int recordBuild(String releaseVersionNumber, Date creationDate, int buildStatusId, String name, String description, List<String> revisions, List<Integer> incidents) throws Exception Creates a new build entry in SpiraTest- Parameters:
releaseVersionNumber- The current releasecreationDate- The creation datebuildStatusId- The status of the build (1 = Fail, 2 = Succeed)name- The name of the builddescription- The full build descriptionrevisions- The list of revisions associated with the buildincidents- The list of incidents fixed in the build- Returns:
- The build ID
- Throws:
Exception
-
convertDatetoUtc
-
cleanText
Removes any invalid XML control characters from a string -
cleanApiText
Escapes strings for safe inclusion in JSON values -
getUrl
-
setUrl
-
getUserName
-
setUserName
-
getPassword
-
setPassword
-
getProjectId
public int getProjectId() -
setProjectId
public void setProjectId(int projectId)
-