|
1 | 1 | /** |
2 | | - * Copyright 2019-2023 LinkedIn Corporation. All rights reserved. |
| 2 | + * Copyright 2019-2025 LinkedIn Corporation. All rights reserved. |
3 | 3 | * Licensed under the BSD-2 Clause license. |
4 | 4 | * See LICENSE in the project root for license information. |
5 | 5 | */ |
@@ -98,12 +98,12 @@ public void testToNullableSchema() { |
98 | 98 | @Test |
99 | 99 | public void testSetupNameAndNamespacePreservesOriginalNamespace() { |
100 | 100 | // Create first nested record with namespace "com.foo.bar" |
101 | | - Schema nestedRecord1 = SchemaBuilder.record("FooRecord").namespace("com.foo.bar").fields().name("field1") |
102 | | - .type().intType().noDefault().endRecord(); |
| 101 | + Schema nestedRecord1 = SchemaBuilder.record("FooRecord").namespace("com.foo.bar").fields().name("field1").type() |
| 102 | + .intType().noDefault().endRecord(); |
103 | 103 |
|
104 | 104 | // Create second nested record with the same name but different namespace "com.baz.qux" |
105 | | - Schema nestedRecord2 = SchemaBuilder.record("FooRecord").namespace("com.baz.qux").fields().name("field2") |
106 | | - .type().stringType().noDefault().endRecord(); |
| 105 | + Schema nestedRecord2 = SchemaBuilder.record("FooRecord").namespace("com.baz.qux").fields().name("field2").type() |
| 106 | + .stringType().noDefault().endRecord(); |
107 | 107 |
|
108 | 108 | // Create nullable unions for both nested records |
109 | 109 | Schema nullableRecord1 = Schema.createUnion(Schema.create(Schema.Type.NULL), nestedRecord1); |
@@ -134,9 +134,8 @@ public void testSetupNameAndNamespacePreservesOriginalNamespace() { |
134 | 134 | Assert.assertEquals(resultRecord2.getName(), "FooRecord"); |
135 | 135 |
|
136 | 136 | // But they should have different namespaces with numeric suffixes to avoid conflicts |
137 | | - Assert.assertNotEquals(namespace1, namespace2, |
138 | | - "Namespaces should be different to avoid conflicts. Got namespace1: " + namespace1 + ", namespace2: " |
139 | | - + namespace2); |
| 137 | + Assert.assertNotEquals(namespace1, namespace2, "Namespaces should be different to avoid conflicts. Got namespace1: " |
| 138 | + + namespace1 + ", namespace2: " + namespace2); |
140 | 139 |
|
141 | 140 | // Verify that numeric suffixes are appended to distinguish the colliding records |
142 | 141 | Assert.assertTrue(namespace1.endsWith("-0") || namespace1.endsWith("-1"), |
@@ -165,8 +164,7 @@ public void testSetupNameAndNamespaceDetectsDirectRecordCollisions() { |
165 | 164 | .type(nestedRecord1).noDefault().name("serviceConfig2").type(nestedRecord2).noDefault().endRecord(); |
166 | 165 |
|
167 | 166 | // Apply setupNameAndNamespace |
168 | | - Schema resultSchema = |
169 | | - SchemaUtilities.setupNameAndNamespace(parentSchema, "ApplicationConfig", "com.app.config"); |
| 167 | + Schema resultSchema = SchemaUtilities.setupNameAndNamespace(parentSchema, "ApplicationConfig", "com.app.config"); |
170 | 168 |
|
171 | 169 | // Extract the nested record schemas from the result |
172 | 170 | Schema.Field config1Field = resultSchema.getField("serviceConfig1"); |
@@ -218,13 +216,13 @@ public void testSetupNameAndNamespaceDetectsDeeplyNestedCollisions() { |
218 | 216 |
|
219 | 217 | // Create an intermediate record that contains both colliding records |
220 | 218 | // This represents the middle layer in the nesting hierarchy |
221 | | - Schema intermediateRecord = SchemaBuilder.record("IntermediateRecord").namespace("com.intermediate").fields() |
222 | | - .name("collidingField1").type(collidingRecord1).noDefault().name("collidingField2").type(collidingRecord2) |
223 | | - .noDefault().endRecord(); |
| 219 | + Schema intermediateRecord = |
| 220 | + SchemaBuilder.record("IntermediateRecord").namespace("com.intermediate").fields().name("collidingField1") |
| 221 | + .type(collidingRecord1).noDefault().name("collidingField2").type(collidingRecord2).noDefault().endRecord(); |
224 | 222 |
|
225 | 223 | // Create top-level parent schema that contains the intermediate record |
226 | | - Schema parentSchema = SchemaBuilder.record("ParentRecord").namespace("com.parent").fields().name("intermediateField") |
227 | | - .type(intermediateRecord).noDefault().endRecord(); |
| 224 | + Schema parentSchema = SchemaBuilder.record("ParentRecord").namespace("com.parent").fields() |
| 225 | + .name("intermediateField").type(intermediateRecord).noDefault().endRecord(); |
228 | 226 |
|
229 | 227 | // Apply setupNameAndNamespace |
230 | 228 | Schema resultSchema = SchemaUtilities.setupNameAndNamespace(parentSchema, "ParentRecord", "com.result"); |
|
0 commit comments