diff --git a/src/main/java/io/cryostat/net/web/http/api/v2/graph/ActiveRecordingsFetcher.java b/src/main/java/io/cryostat/net/web/http/api/v2/graph/ActiveRecordingsFetcher.java index dc5a6f0735..b29673a689 100644 --- a/src/main/java/io/cryostat/net/web/http/api/v2/graph/ActiveRecordingsFetcher.java +++ b/src/main/java/io/cryostat/net/web/http/api/v2/graph/ActiveRecordingsFetcher.java @@ -97,7 +97,7 @@ public Active getAuthenticated(DataFetchingEnvironment environment) throws Excep String recordingName = filter.get(FilterInput.Key.NAME); recordings = recordings.stream() - .filter(r -> r.getName().equals(recordingName)) + .filter(r -> Objects.equals(r.getName(), recordingName)) .collect(Collectors.toList()); } if (filter.contains(FilterInput.Key.NAMES)) { diff --git a/src/test/java/itest/GraphQLIT.java b/src/test/java/itest/GraphQLIT.java index cd98da92d0..c76e2c9311 100644 --- a/src/test/java/itest/GraphQLIT.java +++ b/src/test/java/itest/GraphQLIT.java @@ -713,17 +713,14 @@ public void testQueryForFilteredActiveRecordingsByNames() throws Exception { TargetNodesQueryResponse graphqlResp = resp2.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS); - List filteredRecordings = new ArrayList<>(); List filterNames = Arrays.asList("Recording1", "Recording2"); - for (TargetNode targetNode : graphqlResp.data.targetNodes) { - List recordings = targetNode.recordings.active.data; - for (ActiveRecording recording : recordings) { - if (filterNames.contains(recording.name)) { - filteredRecordings.add(recording); - } - } - } + List filteredRecordings = + graphqlResp.data.targetNodes.stream() + .flatMap(targetNode -> targetNode.recordings.active.data.stream()) + .filter(recording -> filterNames.contains(recording.name)) + .collect(Collectors.toList()); + MatcherAssert.assertThat(filteredRecordings.size(), Matchers.equalTo(2)); ActiveRecording r1 = new ActiveRecording(); r1.name = "Recording1"; @@ -823,8 +820,6 @@ public void shouldReturnArchivedRecordingsFilteredByNames() throws Exception { archiveRecordingFuture.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS); - Thread.sleep(2_000L); - // retrieve to match the exact name CompletableFuture archivedRecordingsFuture2 = new CompletableFuture<>(); webClient @@ -846,7 +841,9 @@ public void shouldReturnArchivedRecordingsFilteredByNames() throws Exception { String query = "query { targetNodes {" + "recordings {" - + "archived(filter: { names: [\"archivedRecording\",\"someOtherName\"] }) {" + + "archived(filter: { names: [\"" + + retrievedArchivedRecordingsName + + "\",\"someOtherName\"] }) {" + "data {" + "name" + "}"