1515
1616package za .co .absa .hyperdrive .ingestor .implementation .utils
1717
18- import io .confluent .kafka .schemaregistry .ParsedSchema
19- import io .confluent .kafka .schemaregistry .avro .AvroSchema
2018import io .confluent .kafka .schemaregistry .client .MockSchemaRegistryClient
2119import org .apache .commons .configuration2 .BaseConfiguration
2220import org .apache .spark .sql .functions ._
@@ -49,8 +47,8 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
4947 ]
5048 } """
5149 }
52- private val dummyRecordNameSchema = new AvroSchema ( AvroSchemaUtils .parse(getSchemaString(recordName, recordNamespace))). asInstanceOf [ ParsedSchema ]
53- private val dummyTopicNameSchema = new AvroSchema ( AvroSchemaUtils .parse(getSchemaString(" topLevelRecord" , " " ))). asInstanceOf [ ParsedSchema ]
50+ private val dummyRecordNameSchema = AvroSchemaUtils .parse(getSchemaString(recordName, recordNamespace))
51+ private val dummyTopicNameSchema = AvroSchemaUtils .parse(getSchemaString(" topLevelRecord" , " " ))
5452 private val dummyExpr = struct(lit(null ).cast(IntegerType ).as(columnName)).expr
5553
5654 private val keyTopic = " kafka.topic"
@@ -94,7 +92,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
9492 val settings = AbrisConfigUtil .getKeyProducerSettings(config, ProducerConfigKeys , dummyExpr)
9593
9694 // then
97- settings.schemaString shouldBe dummyTopicNameSchema.canonicalString()
95+ settings.schemaString shouldBe dummyTopicNameSchema.toString
9896 settings.schemaId shouldBe Some (1 )
9997 mockSchemaRegistryClient.getAllSubjects.asScala should contain theSameElementsAs Seq (s " ${topic}-key " )
10098 }
@@ -111,7 +109,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
111109 val settings = AbrisConfigUtil .getKeyProducerSettings(config, ProducerConfigKeys , dummyExpr)
112110
113111 // then
114- settings.schemaString shouldBe dummyRecordNameSchema.canonicalString()
112+ settings.schemaString shouldBe dummyRecordNameSchema.toString
115113 settings.schemaId shouldBe Some (1 )
116114 mockSchemaRegistryClient.getAllSubjects.asScala should contain theSameElementsAs Seq (s " $recordNamespace. $recordName" )
117115 }
@@ -128,7 +126,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
128126 val settings = AbrisConfigUtil .getKeyProducerSettings(config, ProducerConfigKeys , dummyExpr)
129127
130128 // then
131- settings.schemaString shouldBe dummyRecordNameSchema.canonicalString()
129+ settings.schemaString shouldBe dummyRecordNameSchema.toString
132130 settings.schemaId shouldBe Some (1 )
133131 mockSchemaRegistryClient.getAllSubjects.asScala should contain theSameElementsAs Seq (s " $topic- $recordNamespace. $recordName" )
134132 }
@@ -143,7 +141,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
143141 val settings = AbrisConfigUtil .getValueProducerSettings(config, ProducerConfigKeys , dummyExpr)
144142
145143 // then
146- settings.schemaString shouldBe dummyTopicNameSchema.canonicalString()
144+ settings.schemaString shouldBe dummyTopicNameSchema.toString
147145 settings.schemaId shouldBe Some (1 )
148146 mockSchemaRegistryClient.getAllSubjects.asScala should contain theSameElementsAs Seq (s " $topic-value " )
149147 }
@@ -161,7 +159,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
161159 val settings = AbrisConfigUtil .getKeyConsumerSettings(config, ConsumerConfigKeys )
162160
163161 // then
164- settings.schemaString shouldBe dummyTopicNameSchema.canonicalString()
162+ settings.schemaString shouldBe dummyTopicNameSchema.toString
165163 settings.schemaRegistryConf.get shouldBe Map (" schema.registry.url" -> dummySchemaRegistryUrl)
166164 }
167165
@@ -176,7 +174,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
176174 {"name": " ${columnName}2", "type": ["int", "null"] }
177175 ]
178176 } """
179- val schema2 = new AvroSchema ( AvroSchemaUtils .parse(schema2String)). asInstanceOf [ ParsedSchema ]
177+ val schema2 = AvroSchemaUtils .parse(schema2String)
180178 mockSchemaRegistryClient.register(s " $topic-key " , dummyTopicNameSchema)
181179 mockSchemaRegistryClient.register(s " $topic-key " , schema2)
182180 val config = createBaseConfiguration
@@ -188,7 +186,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
188186 val settings = AbrisConfigUtil .getKeyConsumerSettings(config, ConsumerConfigKeys )
189187
190188 // then
191- settings.schemaString shouldBe schema2.canonicalString()
189+ settings.schemaString shouldBe schema2.toString
192190 settings.schemaRegistryConf.get shouldBe Map (" schema.registry.url" -> dummySchemaRegistryUrl)
193191 }
194192
@@ -207,7 +205,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
207205 val settings = AbrisConfigUtil .getKeyConsumerSettings(config, ConsumerConfigKeys )
208206
209207 // then
210- settings.schemaString shouldBe dummyRecordNameSchema.canonicalString()
208+ settings.schemaString shouldBe dummyRecordNameSchema.toString
211209 settings.schemaRegistryConf.get shouldBe Map (" schema.registry.url" -> dummySchemaRegistryUrl)
212210 }
213211
@@ -226,7 +224,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
226224 val settings = AbrisConfigUtil .getKeyConsumerSettings(config, ConsumerConfigKeys )
227225
228226 // then
229- settings.schemaString shouldBe dummyRecordNameSchema.canonicalString()
227+ settings.schemaString shouldBe dummyRecordNameSchema.toString
230228 settings.schemaRegistryConf.get shouldBe Map (" schema.registry.url" -> dummySchemaRegistryUrl)
231229 }
232230
@@ -243,7 +241,7 @@ class TestAbrisConfigUtil extends FlatSpec with Matchers with BeforeAndAfter {
243241 val settings = AbrisConfigUtil .getValueConsumerSettings(config, ConsumerConfigKeys )
244242
245243 // then
246- settings.schemaString shouldBe dummyTopicNameSchema.canonicalString()
244+ settings.schemaString shouldBe dummyTopicNameSchema.toString
247245 settings.schemaRegistryConf.get shouldBe Map (" schema.registry.url" -> dummySchemaRegistryUrl)
248246 }
249247
0 commit comments