Class ComparizenClient

java.lang.Object
com.comparizen.client.ComparizenClient

public class ComparizenClient extends Object
  • Method Details

    • createTestRun

      public String createTestRun(String projectId) throws ComparizenClientException
      Creates a new Comparizen test run
      Parameters:
      projectId - the project's ID where the test run should be created.
      Returns:
      the new test run's ID
      Throws:
      ComparizenClientException - when the test run could not be created
    • createTestRun

      public String createTestRun(String projectId, String name) throws ComparizenClientException
      Creates a new Comparizen test run
      Parameters:
      projectId - the project's ID where the test run should be created.
      name - a name describing this test run (optional)
      Returns:
      the new test run's ID
      Throws:
      ComparizenClientException - when the test run could not be created
    • createTestRun

      public String createTestRun(String projectId, String name, Map<String,String> customEnvironmentProperties) throws ComparizenClientException
      Creates a new Comparizen test run
      Parameters:
      projectId - the project's ID where the test run should be created.
      name - a name describing this test run (optional)
      customEnvironmentProperties - custom environment properties, used for integrating Comparizen test results with other systems, like CI-builds.
      Returns:
      the new test run's ID
      Throws:
      ComparizenClientException - when the test run could not be created
    • finalizeTestRun

      public void finalizeTestRun(String testRunId) throws ComparizenClientException
      Finalizes a Comparizen test run. Finalizing a test run marks the test run as 'completed' and will prevent the test run from accepting new screenshots.
      Parameters:
      testRunId - the test run's ID
      Throws:
      ComparizenClientException - when the test run could not be finalized
    • createComparison

      public String createComparison(String testRunId, String name, Path file) throws ComparizenClientException
      Adds a new comparison (screenshot) to a test run
      Parameters:
      testRunId - the test run's ID
      name - the name of the screenshot. This screenshot will be compared to a screenshot from the testrun project's baseline with the same name.
      file - path to the screenshot file
      Returns:
      the ID of the newly created comparison
      Throws:
      ComparizenClientException - when something went wrong while uploading the screenshot or creating the comparison
    • createComparison

      public String createComparison(String testRunId, String name, BufferedImage bufferedImage, ImageType imageType) throws ComparizenClientException
      Adds a new comparison (screenshot) to a test run
      Parameters:
      testRunId - the test run's ID
      name - the name of the screenshot. This screenshot will be compared to a screenshot from the testrun project's baseline with the same name.
      bufferedImage - A BufferedImage containing image data
      imageType - an ImageType.
      Returns:
      the ID of the newly created comparison
      Throws:
      ComparizenClientException - when something went wrong while uploading the screenshot or creating the comparison
    • createComparison

      public String createComparison(String testRunId, String name, Path file, ComparisonProperties properties) throws ComparizenClientException
      Adds a new comparison (screenshot) to a test run
      Parameters:
      testRunId - the test run's ID
      name - the name of the screenshot. This screenshot will be compared to a screenshot from the testrun project's baseline with the same name.
      file - path to the screenshot file
      properties - additional properties for this comparison, such as tag names.
      Returns:
      the ID of the newly created comparison
      Throws:
      ComparizenClientException - when something went wrong while uploading the screenshot or creating the comparison
    • createComparison

      public String createComparison(String testRunId, String name, BufferedImage bufferedImage, ImageType imageType, ComparisonProperties properties) throws ComparizenClientException
      Adds a new comparison (screenshot) to a test run
      Parameters:
      testRunId - the test run's ID
      name - the name of the screenshot. This screenshot will be compared to a screenshot from the testrun project's baseline with the same name.
      bufferedImage - A BufferedImage containing image data
      imageType - an ImageType.
      properties - additional properties for this comparison, such as tag names.
      Returns:
      the ID of the newly created comparison
      Throws:
      ComparizenClientException - when something went wrong while uploading the screenshot or creating the comparison
    • getTestRunStatus

      public TestRunStatusResponse getTestRunStatus(String testRunId) throws ComparizenClientException
      Retrieves a test run's status
      Parameters:
      testRunId - the test run's ID
      Returns:
      a TestRunStatusResponse describing the test run's status
      Throws:
      ComparizenClientException - when something went wrong while retrieving the test run's status
    • waitUntilTestRunResult

      public TestRunStatusResponse waitUntilTestRunResult(String testRunId, long timeoutMs) throws ComparizenClientException, InterruptedException
      Waits until a test run is either finalized or the given timeout is passed. This method will poll the Comparizen service every 500 ms.
      Parameters:
      testRunId - a test run's ID
      timeoutMs - the maximum amount of milliseconds to wait.
      Returns:
      a TestRunStatusResponse
      Throws:
      ComparizenClientException - when timeout exceeded or something went wrong while retrieving the test run status
      InterruptedException - when the current Thread is interrupted