Skip to content

Commit

Permalink
chore: fix tests for updated Schema Registry client internals (#9982)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcrfxia committed Jun 23, 2023
1 parent a7bbc14 commit 1c89794
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
Expand Up @@ -28,17 +28,16 @@
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.common.base.Ticker;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.Message;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.confluent.connect.protobuf.ProtobufData;
import io.confluent.kafka.schemaregistry.avro.AvroSchema;
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.json.JsonSchema;
import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema;
Expand Down Expand Up @@ -1228,9 +1227,7 @@ private static Serializer<Object> avroSerializer() {
final Map<String, String> props = new HashMap<>();
props.put("schema.registry.url", "localhost:9092");

final SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
when(schemaRegistryClient.ticker()).thenReturn(Ticker.systemTicker());
return new KafkaAvroSerializer(schemaRegistryClient, props);
return new KafkaAvroSerializer(new MockSchemaRegistryClient(), props);
}

private static Message protobufRecord() {
Expand All @@ -1250,18 +1247,14 @@ private static Serializer<Message> protobufSerializer() {
final Map<String, String> props = new HashMap<>();
props.put("schema.registry.url", "localhost:9092");

final SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
when(schemaRegistryClient.ticker()).thenReturn(Ticker.systemTicker());
return new KafkaProtobufSerializer<>(schemaRegistryClient, props);
return new KafkaProtobufSerializer<>(new MockSchemaRegistryClient(), props);
}

private static Serializer<Object> jsonSrSerializer() {
final Map<String, String> props = new HashMap<>();
props.put("schema.registry.url", "localhost:9092");

final SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
when(schemaRegistryClient.ticker()).thenReturn(Ticker.systemTicker());
return new KafkaJsonSchemaSerializer<>(schemaRegistryClient, props);
return new KafkaJsonSchemaSerializer<>(new MockSchemaRegistryClient(), props);
}
}

Expand Down
Expand Up @@ -3,14 +3,11 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.confluent.kafka.schemaregistry.ParsedSchema;
import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.ksql.serde.connect.ConnectKsqlSchemaTranslator;
import io.confluent.ksql.util.KsqlConfig;
Expand Down Expand Up @@ -85,8 +82,8 @@ public class KsqlJsonSchemaDeserializerTest {
public void before() throws Exception {
schema = (new JsonSchemaTranslator()).fromConnectSchema(ORDER_SCHEMA.schema());

schemaRegistryClient = mock(SchemaRegistryClient.class);
when(schemaRegistryClient.getSchemaBySubjectAndId(anyString(), anyInt())).thenReturn(schema);
schemaRegistryClient = new MockSchemaRegistryClient();
schemaRegistryClient.register(SOME_TOPIC, schema);

final KsqlJsonSerdeFactory jsonSerdeFactory =
new KsqlJsonSerdeFactory(new JsonSchemaProperties(ImmutableMap.of()));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -143,7 +143,7 @@
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
<apache.io.version>2.7</apache.io.version>
<io.confluent.ksql.version>7.6.0-0</io.confluent.ksql.version>
<io.confluent.schema-registry.version>7.6.0-0</io.confluent.schema-registry.version>
<io.confluent.schema-registry.version>7.6.0-26</io.confluent.schema-registry.version>
<netty-tcnative-version>2.0.54.Final</netty-tcnative-version>
<!-- We normally get this from common, but Vertx is built against this -->
<!-- Note: `netty` depends on `tcnative` and if we bump `netty`
Expand Down

0 comments on commit 1c89794

Please sign in to comment.