Repository: ImFlog/schema-registry-plugin
Pull request #117 (2023-02-04 14:06:34)

introduce Subject replacing CompatibilitySubject and RegisterSubject
This change introduces the data class `Subject` replacing the identical data classes `CompatibilitySubject` and `RegisterSubject` and therefore allowing the reuse of subject definitions in the compatibility and register block. 

This change is breaking if `CompatibilitySubject` or `RegisterSubject` were directly used, but I assume most users used the `subject()` DSL in the `register{}` and `compatibility{}` blocks instead, which is not affected by this change. 

@ImFlog please let me know what you think. 

See [issue](https://github.com/ImFlog/schema-registry-plugin/issues/116) 

ImFlog: Hello @chriskn and sorry for the delay.

I finally had time to look into this more deeply. I missread your comment, and while going through the code it indeed does not break anything if people don't directly use the Subjects (and as you said it's probably not the case).
I think your code is great but I am not sure about the naming of the `Subject` class.
Has it will become usable in the gradle files I would love to find something that represent the fact that it's for register and compatibility but I have no idea 😅 

To finish this PR (I can help if needed):
[ ] Add some explanation in the README
[ ] Update the examples ?
[ ] Find the right name ?

Once again thank you for providing this MR and if needed I can do the rest 🙏 
chriskn: Hi @ImFlog, sorry for the late response. If you find the time, help would be appreciated. Otherwise, I can have a look into it in some days, but a suggestion for the Subject name would be needed. 

Patch:
diff --git a/README.md b/README.md
index 0f1d0cf..23681cf 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,22 @@ you can call the `addLocalReference("name", "/a/path")`,
 this will add a reference from a local file and inline it in the schema registry call.
 The addLocalReference calls can be chained.
 
+Notes:
+* If you want to reuse Subjects with the register task you can define a `Subject` object like so:
+  ```groovy
+  def mySubject = Subject("avroSubject", "/path.avsc", "AVRO")
+  
+  schemaRegistry {
+    url = 'http://registry-url:8081'
+    register {
+      subject(mySubject)
+    }
+    compatibility {
+      subject(mySubject)
+    }
+  }
+  ```
+
 #### Avro
 Mixing local and remote references is perfectly fine for Avro without specific configurations.
 
@@ -163,8 +179,6 @@ schemaRegistry {
     }
 }
 ```
-You have to list all the (subject, avsc file path) pairs that you want to send.
-
 If you have references to other schemas required before the register,
 you can call the `addReference("name", "subject", version)`, this will add a reference to use from the registry.
 The addReference calls can be chained.
@@ -174,8 +188,23 @@ you can call the `addLocalReference("name", "/a/path")`,
 this will add a reference from a local file and inline it in the schema registry call.
 The addLocalReference calls can be chained.
 
-A registered.csv file will be created with the following format `subject, path, id` 
+Notes:
+* A registered.csv file will be created with the following format `subject, path, id` 
 if you need information about the registered id.
+* If you want to reuse Subjects with the compatibility task you can define a `Subject` object like so:
+  ```groovy
+  def mySubject = Subject("avroSubject", "/path.avsc", "AVRO")
+  
+  schemaRegistry {
+    url = 'http://registry-url:8081'
+    register {
+      subject(mySubject)
+    }
+    compatibility {
+      subject(mySubject)
+    }
+  }
+  ```
 
 #### Avro
 Mixing local and remote references is perfectly fine for Avro without specific configurations.
@@ -294,6 +323,8 @@ buildscript {
         classpath "com.github.imflog:kafka-schema-registry-gradle-plugin:X.X.X-SNAPSHOT"
     }
 }
+
+apply plugin: "com.github.imflog.kafka-schema-registry-gradle-plugin"
 ```
 
 ## Thanks to all the sponsors :pray:
diff --git a/build.gradle.kts b/build.gradle.kts
index 2a6a784..a7089c1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,7 +5,7 @@ version = "1.9.2-SNAPSHOT"
 
 
 plugins {
-    kotlin("jvm") version "1.8.10"
+    kotlin("jvm") version "1.8.20"
     id("java-gradle-plugin")
     id("com.gradle.plugin-publish") version "1.1.0"
     id("maven-publish")
@@ -17,7 +17,7 @@ repositories {
 }
 
 // Dependencies versions
-val kotlinVersion = "1.8.10"
+val kotlinVersion = "1.8.20"
 val confluentVersion = "7.3.1"
 dependencies {
     implementation(gradleApi())
diff --git a/examples/avro/build.gradle b/examples/avro/build.gradle
index 33b8abf..4df868f 100644
--- a/examples/avro/build.gradle
+++ b/examples/avro/build.gradle
@@ -1,6 +1,10 @@
 plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
 
 schemaRegistry {
     url = 'http://localhost:8081'
@@ -12,8 +16,8 @@ schemaRegistry {
                 .addLocalReference("Address", "schemas/avro/location-address.avsc")
         subject('user', 'schemas/avro/user.avsc', 'AVRO')
                 .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
-        subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -34,7 +38,7 @@ schemaRegistry {
                 .addLocalReference("Address", "schemas/avro/location-address.avsc")
         subject('user', 'schemas/avro/user.avsc', 'AVRO')
                 .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
-        subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index f5f1dd5..5f904a4 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -1,15 +1,18 @@
 buildscript {
     repositories {
         gradlePluginPortal()
+        mavenLocal()
         maven {
             url = uri("https://packages.confluent.io/maven/")
         }
     }
+
+    dependencies {
+        classpath("com.github.imflog:kafka-schema-registry-gradle-plugin:1.9.2-SNAPSHOT")
+    }
 }
 
 plugins {
-    // Set it to false to let subproject apply the plugin
-    id("com.github.imflog.kafka-schema-registry-gradle-plugin") version "1.9.1" apply false
     id("com.avast.gradle.docker-compose") version "0.16.8" apply true
 }
 
diff --git a/examples/json/build.gradle b/examples/json/build.gradle
index e3464f4..9b1c1f3 100644
--- a/examples/json/build.gradle
+++ b/examples/json/build.gradle
@@ -2,6 +2,11 @@ plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
 
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/json/location-address.json', 'JSON')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+
 schemaRegistry {
     url = 'http://localhost:8081'
     quiet = false
@@ -12,8 +17,8 @@ schemaRegistry {
             .addLocalReference('Address', 'schemas/json/location-address.json')
         subject('user', 'schemas/json/user.json', 'JSON')
             .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/json/location-address.json', 'JSON')
-        subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -34,7 +39,7 @@ schemaRegistry {
             .addLocalReference("address", "schemas/json/location-address.json")
         subject('user', 'schemas/json/user.json', 'JSON')
             .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/json/location-address.json', 'JSON')
-        subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/examples/protobuf/build.gradle b/examples/protobuf/build.gradle
index ddcc730..548a1ed 100644
--- a/examples/protobuf/build.gradle
+++ b/examples/protobuf/build.gradle
@@ -2,6 +2,11 @@ plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
 
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+
 schemaRegistry {
     url = 'http://localhost:8081'
     quiet = false
@@ -11,8 +16,8 @@ schemaRegistry {
         subject('company', 'schemas/protobuf/com/example/company.proto', 'PROTOBUF')
         subject('user', 'schemas/protobuf/com/example/user.proto', 'PROTOBUF')
             .addReference('company', 'company', 1)
-        subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
-        subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -32,7 +37,7 @@ schemaRegistry {
         subject('company', 'schemas/protobuf/com/example/company_v2.proto', 'PROTOBUF')
         subject('user', 'schemas/protobuf/com/example/user.proto', 'PROTOBUF')
             .addReference('company', 'company', 1)
-        subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
-        subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt b/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt
new file mode 100644
index 0000000..f6038a4
--- /dev/null
+++ b/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt
@@ -0,0 +1,26 @@
+package com.github.imflog.schema.registry
+
+import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
+
+data class Subject(
+    val inputSubject: String,
+    val file: String,
+    val type: String
+) {
+    val references: MutableList<SchemaReference> = mutableListOf()
+    val localReferences: MutableList<LocalReference> = mutableListOf()
+
+    fun addReference(name: String, subject: String, version: Int): Subject {
+        references.add(SchemaReference(name, subject, version))
+        return this
+    }
+
+    fun addLocalReference(name: String, path: String): Subject {
+        localReferences.add(LocalReference(name, path))
+        return this
+    }
+
+    // Used for data class destructuring
+    operator fun component4() = references
+    operator fun component5() = localReferences
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
index 43d503f..9a82de8 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
@@ -1,10 +1,8 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
-import com.github.imflog.schema.registry.LocalReference
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
-import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.model.ObjectFactory
 import org.gradle.api.provider.ListProperty
 
@@ -13,7 +11,7 @@ open class CompatibilitySubjectExtension(objects: ObjectFactory) {
         const val EXTENSION_NAME = "compatibility"
     }
 
-    val subjects: ListProperty<CompatibilitySubject> = objects.listProperty(CompatibilitySubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     fun subject(inputSubject: String, file: String) = subject(inputSubject, file, AvroSchema.TYPE)
 
@@ -21,27 +19,11 @@ open class CompatibilitySubjectExtension(objects: ObjectFactory) {
         inputSubject: String,
         file: String,
         type: String
-    ): CompatibilitySubject {
-        val compatibilitySubject = CompatibilitySubject(inputSubject, file, type.toSchemaType())
+    ): Subject {
+        val compatibilitySubject = Subject(inputSubject, file, type)
         subjects.add(compatibilitySubject)
         return compatibilitySubject
     }
-}
-
-data class CompatibilitySubject(
-    val inputSubject: String,
-    val file: String,
-    val type: SchemaType,
-    val references: MutableList<SchemaReference> = mutableListOf(),
-    val localReferences: MutableList<LocalReference> = mutableListOf()
-) {
-    fun addReference(name: String, subject: String, version: Int): CompatibilitySubject {
-        references.add(SchemaReference(name, subject, version))
-        return this
-    }
 
-    fun addLocalReference(name: String, path: String): CompatibilitySubject {
-        localReferences.add(LocalReference(name, path))
-        return this
-    }
+    fun subject(subject: Subject) = subject.apply { subjects.add(subject) }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
index b845dab..9be3dcb 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
@@ -1,6 +1,7 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
 import com.github.imflog.schema.registry.RegistryClientWrapper
+import com.github.imflog.schema.registry.Subject
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleScriptException
 import org.gradle.api.model.ObjectFactory
@@ -32,7 +33,7 @@ open class CompatibilityTask @Inject constructor(objects: ObjectFactory) : Defau
     val ssl: MapProperty<String, String> = objects.mapProperty(String::class.java, String::class.java)
 
     @Input
-    val subjects: ListProperty<CompatibilitySubject> = objects.listProperty(CompatibilitySubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     @TaskAction
     fun testCompatibility() {
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
index c5ff65f..ac65915 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
@@ -1,7 +1,9 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
 import com.github.imflog.schema.registry.LoggingUtils.infoIfNotQuiet
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.parser.SchemaParser
+import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
 import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
 import io.confluent.kafka.schemaregistry.rest.exceptions.Errors
@@ -12,7 +14,7 @@ import java.io.IOException
 class CompatibilityTaskAction(
     private val client: SchemaRegistryClient,
     private val rootDir: File,
-    private val subjects: List<CompatibilitySubject>,
+    private val subjects: List<Subject>,
 ) {
 
     private val logger = Logging.getLogger(CompatibilityTaskAction::class.java)
@@ -23,7 +25,7 @@ class CompatibilityTaskAction(
             logger.debug("Loading schema for subject($subject) from $path.")
             val isCompatible = try {
                 val parsedSchema = SchemaParser
-                    .provide(type, client, rootDir)
+                    .provide(type.toSchemaType(), client, rootDir)
                     .parseSchemaFromFile(
                         subject,
                         path,
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
index b7ae4f7..c6830ee 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
@@ -1,6 +1,7 @@
 package com.github.imflog.schema.registry.tasks.register
 
 import com.github.imflog.schema.registry.RegistryClientWrapper
+import com.github.imflog.schema.registry.Subject
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleScriptException
 import org.gradle.api.model.ObjectFactory
@@ -33,7 +34,7 @@ abstract class RegisterSchemasTask @Inject constructor(objects: ObjectFactory) :
     val ssl: MapProperty<String, String> = objects.mapProperty(String::class.java, String::class.java)
 
     @Input
-    val subjects: ListProperty<RegisterSubject> = objects.listProperty(RegisterSubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     @Input
     @Optional
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
index 3367c99..43b2c77 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
@@ -1,11 +1,8 @@
 package com.github.imflog.schema.registry.tasks.register
 
-import com.github.imflog.schema.registry.LocalReference
-import com.github.imflog.schema.registry.MixedReferenceException
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
-import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.model.ObjectFactory
 import org.gradle.api.provider.ListProperty
 
@@ -14,7 +11,7 @@ open class RegisterSubjectExtension(objects: ObjectFactory) {
         const val EXTENSION_NAME = "register"
     }
 
-    val subjects: ListProperty<RegisterSubject> = objects.listProperty(RegisterSubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     fun subject(inputSubject: String, file: String) = subject(inputSubject, file, AvroSchema.TYPE)
 
@@ -22,27 +19,11 @@ open class RegisterSubjectExtension(objects: ObjectFactory) {
         inputSubject: String,
         file: String,
         type: String
-    ): RegisterSubject {
-        val subject = RegisterSubject(inputSubject, file, type.toSchemaType())
+    ): Subject {
+        val subject = Subject(inputSubject, file, type)
         subjects.add(subject)
         return subject
     }
-}
-
-data class RegisterSubject(
-    val inputSubject: String,
-    val file: String,
-    val type: SchemaType,
-    val references: MutableList<SchemaReference> = mutableListOf(),
-    val localReferences: MutableList<LocalReference> = mutableListOf()
-) {
-    fun addReference(name: String, subject: String, version: Int): RegisterSubject {
-        references.add(SchemaReference(name, subject, version))
-        return this
-    }
 
-    fun addLocalReference(name: String, path: String): RegisterSubject {
-        localReferences.add(LocalReference(name, path))
-        return this
-    }
+    fun subject(subject: Subject) = subject.apply { subjects.add(subject) }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
index a53e0a8..48bdd49 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
@@ -3,7 +3,9 @@ package com.github.imflog.schema.registry.tasks.register
 import com.github.imflog.schema.registry.LocalReference
 import com.github.imflog.schema.registry.LoggingUtils.infoIfNotQuiet
 import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.parser.SchemaParser
+import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
 import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.logging.Logging
@@ -13,7 +15,7 @@ import java.io.File
 class RegisterTaskAction(
     private val client: SchemaRegistryClient,
     private val rootDir: File,
-    private val subjects: List<RegisterSubject>,
+    private val subjects: List<Subject>,
     outputDir: String?
 ) {
 
@@ -27,7 +29,7 @@ class RegisterTaskAction(
         writeOutputFileHeader()
         subjects.forEach { (subject, path, type, references, localReferences) ->
             try {
-                val schemaId = registerSchema(subject, path, type, references, localReferences)
+                val schemaId = registerSchema(subject, path, type.toSchemaType(), references, localReferences)
                 writeRegisteredSchemaOutput(subject, path, schemaId)
             } catch (e: Exception) {
                 logger.error("Could not register schema for '$subject'", e)


Test patch:
diff --git a/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt b/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
index 66e06ba..fd4aefd 100644
--- a/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
+++ b/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
@@ -1,6 +1,6 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import io.confluent.kafka.schemaregistry.ParsedSchema
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
 import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
@@ -52,7 +52,7 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects =
-            arrayListOf(CompatibilitySubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO))
+            arrayListOf(Subject("test", "src/main/avro/external/test.avsc", "AVRO"))
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
             """
             {"type": "record",
@@ -141,10 +141,10 @@ class CompatibilityTaskActionTest {
         )
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Address", "Address", 1)
                 .addReference("Street", "Street", 1)
@@ -239,10 +239,10 @@ class CompatibilityTaskActionTest {
         )
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/local/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Street", "Street", 1)
                 .addLocalReference("Country", "src/main/avro/local/country.avsc")
@@ -281,7 +281,7 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects =
-            arrayListOf(CompatibilitySubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO))
+            arrayListOf(Subject("test", "src/main/avro/external/test.avsc", "AVRO"))
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
             """
             {"type": "record",
@@ -316,10 +316,10 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
         )
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
diff --git a/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt b/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
index a0d6c88..0ae6884 100644
--- a/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
+++ b/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
@@ -1,6 +1,6 @@
 package com.github.imflog.schema.registry.tasks.register
 
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
 import io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider
 import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
@@ -47,7 +47,7 @@ class RegisterTaskActionTest {
         )
 
         val subjects = listOf(
-            RegisterSubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO)
+            Subject("test", "src/main/avro/external/test.avsc", "AVRO")
         )
 
         // when
@@ -91,10 +91,10 @@ class RegisterTaskActionTest {
         )
 
         val subjects = listOf(
-            RegisterSubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
         )
 
@@ -174,10 +174,10 @@ class RegisterTaskActionTest {
 
 
         val subjects = listOf(
-            RegisterSubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Address", "Address", 1)
                 .addReference("Street", "Street", 1)
@@ -229,8 +229,8 @@ class RegisterTaskActionTest {
             )
 
         val subjects = listOf(
-            RegisterSubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO),
-            RegisterSubject("test_2", "src/main/avro/external/test_2.avsc", SchemaType.AVRO),
+            Subject("test", "src/main/avro/external/test.avsc", "AVRO"),
+            Subject("test_2", "src/main/avro/external/test_2.avsc", "AVRO"),
         )
 
         // when