From 26418182ead5b0b1b156f881d6d73b49a0cacaa6 Mon Sep 17 00:00:00 2001 From: Steve Hawkins Date: Mon, 5 Jun 2023 12:51:52 -0400 Subject: [PATCH] fix #5194: showing the groups that were visited --- .../fabric8/kubernetes/ApiGroupResourceListsIT.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java index 5e5478379bc..da0d76025a2 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java @@ -28,8 +28,10 @@ import io.fabric8.kubernetes.client.dsl.Resource; import org.junit.jupiter.api.Test; +import java.util.TreeSet; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -74,13 +76,13 @@ void testApiResources() { void testApiVisiting() { APIGroupList list = client.getApiGroups(); - AtomicInteger groupCount = new AtomicInteger(); + TreeSet groups = new TreeSet(); client.visitResources(new ApiVisitor() { @Override public ApiVisitResult visitApiGroup(String group) { - groupCount.incrementAndGet(); + groups.add(group); return ApiVisitResult.CONTINUE; } @@ -93,7 +95,8 @@ public ApiVisitResult visitResource(String group, String version, APIResource ap }); // visit all groups + the core group - assertEquals(list.getGroups().size() + 1, groupCount.get()); + assertEquals(Stream.concat(Stream.of(""), list.getGroups().stream().map(APIGroup::getName)).collect(Collectors.toSet()), + groups); // visit again to make sure we terminate as expected CompletableFuture done = new CompletableFuture<>();