From 688de477f05de93b0cfb39d2339aa1ee71dfd7a0 Mon Sep 17 00:00:00 2001 From: mengjiann Date: Tue, 25 Aug 2020 23:22:37 +0800 Subject: [PATCH] #32 Added end to end test for EnunciateTestsGenerator --- .../DataResource.java | 21 +++++++++ .../confignamespacewithprefix/DataXmlDTO.java | 14 ++++++ .../DataXmlEnum.java | 9 ++++ .../RestApplication.java | 8 ++++ .../confignamespacewithprefix/enunciate.xml | 14 ++++++ .../confignamespacewithprefix/openapi.yml | 46 +++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataResource.java create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlDTO.java create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlEnum.java create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/RestApplication.java create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/enunciate.xml create mode 100644 src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/openapi.yml diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataResource.java b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataResource.java new file mode 100644 index 0000000..526d9af --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataResource.java @@ -0,0 +1,21 @@ +package dk.jyskebank.tools.enunciate.modules.openapi.confignamespacewithprefix; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.webcohesion.enunciate.metadata.rs.TypeHint; + +@Path("/path") +public class DataResource { + + @TypeHint(DataXmlDTO.class) + @GET + @Path("/xmldto") + @Produces(MediaType.APPLICATION_XML) + public Response getXmlType() { + return Response.ok(new DataXmlDTO()).build(); + } +} diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlDTO.java b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlDTO.java new file mode 100644 index 0000000..9197ecb --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlDTO.java @@ -0,0 +1,14 @@ +package dk.jyskebank.tools.enunciate.modules.openapi.confignamespacewithprefix; + +import javax.xml.bind.annotation.*; + +@XmlType(name = "dataXmlDTO", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/1") +@XmlRootElement(name="dataXmlDTO", namespace = "http://www.jyskebank.dk/enunciate/openapi/version/1") +@XmlAccessorType(XmlAccessType.FIELD) +public class DataXmlDTO { + @XmlElement(name="aString") + private String aString; + + @XmlElement + private DataXmlEnum anEnum; +} diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlEnum.java b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlEnum.java new file mode 100644 index 0000000..7285150 --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/DataXmlEnum.java @@ -0,0 +1,9 @@ +package dk.jyskebank.tools.enunciate.modules.openapi.confignamespacewithprefix; + +import javax.xml.bind.annotation.XmlEnum; + +@XmlEnum +public enum DataXmlEnum { + GOOD, + MORNING; +} diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/RestApplication.java b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/RestApplication.java new file mode 100644 index 0000000..423d7cf --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/RestApplication.java @@ -0,0 +1,8 @@ +package dk.jyskebank.tools.enunciate.modules.openapi.confignamespacewithprefix; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("rest") +public class RestApplication extends Application { +} diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/enunciate.xml b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/enunciate.xml new file mode 100644 index 0000000..b363657 --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/enunciate.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/openapi.yml b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/openapi.yml new file mode 100644 index 0000000..d83ae82 --- /dev/null +++ b/src/test/java/dk/jyskebank/tools/enunciate/modules/openapi/confignamespacewithprefix/openapi.yml @@ -0,0 +1,46 @@ +openapi: 3.0.0 +info: + title: "Web Service API" + version: "version" + description: "" +servers: [] +paths: + "/path/xmldto": + get: + description: "" + tags: + - "DataResource" + summary: "" + deprecated: false + operationId: getXmlType + responses: + "200": + description: "" + content: + "*/*": + schema: + $ref: "#/components/schemas/xml_prefix-a_dataXmlDTO" + +components: + schemas: + "xml_ns0_dataXmlEnum": + title: "dataXmlEnum" + type: string + enum: + - "GOOD" + - "MORNING" + "xml_prefix-a_dataXmlDTO": + title: "dataXmlDTO" + allOf: + - type: string + format: binary + - type: object + properties: + "aString": + type: string + "anEnum": + $ref: "#/components/schemas/xml_ns0_dataXmlEnum" + xml: + name: dataXmlDTO + namespace: http://www.jyskebank.dk/enunciate/openapi/version/1 + prefix: prefix-a