I have a record with a fixed type. Both have the record and the fixed type have namespaces set.
I can rename the namespace of the record with avrohugger, but not the namespace of the fixed type
class SpecificSameRecordNameAsNamespaceSpec extends mutable.Specification {
"a Generator" should {
"generate files that compile even if the name of a record is the same as the name of a namespace" in {
val infile = new java.io.File("avrohugger-core/src/test/avro/SpecificSameRecordNameAsNamespace.avsc")
val gen = new Generator(SpecificRecord, avroScalaCustomNamespace = Map(
"namespace.conflict.same_name" -> "namespace.renamed",
"namespace.conflict" -> "namespace.no_conflict"
))
val outDir = gen.defaultOutputDir + "/specific"
gen.fileToFile(infile, outDir)
val sourceRecord = scala.io.Source.fromFile(s"$outDir/namespace/no_conflict/same_name.scala").mkString
sourceRecord ==== util.Util.readFile("avrohugger-core/src/test/expected/specific/namespace/no_conflict/same_name.scala")
val sourceFixedType = scala.io.Source.fromFile(s"$outDir/namespace/renamed/fixed.scala").mkString
sourceFixedType ==== util.Util.readFile("avrohugger-core/src/test/expected/specific/namespace/renamed/fixed.scala")
}
}
}
This test fails because the fixed type is not renamed and so is written to the un-renamed directory
[info] a Generator should
[error] ! generate files that compile even if the name of a record is the same as the name of a namespace
[error] java.io.FileNotFoundException: target/generated-sources/specific/namespace/renamed/fixed.scala (No such file or directory) (SpecificSameRecordNameAsNamespaceSpec.scala:19)
For my use case, renaming only the record's namespace solved the issue I had (which is that the generated class FQN was the same as the fixed type package for this schema, resulting in compilation error for generated code).
I have a record with a fixed type. Both have the record and the fixed type have namespaces set. I can rename the namespace of the record with avrohugger, but not the namespace of the fixed type
Example avro schema.
Unit test demonstrating the issue
This test fails because the fixed type is not renamed and so is written to the un-renamed directory
For my use case, renaming only the record's namespace solved the issue I had (which is that the generated class FQN was the same as the fixed type package for this schema, resulting in compilation error for generated code).