Class TestCatalogFetcher

java.lang.Object
dev.galasa.framework.api.common.TestCatalogFetcher
All Implemented Interfaces:
ITestCatalogFetcher

public class TestCatalogFetcher extends Object implements ITestCatalogFetcher
Fetches a test catalog from the URL configured on a stream, optionally authenticating with Maven credentials stored in the credentials service.

Both StreamTestCatalogRoute and RunsPortfoliosRoute require this behaviour; this class is the single implementation shared between them.

  • Constructor Details

  • Method Details

    • streamTestCatalog

      public void streamTestCatalog(IStream stream, OutputStream outputStream) throws InternalServletException
      Fetches the test catalog for the given stream and writes the raw JSON bytes directly to outputStream without buffering the full body in memory.

      Writes raw bytes from the remote catalog URL directly to outputStream in fixed-size chunks, enforcing the maximum size limit before any byte is written past it.

      Specified by:
      streamTestCatalog in interface ITestCatalogFetcher
      Parameters:
      stream - the stream whose test catalog URL and optional Maven credentials are used to retrieve the catalog.
      outputStream - the stream to write catalog bytes into.
      Throws:
      InternalServletException - if the catalog cannot be fetched, the response status is not 200, the body exceeds the size limit, the content type is invalid, or credentials cannot be resolved.
    • fetchTestCatalog

      public String fetchTestCatalog(IStream stream) throws InternalServletException
      Fetches the test catalog for the given stream and returns it as a JSON string.

      Delegates to streamTestCatalog(dev.galasa.framework.spi.streams.IStream, java.io.OutputStream) capturing output into a ByteArrayOutputStream, then returns the result as a UTF-8 string. Returns null when the stream has no test catalog URL configured.

      Specified by:
      fetchTestCatalog in interface ITestCatalogFetcher
      Parameters:
      stream - the stream whose test catalog URL and optional Maven credentials are used to retrieve the catalog.
      Returns:
      the raw JSON body of the test catalog, or null if the stream has no test catalog URL configured.
      Throws:
      InternalServletException - if the catalog cannot be fetched, the response status is not 200, the body exceeds the size limit, or the credentials cannot be resolved.