Skip to content

Commit

Permalink
fix #5194: showing the groups that were visited
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Jun 15, 2023
1 parent 3e5ae25 commit 2641818
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,13 +76,13 @@ void testApiResources() {
void testApiVisiting() {
APIGroupList list = client.getApiGroups();

AtomicInteger groupCount = new AtomicInteger();
TreeSet<String> groups = new TreeSet<String>();

client.visitResources(new ApiVisitor() {

@Override
public ApiVisitResult visitApiGroup(String group) {
groupCount.incrementAndGet();
groups.add(group);
return ApiVisitResult.CONTINUE;
}

Expand All @@ -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<Boolean> done = new CompletableFuture<>();
Expand Down

0 comments on commit 2641818

Please sign in to comment.