diff --git a/client/src/main/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClient.java b/client/src/main/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClient.java index be619d21d4c..0feba33d942 100644 --- a/client/src/main/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClient.java +++ b/client/src/main/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClient.java @@ -16,7 +16,6 @@ package io.confluent.kafka.schemaregistry.client; -import static io.confluent.kafka.schemaregistry.utils.QualifiedSubject.DEFAULT_CONTEXT; import static io.confluent.kafka.schemaregistry.utils.QualifiedSubject.DEFAULT_TENANT; import com.google.common.collect.Lists; @@ -716,8 +715,8 @@ public String getMode(String subject) throws IOException, RestClientException { public Collection getAllContexts() throws IOException, RestClientException { List results = new ArrayList<>(schemaToIdCache.keySet()).stream() .map(s -> QualifiedSubject.create(DEFAULT_TENANT, s).getContext()) - .filter(s -> !s.isEmpty() && !s.equals(DEFAULT_CONTEXT)) .sorted() + .distinct() .collect(Collectors.toList()); return results; } diff --git a/core/src/test/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClientTest.java b/core/src/test/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClientTest.java index 07423802423..9f98f660b04 100644 --- a/core/src/test/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClientTest.java +++ b/core/src/test/java/io/confluent/kafka/schemaregistry/client/MockSchemaRegistryClientTest.java @@ -227,11 +227,16 @@ public void testGetAllContexts() throws Exception { id = client.register(":.context1:test-value", avroSchema); assertEquals(1, id); + id = client.register(":.context1:test-value2", avroSchema); + assertEquals(1, id); + + id = client.register("test-value", avroSchema); id = client.register("test-value", avroSchema); assertEquals(1, id); Collection contexts = client.getAllContexts(); Iterator iter = contexts.iterator(); + assertEquals(".", iter.next()); assertEquals(".context1", iter.next()); assertEquals(".context2", iter.next()); }