-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix complex default conversion - handle list (#522)
- Loading branch information
1 parent
cd17a70
commit b08911b
Showing
7 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...1/src/test/java/com/linkedin/avroutil1/compatibility/avro111/Avro111FieldBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2023 LinkedIn Corp. | ||
* Licensed under the BSD 2-Clause License (the "License"). | ||
* See License in the project root for license information. | ||
*/ | ||
|
||
package com.linkedin.avroutil1.compatibility.avro111; | ||
|
||
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper; | ||
import com.linkedin.avroutil1.compatibility.FieldBuilder; | ||
import com.linkedin.avroutil1.testcommon.TestUtil; | ||
import java.io.IOException; | ||
import org.apache.avro.Schema; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
public class Avro111FieldBuilderTest { | ||
@Test | ||
public void testArrayOfEnumDefaultValue() throws IOException { | ||
Schema schema = Schema.parse(TestUtil.load("FieldWithArrayOfEnumDefaultValue.avsc")); | ||
Schema.Field field = schema.getField("arrayOfEnum"); | ||
Object defaultValue = AvroCompatibilityHelper.getGenericDefaultValue(field); | ||
FieldBuilder builder = AvroCompatibilityHelper.newField(field); | ||
builder.setDefault(defaultValue); | ||
|
||
// Test that .build() should not throw an exception. | ||
Schema.Field resField = builder.build(); | ||
Assert.assertNotNull(resField); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
helper/tests/helper-tests-common/src/main/resources/FieldWithArrayOfEnumDefaultValue.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "record", | ||
"name": "FieldWithArrayOfEnumDefaultValue", | ||
"fields": [ | ||
{ | ||
"name": "arrayOfEnum", | ||
"type": { | ||
"type": "array", | ||
"items": { | ||
"type": "enum", | ||
"name": "EnumDefaultValue", | ||
"symbols": [ | ||
"A", | ||
"B", | ||
"C" | ||
] | ||
} | ||
}, | ||
"default": [ | ||
"A", | ||
"B" | ||
] | ||
} | ||
] | ||
} |