Skip to content

Commit

Permalink
fix fabric8io#5194: showing the groups that were visited
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jun 5, 2023
1 parent 83cbf77 commit 8b3b831
Showing 1 changed file with 7 additions and 4 deletions.
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 8b3b831

Please sign in to comment.