Class SpiraImportExport

java.lang.Object
com.inflectra.spiratest.plugins.SpiraImportExport

public class SpiraImportExport extends Object
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
  • Constructor Details

    • SpiraImportExport

      public SpiraImportExport()
    • SpiraImportExport

      public SpiraImportExport(String url, String userName, Secret token, int projectId)
  • 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 on
      body - The request body to be sent
      username - The Spira username for authentication
      apiKey - 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 on
      body - The request body to be sent
      username - The Spira username for authentication
      apiKey - The Spira API key for authentication
      Returns:
      The HTTP response code returned from the PUT request
      Throws:
      IOException
    • httpGet

      public static String httpGet(String input, String username, String apiKey) throws IOException
      Performs an HTTP GET request to the specified URL with authentication via headers.
      Parameters:
      input - The URL to perform the query on
      username - The Spira username for authentication
      apiKey - The Spira API key for authentication
      Returns:
      A string containing the JSON returned from the GET request
      Throws:
      IOException
    • testConnection

      public boolean testConnection() throws Exception
      Tests the SpiraTeam connection
      Returns:
      true or false, depending on the result
      Throws:
      Exception
    • verifyRelease

      public Integer verifyRelease(String releaseVersionNumber) throws Exception
      Verifies that the release exists in the project
      Parameters:
      releaseVersionNumber -
      Returns:
      The id of the release or null
      Throws:
      Exception
    • createArtifactUrl

      public String createArtifactUrl(String prefix, int artifactId) throws Exception
      Returns the full spira artifact URL for an artifact
      Parameters:
      prefix - The artifact prefix
      artifactId - 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 release
      creationDate - The creation date
      buildStatusId - The status of the build (1 = Fail, 2 = Succeed)
      name - The name of the build
      description - The full build description
      revisions - The list of revisions associated with the build
      incidents - The list of incidents fixed in the build
      Returns:
      The build ID
      Throws:
      Exception
    • convertDatetoUtc

      public static String convertDatetoUtc(Date date)
    • cleanText

      public String cleanText(String text)
      Removes any invalid XML control characters from a string
    • cleanApiText

      public String cleanApiText(String text)
      Escapes strings for safe inclusion in JSON values
    • getUrl

      public String getUrl()
    • setUrl

      public void setUrl(String url)
    • getUserName

      public String getUserName()
    • setUserName

      public void setUserName(String userName)
    • getPassword

      public Secret getPassword()
    • setPassword

      public void setPassword(Secret password)
    • getProjectId

      public int getProjectId()
    • setProjectId

      public void setProjectId(int projectId)