diff --git a/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsDownloadRoute.java b/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsDownloadRoute.java index a398f6604..0b837ae26 100644 --- a/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsDownloadRoute.java +++ b/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsDownloadRoute.java @@ -95,6 +95,7 @@ private HttpServletResponse downloadArtifact(String runId, String artifactPath, // Get run details in order to find artifacts try { run = getRunByRunId(runId); + run.loadArtifacts(); runName = run.getTestStructure().getRunName(); } catch (ResultArchiveStoreException e) { ServletError error = new ServletError(GAL5002_INVALID_RUN_ID,runId); diff --git a/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsListRoute.java b/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsListRoute.java index e44212ea4..f4cae7d78 100644 --- a/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsListRoute.java +++ b/galasa-parent/dev.galasa.framework.api.ras/src/main/java/dev/galasa/framework/api/ras/internal/routes/RunArtifactsListRoute.java @@ -74,6 +74,7 @@ private String retrieveResults(String runId) throws InternalServletException { JsonArray artifacts = new JsonArray(); try { run = getRunByRunId(runId); + run.loadArtifacts(); } catch (ResultArchiveStoreException e) { ServletError error = new ServletError(GAL5002_INVALID_RUN_ID, runId); throw new InternalServletException(error, HttpServletResponse.SC_NOT_FOUND, e); diff --git a/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/mocks/MockRunResult.java b/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/mocks/MockRunResult.java index 2214bf7dc..2b2383ab2 100644 --- a/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/mocks/MockRunResult.java +++ b/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/mocks/MockRunResult.java @@ -18,6 +18,7 @@ public class MockRunResult implements IRunResult { private Path artifactRoot; private String log; private boolean isDiscarded = false; + private boolean isLoadingArtifactsEnabled = false; public MockRunResult( String runId, @@ -55,9 +56,17 @@ public String getLog() throws ResultArchiveStoreException { public void discard() throws ResultArchiveStoreException { isDiscarded = true; } - + + @Override + public void loadArtifacts() throws ResultArchiveStoreException { + isLoadingArtifactsEnabled = true; + } public boolean isDiscarded() { return this.isDiscarded; } + + public boolean isLoadingArtifactsEnabled() { + return isLoadingArtifactsEnabled; + } } \ No newline at end of file diff --git a/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/routes/TestRunDetailsRoute.java b/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/routes/TestRunDetailsRoute.java index 6b41f8228..337045b84 100644 --- a/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/routes/TestRunDetailsRoute.java +++ b/galasa-parent/dev.galasa.framework.api.ras/src/test/java/dev/galasa/framework/api/ras/internal/routes/TestRunDetailsRoute.java @@ -779,8 +779,10 @@ public void testDeleteRunNoReqPayloadWithGoodRunIdReturnsOK() throws Exception { servlet.doDelete(req,resp); // Then... + MockRunResult deletedRun = (MockRunResult) mockInputRunResults.get(0); assertThat(resp.getStatus()).isEqualTo(204); - assertThat(((MockRunResult) mockInputRunResults.get(0)).isDiscarded()).as("The fake run result has not been discarded.").isTrue(); + assertThat(deletedRun.isLoadingArtifactsEnabled()).as("The fake run result's artifacts should not have been loaded.").isFalse(); + assertThat(deletedRun.isDiscarded()).as("The fake run result has not been discarded.").isTrue(); } diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/ras/directory/DirectoryRASRunResult.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/ras/directory/DirectoryRASRunResult.java index 73601ecc8..4c164cd18 100644 --- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/ras/directory/DirectoryRASRunResult.java +++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/ras/directory/DirectoryRASRunResult.java @@ -81,4 +81,9 @@ public void discard() throws ResultArchiveStoreException { public String getRunId() { return this.id; } + + @Override + public void loadArtifacts() throws ResultArchiveStoreException { + // Artifacts for local runs are already available on the filesystem so there is no need to load anything + } } \ No newline at end of file diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IRunResult.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IRunResult.java index 39e68bac7..61b7ad027 100644 --- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IRunResult.java +++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IRunResult.java @@ -21,4 +21,6 @@ public interface IRunResult { void discard() throws ResultArchiveStoreException; + void loadArtifacts() throws ResultArchiveStoreException; + }