Skip to content

Commit 93ba63c

Browse files
committed
test(normalize-class): add tests and schema for abstract type and empty child normalization
1 parent ab54955 commit 93ba63c

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

plugins/src/test/java/io/github/rawvoid/jaxb/plugin/NormalizeClassPluginTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.Test;
2222

23+
import java.lang.reflect.Modifier;
2324
import java.util.List;
2425
import java.util.stream.Collectors;
2526

@@ -42,13 +43,19 @@ void testNormalizeDuplicateClasses() throws Exception {
4243
.collect(Collectors.groupingBy(Class::getSimpleName));
4344

4445
assertThat(classBySimpleName).containsKeys("NormalizeRoot", "Group", "AnotherGroup", "Entry");
46+
assertThat(classBySimpleName).containsKey("BaseType");
47+
assertThat(classBySimpleName).doesNotContainKey("EmptyChild");
4548
assertThat(classBySimpleName.get("Entry")).hasSize(1);
4649

4750
var groupClass = classBySimpleName.get("Group").getFirst();
4851
var anotherGroupClass = classBySimpleName.get("AnotherGroup").getFirst();
4952
var entryClass = classBySimpleName.get("Entry").getFirst();
53+
var baseTypeClass = classBySimpleName.get("BaseType").getFirst();
54+
var normalizeRootClass = classBySimpleName.get("NormalizeRoot").getFirst();
5055

5156
assertThat(groupClass.getDeclaredField("entry").getType()).isEqualTo(entryClass);
5257
assertThat(anotherGroupClass.getDeclaredField("entry").getType()).isEqualTo(entryClass);
58+
assertThat(normalizeRootClass.getDeclaredField("emptyChild").getType()).isEqualTo(baseTypeClass);
59+
assertThat(Modifier.isAbstract(baseTypeClass.getModifiers())).isFalse();
5360
}
5461
}

plugins/src/test/resources/schema/normalize-class.xsd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@
4848
</xs:sequence>
4949
</xs:complexType>
5050
</xs:element>
51+
<xs:element name="emptyChild" type="tns:EmptyChild"/>
5152
</xs:sequence>
5253
</xs:complexType>
5354

55+
<xs:complexType name="BaseType" abstract="true"/>
56+
57+
<xs:complexType name="EmptyChild">
58+
<xs:complexContent>
59+
<xs:extension base="tns:BaseType"/>
60+
</xs:complexContent>
61+
</xs:complexType>
62+
5463
<xs:element name="normalizeRoot" type="tns:NormalizeRoot"/>
5564
</xs:schema>

0 commit comments

Comments
 (0)