diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingDeleteFromPathHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingDeleteFromPathHandlerTest.java index 14566da79a..bb4d8e680e 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingDeleteFromPathHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingDeleteFromPathHandlerTest.java @@ -32,6 +32,7 @@ import io.cryostat.net.web.http.api.v2.ApiException; import io.cryostat.net.web.http.api.v2.IntermediateResponse; import io.cryostat.net.web.http.api.v2.RequestParameters; +import io.cryostat.recordings.JvmIdHelper; import io.cryostat.recordings.RecordingArchiveHelper; import io.cryostat.recordings.RecordingNotFoundException; import io.cryostat.rules.ArchivedRecordingInfo; @@ -56,13 +57,14 @@ class RecordingDeleteFromPathHandlerTest { @Mock AuthManager auth; @Mock CredentialsManager credentialsManager; @Mock Gson gson; + @Mock JvmIdHelper jvmIdHelper; @Mock RecordingArchiveHelper recordingArchiveHelper; @BeforeEach void setup() { this.handler = new RecordingDeleteFromPathHandler( - auth, credentialsManager, gson, recordingArchiveHelper); + auth, credentialsManager, gson, jvmIdHelper, recordingArchiveHelper); } @Nested @@ -94,7 +96,7 @@ void shouldHaveExpectedRequiredPermissions() { void shouldHandleCorrectPath() { MatcherAssert.assertThat( handler.path(), - Matchers.equalTo("/api/beta/fs/recordings/:subdirectoryName/:recordingName")); + Matchers.equalTo("/api/beta/fs/recordings/:jvmId/:recordingName")); } @Test @@ -117,18 +119,19 @@ class Behaviour { @Test void shouldThrow404IfNoMatchingRecordingFound() throws Exception { String recordingName = "someRecording"; - String subdirectoryName = "someSubdirectory"; + String jvmId = "id"; + when(params.getPathParams()) .thenReturn( Map.of( - "subdirectoryName", - subdirectoryName, + "id", + jvmId, "recordingName", recordingName)); Future future = CompletableFuture.failedFuture( - new RecordingNotFoundException(subdirectoryName, recordingName)); + new RecordingNotFoundException(jvmId, recordingName)); when(recordingArchiveHelper.deleteRecordingFromPath( Mockito.anyString(), Mockito.anyString())) .thenReturn(future); @@ -141,14 +144,14 @@ void shouldThrow404IfNoMatchingRecordingFound() throws Exception { @Test void shouldHandleSuccessfulDELETERequest() throws Exception { String recordingName = "someRecording"; - String subdirectoryName = "someSubdirectory"; + String jvmId = "id"; when(params.getPathParams()) .thenReturn( Map.of( "recordingName", recordingName, - "subdirectoryName", - subdirectoryName)); + "id", + jvmId)); CompletableFuture future = Mockito.mock(CompletableFuture.class); when(recordingArchiveHelper.deleteRecordingFromPath( @@ -161,7 +164,7 @@ void shouldHandleSuccessfulDELETERequest() throws Exception { verify(recordingArchiveHelper) .deleteRecordingFromPath( - Mockito.eq(subdirectoryName), Mockito.eq(recordingName)); + Mockito.eq(jvmId), Mockito.eq(recordingName)); } } } diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingMetadataLabelsPostFromPathHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingMetadataLabelsPostFromPathHandlerTest.java index ef3de0607f..e5d461d785 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingMetadataLabelsPostFromPathHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingMetadataLabelsPostFromPathHandlerTest.java @@ -36,6 +36,7 @@ import io.cryostat.net.web.http.api.v2.ApiException; import io.cryostat.net.web.http.api.v2.IntermediateResponse; import io.cryostat.net.web.http.api.v2.RequestParameters; +import io.cryostat.recordings.JvmIdHelper; import io.cryostat.recordings.RecordingArchiveHelper; import io.cryostat.recordings.RecordingMetadataManager; import io.cryostat.recordings.RecordingMetadataManager.Metadata; @@ -61,6 +62,7 @@ public class RecordingMetadataLabelsPostFromPathHandlerTest { @Mock AuthManager authManager; @Mock CredentialsManager credentialsManager; @Mock Gson gson; + @Mock JvmIdHelper jvmIdHelper; @Mock RecordingArchiveHelper recordingArchiveHelper; @Mock RecordingMetadataManager recordingMetadataManager; @Mock RequestParameters params; @@ -77,6 +79,7 @@ void setup() { authManager, credentialsManager, gson, + jvmIdHelper, recordingArchiveHelper, recordingMetadataManager); } @@ -104,7 +107,7 @@ void shouldHaveTargetsPath() { MatcherAssert.assertThat( handler.path(), Matchers.equalTo( - "/api/beta/fs/recordings/:subdirectoryName/:recordingName/metadata/labels")); + "/api/beta/fs/recordings/:jvmId/:recordingName/metadata/labels")); } @Test @@ -139,7 +142,7 @@ class Behaviour { @Test void shouldUpdateLabels() throws Exception { String recordingName = "someRecording"; - String subdirectoryName = "someTarget"; + String jvmId = "id"; Map labels = Map.of("key", "value"); Metadata metadata = new Metadata(labels); String requestLabels = labels.toString(); @@ -147,16 +150,16 @@ void shouldUpdateLabels() throws Exception { when(requestParameters.getPathParams()).thenReturn(params); when(params.get("recordingName")).thenReturn(recordingName); - when(params.get("subdirectoryName")).thenReturn(subdirectoryName); + when(params.get("jvmId")).thenReturn(jvmId); when(requestParameters.getBody()).thenReturn(requestLabels); - when(recordingArchiveHelper.getRecordingPathFromPath(subdirectoryName, recordingName)) + when(recordingArchiveHelper.getRecordingPathFromPath(jvmId, recordingName)) .thenReturn(CompletableFuture.completedFuture(Path.of(recordingName))); when(recordingMetadataManager.parseRecordingLabels(requestLabels)).thenReturn(labels); when(recordingMetadataManager.setRecordingMetadataFromPath( - subdirectoryName, recordingName, metadata)) + jvmId, recordingName, metadata)) .thenReturn(CompletableFuture.completedFuture(metadata)); IntermediateResponse response = handler.handle(requestParameters); @@ -169,7 +172,7 @@ void shouldThrow400OnEmptyLabels() throws Exception { Map params = Mockito.mock(Map.class); when(requestParameters.getPathParams()).thenReturn(params); when(params.get("recordingName")).thenReturn("someRecording"); - when(params.get("subdirectoryName")).thenReturn("subdirectoryName"); + when(params.get("jvmId")).thenReturn("id"); when(requestParameters.getBody()).thenReturn("invalid"); Mockito.doThrow(new IllegalArgumentException()) .when(recordingMetadataManager) @@ -182,17 +185,17 @@ void shouldThrow400OnEmptyLabels() throws Exception { @Test void shouldThrowWhenRecordingNotFound() throws Exception { - String subdirectoryName = "someSubdirectory"; + String jvmId = "id"; String recordingName = "someNonExistentRecording"; String labels = Map.of("key", "value").toString(); Map params = Mockito.mock(Map.class); when(requestParameters.getPathParams()).thenReturn(params); when(params.get("recordingName")).thenReturn(recordingName); - when(params.get("subdirectoryName")).thenReturn(subdirectoryName); + when(params.get("jvmId")).thenReturn(jvmId); when(requestParameters.getBody()).thenReturn(labels); - when(recordingArchiveHelper.getRecordingPathFromPath(subdirectoryName, recordingName)) + when(recordingArchiveHelper.getRecordingPathFromPath(jvmId, recordingName)) .thenReturn( CompletableFuture.failedFuture( new RecordingNotFoundException( diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingUploadPostFromPathHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingUploadPostFromPathHandlerTest.java index fec828e1b6..273b339cc1 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingUploadPostFromPathHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingUploadPostFromPathHandlerTest.java @@ -34,6 +34,7 @@ import io.cryostat.net.web.http.api.v2.ApiException; import io.cryostat.net.web.http.api.v2.IntermediateResponse; import io.cryostat.net.web.http.api.v2.RequestParameters; +import io.cryostat.recordings.JvmIdHelper; import io.cryostat.recordings.RecordingArchiveHelper; import io.cryostat.recordings.RecordingNotFoundException; @@ -70,6 +71,7 @@ class RecordingUploadPostFromPathHandlerTest { @Mock CredentialsManager credentialsManager; @Mock Environment env; @Mock WebClient webClient; + @Mock JvmIdHelper jvmIdHelper; @Mock RecordingArchiveHelper recordingArchiveHelper; @Mock Gson gson; @@ -82,7 +84,7 @@ class RecordingUploadPostFromPathHandlerTest { void setup() { this.handler = new RecordingUploadPostFromPathHandler( - auth, credentialsManager, env, 30, webClient, recordingArchiveHelper, gson); + auth, credentialsManager, env, 30, webClient, jvmIdHelper, recordingArchiveHelper, gson); } @Nested @@ -115,7 +117,7 @@ void shouldHandleCorrectPath() { MatcherAssert.assertThat( handler.path(), Matchers.equalTo( - "/api/beta/fs/recordings/:subdirectoryName/:recordingName/upload")); + "/api/beta/fs/recordings/:jvmId/:recordingName/upload")); } @Test