|
1 | 1 |
|
2 | 2 | package cz.habarta.typescript.generator; |
3 | 3 |
|
| 4 | +import javax.xml.bind.JAXBElement; |
4 | 5 | import javax.xml.bind.annotation.*; |
5 | 6 | import org.junit.Assert; |
6 | 7 | import org.junit.Test; |
@@ -28,4 +29,36 @@ private static class MyJaxbBean { |
28 | 29 |
|
29 | 30 | } |
30 | 31 |
|
| 32 | + @Test |
| 33 | + public void testJAXBElement() { |
| 34 | + final Settings settings = TestUtils.settings(); |
| 35 | + settings.jsonLibrary = JsonLibrary.jaxb; |
| 36 | + final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ClassWithJAXBElements.class)); |
| 37 | + Assert.assertTrue(output.contains("ExternalReference: string")); |
| 38 | + Assert.assertTrue(output.contains("UserInformation: UserType")); |
| 39 | + Assert.assertTrue(output.contains("Source: EndPointType")); |
| 40 | + Assert.assertTrue(output.contains("AdditionalContextInfo: AdditionalContextType")); |
| 41 | + } |
| 42 | + |
| 43 | + @XmlRootElement |
| 44 | + private static class ClassWithJAXBElements { |
| 45 | + @XmlElement(name = "ExternalReference") |
| 46 | + protected String externalReference; |
| 47 | + @XmlElementRef(name = "UserInformation", type = JAXBElement.class, required = false) |
| 48 | + protected JAXBElement<UserType> userInformation; |
| 49 | + @XmlElementRef(name = "Source", type = JAXBElement.class, required = false) |
| 50 | + protected JAXBElement<EndPointType> source; |
| 51 | + @XmlElementRef(name = "AdditionalContextInfo", type = JAXBElement.class, required = false) |
| 52 | + protected JAXBElement<AdditionalContextType> additionalContextInfo; |
| 53 | + } |
| 54 | + |
| 55 | + private static class UserType { |
| 56 | + } |
| 57 | + |
| 58 | + private static class EndPointType { |
| 59 | + } |
| 60 | + |
| 61 | + private static class AdditionalContextType { |
| 62 | + } |
| 63 | + |
31 | 64 | } |
0 commit comments