From 2cf3796b698507ee23e92672197ab2acc032c293 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 21 Mar 2023 17:49:56 -0400 Subject: [PATCH] remove unnecessary stubbing Signed-off-by: Andrew Azores --- .../v2/graph/TargetNodeRecurseFetcherTest.java | 17 +++++------------ .../api/v2/graph/TargetNodesFetcherTest.java | 11 ++++------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodeRecurseFetcherTest.java b/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodeRecurseFetcherTest.java index 57d7928f73..24e5c2ad99 100644 --- a/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodeRecurseFetcherTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodeRecurseFetcherTest.java @@ -110,16 +110,13 @@ void shouldHaveExpectedRequiredPermissions() { @Test void shouldThrowIllegalStateExceptionOnUnknownNode() throws Exception { - when(env.getGraphQlContext()).thenReturn(graphCtx); - when(auth.validateHttpHeader(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(CompletableFuture.completedFuture(true)); - UnknownNode source = Mockito.mock(UnknownNode.class); when(env.getSource()).thenReturn(source); IllegalStateException ex = - Assertions.assertThrows(IllegalStateException.class, () -> fetcher.get(env)); + Assertions.assertThrows( + IllegalStateException.class, () -> fetcher.getAuthenticated(env)); MatcherAssert.assertThat(ex.getMessage(), Matchers.equalTo(source.getClass().toString())); } @@ -130,8 +127,6 @@ void shouldReturnSource() throws Exception { HttpServerRequest req = Mockito.mock(HttpServerRequest.class); when(ctx.request()).thenReturn(req); when(req.headers()).thenReturn(MultiMap.caseInsensitiveMultiMap()); - when(auth.validateHttpHeader(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(CompletableFuture.completedFuture(true)); TargetNode source = Mockito.mock(TargetNode.class); ServiceRef sr = new ServiceRef("id1", URI.create("uri1"), "alias1"); @@ -139,7 +134,7 @@ void shouldReturnSource() throws Exception { when(env.getSource()).thenReturn(source); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.contains(source)); @@ -155,7 +150,6 @@ void shouldReturnTargetNodes() throws Exception { DataFetchingEnvironmentImpl.newDataFetchingEnvironment( Mockito.any(DataFetchingEnvironment.class))) .thenReturn(builder); - when(env.getGraphQlContext()).thenReturn(graphCtx); when(graphCtx.get(RoutingContext.class)).thenReturn(ctx); HttpServerRequest req = Mockito.mock(HttpServerRequest.class); when(ctx.request()).thenReturn(req); @@ -213,7 +207,7 @@ void shouldReturnTargetNodes() throws Exception { orphanNode, orphanNode); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat( @@ -235,7 +229,6 @@ void shouldReturnTargetNodeFiltered() throws Exception { staticFilter .when(() -> FilterInput.from(Mockito.any(DataFetchingEnvironment.class))) .thenReturn(filter); - when(env.getGraphQlContext()).thenReturn(graphCtx); when(graphCtx.get(RoutingContext.class)).thenReturn(ctx); HttpServerRequest req = Mockito.mock(HttpServerRequest.class); when(ctx.request()).thenReturn(req); @@ -304,7 +297,7 @@ void shouldReturnTargetNodeFiltered() throws Exception { orphanNode, orphanNode); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.containsInAnyOrder(orphanNode)); diff --git a/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodesFetcherTest.java b/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodesFetcherTest.java index f96aaa71b1..1170e8a8e1 100644 --- a/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodesFetcherTest.java +++ b/src/test/java/io/cryostat/net/web/http/api/v2/graph/TargetNodesFetcherTest.java @@ -110,13 +110,10 @@ void shouldReturnEmptyList() throws Exception { staticEnv .when(() -> DataFetchingEnvironmentImpl.newDataFetchingEnvironment(env)) .thenReturn(builder); - when(env.getGraphQlContext()).thenReturn(graphCtx); - when(auth.validateHttpHeader(Mockito.any(), Mockito.any(), Mockito.any())) - .thenReturn(CompletableFuture.completedFuture(true)); when(recurseFetcher.get(Mockito.any())).thenReturn(List.of()); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.empty()); @@ -145,7 +142,7 @@ void shouldReturnTarget() throws Exception { when(recurseFetcher.get(Mockito.any())).thenReturn(List.of(target)); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.contains(target)); @@ -189,7 +186,7 @@ void shouldReturnTargetsFiltered() throws Exception { when(recurseFetcher.get(Mockito.any())) .thenReturn(List.of(target1, target2, target3)); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.containsInAnyOrder(target1, target3)); @@ -274,7 +271,7 @@ void shouldReturnTargetsMultipleFilters() throws Exception { when(recurseFetcher.get(Mockito.any())) .thenReturn(List.of(target1, target2, target3)); - List nodes = fetcher.get(env); + List nodes = fetcher.getAuthenticated(env); MatcherAssert.assertThat(nodes, Matchers.notNullValue()); MatcherAssert.assertThat(nodes, Matchers.contains(target1));