Package dev.galasa.framework.api.common
Class TestCatalogFetcher
java.lang.Object
dev.galasa.framework.api.common.TestCatalogFetcher
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionTestCatalogFetcher(HttpClient httpClient, ICredentialsService credentialsService) -
Method Summary
Modifier and TypeMethodDescriptionfetchTestCatalog(IStream stream) Fetches the test catalog for the given stream and returns it as a JSON string.voidstreamTestCatalog(IStream stream, OutputStream outputStream) Fetches the test catalog for the given stream and writes the raw JSON bytes directly tooutputStreamwithout buffering the full body in memory.
-
Constructor Details
-
TestCatalogFetcher
-
-
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 tooutputStreamwithout buffering the full body in memory.Writes raw bytes from the remote catalog URL directly to
outputStreamin fixed-size chunks, enforcing the maximum size limit before any byte is written past it.- Specified by:
streamTestCatalogin interfaceITestCatalogFetcher- 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
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 aByteArrayOutputStream, then returns the result as a UTF-8 string. Returnsnullwhen the stream has no test catalog URL configured.- Specified by:
fetchTestCatalogin interfaceITestCatalogFetcher- 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
nullif 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.
-