forked from citrusframework/citrus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/issue/1156/test_api_generator_TS' into issue…
…/1161/fluent-generated-openapi-actions-REBASE # Conflicts: # connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiClientRequestActionBuilder.java # pom.xml # src/manual/connector-openapi.adoc # test-api-generator/citrus-test-api-generator-core/pom.xml # test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java # test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/SimpleWsdlToOpenApiTransformer.java # test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache # test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache # test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache # test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GeneratedApiIT.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdIT.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenIT.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenTest.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/ServiceLoaderTest.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/SpringBeanConfigurationIT.java # test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/util/TestApiActionBuilderCustomizer.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/multiparttest-rest-resource.yaml # test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/petstore.yaml # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/GeneratedApiTest/payloads/getPetByIdControlMessage1.json # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestAbstractTestRequest.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestBeanDefinitionParser.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/extension/MultipartTestNamespaceHandler.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/request/MultiparttestControllerApi.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreAbstractTestRequest.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreBeanDefinitionParser.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/extension/PetStoreNamespaceHandler.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/PetApi.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/StoreApi.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/UserApi.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/spring/PetStoreBeanConfiguration.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/OpenApiFromWsdlBeanDefinitionParser.java # test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/extension/OpenApiFromWsdlNamespaceHandler.java # test-api-generator/citrus-test-api-generator-maven-plugin/pom.xml # test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/CodeGenMojoWrapper.java # test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/SpringMetaFileGenerator.java # test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/TestApiGeneratorMojo.java # test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoIntegrationTest.java # test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoUnitTest.java # test-api-generator/pom.xml
- Loading branch information
Showing
67 changed files
with
1,196 additions
and
517 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Citrus Framework | ||
release: | ||
current-version: 4.2.0 | ||
current-version: 4.2.1 | ||
next-version: 4.3.0-SNAPSHOT |
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
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
63 changes: 63 additions & 0 deletions
63
...test/java/org/citrusframework/openapi/actions/OpenApiClientRequestMessageBuilderTest.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,63 @@ | ||
package org.citrusframework.openapi.actions; | ||
|
||
import org.citrusframework.context.TestContext; | ||
import org.citrusframework.http.message.HttpMessage; | ||
import org.citrusframework.message.Message; | ||
import org.citrusframework.openapi.OpenApiSpecification; | ||
import org.citrusframework.spi.Resources; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.citrusframework.openapi.actions.OpenApiActionBuilder.openapi; | ||
|
||
public class OpenApiClientRequestMessageBuilderTest { | ||
|
||
private final OpenApiSpecification petstoreSpec = OpenApiSpecification.from( | ||
Resources.create("classpath:org/citrusframework/openapi/petstore/petstore-derivation-for-message-builder-test.json")); | ||
|
||
|
||
@Test | ||
public void shouldAddRandomDataForOperation() { | ||
Message message = openapi() | ||
.specification(petstoreSpec) | ||
.client() | ||
.send("addPet") // operationId | ||
.build() | ||
.getMessageBuilder() | ||
.build(new TestContext(), ""); | ||
Assert.assertTrue(message instanceof HttpMessage); | ||
HttpMessage httpMessage = (HttpMessage) message; | ||
// test payload | ||
Object payload = httpMessage.getPayload(); | ||
Assert.assertNotNull(payload); | ||
Assert.assertTrue(payload instanceof String); | ||
// test header | ||
Object header = httpMessage.getHeader("X-SAMPLE-HEADER"); | ||
Assert.assertNotNull(header); | ||
} | ||
|
||
@Test | ||
public void shouldAddCustomDataForOperation() { | ||
String body = "{\"a\":\"b\"}"; | ||
String sampleHeader = "X-SAMPLE-HEADER-VALUE"; | ||
Message message = openapi() | ||
.specification(petstoreSpec) | ||
.client() | ||
.send("addPet") // operationId | ||
.message() | ||
.body(body) | ||
.header("X-SAMPLE-HEADER", sampleHeader) | ||
.build() | ||
.getMessageBuilder() | ||
.build(new TestContext(), ""); | ||
Assert.assertTrue(message instanceof HttpMessage); | ||
HttpMessage httpMessage = (HttpMessage) message; | ||
// test payload | ||
Object payload = httpMessage.getPayload(); | ||
Assert.assertEquals(payload, body); | ||
// test header | ||
Object header = httpMessage.getHeader("X-SAMPLE-HEADER"); | ||
Assert.assertEquals(header, sampleHeader); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...trus-openapi/src/test/java/org/citrusframework/openapi/model/v3/Oas30ModelHelperTest.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,54 @@ | ||
package org.citrusframework.openapi.model.v3; | ||
|
||
import io.apicurio.datamodels.openapi.models.OasSchema; | ||
import io.apicurio.datamodels.openapi.v3.models.Oas30Header; | ||
import io.apicurio.datamodels.openapi.v3.models.Oas30Response; | ||
import io.apicurio.datamodels.openapi.v3.models.Oas30Schema; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Map; | ||
|
||
public class Oas30ModelHelperTest { | ||
|
||
@Test | ||
public void shouldNotFindRequiredHeadersWithoutRequiredAttribute() { | ||
var header = new Oas30Header("X-TEST"); | ||
header.schema = new Oas30Schema(); | ||
header.required = null; // explicitely assigned because this is test case | ||
var response = new Oas30Response("200"); | ||
response.headers.put(header.getName(), header); | ||
|
||
Map<String, OasSchema> result = Oas30ModelHelper.getRequiredHeaders(response); | ||
|
||
Assert.assertEquals(result.size(), 0); | ||
} | ||
|
||
@Test | ||
public void shouldFindRequiredHeaders() { | ||
var header = new Oas30Header("X-TEST"); | ||
header.schema = new Oas30Schema(); | ||
header.required = Boolean.TRUE; // explicitely assigned because this is test case | ||
var response = new Oas30Response("200"); | ||
response.headers.put(header.getName(), header); | ||
|
||
Map<String, OasSchema> result = Oas30ModelHelper.getRequiredHeaders(response); | ||
|
||
Assert.assertEquals(result.size(), 1); | ||
Assert.assertSame(result.get(header.getName()), header.schema); | ||
} | ||
|
||
@Test | ||
public void shouldNotFindOptionalHeaders() { | ||
var header = new Oas30Header("X-TEST"); | ||
header.schema = new Oas30Schema(); | ||
header.required = Boolean.FALSE; // explicitely assigned because this is test case | ||
var response = new Oas30Response("200"); | ||
response.headers.put(header.getName(), header); | ||
|
||
Map<String, OasSchema> result = Oas30ModelHelper.getRequiredHeaders(response); | ||
|
||
Assert.assertEquals(result.size(), 0); | ||
} | ||
|
||
} |
164 changes: 164 additions & 0 deletions
164
...es/org/citrusframework/openapi/petstore/petstore-derivation-for-message-builder-test.json
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,164 @@ | ||
{ | ||
"openapi": "3.0.2", | ||
"info": { | ||
"title": "Swagger Petstore", | ||
"version": "1.0.1", | ||
"description": "This is a sample server Petstore server.", | ||
"license": { | ||
"name": "Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
} | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost/petstore/v3" | ||
} | ||
], | ||
"paths": { | ||
"/pet": { | ||
"post": { | ||
"requestBody": { | ||
"description": "Pet object that needs to be added to the store", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Pet" | ||
} | ||
}, | ||
"application/xml": { | ||
"schema": { | ||
"$ref": "#/components/schemas/Pet" | ||
} | ||
} | ||
}, | ||
"required": true | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "X-SAMPLE-HEADER", | ||
"required": true, | ||
"in": "header", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "sample-param", | ||
"required": true, | ||
"in": "query", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"tags": [ | ||
"pet" | ||
], | ||
"responses": { | ||
"201": { | ||
"description": "Created" | ||
}, | ||
"405": { | ||
"description": "Invalid input" | ||
} | ||
}, | ||
"operationId": "addPet", | ||
"summary": "Add a new pet to the store", | ||
"description": "" | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Category": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"format": "int64", | ||
"type": "integer" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"xml": { | ||
"name": "Category" | ||
} | ||
}, | ||
"Tag": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"format": "int64", | ||
"type": "integer" | ||
}, | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"xml": { | ||
"name": "Tag" | ||
} | ||
}, | ||
"Pet": { | ||
"required": [ | ||
"category", | ||
"name", | ||
"status" | ||
], | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"format": "int64", | ||
"type": "integer" | ||
}, | ||
"category": { | ||
"$ref": "#/components/schemas/Category" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"example": "doggie" | ||
}, | ||
"photoUrls": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"xml": { | ||
"name": "photoUrl", | ||
"wrapped": true | ||
} | ||
}, | ||
"tags": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Tag" | ||
}, | ||
"xml": { | ||
"name": "tag", | ||
"wrapped": true | ||
} | ||
}, | ||
"status": { | ||
"description": "pet status in the store", | ||
"enum": [ | ||
"available", | ||
"pending", | ||
"sold" | ||
], | ||
"type": "string" | ||
} | ||
}, | ||
"xml": { | ||
"name": "Pet" | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [ | ||
{ | ||
"name": "pet", | ||
"description": "Everything about your Pets" | ||
} | ||
] | ||
} |
Oops, something went wrong.