From d7e2bb5b5693630aec7bade6562d9bdccb8c3a71 Mon Sep 17 00:00:00 2001 From: Ming Wang Date: Wed, 11 Oct 2023 14:11:04 -0400 Subject: [PATCH] spotless:apply --- .../RecordingDeleteFromPathHandlerTest.java | 14 +----- ...ecordingGetFromPathWithJwtHandlerTest.java | 17 +++++-- ...MetadataLabelsPostFromPathHandlerTest.java | 2 +- ...ecordingUploadPostFromPathHandlerTest.java | 50 ++++++------------- .../beta/ReportGetFromPathHandlerTest.java | 33 +++--------- .../ReportGetFromPathWithJwtHandlerTest.java | 12 +++-- 6 files changed, 44 insertions(+), 84 deletions(-) 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 24651e694f..0e18f7b481 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 @@ -124,12 +124,7 @@ void shouldThrow404IfNoMatchingRecordingFound() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); Future future = CompletableFuture.failedFuture( @@ -151,12 +146,7 @@ void shouldHandleSuccessfulDELETERequest() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "recordingName", - recordingName, - "jvmId", - jvmId)); + .thenReturn(Map.of("recordingName", recordingName, "jvmId", jvmId)); CompletableFuture future = Mockito.mock(CompletableFuture.class); when(recordingArchiveHelper.deleteRecordingFromPath( diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingGetFromPathWithJwtHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingGetFromPathWithJwtHandlerTest.java index 91b0399405..3bb4bfae10 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/RecordingGetFromPathWithJwtHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/RecordingGetFromPathWithJwtHandlerTest.java @@ -67,7 +67,13 @@ class RecordingGetFromPathWithJwtHandlerTest { void setup() { this.handler = new RecordingGetFromPathWithJwtHandler( - auth, credentialsManager, jwt, () -> webServer, jvmIdHelper, archive, logger); + auth, + credentialsManager, + jwt, + () -> webServer, + jvmIdHelper, + archive, + logger); } @Nested @@ -87,8 +93,7 @@ void shouldUseHttpGetVerb() { void shouldUseExpectedPath() { MatcherAssert.assertThat( handler.path(), - Matchers.equalTo( - "/api/beta/fs/recordings/:jvmId/:recordingName/jwt")); + Matchers.equalTo("/api/beta/fs/recordings/:jvmId/:recordingName/jwt")); } @Test @@ -119,7 +124,8 @@ class Behaviour { void shouldRespond404IfNotFound() throws Exception { when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mysubdirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mysubdirectory"); Future future = CompletableFuture.failedFuture( new RecordingNotFoundException("mysubdirectory", "myrecording")); @@ -137,7 +143,8 @@ void shouldSendFileIfFound() throws Exception { when(ctx.response()).thenReturn(resp); when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mysubdirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mysubdirectory"); Path path = Mockito.mock(Path.class); when(path.toAbsolutePath()).thenReturn(path); when(path.toString()).thenReturn("foo.jfr"); 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 d158f2be26..37b5f14638 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 @@ -148,7 +148,7 @@ void shouldUpdateLabels() throws Exception { String requestLabels = labels.toString(); String subdirectoryName = "someSubdirectory"; Map params = Mockito.mock(Map.class); - + when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(requestParameters.getPathParams()).thenReturn(params); when(params.get("recordingName")).thenReturn(recordingName); 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 fcd2fc0845..bcdd5e231f 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 @@ -85,7 +85,14 @@ class RecordingUploadPostFromPathHandlerTest { void setup() { this.handler = new RecordingUploadPostFromPathHandler( - auth, credentialsManager, env, 30, webClient, jvmIdHelper, recordingArchiveHelper, gson); + auth, + credentialsManager, + env, + 30, + webClient, + jvmIdHelper, + recordingArchiveHelper, + gson); } @Nested @@ -117,8 +124,7 @@ void shouldHaveExpectedRequiredPermissions() { void shouldHandleCorrectPath() { MatcherAssert.assertThat( handler.path(), - Matchers.equalTo( - "/api/beta/fs/recordings/:jvmId/:recordingName/upload")); + Matchers.equalTo("/api/beta/fs/recordings/:jvmId/:recordingName/upload")); } @Test @@ -160,12 +166,7 @@ void shouldThrow501IfDatasourceUrlMalformed(String rawUrl) { void shouldThrowExceptionIfRecordingNotFound() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(env.getEnv("GRAFANA_DATASOURCE_URL")).thenReturn(DATASOURCE_URL); CompletableFuture future = Mockito.mock(CompletableFuture.class); @@ -174,8 +175,7 @@ void shouldThrowExceptionIfRecordingNotFound() throws Exception { .thenReturn(future); ExecutionException e = Mockito.mock(ExecutionException.class); when(future.get()).thenThrow(e); - when(e.getCause()) - .thenReturn(new RecordingNotFoundException("foo", recordingName)); + when(e.getCause()).thenReturn(new RecordingNotFoundException("foo", recordingName)); ApiException ex = Assertions.assertThrows(ApiException.class, () -> handler.handle(params)); @@ -186,12 +186,7 @@ void shouldThrowExceptionIfRecordingNotFound() throws Exception { void shouldDoUpload() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn("foo"); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(env.getEnv("GRAFANA_DATASOURCE_URL")).thenReturn(DATASOURCE_URL); CompletableFuture future = Mockito.mock(CompletableFuture.class); @@ -241,12 +236,7 @@ public Void answer(InvocationOnMock args) throws Throwable { void shouldHandleInvalidResponseStatusCode() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn("someSubdirectory"); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(env.getEnv("GRAFANA_DATASOURCE_URL")).thenReturn(DATASOURCE_URL); CompletableFuture future = Mockito.mock(CompletableFuture.class); @@ -303,12 +293,7 @@ public Void answer(InvocationOnMock args) throws Throwable { void shouldHandleNullStatusMessage() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn("someSubdirectory"); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(env.getEnv("GRAFANA_DATASOURCE_URL")).thenReturn(DATASOURCE_URL); CompletableFuture future = Mockito.mock(CompletableFuture.class); @@ -365,12 +350,7 @@ public Void answer(InvocationOnMock args) throws Throwable { void shouldHandleNullResponseBody() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn("someSubdirectory"); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(env.getEnv("GRAFANA_DATASOURCE_URL")).thenReturn(DATASOURCE_URL); CompletableFuture future = Mockito.mock(CompletableFuture.class); diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathHandlerTest.java index 915577735a..6072b9a50b 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathHandlerTest.java @@ -103,8 +103,7 @@ void shouldHaveExpectedRequiredPermissions() { @Test void shouldHandleCorrectPath() { MatcherAssert.assertThat( - handler.path(), - Matchers.equalTo("/api/beta/fs/reports/:jvmId/:recordingName")); + handler.path(), Matchers.equalTo("/api/beta/fs/reports/:jvmId/:recordingName")); } @Test @@ -129,12 +128,7 @@ void shouldThrow404IfNoMatchingRecordingFound() throws Exception { MultiMap queryParams = MultiMap.caseInsensitiveMultiMap(); when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(params.getQueryParams()).thenReturn(queryParams); Future future = @@ -156,12 +150,7 @@ void shouldRespondBySendingFile() throws Exception { MultiMap queryParams = MultiMap.caseInsensitiveMultiMap(); when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(params.getQueryParams()).thenReturn(queryParams); Path fakePath = Mockito.mock(Path.class); @@ -185,12 +174,7 @@ void shouldRespondBySendingFileFiltered() throws Exception { when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(params.getQueryParams()).thenReturn(queryParams); Path fakePath = Mockito.mock(Path.class); @@ -211,15 +195,10 @@ void shouldRespondBySendingFileFiltered() throws Exception { void shouldRespondBySendingFileUnformatted() throws Exception { MultiMap queryParams = MultiMap.caseInsensitiveMultiMap(); queryParams.add("filter", "someFilter"); - + when(jvmIdHelper.jvmIdToSubdirectoryName(jvmId)).thenReturn(subdirectoryName); when(params.getPathParams()) - .thenReturn( - Map.of( - "jvmId", - jvmId, - "recordingName", - recordingName)); + .thenReturn(Map.of("jvmId", jvmId, "recordingName", recordingName)); when(params.getQueryParams()).thenReturn(queryParams); Path fakePath = Mockito.mock(Path.class); diff --git a/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathWithJwtHandlerTest.java b/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathWithJwtHandlerTest.java index 64711a3235..8e5e1ccd13 100644 --- a/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathWithJwtHandlerTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/beta/ReportGetFromPathWithJwtHandlerTest.java @@ -142,7 +142,8 @@ class Behaviour { void shouldRespond404IfNotFound() throws Exception { when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mydirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mydirectory"); Future future = CompletableFuture.failedFuture( @@ -161,7 +162,8 @@ void shouldSendFileIfFound() throws Exception { when(ctx.response()).thenReturn(resp); when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mydirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mydirectory"); Path path = Mockito.mock(Path.class); when(path.toAbsolutePath()).thenReturn(path); when(path.toString()).thenReturn("foo.jfr"); @@ -184,7 +186,8 @@ void shouldSendFileIfFoundFiltered() throws Exception { when(ctx.response()).thenReturn(resp); when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mydirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mydirectory"); Path path = Mockito.mock(Path.class); when(path.toAbsolutePath()).thenReturn(path); when(path.toString()).thenReturn("foo.jfr"); @@ -208,7 +211,8 @@ void shouldSendFileIfFoundUnformatted() throws Exception { when(ctx.response()).thenReturn(resp); when(ctx.pathParam("jvmId")).thenReturn("id"); when(ctx.pathParam("recordingName")).thenReturn("myrecording"); - when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())).thenReturn("mydirectory"); + when(jvmIdHelper.jvmIdToSubdirectoryName(Mockito.anyString())) + .thenReturn("mydirectory"); Path path = Mockito.mock(Path.class); when(path.toAbsolutePath()).thenReturn(path); when(path.toString()).thenReturn("foo.jfr");